-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 20 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 4 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 43 | ||||
-rw-r--r-- | korganizer/kotodoeditor.h | 4 |
6 files changed, 66 insertions, 8 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 6370b54..a9d1ed3 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -369,6 +369,7 @@ void KOEditorGeneralTodo::enableDueEdit(bool enable) | |||
369 | } else { | 369 | } else { |
370 | mDueTimeEdit->setEnabled( false ); | 370 | mDueTimeEdit->setEnabled( false ); |
371 | } | 371 | } |
372 | emit datesChecked(); | ||
372 | } | 373 | } |
373 | 374 | ||
374 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 375 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
@@ -388,6 +389,7 @@ void KOEditorGeneralTodo::enableStartEdit( bool enable ) | |||
388 | } else { | 389 | } else { |
389 | mStartTimeEdit->setEnabled( false ); | 390 | mStartTimeEdit->setEnabled( false ); |
390 | } | 391 | } |
392 | emit datesChecked(); | ||
391 | } | 393 | } |
392 | 394 | ||
393 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 395 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index 98f43dd..b198539 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -72,6 +72,7 @@ class KOEditorGeneralTodo : public KOEditorGeneral | |||
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void openCategoryDialog(); | 74 | void openCategoryDialog(); |
75 | void datesChecked(); | ||
75 | 76 | ||
76 | protected slots: | 77 | protected slots: |
77 | void completedChanged(int); | 78 | void completedChanged(int); |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 4209e10..bedc75a 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <knumvalidator.h> | 42 | #include <knumvalidator.h> |
43 | 43 | ||
44 | #include <libkcal/event.h> | 44 | #include <libkcal/event.h> |
45 | #include <libkcal/todo.h> | ||
45 | 46 | ||
46 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
47 | 48 | ||
@@ -905,16 +906,23 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | |||
905 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 906 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
906 | } | 907 | } |
907 | 908 | ||
908 | void KOEditorRecurrence::readEvent(Event *event) | 909 | void KOEditorRecurrence::readEvent(Incidence *event) |
909 | { | 910 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 911 | |
912 | QDateTime dtEnd; | ||
913 | if ( event->type() == "Event" ) | ||
914 | dtEnd = ((Event*)event)->dtEnd(); | ||
915 | else | ||
916 | dtEnd = ((Todo*)event)->dtDue(); | ||
917 | |||
918 | setDefaults( event->dtStart(), dtEnd, true ); | ||
911 | QBitArray rDays( 7 ); | 919 | QBitArray rDays( 7 ); |
912 | QPtrList<Recurrence::rMonthPos> rmp; | 920 | QPtrList<Recurrence::rMonthPos> rmp; |
913 | QPtrList<int> rmd; | 921 | QPtrList<int> rmd; |
914 | int day = 0; | 922 | int day = 0; |
915 | int count = 0; | 923 | int count = 0; |
916 | int month = 0; | 924 | int month = 0; |
917 | setDateTimes( event->dtStart(), event->dtEnd() ); | 925 | setDateTimes( event->dtStart(), dtEnd ); |
918 | 926 | ||
919 | Recurrence *r = event->recurrence(); | 927 | Recurrence *r = event->recurrence(); |
920 | int f = r->frequency(); | 928 | int f = r->frequency(); |
@@ -928,7 +936,7 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
928 | 936 | ||
929 | switch ( recurs ) { | 937 | switch ( recurs ) { |
930 | case Recurrence::rNone: | 938 | case Recurrence::rNone: |
931 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 939 | setDefaults( event->dtStart(), dtEnd, true ); |
932 | break; | 940 | break; |
933 | case Recurrence::rDaily: | 941 | case Recurrence::rDaily: |
934 | recurrenceType = RecurrenceChooser::Daily; | 942 | recurrenceType = RecurrenceChooser::Daily; |
@@ -1000,7 +1008,7 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
1000 | mYearly->setFrequency( f ); | 1008 | mYearly->setFrequency( f ); |
1001 | break; | 1009 | break; |
1002 | default: | 1010 | default: |
1003 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 1011 | setDefaults( event->dtStart(), dtEnd, true ); |
1004 | break; | 1012 | break; |
1005 | } | 1013 | } |
1006 | 1014 | ||
@@ -1024,7 +1032,7 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
1024 | mExceptions->setDates( event->exDates() ); | 1032 | mExceptions->setDates( event->exDates() ); |
1025 | } | 1033 | } |
1026 | 1034 | ||
1027 | void KOEditorRecurrence::writeEvent( Event *event ) | 1035 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
1028 | { | 1036 | { |
1029 | Recurrence *r = event->recurrence(); | 1037 | Recurrence *r = event->recurrence(); |
1030 | 1038 | ||
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index 2b59085..a15afcb 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -274,9 +274,9 @@ class KOEditorRecurrence : public QWidget | |||
274 | /** Set widgets to default values */ | 274 | /** Set widgets to default values */ |
275 | void setDefaults( QDateTime from, QDateTime to, bool allday ); | 275 | void setDefaults( QDateTime from, QDateTime to, bool allday ); |
276 | /** Read event object and setup widgets accordingly */ | 276 | /** Read event object and setup widgets accordingly */ |
277 | void readEvent( Event * ); | 277 | void readEvent( Incidence * ); |
278 | /** Write event settings to event object */ | 278 | /** Write event settings to event object */ |
279 | void writeEvent( Event * ); | 279 | void writeEvent( Incidence * ); |
280 | 280 | ||
281 | /** Check if the input is valid. */ | 281 | /** Check if the input is valid. */ |
282 | bool validateInput(); | 282 | bool validateInput(); |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 70dfbd1..069dda8 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | ||
33 | 34 | ||
34 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
35 | #include <klocale.h> | 36 | #include <klocale.h> |
@@ -43,6 +44,7 @@ | |||
43 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
44 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
45 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | ||
46 | 48 | ||
47 | #include "koprefs.h" | 49 | #include "koprefs.h" |
48 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
@@ -68,7 +70,18 @@ void KOTodoEditor::init() | |||
68 | { | 70 | { |
69 | setupGeneral(); | 71 | setupGeneral(); |
70 | setupAttendeesTab(); | 72 | setupAttendeesTab(); |
73 | setupRecurrence(); | ||
74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | ||
71 | } | 75 | } |
76 | void KOTodoEditor::setupRecurrence() | ||
77 | { | ||
78 | QFrame *topFrame = addPage( i18n("Recurrence") ); | ||
79 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | ||
80 | |||
81 | mRecurrence = new KOEditorRecurrence( topFrame ); | ||
82 | topLayout->addWidget( mRecurrence ); | ||
83 | } | ||
84 | |||
72 | void KOTodoEditor::setCategories( QString s ) | 85 | void KOTodoEditor::setCategories( QString s ) |
73 | { | 86 | { |
74 | mGeneral->setCategories(s); | 87 | mGeneral->setCategories(s); |
@@ -194,6 +207,7 @@ void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | |||
194 | showPage( 0 ); | 207 | showPage( 0 ); |
195 | mGeneral->setFocusOn( 2 ); | 208 | mGeneral->setFocusOn( 2 ); |
196 | } | 209 | } |
210 | checkRecurrence(); | ||
197 | } | 211 | } |
198 | 212 | ||
199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 213 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
@@ -287,8 +301,33 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | |||
287 | 301 | ||
288 | } else | 302 | } else |
289 | mGeneral->setFocusOn( 2 ); | 303 | mGeneral->setFocusOn( 2 ); |
304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | ||
305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | ||
290 | } | 306 | } |
307 | void KOTodoEditor::checkRecurrence() | ||
308 | { | ||
309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | ||
310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | ||
291 | 311 | ||
312 | if ( mTodo ) | ||
313 | mRecurrence->readEvent( mTodo ); | ||
314 | else { | ||
315 | bool time = mGeneral->mTimeButton->isChecked(); | ||
316 | QDateTime from,to; | ||
317 | if ( time ) { | ||
318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | ||
319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | ||
320 | } else { | ||
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | ||
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | ||
323 | } | ||
324 | mRecurrence->setDefaults(from,to,!time); | ||
325 | } | ||
326 | } else { | ||
327 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | ||
328 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | ||
329 | } | ||
330 | } | ||
292 | void KOTodoEditor::readTodo(Todo *todo) | 331 | void KOTodoEditor::readTodo(Todo *todo) |
293 | { | 332 | { |
294 | mGeneral->readTodo(todo); | 333 | mGeneral->readTodo(todo); |
@@ -309,6 +348,10 @@ void KOTodoEditor::writeTodo(Todo *event) | |||
309 | if (mRelatedTodo) { | 348 | if (mRelatedTodo) { |
310 | event->setRelatedTo(mRelatedTodo); | 349 | event->setRelatedTo(mRelatedTodo); |
311 | } | 350 | } |
351 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | ||
352 | mRecurrence->writeEvent(event); | ||
353 | } else | ||
354 | event->recurrence()->unsetRecurs(); | ||
312 | } | 355 | } |
313 | 356 | ||
314 | bool KOTodoEditor::validateInput() | 357 | bool KOTodoEditor::validateInput() |
diff --git a/korganizer/kotodoeditor.h b/korganizer/kotodoeditor.h index 2657bd8..1b5e3b4 100644 --- a/korganizer/kotodoeditor.h +++ b/korganizer/kotodoeditor.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "koeditorgeneraltodo.h" | 29 | #include "koeditorgeneraltodo.h" |
30 | #include "koeditordetails.h" | 30 | #include "koeditordetails.h" |
31 | #include "koincidenceeditor.h" | 31 | #include "koincidenceeditor.h" |
32 | #include "koeditorrecurrence.h" | ||
32 | 33 | ||
33 | class QDateTime; | 34 | class QDateTime; |
34 | 35 | ||
@@ -82,6 +83,7 @@ class KOTodoEditor : public KOIncidenceEditor | |||
82 | protected slots: | 83 | protected slots: |
83 | void loadDefaults(); | 84 | void loadDefaults(); |
84 | void deleteTodo(); | 85 | void deleteTodo(); |
86 | void checkRecurrence(); | ||
85 | 87 | ||
86 | void slotLoadTemplate(); | 88 | void slotLoadTemplate(); |
87 | void slotSaveTemplate(); | 89 | void slotSaveTemplate(); |
@@ -90,6 +92,7 @@ class KOTodoEditor : public KOIncidenceEditor | |||
90 | protected: | 92 | protected: |
91 | void setupGeneral(); | 93 | void setupGeneral(); |
92 | int msgItemDelete(); | 94 | int msgItemDelete(); |
95 | void setupRecurrence(); | ||
93 | 96 | ||
94 | private: | 97 | private: |
95 | Todo *mTodo; | 98 | Todo *mTodo; |
@@ -97,6 +100,7 @@ class KOTodoEditor : public KOIncidenceEditor | |||
97 | Incidence *mRelatedTodo; | 100 | Incidence *mRelatedTodo; |
98 | 101 | ||
99 | KOEditorGeneralTodo *mGeneral; | 102 | KOEditorGeneralTodo *mGeneral; |
103 | KOEditorRecurrence *mRecurrence; | ||
100 | }; | 104 | }; |
101 | 105 | ||
102 | #endif | 106 | #endif |