-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 | 47 | ||||
-rw-r--r-- | korganizer/kotodoeditor.h | 4 |
6 files changed, 68 insertions, 10 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 6370b54..a9d1ed3 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -340,83 +340,85 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo) | |||
340 | todo->setPercentComplete(0); | 340 | todo->setPercentComplete(0); |
341 | todo->setPercentComplete(100); | 341 | todo->setPercentComplete(100); |
342 | todo->setCompleted(comp); | 342 | todo->setCompleted(comp); |
343 | } else { | 343 | } else { |
344 | todo->setPercentComplete( 100 ); | 344 | todo->setPercentComplete( 100 ); |
345 | if ( mCompleted.isValid() ) | 345 | if ( mCompleted.isValid() ) |
346 | todo->setCompleted(mCompleted); | 346 | todo->setCompleted(mCompleted); |
347 | } | 347 | } |
348 | } else { | 348 | } else { |
349 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 349 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
350 | } | 350 | } |
351 | 351 | ||
352 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 352 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
353 | } | 353 | } |
354 | 354 | ||
355 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 355 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
356 | { | 356 | { |
357 | mDueDateEdit->setEnabled( enable ); | 357 | mDueDateEdit->setEnabled( enable ); |
358 | 358 | ||
359 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 359 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
360 | mTimeButton->setEnabled(true); | 360 | mTimeButton->setEnabled(true); |
361 | } | 361 | } |
362 | else { | 362 | else { |
363 | mTimeButton->setEnabled(false); | 363 | mTimeButton->setEnabled(false); |
364 | mTimeButton->setChecked(false); | 364 | mTimeButton->setChecked(false); |
365 | } | 365 | } |
366 | 366 | ||
367 | if (enable) { | 367 | if (enable) { |
368 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 368 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
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 ) |
375 | { | 376 | { |
376 | mStartDateEdit->setEnabled( enable ); | 377 | mStartDateEdit->setEnabled( enable ); |
377 | 378 | ||
378 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 379 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
379 | mTimeButton->setEnabled(true); | 380 | mTimeButton->setEnabled(true); |
380 | } | 381 | } |
381 | else { | 382 | else { |
382 | mTimeButton->setEnabled(false); | 383 | mTimeButton->setEnabled(false); |
383 | mTimeButton->setChecked(false); | 384 | mTimeButton->setChecked(false); |
384 | } | 385 | } |
385 | 386 | ||
386 | if (enable) { | 387 | if (enable) { |
387 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 388 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
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) |
394 | { | 396 | { |
395 | if(mStartCheck->isChecked()) { | 397 | if(mStartCheck->isChecked()) { |
396 | mStartTimeEdit->setEnabled( enable ); | 398 | mStartTimeEdit->setEnabled( enable ); |
397 | } | 399 | } |
398 | if(mDueCheck->isChecked()) { | 400 | if(mDueCheck->isChecked()) { |
399 | mDueTimeEdit->setEnabled( enable ); | 401 | mDueTimeEdit->setEnabled( enable ); |
400 | } | 402 | } |
401 | } | 403 | } |
402 | 404 | ||
403 | void KOEditorGeneralTodo::showAlarm() | 405 | void KOEditorGeneralTodo::showAlarm() |
404 | { | 406 | { |
405 | if ( mDueCheck->isChecked() ) { | 407 | if ( mDueCheck->isChecked() ) { |
406 | alarmDisable(false); | 408 | alarmDisable(false); |
407 | } | 409 | } |
408 | else { | 410 | else { |
409 | alarmDisable(true); | 411 | alarmDisable(true); |
410 | } | 412 | } |
411 | } | 413 | } |
412 | 414 | ||
413 | bool KOEditorGeneralTodo::validateInput() | 415 | bool KOEditorGeneralTodo::validateInput() |
414 | { | 416 | { |
415 | if (mDueCheck->isChecked()) { | 417 | if (mDueCheck->isChecked()) { |
416 | if (!mDueDateEdit->inputIsValid()) { | 418 | if (!mDueDateEdit->inputIsValid()) { |
417 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 419 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
418 | return false; | 420 | return false; |
419 | } | 421 | } |
420 | } | 422 | } |
421 | 423 | ||
422 | if (mStartCheck->isChecked()) { | 424 | if (mStartCheck->isChecked()) { |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index 98f43dd..b198539 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -43,64 +43,65 @@ class KDateEdit; | |||
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class KOEditorGeneralTodo : public KOEditorGeneral | 46 | class KOEditorGeneralTodo : public KOEditorGeneral |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); | 50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); |
51 | virtual ~KOEditorGeneralTodo(); | 51 | virtual ~KOEditorGeneralTodo(); |
52 | 52 | ||
53 | void initTime(QWidget *, QBoxLayout *); | 53 | void initTime(QWidget *, QBoxLayout *); |
54 | void initStatus(QWidget *, QBoxLayout *); | 54 | void initStatus(QWidget *, QBoxLayout *); |
55 | void initCompletion(QWidget *, QBoxLayout *); | 55 | void initCompletion(QWidget *, QBoxLayout *); |
56 | void initPriority(QWidget *, QBoxLayout *); | 56 | void initPriority(QWidget *, QBoxLayout *); |
57 | 57 | ||
58 | void finishSetup(); | 58 | void finishSetup(); |
59 | 59 | ||
60 | /** Set widgets to default values */ | 60 | /** Set widgets to default values */ |
61 | void setDefaults(QDateTime due,bool allDay); | 61 | void setDefaults(QDateTime due,bool allDay); |
62 | /** Read todo object and setup widgets accordingly */ | 62 | /** Read todo object and setup widgets accordingly */ |
63 | void readTodo(Todo *); | 63 | void readTodo(Todo *); |
64 | /** Write todo settings to event object */ | 64 | /** Write todo settings to event object */ |
65 | void writeTodo(Todo *); | 65 | void writeTodo(Todo *); |
66 | 66 | ||
67 | /** Check if the input is valid. */ | 67 | /** Check if the input is valid. */ |
68 | bool validateInput(); | 68 | bool validateInput(); |
69 | 69 | ||
70 | /** The todo has been modified externally */ | 70 | /** The todo has been modified externally */ |
71 | void modified (Todo*, int); | 71 | void modified (Todo*, int); |
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); |
78 | 79 | ||
79 | void enableDueEdit( bool enable ); | 80 | void enableDueEdit( bool enable ); |
80 | void enableStartEdit( bool enable ); | 81 | void enableStartEdit( bool enable ); |
81 | void enableTimeEdits( bool enable ); | 82 | void enableTimeEdits( bool enable ); |
82 | void showAlarm(); | 83 | void showAlarm(); |
83 | 84 | ||
84 | protected: | 85 | protected: |
85 | void setCompletedDate(); | 86 | void setCompletedDate(); |
86 | 87 | ||
87 | private: | 88 | private: |
88 | friend class KOTodoEditor; | 89 | friend class KOTodoEditor; |
89 | KDateEdit *mStartDateEdit; | 90 | KDateEdit *mStartDateEdit; |
90 | KOTimeEdit *mStartTimeEdit; | 91 | KOTimeEdit *mStartTimeEdit; |
91 | KDateEdit *mCompleteDateEdit; | 92 | KDateEdit *mCompleteDateEdit; |
92 | KOTimeEdit *mCompleteTimeEdit; | 93 | KOTimeEdit *mCompleteTimeEdit; |
93 | QCheckBox *mTimeButton; | 94 | QCheckBox *mTimeButton; |
94 | QCheckBox *mDueCheck; | 95 | QCheckBox *mDueCheck; |
95 | KDateEdit *mDueDateEdit; | 96 | KDateEdit *mDueDateEdit; |
96 | KOTimeEdit *mDueTimeEdit; | 97 | KOTimeEdit *mDueTimeEdit; |
97 | QComboBox *mCompletedCombo; | 98 | QComboBox *mCompletedCombo; |
98 | QLabel *mCompletedLabel; | 99 | QLabel *mCompletedLabel; |
99 | QLabel *mPriorityLabel; | 100 | QLabel *mPriorityLabel; |
100 | QComboBox *mPriorityCombo; | 101 | QComboBox *mPriorityCombo; |
101 | 102 | ||
102 | QCheckBox *mStartCheck; | 103 | QCheckBox *mStartCheck; |
103 | 104 | ||
104 | QDateTime mCompleted; | 105 | QDateTime mCompleted; |
105 | }; | 106 | }; |
106 | 107 | ||
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 4209e10..bedc75a 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -13,64 +13,65 @@ | |||
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 <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.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 <qlistbox.h> | 32 | #include <qlistbox.h> |
33 | #include <qspinbox.h> | 33 | #include <qspinbox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | 36 | ||
37 | #include <kdialog.h> | 37 | #include <kdialog.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
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 | ||
48 | #include "koprefs.h" | 49 | #include "koprefs.h" |
49 | 50 | ||
50 | #include "koeditorrecurrence.h" | 51 | #include "koeditorrecurrence.h" |
51 | 52 | ||
52 | /////////////////////////// RecurBase /////////////////////////////// | 53 | /////////////////////////// RecurBase /////////////////////////////// |
53 | 54 | ||
54 | RecurBase::RecurBase( QWidget *parent, const char *name ) : | 55 | RecurBase::RecurBase( QWidget *parent, const char *name ) : |
55 | QWidget( parent, name ) | 56 | QWidget( parent, name ) |
56 | { | 57 | { |
57 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); | 58 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); |
58 | mFrequencyEdit->setValue( 1 ); | 59 | mFrequencyEdit->setValue( 1 ); |
59 | } | 60 | } |
60 | 61 | ||
61 | QWidget *RecurBase::frequencyEdit() | 62 | QWidget *RecurBase::frequencyEdit() |
62 | { | 63 | { |
63 | return mFrequencyEdit; | 64 | return mFrequencyEdit; |
64 | } | 65 | } |
65 | 66 | ||
66 | void RecurBase::setFrequency( int f ) | 67 | void RecurBase::setFrequency( int f ) |
67 | { | 68 | { |
68 | if ( f < 1 ) f = 1; | 69 | if ( f < 1 ) f = 1; |
69 | 70 | ||
70 | mFrequencyEdit->setValue( f ); | 71 | mFrequencyEdit->setValue( f ); |
71 | } | 72 | } |
72 | 73 | ||
73 | int RecurBase::frequency() | 74 | int RecurBase::frequency() |
74 | { | 75 | { |
75 | return mFrequencyEdit->value(); | 76 | return mFrequencyEdit->value(); |
76 | } | 77 | } |
@@ -876,88 +877,95 @@ void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | |||
876 | 877 | ||
877 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 878 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
878 | { | 879 | { |
879 | 880 | ||
880 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 881 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
881 | setDateTimes( from, to ); | 882 | setDateTimes( from, to ); |
882 | 883 | ||
883 | bool enabled = false; | 884 | bool enabled = false; |
884 | mEnabledCheck->setChecked( enabled ); | 885 | mEnabledCheck->setChecked( enabled ); |
885 | setEnabled( enabled ); | 886 | setEnabled( enabled ); |
886 | 887 | ||
887 | mExceptions->setDefaults( to ); | 888 | mExceptions->setDefaults( to ); |
888 | mRecurrenceRange->setDefaults( to ); | 889 | mRecurrenceRange->setDefaults( to ); |
889 | 890 | ||
890 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 891 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
891 | showCurrentRule( mRecurrenceChooser->type() ); | 892 | showCurrentRule( mRecurrenceChooser->type() ); |
892 | 893 | ||
893 | mDaily->setFrequency( 1 ); | 894 | mDaily->setFrequency( 1 ); |
894 | 895 | ||
895 | mWeekly->setFrequency( 1 ); | 896 | mWeekly->setFrequency( 1 ); |
896 | QBitArray days( 7 ); | 897 | QBitArray days( 7 ); |
897 | days.fill( 0 ); | 898 | days.fill( 0 ); |
898 | days.setBit( from.date().dayOfWeek()- 1); | 899 | days.setBit( from.date().dayOfWeek()- 1); |
899 | mWeekly->setDays( days ); | 900 | mWeekly->setDays( days ); |
900 | mMonthly->setFrequency( 1 ); | 901 | mMonthly->setFrequency( 1 ); |
901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 902 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
902 | mMonthly->setByDay( from.date().day()-1 ); | 903 | mMonthly->setByDay( from.date().day()-1 ); |
903 | mYearly->setFrequency( 1 ); | 904 | mYearly->setFrequency( 1 ); |
904 | mYearly->setByDay( from.date().dayOfYear() ); | 905 | mYearly->setByDay( from.date().dayOfYear() ); |
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(); |
921 | 929 | ||
922 | int recurs = r->doesRecur(); | 930 | int recurs = r->doesRecur(); |
923 | 931 | ||
924 | mEnabledCheck->setChecked( recurs ); | 932 | mEnabledCheck->setChecked( recurs ); |
925 | setEnabled( recurs ); | 933 | setEnabled( recurs ); |
926 | 934 | ||
927 | int recurrenceType = RecurrenceChooser::Weekly; | 935 | int recurrenceType = RecurrenceChooser::Weekly; |
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; |
935 | mDaily->setFrequency( f ); | 943 | mDaily->setFrequency( f ); |
936 | break; | 944 | break; |
937 | case Recurrence::rWeekly: | 945 | case Recurrence::rWeekly: |
938 | recurrenceType = RecurrenceChooser::Weekly; | 946 | recurrenceType = RecurrenceChooser::Weekly; |
939 | mWeekly->setFrequency( f ); | 947 | mWeekly->setFrequency( f ); |
940 | mWeekly->setDays( r->days() ); | 948 | mWeekly->setDays( r->days() ); |
941 | break; | 949 | break; |
942 | case Recurrence::rMonthlyPos: | 950 | case Recurrence::rMonthlyPos: |
943 | // we only handle one possibility in the list right now, | 951 | // we only handle one possibility in the list right now, |
944 | // so I have hardcoded calls with first(). If we make the GUI | 952 | // so I have hardcoded calls with first(). If we make the GUI |
945 | // more extended, this can be changed. | 953 | // more extended, this can be changed. |
946 | recurrenceType = RecurrenceChooser::Monthly; | 954 | recurrenceType = RecurrenceChooser::Monthly; |
947 | 955 | ||
948 | rmp = r->monthPositions(); | 956 | rmp = r->monthPositions(); |
949 | if ( rmp.first()->negative ) | 957 | if ( rmp.first()->negative ) |
950 | count = 5 - rmp.first()->rPos - 1; | 958 | count = 5 - rmp.first()->rPos - 1; |
951 | else | 959 | else |
952 | count = rmp.first()->rPos - 1; | 960 | count = rmp.first()->rPos - 1; |
953 | day = 0; | 961 | day = 0; |
954 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 962 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
955 | mMonthly->setByPos( count, day ); | 963 | mMonthly->setByPos( count, day ); |
956 | 964 | ||
957 | mMonthly->setFrequency( f ); | 965 | mMonthly->setFrequency( f ); |
958 | 966 | ||
959 | break; | 967 | break; |
960 | case Recurrence::rMonthlyDay: | 968 | case Recurrence::rMonthlyDay: |
961 | recurrenceType = RecurrenceChooser::Monthly; | 969 | recurrenceType = RecurrenceChooser::Monthly; |
962 | 970 | ||
963 | rmd = r->monthDays(); | 971 | rmd = r->monthDays(); |
@@ -971,89 +979,89 @@ void KOEditorRecurrence::readEvent(Event *event) | |||
971 | { | 979 | { |
972 | recurrenceType = RecurrenceChooser::Yearly; | 980 | recurrenceType = RecurrenceChooser::Yearly; |
973 | qDebug("Recurrence::rYearlyMonth: "); | 981 | qDebug("Recurrence::rYearlyMonth: "); |
974 | day = event->dtStart().date().day(); | 982 | day = event->dtStart().date().day(); |
975 | rmd = r->yearNums(); | 983 | rmd = r->yearNums(); |
976 | if ( rmd.count() > 0 ) | 984 | if ( rmd.count() > 0 ) |
977 | month = *rmd.first(); | 985 | month = *rmd.first(); |
978 | else | 986 | else |
979 | month = event->dtStart().date().month() ; | 987 | month = event->dtStart().date().month() ; |
980 | mYearly->setByMonth( month, day ); | 988 | mYearly->setByMonth( month, day ); |
981 | #if 0 | 989 | #if 0 |
982 | qDebug("2day = %d ",day ); | 990 | qDebug("2day = %d ",day ); |
983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 991 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
984 | int month; | 992 | int month; |
985 | if ( !monthlist.isEmpty() ) { | 993 | if ( !monthlist.isEmpty() ) { |
986 | month = monthlist.first()->rPos ; | 994 | month = monthlist.first()->rPos ; |
987 | } else { | 995 | } else { |
988 | month = event->dtStart().date().month() ; | 996 | month = event->dtStart().date().month() ; |
989 | } | 997 | } |
990 | mYearly->setByMonth( day, month ); | 998 | mYearly->setByMonth( day, month ); |
991 | #endif | 999 | #endif |
992 | mYearly->setFrequency( f ); | 1000 | mYearly->setFrequency( f ); |
993 | } | 1001 | } |
994 | 1002 | ||
995 | break; | 1003 | break; |
996 | case Recurrence::rYearlyDay: | 1004 | case Recurrence::rYearlyDay: |
997 | qDebug("Recurrence::rYearlyDay: "); | 1005 | qDebug("Recurrence::rYearlyDay: "); |
998 | recurrenceType = RecurrenceChooser::Yearly; | 1006 | recurrenceType = RecurrenceChooser::Yearly; |
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 1007 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
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 | ||
1007 | mRecurrenceChooser->setType( recurrenceType ); | 1015 | mRecurrenceChooser->setType( recurrenceType ); |
1008 | showCurrentRule( recurrenceType ); | 1016 | showCurrentRule( recurrenceType ); |
1009 | 1017 | ||
1010 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 1018 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
1011 | 1019 | ||
1012 | if ( r->doesRecur() ) { | 1020 | if ( r->doesRecur() ) { |
1013 | mRecurrenceRange->setDuration( r->duration() ); | 1021 | mRecurrenceRange->setDuration( r->duration() ); |
1014 | if ( r->duration() == 0 ) | 1022 | if ( r->duration() == 0 ) |
1015 | { | 1023 | { |
1016 | if ( r->endDate() < event->dtStart().date() ) | 1024 | if ( r->endDate() < event->dtStart().date() ) |
1017 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1025 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1018 | else | 1026 | else |
1019 | mRecurrenceRange->setEndDate( r->endDate() ); | 1027 | mRecurrenceRange->setEndDate( r->endDate() ); |
1020 | } else | 1028 | } else |
1021 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1029 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1022 | } | 1030 | } |
1023 | 1031 | ||
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 | ||
1031 | // clear out any old settings; | 1039 | // clear out any old settings; |
1032 | r->unsetRecurs(); | 1040 | r->unsetRecurs(); |
1033 | 1041 | ||
1034 | if ( mEnabledCheck->isChecked() ) { | 1042 | if ( mEnabledCheck->isChecked() ) { |
1035 | int duration = mRecurrenceRange->duration(); | 1043 | int duration = mRecurrenceRange->duration(); |
1036 | QDate endDate; | 1044 | QDate endDate; |
1037 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1045 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1038 | 1046 | ||
1039 | int recurrenceType = mRecurrenceChooser->type(); | 1047 | int recurrenceType = mRecurrenceChooser->type(); |
1040 | 1048 | ||
1041 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1049 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1042 | int freq = mDaily->frequency(); | 1050 | int freq = mDaily->frequency(); |
1043 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1051 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1044 | else r->setDaily( freq, endDate ); | 1052 | else r->setDaily( freq, endDate ); |
1045 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1053 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1046 | int freq = mWeekly->frequency(); | 1054 | int freq = mWeekly->frequency(); |
1047 | QBitArray days = mWeekly->days(); | 1055 | QBitArray days = mWeekly->days(); |
1048 | int j; | 1056 | int j; |
1049 | bool found = false; | 1057 | bool found = false; |
1050 | for (j = 0; j < 7 ; ++j ) { | 1058 | for (j = 0; j < 7 ; ++j ) { |
1051 | found |=days.at(j); | 1059 | found |=days.at(j); |
1052 | } | 1060 | } |
1053 | if ( !found ) { | 1061 | if ( !found ) { |
1054 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1062 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1055 | qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1063 | qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1056 | } | 1064 | } |
1057 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1065 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1058 | else r->setWeekly( freq, days, endDate ); | 1066 | else r->setWeekly( freq, days, endDate ); |
1059 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1067 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index 2b59085..a15afcb 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -245,67 +245,67 @@ class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase | |||
245 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase | 245 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase |
246 | { | 246 | { |
247 | public: | 247 | public: |
248 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); | 248 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); |
249 | 249 | ||
250 | void setDefaults( const QDateTime &from ); | 250 | void setDefaults( const QDateTime &from ); |
251 | 251 | ||
252 | void setDuration( int ); | 252 | void setDuration( int ); |
253 | int duration(); | 253 | int duration(); |
254 | 254 | ||
255 | void setEndDate( const QDate & ); | 255 | void setEndDate( const QDate & ); |
256 | QDate endDate(); | 256 | QDate endDate(); |
257 | 257 | ||
258 | void setDateTimes( const QDateTime &start, | 258 | void setDateTimes( const QDateTime &start, |
259 | const QDateTime &end = QDateTime() ); | 259 | const QDateTime &end = QDateTime() ); |
260 | 260 | ||
261 | private: | 261 | private: |
262 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 262 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | class KOEditorRecurrence : public QWidget | 265 | class KOEditorRecurrence : public QWidget |
266 | { | 266 | { |
267 | Q_OBJECT | 267 | Q_OBJECT |
268 | public: | 268 | public: |
269 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); | 269 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); |
270 | virtual ~KOEditorRecurrence(); | 270 | virtual ~KOEditorRecurrence(); |
271 | 271 | ||
272 | enum { Daily, Weekly, Monthly, Yearly }; | 272 | enum { Daily, Weekly, Monthly, Yearly }; |
273 | 273 | ||
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(); |
283 | 283 | ||
284 | public slots: | 284 | public slots: |
285 | void setEnabled( bool ); | 285 | void setEnabled( bool ); |
286 | void setDateTimes( QDateTime start, QDateTime end ); | 286 | void setDateTimes( QDateTime start, QDateTime end ); |
287 | void setDateTimeStr( const QString & ); | 287 | void setDateTimeStr( const QString & ); |
288 | 288 | ||
289 | signals: | 289 | signals: |
290 | void dateTimesChanged( QDateTime start, QDateTime end ); | 290 | void dateTimesChanged( QDateTime start, QDateTime end ); |
291 | 291 | ||
292 | protected slots: | 292 | protected slots: |
293 | void showCurrentRule( int ); | 293 | void showCurrentRule( int ); |
294 | void showExceptionsDialog(); | 294 | void showExceptionsDialog(); |
295 | void showRecurrenceRangeDialog(); | 295 | void showRecurrenceRangeDialog(); |
296 | 296 | ||
297 | private: | 297 | private: |
298 | QCheckBox *mEnabledCheck; | 298 | QCheckBox *mEnabledCheck; |
299 | 299 | ||
300 | QGroupBox *mTimeGroupBox; | 300 | QGroupBox *mTimeGroupBox; |
301 | QLabel *mDateTimeLabel; | 301 | QLabel *mDateTimeLabel; |
302 | 302 | ||
303 | QGroupBox *mRuleBox; | 303 | QGroupBox *mRuleBox; |
304 | QWidgetStack *mRuleStack; | 304 | QWidgetStack *mRuleStack; |
305 | RecurrenceChooser *mRecurrenceChooser; | 305 | RecurrenceChooser *mRecurrenceChooser; |
306 | 306 | ||
307 | RecurDaily *mDaily; | 307 | RecurDaily *mDaily; |
308 | RecurWeekly *mWeekly; | 308 | RecurWeekly *mWeekly; |
309 | RecurMonthly *mMonthly; | 309 | RecurMonthly *mMonthly; |
310 | RecurYearly *mYearly; | 310 | RecurYearly *mYearly; |
311 | 311 | ||
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 70dfbd1..069dda8 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,103 +1,116 @@ | |||
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 <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> |
36 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
37 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
39 | 40 | ||
40 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
41 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
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" |
49 | 51 | ||
50 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
51 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
52 | 54 | ||
53 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
54 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
55 | { | 57 | { |
56 | mTodo = 0; | 58 | mTodo = 0; |
57 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
58 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
59 | init(); | 61 | init(); |
60 | } | 62 | } |
61 | 63 | ||
62 | KOTodoEditor::~KOTodoEditor() | 64 | KOTodoEditor::~KOTodoEditor() |
63 | { | 65 | { |
64 | emit dialogClose( mTodo ); | 66 | emit dialogClose( mTodo ); |
65 | } | 67 | } |
66 | 68 | ||
67 | void KOTodoEditor::init() | 69 | 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); |
75 | } | 88 | } |
76 | void KOTodoEditor::setSecrecy( int sec ) | 89 | void KOTodoEditor::setSecrecy( int sec ) |
77 | { | 90 | { |
78 | mGeneral->setSecrecy( sec ); | 91 | mGeneral->setSecrecy( sec ); |
79 | } | 92 | } |
80 | void KOTodoEditor::reload() | 93 | void KOTodoEditor::reload() |
81 | { | 94 | { |
82 | if ( mTodo ) readTodo( mTodo ); | 95 | if ( mTodo ) readTodo( mTodo ); |
83 | } | 96 | } |
84 | 97 | ||
85 | void KOTodoEditor::setupGeneral() | 98 | void KOTodoEditor::setupGeneral() |
86 | { | 99 | { |
87 | mGeneral = new KOEditorGeneralTodo(this); | 100 | mGeneral = new KOEditorGeneralTodo(this); |
88 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 101 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
89 | 102 | ||
90 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 103 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
91 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 104 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
92 | // mGeneral,SLOT(setCategories(const QString &))); | 105 | // mGeneral,SLOT(setCategories(const QString &))); |
93 | 106 | ||
94 | if (KOPrefs::instance()->mCompactDialogs) { | 107 | if (KOPrefs::instance()->mCompactDialogs) { |
95 | QFrame *topFrame = addPage(i18n("General")); | 108 | QFrame *topFrame = addPage(i18n("General")); |
96 | 109 | ||
97 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 110 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
98 | if ( QApplication::desktop()->width() < 480 ) { | 111 | if ( QApplication::desktop()->width() < 480 ) { |
99 | topLayout->setMargin(1); | 112 | topLayout->setMargin(1); |
100 | topLayout->setSpacing(1); | 113 | topLayout->setSpacing(1); |
101 | } else { | 114 | } else { |
102 | topLayout->setMargin(marginHint()-1); | 115 | topLayout->setMargin(marginHint()-1); |
103 | topLayout->setSpacing(spacingHint()-1); | 116 | topLayout->setSpacing(spacingHint()-1); |
@@ -165,64 +178,65 @@ void KOTodoEditor::setupGeneral() | |||
165 | QFrame *topFrame = addPage(i18n("General")); | 178 | QFrame *topFrame = addPage(i18n("General")); |
166 | 179 | ||
167 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 180 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
168 | topLayout->setSpacing(spacingHint()); | 181 | topLayout->setSpacing(spacingHint()); |
169 | 182 | ||
170 | mGeneral->initHeader(topFrame,topLayout); | 183 | mGeneral->initHeader(topFrame,topLayout); |
171 | mGeneral->initTime(topFrame,topLayout); | 184 | mGeneral->initTime(topFrame,topLayout); |
172 | mGeneral->initStatus(topFrame,topLayout); | 185 | mGeneral->initStatus(topFrame,topLayout); |
173 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 186 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
174 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 187 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
175 | mGeneral->initDescription(topFrame,topLayout); | 188 | mGeneral->initDescription(topFrame,topLayout); |
176 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 189 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
177 | mGeneral->initCategories( topFrame, detailsLayout ); | 190 | mGeneral->initCategories( topFrame, detailsLayout ); |
178 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 191 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
179 | } | 192 | } |
180 | mGeneral->finishSetup(); | 193 | mGeneral->finishSetup(); |
181 | 194 | ||
182 | } | 195 | } |
183 | 196 | ||
184 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 197 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
185 | { | 198 | { |
186 | //init(); | 199 | //init(); |
187 | 200 | ||
188 | mTodo = todo; | 201 | mTodo = todo; |
189 | readTodo(mTodo); | 202 | readTodo(mTodo); |
190 | if ( editDescription ) { | 203 | if ( editDescription ) { |
191 | showPage( 1 ); | 204 | showPage( 1 ); |
192 | mGeneral->setFocusOn( 1 ); | 205 | mGeneral->setFocusOn( 1 ); |
193 | } else { | 206 | } else { |
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) |
200 | { | 214 | { |
201 | //init(); | 215 | //init(); |
202 | 216 | ||
203 | mTodo = 0; | 217 | mTodo = 0; |
204 | setDefaults(due,relatedTodo,allDay); | 218 | setDefaults(due,relatedTodo,allDay); |
205 | } | 219 | } |
206 | 220 | ||
207 | void KOTodoEditor::loadDefaults() | 221 | void KOTodoEditor::loadDefaults() |
208 | { | 222 | { |
209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 223 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
210 | } | 224 | } |
211 | 225 | ||
212 | bool KOTodoEditor::processInput( bool emitTime ) | 226 | bool KOTodoEditor::processInput( bool emitTime ) |
213 | { | 227 | { |
214 | if (!validateInput()) return false; | 228 | if (!validateInput()) return false; |
215 | 229 | ||
216 | Todo *todo = 0; | 230 | Todo *todo = 0; |
217 | 231 | ||
218 | if (mTodo) todo = mTodo; | 232 | if (mTodo) todo = mTodo; |
219 | else { | 233 | else { |
220 | todo = new Todo; | 234 | todo = new Todo; |
221 | todo->setOrganizer(KOPrefs::instance()->email()); | 235 | todo->setOrganizer(KOPrefs::instance()->email()); |
222 | } | 236 | } |
223 | 237 | ||
224 | writeTodo(todo); | 238 | writeTodo(todo); |
225 | if ( emitTime ) { | 239 | if ( emitTime ) { |
226 | globalFlagBlockAgenda = 1; | 240 | globalFlagBlockAgenda = 1; |
227 | emit showAgendaView( false ); | 241 | emit showAgendaView( false ); |
228 | if ( todo->hasDueDate() ) | 242 | if ( todo->hasDueDate() ) |
@@ -258,86 +272,115 @@ void KOTodoEditor::deleteTodo() | |||
258 | else { | 272 | else { |
259 | emit todoToBeDeleted(mTodo); | 273 | emit todoToBeDeleted(mTodo); |
260 | emit dialogClose(mTodo); | 274 | emit dialogClose(mTodo); |
261 | mCalendar->deleteTodo(mTodo); | 275 | mCalendar->deleteTodo(mTodo); |
262 | emit todoDeleted(); | 276 | emit todoDeleted(); |
263 | reject(); | 277 | reject(); |
264 | } | 278 | } |
265 | } else { | 279 | } else { |
266 | reject(); | 280 | reject(); |
267 | } | 281 | } |
268 | } | 282 | } |
269 | 283 | ||
270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 284 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
271 | { | 285 | { |
272 | mRelatedTodo = relatedEvent; | 286 | mRelatedTodo = relatedEvent; |
273 | 287 | ||
274 | mGeneral->setDefaults(due,allDay); | 288 | mGeneral->setDefaults(due,allDay); |
275 | mDetails->setDefaults(); | 289 | mDetails->setDefaults(); |
276 | showPage( 0 ); | 290 | showPage( 0 ); |
277 | if ( mRelatedTodo ) { | 291 | if ( mRelatedTodo ) { |
278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
280 | if ( mRelatedTodo->priority() < 3 ) | 294 | if ( mRelatedTodo->priority() < 3 ) |
281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
283 | int len = mRelatedTodo->summary().length(); | 297 | int len = mRelatedTodo->summary().length(); |
284 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
286 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
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); | ||
306 | } | ||
307 | void KOTodoEditor::checkRecurrence() | ||
308 | { | ||
309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | ||
310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | ||
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 | } | ||
290 | } | 330 | } |
291 | |||
292 | void KOTodoEditor::readTodo(Todo *todo) | 331 | void KOTodoEditor::readTodo(Todo *todo) |
293 | { | 332 | { |
294 | mGeneral->readTodo(todo); | 333 | mGeneral->readTodo(todo); |
295 | mDetails->readEvent(todo); | 334 | mDetails->readEvent(todo); |
296 | mRelatedTodo = 0;//todo->relatedTo(); | 335 | mRelatedTodo = 0;//todo->relatedTo(); |
297 | // categories | 336 | // categories |
298 | // mCategoryDialog->setSelected(todo->categories()); | 337 | // mCategoryDialog->setSelected(todo->categories()); |
299 | 338 | ||
300 | // We should handle read-only events here. | 339 | // We should handle read-only events here. |
301 | } | 340 | } |
302 | 341 | ||
303 | void KOTodoEditor::writeTodo(Todo *event) | 342 | void KOTodoEditor::writeTodo(Todo *event) |
304 | { | 343 | { |
305 | mGeneral->writeTodo(event); | 344 | mGeneral->writeTodo(event); |
306 | mDetails->writeEvent(event); | 345 | mDetails->writeEvent(event); |
307 | 346 | ||
308 | // set related event, i.e. parent to-do in this case. | 347 | // set related event, i.e. parent to-do in this case. |
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() |
315 | { | 358 | { |
316 | if (!mGeneral->validateInput()) return false; | 359 | if (!mGeneral->validateInput()) return false; |
317 | if (!mDetails->validateInput()) return false; | 360 | if (!mDetails->validateInput()) return false; |
318 | return true; | 361 | return true; |
319 | } | 362 | } |
320 | 363 | ||
321 | int KOTodoEditor::msgItemDelete() | 364 | int KOTodoEditor::msgItemDelete() |
322 | { | 365 | { |
323 | return KMessageBox::warningContinueCancel(this, | 366 | return KMessageBox::warningContinueCancel(this, |
324 | i18n("This item will be permanently deleted."), | 367 | i18n("This item will be permanently deleted."), |
325 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 368 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
326 | } | 369 | } |
327 | 370 | ||
328 | void KOTodoEditor::modified (int modification) | 371 | void KOTodoEditor::modified (int modification) |
329 | { | 372 | { |
330 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 373 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
331 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 374 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
332 | // mCategoryDialog->setSelected (mTodo->categories ()); | 375 | // mCategoryDialog->setSelected (mTodo->categories ()); |
333 | mGeneral->modified (mTodo, modification); | 376 | mGeneral->modified (mTodo, modification); |
334 | 377 | ||
335 | } | 378 | } |
336 | 379 | ||
337 | void KOTodoEditor::slotLoadTemplate() | 380 | void KOTodoEditor::slotLoadTemplate() |
338 | { | 381 | { |
339 | 382 | ||
340 | QString fileName =locateLocal( "templates", "todos" ); | 383 | QString fileName =locateLocal( "templates", "todos" ); |
341 | QDir t_dir; | 384 | QDir t_dir; |
342 | if ( !t_dir.exists(fileName) ) | 385 | if ( !t_dir.exists(fileName) ) |
343 | t_dir.mkdir ( fileName ); | 386 | t_dir.mkdir ( fileName ); |
diff --git a/korganizer/kotodoeditor.h b/korganizer/kotodoeditor.h index 2657bd8..1b5e3b4 100644 --- a/korganizer/kotodoeditor.h +++ b/korganizer/kotodoeditor.h | |||
@@ -1,102 +1,106 @@ | |||
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 | #ifndef _KOTODOEDITOR_H | 24 | #ifndef _KOTODOEDITOR_H |
25 | #define _KOTODOEDITOR_H | 25 | #define _KOTODOEDITOR_H |
26 | 26 | ||
27 | #include <libkcal/calendar.h> | 27 | #include <libkcal/calendar.h> |
28 | 28 | ||
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 | ||
35 | /** | 36 | /** |
36 | This class provides a dialog for editing a Todo. | 37 | This class provides a dialog for editing a Todo. |
37 | */ | 38 | */ |
38 | class KOTodoEditor : public KOIncidenceEditor | 39 | class KOTodoEditor : public KOIncidenceEditor |
39 | { | 40 | { |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | public: | 42 | public: |
42 | /** | 43 | /** |
43 | Constructs a new todo editor. | 44 | Constructs a new todo editor. |
44 | */ | 45 | */ |
45 | KOTodoEditor( Calendar *calendar, QWidget *parent ); | 46 | KOTodoEditor( Calendar *calendar, QWidget *parent ); |
46 | virtual ~KOTodoEditor(); | 47 | virtual ~KOTodoEditor(); |
47 | 48 | ||
48 | void init(); | 49 | void init(); |
49 | 50 | ||
50 | void reload(); | 51 | void reload(); |
51 | void setSecrecy( int sec ); | 52 | void setSecrecy( int sec ); |
52 | /** | 53 | /** |
53 | Clear editor for new todo, and preset the dates and times with hint. | 54 | Clear editor for new todo, and preset the dates and times with hint. |
54 | */ | 55 | */ |
55 | void newTodo(QDateTime due,Todo *relatedTodo=0,bool allDay=false); | 56 | void newTodo(QDateTime due,Todo *relatedTodo=0,bool allDay=false); |
56 | 57 | ||
57 | /** Edit an existing todo. */ | 58 | /** Edit an existing todo. */ |
58 | void editTodo(Todo * ,bool editDescription = false ); | 59 | void editTodo(Todo * ,bool editDescription = false ); |
59 | 60 | ||
60 | /** Set widgets to default values */ | 61 | /** Set widgets to default values */ |
61 | void setDefaults(QDateTime due,Todo *relatedTodo,bool allDay); | 62 | void setDefaults(QDateTime due,Todo *relatedTodo,bool allDay); |
62 | /** Read event object and setup widgets accordingly */ | 63 | /** Read event object and setup widgets accordingly */ |
63 | void readTodo(Todo *); | 64 | void readTodo(Todo *); |
64 | /** Write event settings to event object */ | 65 | /** Write event settings to event object */ |
65 | void writeTodo(Todo *); | 66 | void writeTodo(Todo *); |
66 | 67 | ||
67 | /** Check if the input is valid. */ | 68 | /** Check if the input is valid. */ |
68 | bool validateInput(); | 69 | bool validateInput(); |
69 | /** Process user input and create or update event. Returns false if input | 70 | /** Process user input and create or update event. Returns false if input |
70 | * is not valid */ | 71 | * is not valid */ |
71 | bool processInput( bool ); | 72 | bool processInput( bool ); |
72 | 73 | ||
73 | /** This todo has been modified externally */ | 74 | /** This todo has been modified externally */ |
74 | void modified (int); | 75 | void modified (int); |
75 | void setCategories( QString s ); | 76 | void setCategories( QString s ); |
76 | signals: | 77 | signals: |
77 | void todoChanged(Todo *); | 78 | void todoChanged(Todo *); |
78 | void todoAdded(Todo *); | 79 | void todoAdded(Todo *); |
79 | void todoToBeDeleted(Todo *); | 80 | void todoToBeDeleted(Todo *); |
80 | void todoDeleted(); | 81 | void todoDeleted(); |
81 | 82 | ||
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(); |
88 | void saveTemplate( const QString & ); | 90 | void saveTemplate( const QString & ); |
89 | 91 | ||
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; |
96 | 99 | ||
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 |