-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 52 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 2 |
2 files changed, 44 insertions, 10 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index b9a028b..ce0d7a9 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -139,35 +139,48 @@ void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | |||
139 | // xgettext:no-c-format | 139 | // xgettext:no-c-format |
140 | mCompletedCombo->insertItem(i18n(" 40 %")); | 140 | mCompletedCombo->insertItem(i18n(" 40 %")); |
141 | // xgettext:no-c-format | 141 | // xgettext:no-c-format |
142 | mCompletedCombo->insertItem(i18n(" 60 %")); | 142 | mCompletedCombo->insertItem(i18n(" 60 %")); |
143 | // xgettext:no-c-format | 143 | // xgettext:no-c-format |
144 | mCompletedCombo->insertItem(i18n(" 80 %")); | 144 | mCompletedCombo->insertItem(i18n(" 80 %")); |
145 | // xgettext:no-c-format | 145 | // xgettext:no-c-format |
146 | mCompletedCombo->insertItem(i18n("100 %")); | 146 | mCompletedCombo->insertItem(i18n("100 %")); |
147 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 147 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
148 | topLayout->addWidget(mCompletedCombo); | 148 | topLayout->addWidget(mCompletedCombo); |
149 | 149 | ||
150 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 150 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
151 | topLayout->addWidget(mCompletedLabel); | 151 | topLayout->addWidget(mCompletedLabel); |
152 | |||
153 | mCompleteDateEdit = new KDateEdit(parent); | ||
154 | topLayout->addWidget(mCompleteDateEdit ); | ||
155 | |||
156 | mCompleteTimeEdit = new KOTimeEdit(parent); | ||
157 | topLayout->addWidget( mCompleteTimeEdit); | ||
158 | |||
159 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | ||
160 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | ||
161 | |||
162 | if ( QApplication::desktop()->width() < 320 ) { | ||
163 | mCompleteDateEdit->setMaximumWidth( 85 ); | ||
164 | topLayout->setSpacing( 0 ); | ||
165 | } | ||
152 | } | 166 | } |
153 | 167 | ||
154 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 168 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
155 | { | 169 | { |
156 | 170 | ||
157 | QHBox* h = new QHBox ( parent ); | 171 | QHBox* h = new QHBox ( parent ); |
158 | topLayout->addWidget( h ); | 172 | topLayout->addWidget( h ); |
159 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 173 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
160 | // topLayout->addWidget(priorityLabel); | 174 | // topLayout->addWidget(priorityLabel); |
161 | |||
162 | mPriorityCombo = new QComboBox( h ); | 175 | mPriorityCombo = new QComboBox( h ); |
163 | mPriorityCombo->insertItem(i18n("1 (high)")); | 176 | mPriorityCombo->insertItem(i18n("1 (high)")); |
164 | mPriorityCombo->insertItem(i18n("2")); | 177 | mPriorityCombo->insertItem(i18n("2")); |
165 | mPriorityCombo->insertItem(i18n("3")); | 178 | mPriorityCombo->insertItem(i18n("3")); |
166 | mPriorityCombo->insertItem(i18n("4")); | 179 | mPriorityCombo->insertItem(i18n("4")); |
167 | mPriorityCombo->insertItem(i18n("5 (low)")); | 180 | mPriorityCombo->insertItem(i18n("5 (low)")); |
168 | //topLayout->addWidget(mPriorityCombo); | 181 | //topLayout->addWidget(mPriorityCombo); |
169 | } | 182 | } |
170 | 183 | ||
171 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 184 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
172 | { | 185 | { |
173 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 186 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
@@ -303,33 +316,42 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo) | |||
303 | tmpDate = mDueDateEdit->date(); | 316 | tmpDate = mDueDateEdit->date(); |
304 | tmpTime.setHMS(0,0,0); | 317 | tmpTime.setHMS(0,0,0); |
305 | tmpDT.setDate(tmpDate); | 318 | tmpDT.setDate(tmpDate); |
306 | tmpDT.setTime(tmpTime); | 319 | tmpDT.setTime(tmpTime); |
307 | todo->setDtDue(tmpDT); | 320 | todo->setDtDue(tmpDT); |
308 | 321 | ||
309 | tmpDate = mStartDateEdit->date(); | 322 | tmpDate = mStartDateEdit->date(); |
310 | tmpTime.setHMS(0,0,0); | 323 | tmpTime.setHMS(0,0,0); |
311 | tmpDT.setDate(tmpDate); | 324 | tmpDT.setDate(tmpDate); |
312 | tmpDT.setTime(tmpTime); | 325 | tmpDT.setTime(tmpTime); |
313 | todo->setDtStart(tmpDT); | 326 | todo->setDtStart(tmpDT); |
314 | } | 327 | } |
315 | |||
316 | todo->setPriority(mPriorityCombo->currentItem()+1); | 328 | todo->setPriority(mPriorityCombo->currentItem()+1); |
317 | 329 | ||
318 | // set completion state | 330 | // set completion state |
319 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 331 | if ( mCompletedCombo->currentItem() == 5 ) { |
320 | 332 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | |
321 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 333 | if ( comp.isValid () ) { |
322 | todo->setCompleted(mCompleted); | 334 | todo->setPercentComplete(0); |
335 | todo->setPercentComplete(100); | ||
336 | todo->setCompleted(comp); | ||
337 | } else { | ||
338 | todo->setPercentComplete( 100 ); | ||
339 | if ( mCompleted.isValid() ) | ||
340 | todo->setCompleted(mCompleted); | ||
341 | } | ||
342 | } else { | ||
343 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | ||
323 | } | 344 | } |
345 | |||
324 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 346 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
325 | } | 347 | } |
326 | 348 | ||
327 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 349 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
328 | { | 350 | { |
329 | mDueDateEdit->setEnabled( enable ); | 351 | mDueDateEdit->setEnabled( enable ); |
330 | 352 | ||
331 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 353 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
332 | mTimeButton->setEnabled(true); | 354 | mTimeButton->setEnabled(true); |
333 | } | 355 | } |
334 | else { | 356 | else { |
335 | mTimeButton->setEnabled(false); | 357 | mTimeButton->setEnabled(false); |
@@ -411,36 +433,46 @@ bool KOEditorGeneralTodo::validateInput() | |||
411 | KMessageBox::sorry(0, | 433 | KMessageBox::sorry(0, |
412 | i18n("The start date cannot be after the due date.")); | 434 | i18n("The start date cannot be after the due date.")); |
413 | return false; | 435 | return false; |
414 | } | 436 | } |
415 | } | 437 | } |
416 | 438 | ||
417 | return KOEditorGeneral::validateInput(); | 439 | return KOEditorGeneral::validateInput(); |
418 | } | 440 | } |
419 | 441 | ||
420 | void KOEditorGeneralTodo::completedChanged(int index) | 442 | void KOEditorGeneralTodo::completedChanged(int index) |
421 | { | 443 | { |
422 | if (index == 5) { | 444 | if (index == 5) { |
423 | mCompleted = QDateTime::currentDateTime(); | 445 | //get rid of milli sec |
446 | mCompleted = QDateTime::currentDateTime(); | ||
424 | } | 447 | } |
425 | setCompletedDate(); | 448 | setCompletedDate(); |
426 | } | 449 | } |
427 | 450 | ||
428 | void KOEditorGeneralTodo::setCompletedDate() | 451 | void KOEditorGeneralTodo::setCompletedDate() |
429 | { | 452 | { |
430 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 453 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
431 | mCompletedLabel->setText(i18n("completed on %1") | 454 | if ( QApplication::desktop()->width() < 480 ) { |
432 | .arg(KGlobal::locale()->formatDateTime(mCompleted))); | 455 | mCompletedLabel->setText(i18n(" on")); |
456 | } | ||
457 | else | ||
458 | mCompletedLabel->setText(i18n(" completed on ")); | ||
459 | mCompleteDateEdit->show(); | ||
460 | mCompleteTimeEdit->show(); | ||
461 | mCompleteTimeEdit->setTime( mCompleted.time() ); | ||
462 | mCompleteDateEdit->setDate( mCompleted.date() ); | ||
433 | } else { | 463 | } else { |
434 | mCompletedLabel->setText(i18n("completed")); | 464 | mCompletedLabel->setText(i18n("completed")); |
465 | mCompleteDateEdit->hide(); | ||
466 | mCompleteTimeEdit->hide(); | ||
435 | } | 467 | } |
436 | } | 468 | } |
437 | 469 | ||
438 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 470 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
439 | { | 471 | { |
440 | switch (modification) { | 472 | switch (modification) { |
441 | case KOGlobals::PRIORITY_MODIFIED: | 473 | case KOGlobals::PRIORITY_MODIFIED: |
442 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 474 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
443 | break; | 475 | break; |
444 | case KOGlobals::COMPLETION_MODIFIED: | 476 | case KOGlobals::COMPLETION_MODIFIED: |
445 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 477 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
446 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 478 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index 5f1c3cc..98f43dd 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -79,24 +79,26 @@ class KOEditorGeneralTodo : public KOEditorGeneral | |||
79 | void enableDueEdit( bool enable ); | 79 | void enableDueEdit( bool enable ); |
80 | void enableStartEdit( bool enable ); | 80 | void enableStartEdit( bool enable ); |
81 | void enableTimeEdits( bool enable ); | 81 | void enableTimeEdits( bool enable ); |
82 | void showAlarm(); | 82 | void showAlarm(); |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | void setCompletedDate(); | 85 | void setCompletedDate(); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | friend class KOTodoEditor; | 88 | friend class KOTodoEditor; |
89 | KDateEdit *mStartDateEdit; | 89 | KDateEdit *mStartDateEdit; |
90 | KOTimeEdit *mStartTimeEdit; | 90 | KOTimeEdit *mStartTimeEdit; |
91 | KDateEdit *mCompleteDateEdit; | ||
92 | KOTimeEdit *mCompleteTimeEdit; | ||
91 | QCheckBox *mTimeButton; | 93 | QCheckBox *mTimeButton; |
92 | QCheckBox *mDueCheck; | 94 | QCheckBox *mDueCheck; |
93 | KDateEdit *mDueDateEdit; | 95 | KDateEdit *mDueDateEdit; |
94 | KOTimeEdit *mDueTimeEdit; | 96 | KOTimeEdit *mDueTimeEdit; |
95 | QComboBox *mCompletedCombo; | 97 | QComboBox *mCompletedCombo; |
96 | QLabel *mCompletedLabel; | 98 | QLabel *mCompletedLabel; |
97 | QLabel *mPriorityLabel; | 99 | QLabel *mPriorityLabel; |
98 | QComboBox *mPriorityCombo; | 100 | QComboBox *mPriorityCombo; |
99 | 101 | ||
100 | QCheckBox *mStartCheck; | 102 | QCheckBox *mStartCheck; |
101 | 103 | ||
102 | QDateTime mCompleted; | 104 | QDateTime mCompleted; |