-rw-r--r-- | korganizer/koeditorgeneral.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 5c94f62..2fbcd42 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,568 +1,569 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qregexp.h> | ||
34 | 35 | ||
35 | 36 | ||
36 | #include <kglobal.h> | 37 | #include <kglobal.h> |
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <klocale.h> | 39 | #include <klocale.h> |
39 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
40 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
41 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
42 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
43 | 44 | ||
44 | #include <libkcal/todo.h> | 45 | #include <libkcal/todo.h> |
45 | #include <libkcal/event.h> | 46 | #include <libkcal/event.h> |
46 | #include <libkdepim/categoryselectdialog.h> | 47 | #include <libkdepim/categoryselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 48 | #include <libkdepim/kdateedit.h> |
48 | 49 | ||
49 | #include "koprefs.h" | 50 | #include "koprefs.h" |
50 | #include "koglobals.h" | 51 | #include "koglobals.h" |
51 | 52 | ||
52 | #include "koeditorgeneral.h" | 53 | #include "koeditorgeneral.h" |
53 | #include "kolocationbox.h" | 54 | #include "kolocationbox.h" |
54 | #ifndef DESKTOP_VERSION | 55 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 56 | #include <qpe/qpeapplication.h> |
56 | #else | 57 | #else |
57 | #include <qapplication.h> | 58 | #include <qapplication.h> |
58 | #endif | 59 | #endif |
59 | 60 | ||
60 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 61 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
61 | QObject( parent, name) | 62 | QObject( parent, name) |
62 | { | 63 | { |
63 | mNextFocus = 0; | 64 | mNextFocus = 0; |
64 | } | 65 | } |
65 | 66 | ||
66 | KOEditorGeneral::~KOEditorGeneral() | 67 | KOEditorGeneral::~KOEditorGeneral() |
67 | { | 68 | { |
68 | } | 69 | } |
69 | 70 | ||
70 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 71 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
71 | { | 72 | { |
72 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 73 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
73 | 74 | ||
74 | #if 0 | 75 | #if 0 |
75 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 76 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
76 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 77 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 80 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
80 | headerLayout->addWidget(summaryLabel,1,0); | 81 | headerLayout->addWidget(summaryLabel,1,0); |
81 | 82 | ||
82 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 83 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
83 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 84 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
84 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 85 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
85 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 86 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
86 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 87 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
87 | if ( QApplication::desktop()->width() > 320 ) | 88 | if ( QApplication::desktop()->width() > 320 ) |
88 | mSummaryEdit->setMaximumHeight( hei +6 ); | 89 | mSummaryEdit->setMaximumHeight( hei +6 ); |
89 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 90 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
90 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 91 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
91 | // mSummaryEdit = new QLineEdit(parent); | 92 | // mSummaryEdit = new QLineEdit(parent); |
92 | headerLayout->addWidget(mSummaryEdit,1,1); | 93 | headerLayout->addWidget(mSummaryEdit,1,1); |
93 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 94 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
94 | 95 | ||
95 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 96 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
96 | if ( QApplication::desktop()->height() < 320 ) | 97 | if ( QApplication::desktop()->height() < 320 ) |
97 | headerLayout->addWidget(locationLabel,1,2); | 98 | headerLayout->addWidget(locationLabel,1,2); |
98 | else | 99 | else |
99 | headerLayout->addWidget(locationLabel,2,0); | 100 | headerLayout->addWidget(locationLabel,2,0); |
100 | 101 | ||
101 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 102 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
102 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 103 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
103 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) | 104 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) |
104 | mLocationEdit->setMaximumHeight( hei + 6); | 105 | mLocationEdit->setMaximumHeight( hei + 6); |
105 | 106 | ||
106 | // mLocationEdit = new QLineEdit(parent); | 107 | // mLocationEdit = new QLineEdit(parent); |
107 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 108 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
108 | if ( QApplication::desktop()->height() < 320 ) { | 109 | if ( QApplication::desktop()->height() < 320 ) { |
109 | headerLayout->addWidget(mLocationEdit,1,3); | 110 | headerLayout->addWidget(mLocationEdit,1,3); |
110 | headerLayout->setColStretch( 1, 10); | 111 | headerLayout->setColStretch( 1, 10); |
111 | headerLayout->setColStretch( 3, 10); | 112 | headerLayout->setColStretch( 3, 10); |
112 | } | 113 | } |
113 | else { | 114 | else { |
114 | headerLayout->addWidget(mLocationEdit,2,1); | 115 | headerLayout->addWidget(mLocationEdit,2,1); |
115 | headerLayout->setColStretch( 1, 10); | 116 | headerLayout->setColStretch( 1, 10); |
116 | } | 117 | } |
117 | } | 118 | } |
118 | void KOEditorGeneral::setFocusOn( int i ) | 119 | void KOEditorGeneral::setFocusOn( int i ) |
119 | { | 120 | { |
120 | mNextFocus = i; | 121 | mNextFocus = i; |
121 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 122 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
122 | } | 123 | } |
123 | void KOEditorGeneral::slotSetFocusOn() | 124 | void KOEditorGeneral::slotSetFocusOn() |
124 | { | 125 | { |
125 | mNextFocus; | 126 | mNextFocus; |
126 | if ( mNextFocus == 1 ) { | 127 | if ( mNextFocus == 1 ) { |
127 | mDescriptionEdit->setFocus(); | 128 | mDescriptionEdit->setFocus(); |
128 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 129 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
129 | } | 130 | } |
130 | if ( mNextFocus == 2 ) { | 131 | if ( mNextFocus == 2 ) { |
131 | mSummaryEdit->setFocus(); | 132 | mSummaryEdit->setFocus(); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | void KOEditorGeneral::editCategories() | 135 | void KOEditorGeneral::editCategories() |
135 | { | 136 | { |
136 | // qDebug("KOEditorGeneral::editCategories() "); | 137 | // qDebug("KOEditorGeneral::editCategories() "); |
137 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 138 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
138 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 139 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
139 | //KOGlobals::fitDialogToScreen( csd ); | 140 | //KOGlobals::fitDialogToScreen( csd ); |
140 | csd->setColorEnabled(); | 141 | csd->setColorEnabled(); |
141 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 142 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
142 | csd->exec(); | 143 | csd->exec(); |
143 | delete csd; | 144 | delete csd; |
144 | } | 145 | } |
145 | 146 | ||
146 | void KOEditorGeneral::showCatPopup() | 147 | void KOEditorGeneral::showCatPopup() |
147 | { | 148 | { |
148 | mCatPopup->clear(); | 149 | mCatPopup->clear(); |
149 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); | 150 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); |
150 | int index = 0; | 151 | int index = 0; |
151 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 152 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
152 | it != KOPrefs::instance()->mCustomCategories.end (); | 153 | it != KOPrefs::instance()->mCustomCategories.end (); |
153 | ++it) { | 154 | ++it) { |
154 | mCatPopup->insertItem (*it, index ); | 155 | mCatPopup->insertItem (*it, index ); |
155 | //mCategory[index] = *it; | 156 | //mCategory[index] = *it; |
156 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); | 157 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); |
157 | ++index; | 158 | ++index; |
158 | } | 159 | } |
159 | } | 160 | } |
160 | void KOEditorGeneral::selectedCatPopup( int index ) | 161 | void KOEditorGeneral::selectedCatPopup( int index ) |
161 | { | 162 | { |
162 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); | 163 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); |
163 | QString colcat = categories.first(); | 164 | QString colcat = categories.first(); |
164 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 165 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
165 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 166 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
166 | else | 167 | else |
167 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 168 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
168 | categories.sort (); | 169 | categories.sort (); |
169 | if ( !colcat.isEmpty() ) { | 170 | if ( !colcat.isEmpty() ) { |
170 | if ( categories.find ( colcat ) != categories.end () ) { | 171 | if ( categories.find ( colcat ) != categories.end () ) { |
171 | categories.remove( colcat ); | 172 | categories.remove( colcat ); |
172 | categories.prepend( colcat ); | 173 | categories.prepend( colcat ); |
173 | } | 174 | } |
174 | } | 175 | } |
175 | setCategories( categories.join(",") ); | 176 | setCategories( categories.join(",") ); |
176 | } | 177 | } |
177 | 178 | ||
178 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 179 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
179 | { | 180 | { |
180 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 181 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
181 | mCatPopup = new QPopupMenu ( parent ); | 182 | mCatPopup = new QPopupMenu ( parent ); |
182 | mCatPopup->setCheckable (true); | 183 | mCatPopup->setCheckable (true); |
183 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); | 184 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); |
184 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); | 185 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); |
185 | mCategoriesButton = new QPushButton(parent); | 186 | mCategoriesButton = new QPushButton(parent); |
186 | mCategoriesButton->setText(i18n("Categories")); | 187 | mCategoriesButton->setText(i18n("Categories")); |
187 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 188 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
188 | categoriesLayout->addWidget(mCategoriesButton); | 189 | categoriesLayout->addWidget(mCategoriesButton); |
189 | mCategoriesButton->setPopup( mCatPopup ); | 190 | mCategoriesButton->setPopup( mCatPopup ); |
190 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); | 191 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); |
191 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 192 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
192 | connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() )); | 193 | connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() )); |
193 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 194 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
194 | categoriesLayout->addWidget(mCategoriesLabel,1); | 195 | categoriesLayout->addWidget(mCategoriesLabel,1); |
195 | } | 196 | } |
196 | 197 | ||
197 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 198 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
198 | { | 199 | { |
199 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 200 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
200 | 201 | ||
201 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 202 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
202 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 203 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
203 | secrecyLayout->addWidget(mCancelBox); | 204 | secrecyLayout->addWidget(mCancelBox); |
204 | secrecyLayout->addWidget(secrecyLabel); | 205 | secrecyLayout->addWidget(secrecyLabel); |
205 | 206 | ||
206 | mSecrecyCombo = new QComboBox(parent); | 207 | mSecrecyCombo = new QComboBox(parent); |
207 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 208 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
208 | secrecyLayout->addWidget(mSecrecyCombo); | 209 | secrecyLayout->addWidget(mSecrecyCombo); |
209 | } | 210 | } |
210 | 211 | ||
211 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 212 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
212 | { | 213 | { |
213 | mDescriptionEdit = new KTextEdit(parent); | 214 | mDescriptionEdit = new KTextEdit(parent); |
214 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 215 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
215 | mDescriptionEdit->append(""); | 216 | mDescriptionEdit->append(""); |
216 | mDescriptionEdit->setReadOnly(false); | 217 | mDescriptionEdit->setReadOnly(false); |
217 | mDescriptionEdit->setOverwriteMode(false); | 218 | mDescriptionEdit->setOverwriteMode(false); |
218 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 219 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
219 | topLayout->addWidget(mDescriptionEdit); | 220 | topLayout->addWidget(mDescriptionEdit); |
220 | #ifndef DESKTOP_VERSION | 221 | #ifndef DESKTOP_VERSION |
221 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 222 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
222 | #endif | 223 | #endif |
223 | 224 | ||
224 | } | 225 | } |
225 | 226 | ||
226 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 227 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
227 | { | 228 | { |
228 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 229 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
229 | 230 | ||
230 | //mAlarmBell = new QLabel(parent); | 231 | //mAlarmBell = new QLabel(parent); |
231 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 232 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
232 | //alarmLayout->addWidget(mAlarmBell); | 233 | //alarmLayout->addWidget(mAlarmBell); |
233 | if ( QApplication::desktop()->width() < 320 ) | 234 | if ( QApplication::desktop()->width() < 320 ) |
234 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 235 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
235 | else | 236 | else |
236 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 237 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
237 | 238 | ||
238 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 239 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
239 | alarmLayout->addWidget(mAlarmButton); | 240 | alarmLayout->addWidget(mAlarmButton); |
240 | 241 | ||
241 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 242 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
242 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 243 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
243 | alarmLayout->addWidget(mAlarmTimeEdit); | 244 | alarmLayout->addWidget(mAlarmTimeEdit); |
244 | mAlarmIncrCombo = new QComboBox(false, parent); | 245 | mAlarmIncrCombo = new QComboBox(false, parent); |
245 | if ( QApplication::desktop()->width() < 320 ) { | 246 | if ( QApplication::desktop()->width() < 320 ) { |
246 | mAlarmIncrCombo->insertItem(i18n("min")); | 247 | mAlarmIncrCombo->insertItem(i18n("min")); |
247 | mAlarmIncrCombo->insertItem(i18n("hou")); | 248 | mAlarmIncrCombo->insertItem(i18n("hou")); |
248 | mAlarmIncrCombo->insertItem(i18n("day")); | 249 | mAlarmIncrCombo->insertItem(i18n("day")); |
249 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 250 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
250 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 251 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
251 | } else { | 252 | } else { |
252 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 253 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
253 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 254 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
254 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 255 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
255 | } | 256 | } |
256 | 257 | ||
257 | // mAlarmIncrCombo->setMinimumHeight(20); | 258 | // mAlarmIncrCombo->setMinimumHeight(20); |
258 | alarmLayout->addWidget(mAlarmIncrCombo); | 259 | alarmLayout->addWidget(mAlarmIncrCombo); |
259 | mAlarmSoundButton = new QPushButton(parent); | 260 | mAlarmSoundButton = new QPushButton(parent); |
260 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 261 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
261 | mAlarmSoundButton->setToggleButton(true); | 262 | mAlarmSoundButton->setToggleButton(true); |
262 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 263 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
263 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 264 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
264 | alarmLayout->addWidget(mAlarmSoundButton); | 265 | alarmLayout->addWidget(mAlarmSoundButton); |
265 | 266 | ||
266 | mAlarmProgramButton = new QPushButton(parent); | 267 | mAlarmProgramButton = new QPushButton(parent); |
267 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 268 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
268 | mAlarmProgramButton->setToggleButton(true); | 269 | mAlarmProgramButton->setToggleButton(true); |
269 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 270 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
270 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 271 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
271 | alarmLayout->addWidget(mAlarmProgramButton); | 272 | alarmLayout->addWidget(mAlarmProgramButton); |
272 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 273 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
273 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 274 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
274 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 275 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
275 | // mAlarmSoundButton->hide(); | 276 | // mAlarmSoundButton->hide(); |
276 | // mAlarmProgramButton->hide(); | 277 | // mAlarmProgramButton->hide(); |
277 | // } | 278 | // } |
278 | } | 279 | } |
279 | 280 | ||
280 | void KOEditorGeneral::pickAlarmSound() | 281 | void KOEditorGeneral::pickAlarmSound() |
281 | { | 282 | { |
282 | 283 | ||
283 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 284 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
284 | 285 | ||
285 | bool oldState = mAlarmSoundButton->isOn(); | 286 | bool oldState = mAlarmSoundButton->isOn(); |
286 | 287 | ||
287 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 288 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
288 | i18n("*.wav|Wav Files"), 0)); | 289 | i18n("*.wav|Wav Files"), 0)); |
289 | if (!fileName.isEmpty()) { | 290 | if (!fileName.isEmpty()) { |
290 | mAlarmSound = fileName; | 291 | mAlarmSound = fileName; |
291 | QToolTip::remove(mAlarmSoundButton); | 292 | QToolTip::remove(mAlarmSoundButton); |
292 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 293 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
293 | QToolTip::add(mAlarmSoundButton, dispStr); | 294 | QToolTip::add(mAlarmSoundButton, dispStr); |
294 | mAlarmProgramButton->setOn(false); | 295 | mAlarmProgramButton->setOn(false); |
295 | mAlarmSoundButton->setOn(true); | 296 | mAlarmSoundButton->setOn(true); |
296 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 297 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
297 | } else { | 298 | } else { |
298 | mAlarmProgramButton->setOn(oldState); | 299 | mAlarmProgramButton->setOn(oldState); |
299 | mAlarmSoundButton->setOn(!oldState); | 300 | mAlarmSoundButton->setOn(!oldState); |
300 | 301 | ||
301 | 302 | ||
302 | } | 303 | } |
303 | 304 | ||
304 | if (mAlarmProgramButton->isOn()) | 305 | if (mAlarmProgramButton->isOn()) |
305 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 306 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
306 | if ( mAlarmSoundButton->isOn()) | 307 | if ( mAlarmSoundButton->isOn()) |
307 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 308 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
308 | 309 | ||
309 | } | 310 | } |
310 | 311 | ||
311 | void KOEditorGeneral::pickAlarmProgram() | 312 | void KOEditorGeneral::pickAlarmProgram() |
312 | { | 313 | { |
313 | bool oldState = mAlarmProgramButton->isOn(); | 314 | bool oldState = mAlarmProgramButton->isOn(); |
314 | 315 | ||
315 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 316 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
316 | if (!fileName.isEmpty()) { | 317 | if (!fileName.isEmpty()) { |
317 | mAlarmProgram = fileName; | 318 | mAlarmProgram = fileName; |
318 | QToolTip::remove(mAlarmProgramButton); | 319 | QToolTip::remove(mAlarmProgramButton); |
319 | QString dispStr = i18n("Running '%1'").arg(fileName); | 320 | QString dispStr = i18n("Running '%1'").arg(fileName); |
320 | QToolTip::add(mAlarmProgramButton, dispStr); | 321 | QToolTip::add(mAlarmProgramButton, dispStr); |
321 | mAlarmSoundButton->setOn(false); | 322 | mAlarmSoundButton->setOn(false); |
322 | mAlarmProgramButton->setOn(true); | 323 | mAlarmProgramButton->setOn(true); |
323 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 324 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
324 | } else { | 325 | } else { |
325 | mAlarmProgramButton->setOn(!oldState); | 326 | mAlarmProgramButton->setOn(!oldState); |
326 | mAlarmSoundButton->setOn(oldState); | 327 | mAlarmSoundButton->setOn(oldState); |
327 | } | 328 | } |
328 | 329 | ||
329 | if (mAlarmProgramButton->isOn()) | 330 | if (mAlarmProgramButton->isOn()) |
330 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 331 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
331 | if ( mAlarmSoundButton->isOn()) | 332 | if ( mAlarmSoundButton->isOn()) |
332 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 333 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
333 | 334 | ||
334 | } | 335 | } |
335 | 336 | ||
336 | 337 | ||
337 | QString KOEditorGeneral::getFittingPath( const QString s ) | 338 | QString KOEditorGeneral::getFittingPath( const QString s ) |
338 | { | 339 | { |
339 | int maxlen = 50; | 340 | int maxlen = 50; |
340 | if ( QApplication::desktop()->width() < 640 ) { | 341 | if ( QApplication::desktop()->width() < 640 ) { |
341 | if ( QApplication::desktop()->width() < 320 ) | 342 | if ( QApplication::desktop()->width() < 320 ) |
342 | maxlen = 22; | 343 | maxlen = 22; |
343 | else | 344 | else |
344 | maxlen = 35; | 345 | maxlen = 35; |
345 | } | 346 | } |
346 | if ( s.length() > maxlen ) { | 347 | if ( s.length() > maxlen ) { |
347 | return "..."+s.right(maxlen -3); | 348 | return "..."+s.right(maxlen -3); |
348 | } | 349 | } |
349 | return s; | 350 | return s; |
350 | } | 351 | } |
351 | 352 | ||
352 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 353 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
353 | { | 354 | { |
354 | if ( enable ) { | 355 | if ( enable ) { |
355 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 356 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
356 | mAlarmSoundButton->setOn( true ); | 357 | mAlarmSoundButton->setOn( true ); |
357 | if ( mAlarmSound.isEmpty() ) | 358 | if ( mAlarmSound.isEmpty() ) |
358 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 359 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
359 | else { | 360 | else { |
360 | if ( ! QFile::exists( mAlarmSound ) ) | 361 | if ( ! QFile::exists( mAlarmSound ) ) |
361 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 362 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | } | 365 | } |
365 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 366 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
366 | mAlarmTimeEdit->setEnabled(enable); | 367 | mAlarmTimeEdit->setEnabled(enable); |
367 | mAlarmSoundButton->setEnabled(enable); | 368 | mAlarmSoundButton->setEnabled(enable); |
368 | mAlarmProgramButton->setEnabled(enable); | 369 | mAlarmProgramButton->setEnabled(enable); |
369 | mAlarmIncrCombo->setEnabled(enable); | 370 | mAlarmIncrCombo->setEnabled(enable); |
370 | } | 371 | } |
371 | 372 | ||
372 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 373 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
373 | { | 374 | { |
374 | enableAlarmEdit( !disable ); | 375 | enableAlarmEdit( !disable ); |
375 | } | 376 | } |
376 | 377 | ||
377 | void KOEditorGeneral::enableAlarm( bool enable ) | 378 | void KOEditorGeneral::enableAlarm( bool enable ) |
378 | { | 379 | { |
379 | enableAlarmEdit( enable ); | 380 | enableAlarmEdit( enable ); |
380 | } | 381 | } |
381 | 382 | ||
382 | void KOEditorGeneral::alarmDisable(bool disable) | 383 | void KOEditorGeneral::alarmDisable(bool disable) |
383 | { | 384 | { |
384 | if (!disable) { | 385 | if (!disable) { |
385 | //mAlarmBell->setEnabled(true); | 386 | //mAlarmBell->setEnabled(true); |
386 | mAlarmButton->setEnabled(true); | 387 | mAlarmButton->setEnabled(true); |
387 | } else { | 388 | } else { |
388 | //mAlarmBell->setEnabled(false); | 389 | //mAlarmBell->setEnabled(false); |
389 | mAlarmButton->setEnabled(false); | 390 | mAlarmButton->setEnabled(false); |
390 | mAlarmButton->setChecked(false); | 391 | mAlarmButton->setChecked(false); |
391 | mAlarmTimeEdit->setEnabled(false); | 392 | mAlarmTimeEdit->setEnabled(false); |
392 | mAlarmSoundButton->setEnabled(false); | 393 | mAlarmSoundButton->setEnabled(false); |
393 | mAlarmProgramButton->setEnabled(false); | 394 | mAlarmProgramButton->setEnabled(false); |
394 | mAlarmIncrCombo->setEnabled(false); | 395 | mAlarmIncrCombo->setEnabled(false); |
395 | } | 396 | } |
396 | } | 397 | } |
397 | 398 | ||
398 | void KOEditorGeneral::setCategories(const QString &str) | 399 | void KOEditorGeneral::setCategories(const QString &str) |
399 | { | 400 | { |
400 | QString tt = str; | 401 | QString tt = str; |
401 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); | 402 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); |
402 | mCategoriesLabel->setText(str); | 403 | mCategoriesLabel->setText(str); |
403 | } | 404 | } |
404 | 405 | ||
405 | void KOEditorGeneral::setDefaults(bool allDay) | 406 | void KOEditorGeneral::setDefaults(bool allDay) |
406 | { | 407 | { |
407 | #if 0 | 408 | #if 0 |
408 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 409 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
409 | #endif | 410 | #endif |
410 | 411 | ||
411 | mAlarmMessage = i18n("Edit new item"); | 412 | mAlarmMessage = i18n("Edit new item"); |
412 | enableAlarmEdit( !allDay ); | 413 | enableAlarmEdit( !allDay ); |
413 | 414 | ||
414 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 415 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
415 | int alarmTime; | 416 | int alarmTime; |
416 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 417 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
417 | int index = KOPrefs::instance()->mAlarmTime; | 418 | int index = KOPrefs::instance()->mAlarmTime; |
418 | if (index < 0 || index > 7) { | 419 | if (index < 0 || index > 7) { |
419 | alarmTime = 15; | 420 | alarmTime = 15; |
420 | } else { | 421 | } else { |
421 | alarmTime = a[index]; | 422 | alarmTime = a[index]; |
422 | } | 423 | } |
423 | mAlarmButton ->setChecked( false ); | 424 | mAlarmButton ->setChecked( false ); |
424 | mAlarmTimeEdit->setValue(alarmTime); | 425 | mAlarmTimeEdit->setValue(alarmTime); |
425 | mAlarmIncrCombo->setCurrentItem(0); | 426 | mAlarmIncrCombo->setCurrentItem(0); |
426 | enableAlarmEdit( false ); | 427 | enableAlarmEdit( false ); |
427 | //alarmDisable (false); | 428 | //alarmDisable (false); |
428 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 429 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
429 | mCancelBox->setChecked( false ); | 430 | mCancelBox->setChecked( false ); |
430 | mSummaryEdit->setEditText(""); | 431 | mSummaryEdit->setEditText(""); |
431 | mLocationEdit->setEditText(""); | 432 | mLocationEdit->setEditText(""); |
432 | mDescriptionEdit->setText(""); | 433 | mDescriptionEdit->setText(""); |
433 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 434 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
434 | setCategories(""); | 435 | setCategories(""); |
435 | } | 436 | } |
436 | void KOEditorGeneral::setSecrecy( int num ) | 437 | void KOEditorGeneral::setSecrecy( int num ) |
437 | { | 438 | { |
438 | mSecrecyCombo->setCurrentItem(num); | 439 | mSecrecyCombo->setCurrentItem(num); |
439 | } | 440 | } |
440 | void KOEditorGeneral::readIncidence(Incidence *event) | 441 | void KOEditorGeneral::readIncidence(Incidence *event) |
441 | { | 442 | { |
442 | 443 | ||
443 | mAlarmMessage = event->summary(); | 444 | mAlarmMessage = event->summary(); |
444 | if ( ! event->location().isEmpty() ) | 445 | if ( ! event->location().isEmpty() ) |
445 | mAlarmMessage += " ("+event->location()+")"; | 446 | mAlarmMessage += " ("+event->location()+")"; |
446 | mAlarmIncrCombo->setCurrentItem(0); | 447 | mAlarmIncrCombo->setCurrentItem(0); |
447 | mSummaryEdit->setEditText(event->summary()); | 448 | mSummaryEdit->setEditText(event->summary()); |
448 | mLocationEdit->setEditText(event->location()); | 449 | mLocationEdit->setEditText(event->location()); |
449 | mDescriptionEdit->setText(event->description()); | 450 | mDescriptionEdit->setText(event->description()); |
450 | 451 | ||
451 | #if 0 | 452 | #if 0 |
452 | // organizer information | 453 | // organizer information |
453 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 454 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
454 | #endif | 455 | #endif |
455 | 456 | ||
456 | enableAlarmEdit( event->isAlarmEnabled() ); | 457 | enableAlarmEdit( event->isAlarmEnabled() ); |
457 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 458 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
458 | if(!event->isAlarmEnabled()) { | 459 | if(!event->isAlarmEnabled()) { |
459 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 460 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
460 | int alarmTime; | 461 | int alarmTime; |
461 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 462 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
462 | int index = KOPrefs::instance()->mAlarmTime; | 463 | int index = KOPrefs::instance()->mAlarmTime; |
463 | if (index < 0 || index > 7) { | 464 | if (index < 0 || index > 7) { |
464 | alarmTime = 15; | 465 | alarmTime = 15; |
465 | } else { | 466 | } else { |
466 | alarmTime = a[index]; | 467 | alarmTime = a[index]; |
467 | } | 468 | } |
468 | mAlarmTimeEdit->setValue(alarmTime); | 469 | mAlarmTimeEdit->setValue(alarmTime); |
469 | } | 470 | } |
470 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 471 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
471 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 472 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
472 | mCancelBox->setChecked( event->cancelled() ); | 473 | mCancelBox->setChecked( event->cancelled() ); |
473 | mAlarmProgramButton->setOn(false); | 474 | mAlarmProgramButton->setOn(false); |
474 | mAlarmSoundButton->setOn(false); | 475 | mAlarmSoundButton->setOn(false); |
475 | 476 | ||
476 | // set up alarm stuff | 477 | // set up alarm stuff |
477 | QPtrList<Alarm> alarms = event->alarms(); | 478 | QPtrList<Alarm> alarms = event->alarms(); |
478 | Alarm* alarm; | 479 | Alarm* alarm; |
479 | mAlarmIncrCombo->setCurrentItem(0); | 480 | mAlarmIncrCombo->setCurrentItem(0); |
480 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 481 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
481 | int offset; | 482 | int offset; |
482 | if ( alarm->hasTime() ) { | 483 | if ( alarm->hasTime() ) { |
483 | QDateTime t = alarm->time(); | 484 | QDateTime t = alarm->time(); |
484 | offset = event->dtStart().secsTo( t ); | 485 | offset = event->dtStart().secsTo( t ); |
485 | } else { | 486 | } else { |
486 | offset = alarm->startOffset().asSeconds(); | 487 | offset = alarm->startOffset().asSeconds(); |
487 | } | 488 | } |
488 | if ( offset != 0 ) { | 489 | if ( offset != 0 ) { |
489 | offset = offset / -60; // make minutes | 490 | offset = offset / -60; // make minutes |
490 | if (offset % 60 == 0) { // divides evenly into hours? | 491 | if (offset % 60 == 0) { // divides evenly into hours? |
491 | offset = offset / 60; | 492 | offset = offset / 60; |
492 | mAlarmIncrCombo->setCurrentItem(1); | 493 | mAlarmIncrCombo->setCurrentItem(1); |
493 | if (offset % 24 == 0) { // divides evenly into days? | 494 | if (offset % 24 == 0) { // divides evenly into days? |
494 | offset = offset / 24; | 495 | offset = offset / 24; |
495 | mAlarmIncrCombo->setCurrentItem(2); | 496 | mAlarmIncrCombo->setCurrentItem(2); |
496 | } | 497 | } |
497 | } | 498 | } |
498 | } | 499 | } |
499 | mAlarmTimeEdit->setValue( offset ); | 500 | mAlarmTimeEdit->setValue( offset ); |
500 | if (alarm->type() == Alarm::Procedure) { | 501 | if (alarm->type() == Alarm::Procedure) { |
501 | 502 | ||
502 | mAlarmProgram = alarm->programFile(); | 503 | mAlarmProgram = alarm->programFile(); |
503 | mAlarmProgramButton->setOn(true); | 504 | mAlarmProgramButton->setOn(true); |
504 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); | 505 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); |
505 | QToolTip::add(mAlarmProgramButton, dispStr); | 506 | QToolTip::add(mAlarmProgramButton, dispStr); |
506 | } | 507 | } |
507 | else if (alarm->type() == Alarm::Audio) { | 508 | else if (alarm->type() == Alarm::Audio) { |
508 | mAlarmSound = alarm->audioFile(); | 509 | mAlarmSound = alarm->audioFile(); |
509 | if ( ! QFile::exists( mAlarmSound ) ) | 510 | if ( ! QFile::exists( mAlarmSound ) ) |
510 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 511 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
511 | mAlarmSoundButton->setOn(true); | 512 | mAlarmSoundButton->setOn(true); |
512 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); | 513 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); |
513 | QToolTip::add(mAlarmSoundButton, dispStr); | 514 | QToolTip::add(mAlarmSoundButton, dispStr); |
514 | } | 515 | } |
515 | mAlarmButton->setChecked(alarm->enabled()); | 516 | mAlarmButton->setChecked(alarm->enabled()); |
516 | enableAlarmEdit( alarm->enabled() ); | 517 | enableAlarmEdit( alarm->enabled() ); |
517 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); | 518 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); |
518 | // TODO: Deal with multiple alarms | 519 | // TODO: Deal with multiple alarms |
519 | break; // For now, stop after the first alarm | 520 | break; // For now, stop after the first alarm |
520 | } | 521 | } |
521 | 522 | ||
522 | setCategories(event->categoriesStr()); | 523 | setCategories(event->categoriesStr()); |
523 | } | 524 | } |
524 | 525 | ||
525 | void KOEditorGeneral::writeIncidence(Incidence *event) | 526 | void KOEditorGeneral::writeIncidence(Incidence *event) |
526 | { | 527 | { |
527 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; | 528 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; |
528 | mLocationEdit->save(KOLocationBox::LOCATION); | 529 | mLocationEdit->save(KOLocationBox::LOCATION); |
529 | event->setSummary(mSummaryEdit->currentText()); | 530 | event->setSummary(mSummaryEdit->currentText()); |
530 | event->setLocation(mLocationEdit->currentText()); | 531 | event->setLocation(mLocationEdit->currentText()); |
531 | event->setDescription(mDescriptionEdit->text()); | 532 | event->setDescription(mDescriptionEdit->text()); |
532 | event->setCategories(mCategoriesLabel->text()); | 533 | event->setCategories(mCategoriesLabel->text()); |
533 | event->setSecrecy(mSecrecyCombo->currentItem()); | 534 | event->setSecrecy(mSecrecyCombo->currentItem()); |
534 | event->setCancelled(mCancelBox->isChecked() );; | 535 | event->setCancelled(mCancelBox->isChecked() );; |
535 | // alarm stuff | 536 | // alarm stuff |
536 | if (mAlarmButton->isChecked()) { | 537 | if (mAlarmButton->isChecked()) { |
537 | if (event->alarms().count() == 0) | 538 | if (event->alarms().count() == 0) |
538 | event->newAlarm(); | 539 | event->newAlarm(); |
539 | QPtrList<Alarm> alarms = event->alarms(); | 540 | QPtrList<Alarm> alarms = event->alarms(); |
540 | Alarm *alarm; | 541 | Alarm *alarm; |
541 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 542 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
542 | alarm->setEnabled(true); | 543 | alarm->setEnabled(true); |
543 | int j = mAlarmTimeEdit->value()* -60; | 544 | int j = mAlarmTimeEdit->value()* -60; |
544 | if (mAlarmIncrCombo->currentItem() == 1) | 545 | if (mAlarmIncrCombo->currentItem() == 1) |
545 | j = j * 60; | 546 | j = j * 60; |
546 | else if (mAlarmIncrCombo->currentItem() == 2) | 547 | else if (mAlarmIncrCombo->currentItem() == 2) |
547 | j = j * (60 * 24); | 548 | j = j * (60 * 24); |
548 | alarm->setStartOffset( j ); | 549 | alarm->setStartOffset( j ); |
549 | 550 | ||
550 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { | 551 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { |
551 | alarm->setProcedureAlarm(mAlarmProgram); | 552 | alarm->setProcedureAlarm(mAlarmProgram); |
552 | } | 553 | } |
553 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 554 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
554 | alarm->setAudioAlarm(mAlarmSound); | 555 | alarm->setAudioAlarm(mAlarmSound); |
555 | else | 556 | else |
556 | alarm->setType(Alarm::Invalid); | 557 | alarm->setType(Alarm::Invalid); |
557 | //alarm->setAudioAlarm("default"); | 558 | //alarm->setAudioAlarm("default"); |
558 | // TODO: Deal with multiple alarms | 559 | // TODO: Deal with multiple alarms |
559 | break; // For now, stop after the first alarm | 560 | break; // For now, stop after the first alarm |
560 | } | 561 | } |
561 | } else { | 562 | } else { |
562 | Alarm* alarm = event->alarms().first(); | 563 | Alarm* alarm = event->alarms().first(); |
563 | if ( alarm ) { | 564 | if ( alarm ) { |
564 | alarm->setEnabled(false); | 565 | alarm->setEnabled(false); |
565 | alarm->setType(Alarm::Invalid); | 566 | alarm->setType(Alarm::Invalid); |
566 | } | 567 | } |
567 | } | 568 | } |
568 | } | 569 | } |