-rw-r--r-- | korganizer/kotodoeditor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 682f83b..20a35d2 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,125 +1,126 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qtimer.h> | ||
30 | #include <qdir.h> | 31 | #include <qdir.h> |
31 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 33 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | 34 | #include <qtabwidget.h> |
34 | 35 | ||
35 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
36 | #include <klocale.h> | 37 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 38 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 39 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 40 | #include <kmessagebox.h> |
40 | 41 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 42 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 43 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 44 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 45 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 46 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 47 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 48 | #include <libkdepim/kdateedit.h> |
48 | 49 | ||
49 | #include "koprefs.h" | 50 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 51 | #include "kolocationbox.h" |
51 | 52 | ||
52 | #include "kotodoeditor.h" | 53 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 54 | extern int globalFlagBlockAgenda; |
54 | 55 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 56 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 57 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 58 | { |
58 | mTodo = 0; | 59 | mTodo = 0; |
59 | mRelatedTodo = 0; | 60 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 61 | findButton(User1)->hide(); |
61 | init(); | 62 | init(); |
62 | if ( QApplication::desktop()->height() <= 240 ) | 63 | if ( QApplication::desktop()->height() <= 240 ) |
63 | hideButtons(); | 64 | hideButtons(); |
64 | } | 65 | } |
65 | 66 | ||
66 | KOTodoEditor::~KOTodoEditor() | 67 | KOTodoEditor::~KOTodoEditor() |
67 | { | 68 | { |
68 | emit dialogClose( mTodo ); | 69 | emit dialogClose( mTodo ); |
69 | } | 70 | } |
70 | 71 | ||
71 | void KOTodoEditor::init() | 72 | void KOTodoEditor::init() |
72 | { | 73 | { |
73 | setupGeneral(); | 74 | setupGeneral(); |
74 | setupAttendeesTab(); | 75 | setupAttendeesTab(); |
75 | setupRecurrence(); | 76 | setupRecurrence(); |
76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 77 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 78 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
78 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 79 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
79 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | 80 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); |
80 | } | 81 | } |
81 | void KOTodoEditor::setupRecurrence() | 82 | void KOTodoEditor::setupRecurrence() |
82 | { | 83 | { |
83 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 84 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
84 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 85 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
85 | 86 | ||
86 | mRecurrence = new KOEditorRecurrence( topFrame ); | 87 | mRecurrence = new KOEditorRecurrence( topFrame ); |
87 | topLayout->addWidget( mRecurrence ); | 88 | topLayout->addWidget( mRecurrence ); |
88 | } | 89 | } |
89 | 90 | ||
90 | void KOTodoEditor::setCategories( QString s ) | 91 | void KOTodoEditor::setCategories( QString s ) |
91 | { | 92 | { |
92 | mGeneral->setCategories(s); | 93 | mGeneral->setCategories(s); |
93 | } | 94 | } |
94 | void KOTodoEditor::setSecrecy( int sec ) | 95 | void KOTodoEditor::setSecrecy( int sec ) |
95 | { | 96 | { |
96 | mGeneral->setSecrecy( sec ); | 97 | mGeneral->setSecrecy( sec ); |
97 | } | 98 | } |
98 | void KOTodoEditor::reload() | 99 | void KOTodoEditor::reload() |
99 | { | 100 | { |
100 | if ( mTodo ) readTodo( mTodo ); | 101 | if ( mTodo ) readTodo( mTodo ); |
101 | } | 102 | } |
102 | 103 | ||
103 | void KOTodoEditor::setupGeneral() | 104 | void KOTodoEditor::setupGeneral() |
104 | { | 105 | { |
105 | mGeneral = new KOEditorGeneralTodo(this); | 106 | mGeneral = new KOEditorGeneralTodo(this); |
106 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 107 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
107 | 108 | ||
108 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 109 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
109 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 110 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
110 | // mGeneral,SLOT(setCategories(const QString &))); | 111 | // mGeneral,SLOT(setCategories(const QString &))); |
111 | 112 | ||
112 | if (KOPrefs::instance()->mCompactDialogs) { | 113 | if (KOPrefs::instance()->mCompactDialogs) { |
113 | QFrame *topFrame = addPage(i18n("General")); | 114 | QFrame *topFrame = addPage(i18n("General")); |
114 | 115 | ||
115 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 116 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
116 | if ( QApplication::desktop()->width() < 480 ) { | 117 | if ( QApplication::desktop()->width() < 480 ) { |
117 | topLayout->setMargin(marginHintSmall()); | 118 | topLayout->setMargin(marginHintSmall()); |
118 | topLayout->setSpacing(spacingHintSmall()); | 119 | topLayout->setSpacing(spacingHintSmall()); |
119 | } else { | 120 | } else { |
120 | topLayout->setMargin(marginHint()); | 121 | topLayout->setMargin(marginHint()); |
121 | topLayout->setSpacing(spacingHint()); | 122 | topLayout->setSpacing(spacingHint()); |
122 | } | 123 | } |
123 | topLayout->addStretch( 1 ); | 124 | topLayout->addStretch( 1 ); |
124 | mGeneral->initHeader(topFrame,topLayout); | 125 | mGeneral->initHeader(topFrame,topLayout); |
125 | topLayout->addStretch( 1 ); | 126 | topLayout->addStretch( 1 ); |
@@ -166,192 +167,195 @@ void KOTodoEditor::setupGeneral() | |||
166 | QFrame *topFrame2 = addPage(i18n("Details")); | 167 | QFrame *topFrame2 = addPage(i18n("Details")); |
167 | 168 | ||
168 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 169 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
169 | topLayout2->setMargin(marginHint()); | 170 | topLayout2->setMargin(marginHint()); |
170 | topLayout2->setSpacing(spacingHint()); | 171 | topLayout2->setSpacing(spacingHint()); |
171 | 172 | ||
172 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 173 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
173 | mGeneral->initCompletion(topFrame2,completionLayout); | 174 | mGeneral->initCompletion(topFrame2,completionLayout); |
174 | 175 | ||
175 | 176 | ||
176 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 177 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
177 | mGeneral->initDescription(topFrame2,topLayout2); | 178 | mGeneral->initDescription(topFrame2,topLayout2); |
178 | 179 | ||
179 | // QHBox * hb = new QHBox ( topFrame2 ); | 180 | // QHBox * hb = new QHBox ( topFrame2 ); |
180 | // topLayout2->addWidget(hb); | 181 | // topLayout2->addWidget(hb); |
181 | // hb->setSpacing( 3 ); | 182 | // hb->setSpacing( 3 ); |
182 | 183 | ||
183 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 184 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
184 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 185 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
185 | 186 | ||
186 | } else { | 187 | } else { |
187 | QFrame *topFrame = addPage(i18n("General")); | 188 | QFrame *topFrame = addPage(i18n("General")); |
188 | 189 | ||
189 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 190 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
190 | topLayout->setSpacing(spacingHint()); | 191 | topLayout->setSpacing(spacingHint()); |
191 | 192 | ||
192 | mGeneral->initHeader(topFrame,topLayout); | 193 | mGeneral->initHeader(topFrame,topLayout); |
193 | mGeneral->initTime(topFrame,topLayout); | 194 | mGeneral->initTime(topFrame,topLayout); |
194 | mGeneral->initStatus(topFrame,topLayout); | 195 | mGeneral->initStatus(topFrame,topLayout); |
195 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 196 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
196 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 197 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
197 | mGeneral->initDescription(topFrame,topLayout); | 198 | mGeneral->initDescription(topFrame,topLayout); |
198 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 199 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
199 | mGeneral->initCategories( topFrame, detailsLayout ); | 200 | mGeneral->initCategories( topFrame, detailsLayout ); |
200 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 201 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
201 | } | 202 | } |
202 | mGeneral->finishSetup(); | 203 | mGeneral->finishSetup(); |
203 | 204 | ||
204 | } | 205 | } |
205 | 206 | ||
206 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 207 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
207 | { | 208 | { |
208 | //init(); | 209 | //init(); |
209 | 210 | ||
210 | mTodo = todo; | 211 | mTodo = todo; |
211 | readTodo(mTodo); | 212 | readTodo(mTodo); |
212 | if ( editDescription ) { | 213 | if ( editDescription ) { |
213 | showPage( 1 ); | 214 | showPage( 1 ); |
214 | mGeneral->setFocusOn( 1 ); | 215 | mGeneral->setFocusOn( 1 ); |
215 | } else { | 216 | } else { |
216 | showPage( 0 ); | 217 | showPage( 0 ); |
217 | mGeneral->setFocusOn( 2 ); | 218 | mGeneral->setFocusOn( 2 ); |
218 | } | 219 | } |
219 | checkRecurrence(); | 220 | checkRecurrence(); |
220 | } | 221 | } |
221 | 222 | ||
222 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 223 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
223 | { | 224 | { |
224 | //init(); | 225 | //init(); |
225 | 226 | ||
226 | mTodo = 0; | 227 | mTodo = 0; |
227 | setDefaults(due,relatedTodo,allDay); | 228 | setDefaults(due,relatedTodo,allDay); |
228 | } | 229 | } |
229 | 230 | ||
230 | void KOTodoEditor::loadDefaults() | 231 | void KOTodoEditor::loadDefaults() |
231 | { | 232 | { |
232 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 233 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
233 | } | 234 | } |
234 | 235 | ||
235 | bool KOTodoEditor::processInput( bool emitTime ) | 236 | bool KOTodoEditor::processInput( bool emitTime ) |
236 | { | 237 | { |
237 | if (!validateInput()) return false; | 238 | if (!validateInput()) return false; |
238 | 239 | ||
239 | Todo *todo = 0; | 240 | Todo *todo = 0; |
240 | 241 | ||
241 | if (mTodo) todo = mTodo; | 242 | if (mTodo) todo = mTodo; |
242 | else { | 243 | else { |
243 | todo = new Todo; | 244 | todo = new Todo; |
244 | todo->setOrganizer(KOPrefs::instance()->email()); | 245 | todo->setOrganizer(KOPrefs::instance()->email()); |
245 | } | 246 | } |
246 | 247 | ||
247 | writeTodo(todo); | 248 | writeTodo(todo); |
248 | if ( emitTime ) { | 249 | if ( emitTime ) { |
249 | globalFlagBlockAgenda = 1; | 250 | globalFlagBlockAgenda = 1; |
250 | emit showAgendaView( false ); | 251 | emit showAgendaView( false ); |
251 | if ( todo->hasDueDate() ) | 252 | if ( todo->hasDueDate() ) |
252 | emit jumpToTime( todo->dtDue().date() ); | 253 | emit jumpToTime( todo->dtDue().date() ); |
253 | globalFlagBlockAgenda = 2; | 254 | globalFlagBlockAgenda = 2; |
254 | } | 255 | } |
255 | if (mTodo) { | 256 | if (mTodo) { |
256 | todo->setRevision(todo->revision()+1); | 257 | todo->setRevision(todo->revision()+1); |
257 | emit todoChanged(todo); | 258 | emit todoChanged(todo); |
258 | } else { | 259 | } else { |
259 | mCalendar->addTodo(todo); | 260 | mCalendar->addTodo(todo); |
260 | mTodo = todo; | 261 | mTodo = todo; |
261 | emit todoAdded(todo); | 262 | emit todoAdded(todo); |
263 | if ( todo->isAlarmEnabled () && !todo->alarmEnabled () ) { | ||
264 | QTimer::singleShot( 0, this, SLOT ( alarmWarning() ) ); | ||
265 | } | ||
262 | } | 266 | } |
263 | 267 | ||
264 | return true; | 268 | return true; |
265 | } | 269 | } |
266 | 270 | ||
267 | void KOTodoEditor::deleteTodo() | 271 | void KOTodoEditor::deleteTodo() |
268 | { | 272 | { |
269 | if (mTodo) { | 273 | if (mTodo) { |
270 | if (KOPrefs::instance()->mConfirm) { | 274 | if (KOPrefs::instance()->mConfirm) { |
271 | switch (msgItemDelete()) { | 275 | switch (msgItemDelete()) { |
272 | case KMessageBox::Continue: // OK | 276 | case KMessageBox::Continue: // OK |
273 | emit todoToBeDeleted(mTodo); | 277 | emit todoToBeDeleted(mTodo); |
274 | emit dialogClose(mTodo); | 278 | emit dialogClose(mTodo); |
275 | mCalendar->deleteTodo(mTodo); | 279 | mCalendar->deleteTodo(mTodo); |
276 | emit todoDeleted(); | 280 | emit todoDeleted(); |
277 | reject(); | 281 | reject(); |
278 | break; | 282 | break; |
279 | } | 283 | } |
280 | } | 284 | } |
281 | else { | 285 | else { |
282 | emit todoToBeDeleted(mTodo); | 286 | emit todoToBeDeleted(mTodo); |
283 | emit dialogClose(mTodo); | 287 | emit dialogClose(mTodo); |
284 | mCalendar->deleteTodo(mTodo); | 288 | mCalendar->deleteTodo(mTodo); |
285 | emit todoDeleted(); | 289 | emit todoDeleted(); |
286 | reject(); | 290 | reject(); |
287 | } | 291 | } |
288 | } else { | 292 | } else { |
289 | reject(); | 293 | reject(); |
290 | } | 294 | } |
291 | } | 295 | } |
292 | 296 | ||
293 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 297 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
294 | { | 298 | { |
295 | mRelatedTodo = relatedEvent; | 299 | mRelatedTodo = relatedEvent; |
296 | 300 | ||
297 | mGeneral->setDefaults(due,allDay); | 301 | mGeneral->setDefaults(due,allDay); |
298 | mDetails->setDefaults(); | 302 | mDetails->setDefaults(); |
299 | showPage( 0 ); | 303 | showPage( 0 ); |
300 | if ( mRelatedTodo ) { | 304 | if ( mRelatedTodo ) { |
301 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); | 305 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); |
302 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 306 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
303 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 307 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
304 | if ( mRelatedTodo->priority() < 3 ) | 308 | if ( mRelatedTodo->priority() < 3 ) |
305 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 309 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
306 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 310 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
307 | int len = mRelatedTodo->summary().length(); | 311 | int len = mRelatedTodo->summary().length(); |
308 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 312 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
309 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 313 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
310 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 314 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
311 | 315 | ||
312 | } else | 316 | } else |
313 | mGeneral->setFocusOn( 2 ); | 317 | mGeneral->setFocusOn( 2 ); |
314 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 318 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
315 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); | 319 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
316 | } | 320 | } |
317 | void KOTodoEditor::checkRecurrence() | 321 | void KOTodoEditor::checkRecurrence() |
318 | { | 322 | { |
319 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 323 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
320 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 324 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
321 | 325 | ||
322 | if ( mTodo ) | 326 | if ( mTodo ) |
323 | mRecurrence->readEvent( mTodo ); | 327 | mRecurrence->readEvent( mTodo ); |
324 | else { | 328 | else { |
325 | bool time = mGeneral->mTimeButton->isChecked(); | 329 | bool time = mGeneral->mTimeButton->isChecked(); |
326 | QDateTime from,to; | 330 | QDateTime from,to; |
327 | if ( time ) { | 331 | if ( time ) { |
328 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 332 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
329 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 333 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
330 | } else { | 334 | } else { |
331 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 335 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
332 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 336 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
333 | } | 337 | } |
334 | if ( to < from ) | 338 | if ( to < from ) |
335 | to = from; | 339 | to = from; |
336 | mRecurrence->setDefaults(from,to); | 340 | mRecurrence->setDefaults(from,to); |
337 | } | 341 | } |
338 | } else { | 342 | } else { |
339 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 343 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
340 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); | 344 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
341 | } | 345 | } |
342 | } | 346 | } |
343 | void KOTodoEditor::readTodo(Todo *todo) | 347 | void KOTodoEditor::readTodo(Todo *todo) |
344 | { | 348 | { |
345 | mGeneral->readTodo(todo); | 349 | mGeneral->readTodo(todo); |
346 | mDetails->readEvent(todo); | 350 | mDetails->readEvent(todo); |
347 | mRelatedTodo = 0;//todo->relatedTo(); | 351 | mRelatedTodo = 0;//todo->relatedTo(); |
348 | // categories | 352 | // categories |
349 | // mCategoryDialog->setSelected(todo->categories()); | 353 | // mCategoryDialog->setSelected(todo->categories()); |
350 | 354 | ||
351 | // We should handle read-only events here. | 355 | // We should handle read-only events here. |
352 | } | 356 | } |
353 | 357 | ||
354 | void KOTodoEditor::writeTodo(Todo *event) | 358 | void KOTodoEditor::writeTodo(Todo *event) |
355 | { | 359 | { |
356 | bool maybeComputeRecurrenceTime = false; | 360 | bool maybeComputeRecurrenceTime = false; |
357 | if( event->hasRecurrenceID() && event->percentComplete() < 100) | 361 | if( event->hasRecurrenceID() && event->percentComplete() < 100) |