author | zautrix <zautrix> | 2005-04-18 10:41:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-18 10:41:31 (UTC) |
commit | 409e329447a7d00a93a56855fcddadbb0f793163 (patch) (unidiff) | |
tree | 1c92498d2dfb4c89358c64a6944aca1300a27d11 /korganizer/kotodoeditor.cpp | |
parent | 0ff0dca7ccb94ebb1381351e4e4081fe0bac500a (diff) | |
download | kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.zip kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.gz kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.bz2 |
morefixes
-rw-r--r-- | korganizer/kotodoeditor.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 6a05cc8..5513e8b 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -65,101 +65,101 @@ KOTodoEditor::~KOTodoEditor() | |||
65 | { | 65 | { |
66 | emit dialogClose( mTodo ); | 66 | emit dialogClose( mTodo ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void KOTodoEditor::init() | 69 | void KOTodoEditor::init() |
70 | { | 70 | { |
71 | setupGeneral(); | 71 | setupGeneral(); |
72 | setupAttendeesTab(); | 72 | setupAttendeesTab(); |
73 | setupRecurrence(); | 73 | setupRecurrence(); |
74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
75 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 75 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
76 | } | 76 | } |
77 | void KOTodoEditor::setupRecurrence() | 77 | void KOTodoEditor::setupRecurrence() |
78 | { | 78 | { |
79 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 79 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
80 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 80 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
81 | 81 | ||
82 | mRecurrence = new KOEditorRecurrence( topFrame ); | 82 | mRecurrence = new KOEditorRecurrence( topFrame ); |
83 | topLayout->addWidget( mRecurrence ); | 83 | topLayout->addWidget( mRecurrence ); |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOTodoEditor::setCategories( QString s ) | 86 | void KOTodoEditor::setCategories( QString s ) |
87 | { | 87 | { |
88 | mGeneral->setCategories(s); | 88 | mGeneral->setCategories(s); |
89 | } | 89 | } |
90 | void KOTodoEditor::setSecrecy( int sec ) | 90 | void KOTodoEditor::setSecrecy( int sec ) |
91 | { | 91 | { |
92 | mGeneral->setSecrecy( sec ); | 92 | mGeneral->setSecrecy( sec ); |
93 | } | 93 | } |
94 | void KOTodoEditor::reload() | 94 | void KOTodoEditor::reload() |
95 | { | 95 | { |
96 | if ( mTodo ) readTodo( mTodo ); | 96 | if ( mTodo ) readTodo( mTodo ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void KOTodoEditor::setupGeneral() | 99 | void KOTodoEditor::setupGeneral() |
100 | { | 100 | { |
101 | mGeneral = new KOEditorGeneralTodo(this); | 101 | mGeneral = new KOEditorGeneralTodo(this); |
102 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 102 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
103 | 103 | ||
104 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 104 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
105 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 105 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
106 | // mGeneral,SLOT(setCategories(const QString &))); | 106 | // mGeneral,SLOT(setCategories(const QString &))); |
107 | 107 | ||
108 | if (KOPrefs::instance()->mCompactDialogs) { | 108 | if (KOPrefs::instance()->mCompactDialogs) { |
109 | QFrame *topFrame = addPage(i18n("General")); | 109 | QFrame *topFrame = addPage(i18n("General")); |
110 | 110 | ||
111 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 111 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
112 | if ( QApplication::desktop()->width() < 480 ) { | 112 | if ( QApplication::desktop()->width() < 480 ) { |
113 | topLayout->setMargin(1); | 113 | topLayout->setMargin(marginHintSmall()); |
114 | topLayout->setSpacing(1); | 114 | topLayout->setSpacing(spacingHintSmall()); |
115 | } else { | 115 | } else { |
116 | topLayout->setMargin(marginHint()-1); | 116 | topLayout->setMargin(marginHint()); |
117 | topLayout->setSpacing(spacingHint()-1); | 117 | topLayout->setSpacing(spacingHint()); |
118 | } | 118 | } |
119 | mGeneral->initHeader(topFrame,topLayout); | 119 | mGeneral->initHeader(topFrame,topLayout); |
120 | mGeneral->initTime(topFrame,topLayout); | 120 | mGeneral->initTime(topFrame,topLayout); |
121 | mGeneral->initAlarm(topFrame,topLayout); | 121 | mGeneral->initAlarm(topFrame,topLayout); |
122 | mGeneral->enableAlarm( false ); | 122 | mGeneral->enableAlarm( false ); |
123 | 123 | ||
124 | 124 | ||
125 | QBoxLayout *priorityLayout; | 125 | QBoxLayout *priorityLayout; |
126 | if ( QApplication::desktop()->width() < 500 ) | 126 | if ( QApplication::desktop()->width() < 500 ) |
127 | priorityLayout = new QVBoxLayout( topLayout ); | 127 | priorityLayout = new QVBoxLayout( topLayout ); |
128 | else | 128 | else |
129 | priorityLayout = new QHBoxLayout( topLayout ); | 129 | priorityLayout = new QHBoxLayout( topLayout ); |
130 | QWidget* prioWidget = new QWidget (topFrame); | 130 | QWidget* prioWidget = new QWidget (topFrame); |
131 | priorityLayout->addWidget( prioWidget ); | 131 | priorityLayout->addWidget( prioWidget ); |
132 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 132 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
133 | 133 | ||
134 | 134 | ||
135 | QIconSet icon; | 135 | QIconSet icon; |
136 | if ( QApplication::desktop()->width() < 321 ) | 136 | if ( QApplication::desktop()->width() < 321 ) |
137 | icon = SmallIcon("fileimport16"); | 137 | icon = SmallIcon("fileimport16"); |
138 | else | 138 | else |
139 | icon = SmallIcon("fileimport"); | 139 | icon = SmallIcon("fileimport"); |
140 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 140 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
141 | loadTemplate->setIconSet (icon ) ; | 141 | loadTemplate->setIconSet (icon ) ; |
142 | int size = loadTemplate->sizeHint().height(); | 142 | int size = loadTemplate->sizeHint().height(); |
143 | loadTemplate->setFixedSize( size, size ); | 143 | loadTemplate->setFixedSize( size, size ); |
144 | if ( QApplication::desktop()->width() < 321 ) | 144 | if ( QApplication::desktop()->width() < 321 ) |
145 | icon = SmallIcon("fileexport16"); | 145 | icon = SmallIcon("fileexport16"); |
146 | else | 146 | else |
147 | icon = SmallIcon("fileexport"); | 147 | icon = SmallIcon("fileexport"); |
148 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 148 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
149 | saveTemplate->setIconSet (icon ) ; | 149 | saveTemplate->setIconSet (icon ) ; |
150 | saveTemplate->setFixedSize( size, size ); | 150 | saveTemplate->setFixedSize( size, size ); |
151 | 151 | ||
152 | priorityLayout2->addWidget(loadTemplate); | 152 | priorityLayout2->addWidget(loadTemplate); |
153 | priorityLayout2->addWidget(saveTemplate); | 153 | priorityLayout2->addWidget(saveTemplate); |
154 | mGeneral->initPriority(prioWidget,priorityLayout2); | 154 | mGeneral->initPriority(prioWidget,priorityLayout2); |
155 | mGeneral->initCategories( topFrame, priorityLayout ); | 155 | mGeneral->initCategories( topFrame, priorityLayout ); |
156 | topLayout->addStretch(1); | 156 | topLayout->addStretch(1); |
157 | 157 | ||
158 | QFrame *topFrame2 = addPage(i18n("Details")); | 158 | QFrame *topFrame2 = addPage(i18n("Details")); |
159 | 159 | ||
160 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 160 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
161 | topLayout2->setMargin(marginHint()); | 161 | topLayout2->setMargin(marginHint()); |
162 | topLayout2->setSpacing(spacingHint()); | 162 | topLayout2->setSpacing(spacingHint()); |
163 | 163 | ||
164 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 164 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
165 | mGeneral->initCompletion(topFrame2,completionLayout); | 165 | mGeneral->initCompletion(topFrame2,completionLayout); |
@@ -299,115 +299,122 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | |||
299 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 299 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
300 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 300 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
301 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 301 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
302 | 302 | ||
303 | } else | 303 | } else |
304 | mGeneral->setFocusOn( 2 ); | 304 | mGeneral->setFocusOn( 2 ); |
305 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 305 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
306 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 306 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
307 | } | 307 | } |
308 | void KOTodoEditor::checkRecurrence() | 308 | void KOTodoEditor::checkRecurrence() |
309 | { | 309 | { |
310 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 310 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
311 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 311 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
312 | 312 | ||
313 | if ( mTodo ) | 313 | if ( mTodo ) |
314 | mRecurrence->readEvent( mTodo ); | 314 | mRecurrence->readEvent( mTodo ); |
315 | else { | 315 | else { |
316 | bool time = mGeneral->mTimeButton->isChecked(); | 316 | bool time = mGeneral->mTimeButton->isChecked(); |
317 | QDateTime from,to; | 317 | QDateTime from,to; |
318 | if ( time ) { | 318 | if ( time ) { |
319 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 319 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
320 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 320 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
321 | } else { | 321 | } else { |
322 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 322 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
323 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 323 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
324 | } | 324 | } |
325 | if ( to < from ) | 325 | if ( to < from ) |
326 | to = from; | 326 | to = from; |
327 | mRecurrence->setDefaults(from,to,!time); | 327 | mRecurrence->setDefaults(from,to,!time); |
328 | } | 328 | } |
329 | } else { | 329 | } else { |
330 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 330 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
331 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 331 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | void KOTodoEditor::readTodo(Todo *todo) | 334 | void KOTodoEditor::readTodo(Todo *todo) |
335 | { | 335 | { |
336 | mGeneral->readTodo(todo); | 336 | mGeneral->readTodo(todo); |
337 | mDetails->readEvent(todo); | 337 | mDetails->readEvent(todo); |
338 | mRelatedTodo = 0;//todo->relatedTo(); | 338 | mRelatedTodo = 0;//todo->relatedTo(); |
339 | // categories | 339 | // categories |
340 | // mCategoryDialog->setSelected(todo->categories()); | 340 | // mCategoryDialog->setSelected(todo->categories()); |
341 | 341 | ||
342 | // We should handle read-only events here. | 342 | // We should handle read-only events here. |
343 | } | 343 | } |
344 | 344 | ||
345 | void KOTodoEditor::writeTodo(Todo *event) | 345 | void KOTodoEditor::writeTodo(Todo *event) |
346 | { | 346 | { |
347 | mGeneral->writeTodo(event); | 347 | bool maybeComputeRecurrenceTime = false; |
348 | mDetails->writeEvent(event); | 348 | if( event->hasRecurrenceID() && event->percentComplete() < 100) |
349 | 349 | maybeComputeRecurrenceTime = true; | |
350 | // set related event, i.e. parent to-do in this case. | 350 | event->setHasRecurrenceID( false ); |
351 | if (mRelatedTodo) { | 351 | mGeneral->writeTodo(event); |
352 | event->setRelatedTo(mRelatedTodo); | 352 | mDetails->writeEvent(event); |
353 | } | 353 | |
354 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 354 | // set related event, i.e. parent to-do in this case. |
355 | mRecurrence->writeEvent(event); | 355 | if (mRelatedTodo) { |
356 | if ( event->doesRecur() ) { | 356 | event->setRelatedTo(mRelatedTodo); |
357 | event->setRecurrenceID( event->dtStart().addSecs(-1) ); | 357 | } |
358 | event->setRecurDates(); | 358 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
359 | } else { | 359 | mRecurrence->writeEvent(event); |
360 | event->setHasRecurrenceID( false ); | 360 | if ( event->doesRecur() ) { |
361 | } | 361 | int addSec = -1 ; |
362 | } else { | 362 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) |
363 | event->setHasRecurrenceID( false ); | 363 | addSec = 1; |
364 | event->recurrence()->unsetRecurs(); | 364 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); |
365 | } | 365 | event->setRecurDates(); |
366 | } else { | ||
367 | event->setHasRecurrenceID( false ); | ||
368 | } | ||
369 | } else { | ||
370 | event->setHasRecurrenceID( false ); | ||
371 | event->recurrence()->unsetRecurs(); | ||
372 | } | ||
366 | } | 373 | } |
367 | 374 | ||
368 | bool KOTodoEditor::validateInput() | 375 | bool KOTodoEditor::validateInput() |
369 | { | 376 | { |
370 | if (!mGeneral->validateInput()) return false; | 377 | if (!mGeneral->validateInput()) return false; |
371 | if (!mDetails->validateInput()) return false; | 378 | if (!mDetails->validateInput()) return false; |
372 | return true; | 379 | return true; |
373 | } | 380 | } |
374 | 381 | ||
375 | int KOTodoEditor::msgItemDelete() | 382 | int KOTodoEditor::msgItemDelete() |
376 | { | 383 | { |
377 | return KMessageBox::warningContinueCancel(this, | 384 | return KMessageBox::warningContinueCancel(this, |
378 | i18n("This item will be permanently deleted."), | 385 | i18n("This item will be permanently deleted."), |
379 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 386 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
380 | } | 387 | } |
381 | 388 | ||
382 | void KOTodoEditor::modified (int modification) | 389 | void KOTodoEditor::modified (int modification) |
383 | { | 390 | { |
384 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 391 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
385 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 392 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
386 | // mCategoryDialog->setSelected (mTodo->categories ()); | 393 | // mCategoryDialog->setSelected (mTodo->categories ()); |
387 | mGeneral->modified (mTodo, modification); | 394 | mGeneral->modified (mTodo, modification); |
388 | 395 | ||
389 | } | 396 | } |
390 | 397 | ||
391 | void KOTodoEditor::slotLoadTemplate() | 398 | void KOTodoEditor::slotLoadTemplate() |
392 | { | 399 | { |
393 | 400 | ||
394 | QString fileName =locateLocal( "templates", "todos" ); | 401 | QString fileName =locateLocal( "templates", "todos" ); |
395 | QDir t_dir; | 402 | QDir t_dir; |
396 | if ( !t_dir.exists(fileName) ) | 403 | if ( !t_dir.exists(fileName) ) |
397 | t_dir.mkdir ( fileName ); | 404 | t_dir.mkdir ( fileName ); |
398 | fileName += "/todo"; | 405 | fileName += "/todo"; |
399 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 406 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
400 | if ( fileName.length() == 0 ) | 407 | if ( fileName.length() == 0 ) |
401 | return; | 408 | return; |
402 | CalendarLocal cal; | 409 | CalendarLocal cal; |
403 | ICalFormat format; | 410 | ICalFormat format; |
404 | if ( !format.load( &cal, fileName ) ) { | 411 | if ( !format.load( &cal, fileName ) ) { |
405 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 412 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
406 | .arg( fileName ) ); | 413 | .arg( fileName ) ); |
407 | return ; | 414 | return ; |
408 | } | 415 | } |
409 | QPtrList<Todo> todos = cal.todos(); | 416 | QPtrList<Todo> todos = cal.todos(); |
410 | Todo * todo = todos.first(); | 417 | Todo * todo = todos.first(); |
411 | if ( !todo ) { | 418 | if ( !todo ) { |
412 | KMessageBox::error( this, | 419 | KMessageBox::error( this, |
413 | i18n("Template does not\ncontain a valid Todo.")); | 420 | i18n("Template does not\ncontain a valid Todo.")); |