-rw-r--r-- | bin/kdepim/WhatsNew.txt | 3 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 9 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 42 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 4 | ||||
-rw-r--r-- | korganizer/koeventeditor.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 8 |
10 files changed, 49 insertions, 26 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index fdaf740..4b965c1 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,151 +1,154 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.9 ************ | 3 | ********** VERSION 2.1.9 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Fixed some problems of the new search options in the search dialog. | 6 | Fixed some problems of the new search options in the search dialog. |
7 | Fixed some problems in the new resource config options. | 7 | Fixed some problems in the new resource config options. |
8 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. | 8 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. |
9 | Fixed a problem cearting new events in the agenda view if at the day/time is already an agenda item shown: | ||
10 | Now you can click on the bottom/top of an allday agenda item and on the left/right of an agenda item to get the "new todo/new event" popup. | ||
11 | |||
9 | 12 | ||
10 | PwM/Pi: | 13 | PwM/Pi: |
11 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 14 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
12 | 15 | ||
13 | ********** VERSION 2.1.8 ************ | 16 | ********** VERSION 2.1.8 ************ |
14 | 17 | ||
15 | KO/Pi: | 18 | KO/Pi: |
16 | Added info about the completion state of a todo in the ListView/Searchdialog. | 19 | Added info about the completion state of a todo in the ListView/Searchdialog. |
17 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 20 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
18 | Fixed some updating problems when changing the filter. | 21 | Fixed some updating problems when changing the filter. |
19 | 22 | ||
20 | KA/Pi: | 23 | KA/Pi: |
21 | In the addressee selection dialog now the formatted name is shown, if not empty. | 24 | In the addressee selection dialog now the formatted name is shown, if not empty. |
22 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 25 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
23 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 26 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
24 | 27 | ||
25 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 28 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
26 | Fixed the sorting for size in the file selector on the Z. | 29 | Fixed the sorting for size in the file selector on the Z. |
27 | 30 | ||
28 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 31 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
29 | 32 | ||
30 | ********** VERSION 2.1.7 ************ | 33 | ********** VERSION 2.1.7 ************ |
31 | 34 | ||
32 | KO/Pi: | 35 | KO/Pi: |
33 | Fixed several problems in the new Resource handling. | 36 | Fixed several problems in the new Resource handling. |
34 | Added more options to the search dialog. | 37 | Added more options to the search dialog. |
35 | Fixed a problem in the Month view. | 38 | Fixed a problem in the Month view. |
36 | Added more options to the dialog when setting a todo to stopped. | 39 | Added more options to the dialog when setting a todo to stopped. |
37 | 40 | ||
38 | Fixed two small problems in KO/Pi Alarm applet. | 41 | Fixed two small problems in KO/Pi Alarm applet. |
39 | 42 | ||
40 | ********** VERSION 2.1.6 ************ | 43 | ********** VERSION 2.1.6 ************ |
41 | 44 | ||
42 | This release is for testing only. | 45 | This release is for testing only. |
43 | 46 | ||
44 | KO/Pi: | 47 | KO/Pi: |
45 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 48 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
46 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 49 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
47 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 50 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
48 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 51 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
49 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 52 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
50 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 53 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
51 | 54 | ||
52 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 55 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
53 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. | 56 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. |
54 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 57 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
55 | 58 | ||
56 | A calendar is enabled in the resource view if the "eye" column is checked. | 59 | A calendar is enabled in the resource view if the "eye" column is checked. |
57 | You can set a calendar to be the default for new items( "+" column ). | 60 | You can set a calendar to be the default for new items( "+" column ). |
58 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 61 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
59 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 62 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
60 | 63 | ||
61 | 64 | ||
62 | ********** VERSION 2.1.5 ************ | 65 | ********** VERSION 2.1.5 ************ |
63 | 66 | ||
64 | This is the new stable version. | 67 | This is the new stable version. |
65 | Bugfix: | 68 | Bugfix: |
66 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 69 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
67 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 70 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
68 | Added config option to not display completed todos in agenda view. | 71 | Added config option to not display completed todos in agenda view. |
69 | Addressee view is now using the formatted name, if defined. | 72 | Addressee view is now using the formatted name, if defined. |
70 | That makes it possible to display "lastname, firstname" in that view now. | 73 | That makes it possible to display "lastname, firstname" in that view now. |
71 | To set the formatted name for all contacts, please use menu: | 74 | To set the formatted name for all contacts, please use menu: |
72 | Edit->Change->Set formatted name. | 75 | Edit->Change->Set formatted name. |
73 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 76 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
74 | 77 | ||
75 | ********** VERSION 2.1.4 ************ | 78 | ********** VERSION 2.1.4 ************ |
76 | 79 | ||
77 | Fixed two more bugs in the KA/Pi CSV import dialog: | 80 | Fixed two more bugs in the KA/Pi CSV import dialog: |
78 | Made it possible to read multi-line fields and import it to the "Note" field. | 81 | Made it possible to read multi-line fields and import it to the "Note" field. |
79 | Fixed a problem in mapping custom fields, whatever a custem field is... | 82 | Fixed a problem in mapping custom fields, whatever a custem field is... |
80 | 83 | ||
81 | ********** VERSION 2.1.3 ************ | 84 | ********** VERSION 2.1.3 ************ |
82 | 85 | ||
83 | Changed the menu structure of the alarm applet: | 86 | Changed the menu structure of the alarm applet: |
84 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 87 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
85 | 88 | ||
86 | Fixed several problems in the KA/Pi CSV import dialog: | 89 | Fixed several problems in the KA/Pi CSV import dialog: |
87 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 90 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
88 | 91 | ||
89 | 92 | ||
90 | ********** VERSION 2.1.2 ************ | 93 | ********** VERSION 2.1.2 ************ |
91 | 94 | ||
92 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 95 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
93 | 96 | ||
94 | Fixed a problem when importing data from Outlook with mutiple categories set. | 97 | Fixed a problem when importing data from Outlook with mutiple categories set. |
95 | 98 | ||
96 | Changed display of days in datenavigator: | 99 | Changed display of days in datenavigator: |
97 | Birthdays are now blue, not dark green. | 100 | Birthdays are now blue, not dark green. |
98 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 101 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
99 | When journal view is shown, only holidays are shown and days with journals are blue. | 102 | When journal view is shown, only holidays are shown and days with journals are blue. |
100 | 103 | ||
101 | Added Backup options to global config: | 104 | Added Backup options to global config: |
102 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). | 105 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). |
103 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. | 106 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. |
104 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. | 107 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. |
105 | 108 | ||
106 | ********** VERSION 2.1.1 ************ | 109 | ********** VERSION 2.1.1 ************ |
107 | 110 | ||
108 | Stable release 2.1.1! | 111 | Stable release 2.1.1! |
109 | 112 | ||
110 | KO/Pi: | 113 | KO/Pi: |
111 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 114 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
112 | 115 | ||
113 | ********** VERSION 2.1.0 ************ | 116 | ********** VERSION 2.1.0 ************ |
114 | 117 | ||
115 | Stable release 2.1.0! | 118 | Stable release 2.1.0! |
116 | 119 | ||
117 | Summary of changes/fixes compared to version 2.0.6: | 120 | Summary of changes/fixes compared to version 2.0.6: |
118 | 121 | ||
119 | Many bugs of version 2.0.6 fixed. | 122 | Many bugs of version 2.0.6 fixed. |
120 | Most of them were small bugs, but some of them were important. | 123 | Most of them were small bugs, but some of them were important. |
121 | It is recommended to use version 2.1.0 and not version 2.0.6. | 124 | It is recommended to use version 2.1.0 and not version 2.0.6. |
122 | 125 | ||
123 | Important changes: | 126 | Important changes: |
124 | 127 | ||
125 | Added recurring todos to KO/Pi. | 128 | Added recurring todos to KO/Pi. |
126 | 129 | ||
127 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 130 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
128 | 131 | ||
129 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 132 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
130 | 133 | ||
131 | Datenavigator can now display many months. Very useful on the desktop. | 134 | Datenavigator can now display many months. Very useful on the desktop. |
132 | 135 | ||
133 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 136 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
134 | 137 | ||
135 | Made alarm sound working on Linux desktop. | 138 | Made alarm sound working on Linux desktop. |
136 | 139 | ||
137 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 140 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
138 | 141 | ||
139 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 142 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
140 | 143 | ||
141 | Many other usebility enhancements. | 144 | Many other usebility enhancements. |
142 | Special thanks to Ben for his suggestions! | 145 | Special thanks to Ben for his suggestions! |
143 | 146 | ||
144 | You can find the complete changelog | 147 | You can find the complete changelog |
145 | from version 1.7.7 to 2.1.0 | 148 | from version 1.7.7 to 2.1.0 |
146 | in the source package or on | 149 | in the source package or on |
147 | 150 | ||
148 | http://www.pi-sync.net/html/changelog.html | 151 | http://www.pi-sync.net/html/changelog.html |
149 | 152 | ||
150 | 153 | ||
151 | 154 | ||
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h index 2069e9c..a8f6443 100644 --- a/korganizer/koeditorgeneral.h +++ b/korganizer/koeditorgeneral.h | |||
@@ -1,115 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 | #ifndef KOEDITORGENERAL_H | 23 | #ifndef KOEDITORGENERAL_H |
24 | #define KOEDITORGENERAL_H | 24 | #define KOEDITORGENERAL_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlistview.h> | 33 | #include <qlistview.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | 37 | ||
38 | #include <ktextedit.h> | 38 | #include <ktextedit.h> |
39 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
40 | 40 | ||
41 | #include <libkcal/incidence.h> | 41 | #include <libkcal/incidence.h> |
42 | 42 | ||
43 | #include "ktimeedit.h" | 43 | #include "ktimeedit.h" |
44 | 44 | ||
45 | class KDateEdit; | 45 | class KDateEdit; |
46 | class KOLocationBox; | 46 | class KOLocationBox; |
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | class KOEditorGeneral : public QObject | 49 | class KOEditorGeneral : public QObject |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | KOEditorGeneral (QObject* parent=0,const char* name=0); | 53 | KOEditorGeneral (QObject* parent=0,const char* name=0); |
54 | virtual ~KOEditorGeneral(); | 54 | virtual ~KOEditorGeneral(); |
55 | void setFocusOn( int i ); | 55 | void setFocusOn( int i ); |
56 | void initHeader(QWidget *,QBoxLayout *); | 56 | void initHeader(QWidget *,QBoxLayout *); |
57 | void initDescription(QWidget *,QBoxLayout *); | 57 | void initDescription(QWidget *,QBoxLayout *); |
58 | void initSecrecy(QWidget *,QBoxLayout *); | 58 | void initSecrecy(QWidget *,QBoxLayout *); |
59 | void initCategories(QWidget *,QBoxLayout *); | 59 | void initCategories(QWidget *,QBoxLayout *); |
60 | void initAlarm(QWidget *,QBoxLayout *); | 60 | void initAlarm(QWidget *,QBoxLayout *); |
61 | 61 | ||
62 | /** Set widgets to default values */ | 62 | /** Set widgets to default values */ |
63 | void setDefaults(bool allDay); | 63 | void setDefaults(bool allDay); |
64 | /** Read event object and setup widgets accordingly */ | 64 | /** Read event object and setup widgets accordingly */ |
65 | void readIncidence(Incidence *); | 65 | void readIncidence(Incidence *); |
66 | /** Write event settings to event object */ | 66 | /** Write event settings to event object */ |
67 | void writeIncidence(Incidence *); | 67 | void writeIncidence(Incidence *); |
68 | 68 | ||
69 | /** Check if the input is valid. */ | 69 | /** Check if the input is valid. */ |
70 | bool validateInput() { return true; } | 70 | bool validateInput() { return true; } |
71 | 71 | ||
72 | void enableAlarm( bool enable ); | 72 | void enableAlarm( bool enable ); |
73 | void setSecrecy( int num ); | 73 | void setSecrecy( int num ); |
74 | public slots: | 74 | public slots: |
75 | void setCategories(const QString &); | 75 | void setCategories(const QString &); |
76 | void editCategories(); | 76 | void editCategories(); |
77 | 77 | ||
78 | protected slots: | 78 | protected slots: |
79 | void enableAlarmEdit( bool enable ); | 79 | void enableAlarmEdit( bool enable ); |
80 | void disableAlarmEdit( bool disable ); | 80 | void disableAlarmEdit( bool disable ); |
81 | void alarmDisable( bool disable ); | 81 | void alarmDisable( bool disable ); |
82 | void pickAlarmSound(); | 82 | void pickAlarmSound(); |
83 | void pickAlarmProgram(); | 83 | void pickAlarmProgram(); |
84 | void slotSetFocusOn(); | 84 | void slotSetFocusOn(); |
85 | signals: | 85 | signals: |
86 | void openCategoryDialog(); | 86 | void openCategoryDialog(); |
87 | void allAccepted(); | 87 | void allAccepted(); |
88 | void dateTimesChanged(QDateTime,QDateTime); | ||
88 | 89 | ||
89 | protected: | 90 | protected: |
90 | int mNextFocus; | 91 | int mNextFocus; |
91 | //QLineEdit *mSummaryEdit; | 92 | //QLineEdit *mSummaryEdit; |
92 | //QLineEdit *mLocationEdit; | 93 | //QLineEdit *mLocationEdit; |
93 | KOLocationBox *mSummaryEdit; | 94 | KOLocationBox *mSummaryEdit; |
94 | KOLocationBox *mLocationEdit; | 95 | KOLocationBox *mLocationEdit; |
95 | QLabel *mAlarmBell; | 96 | QLabel *mAlarmBell; |
96 | QCheckBox *mAlarmButton; | 97 | QCheckBox *mAlarmButton; |
97 | QSpinBox *mAlarmTimeEdit; | 98 | QSpinBox *mAlarmTimeEdit; |
98 | QPushButton *mAlarmSoundButton; | 99 | QPushButton *mAlarmSoundButton; |
99 | QPushButton *mAlarmProgramButton; | 100 | QPushButton *mAlarmProgramButton; |
100 | QComboBox *mAlarmIncrCombo; | 101 | QComboBox *mAlarmIncrCombo; |
101 | KTextEdit *mDescriptionEdit; | 102 | KTextEdit *mDescriptionEdit; |
102 | QLabel *mOwnerLabel; | 103 | QLabel *mOwnerLabel; |
103 | QComboBox *mSecrecyCombo; | 104 | QComboBox *mSecrecyCombo; |
104 | QCheckBox *mCancelBox; | 105 | QCheckBox *mCancelBox; |
105 | QPushButton *mCategoriesButton; | 106 | QPushButton *mCategoriesButton; |
106 | QLabel *mCategoriesLabel; | 107 | QLabel *mCategoriesLabel; |
107 | 108 | ||
108 | private: | 109 | private: |
109 | QString getFittingPath( const QString ) ; | 110 | QString getFittingPath( const QString ) ; |
110 | QString mAlarmSound; | 111 | QString mAlarmSound; |
111 | QString mAlarmProgram; | 112 | QString mAlarmProgram; |
112 | QString mAlarmMessage; | 113 | QString mAlarmMessage; |
113 | }; | 114 | }; |
114 | 115 | ||
115 | #endif | 116 | #endif |
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index af97ee9..3dd7f5c 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp | |||
@@ -48,385 +48,385 @@ | |||
48 | 48 | ||
49 | KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, | 49 | KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, |
50 | const char* name) : | 50 | const char* name) : |
51 | KOEditorGeneral( parent, name) | 51 | KOEditorGeneral( parent, name) |
52 | { | 52 | { |
53 | mTemplate = false; | 53 | mTemplate = false; |
54 | connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 54 | connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
55 | SLOT(setDuration())); | 55 | SLOT(setDuration())); |
56 | connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 56 | connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
57 | SLOT(emitDateTimeStr())); | 57 | SLOT(emitDateTimeStr())); |
58 | } | 58 | } |
59 | 59 | ||
60 | KOEditorGeneralEvent::~KOEditorGeneralEvent() | 60 | KOEditorGeneralEvent::~KOEditorGeneralEvent() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | void KOEditorGeneralEvent::finishSetup() | 64 | void KOEditorGeneralEvent::finishSetup() |
65 | { | 65 | { |
66 | 66 | ||
67 | //disabled | 67 | //disabled |
68 | // QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); | 68 | // QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); |
69 | // QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); | 69 | // QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); |
70 | // QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); | 70 | // QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); |
71 | // QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); | 71 | // QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); |
72 | // QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); | 72 | // QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); |
73 | // QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); | 73 | // QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); |
74 | // QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); | 74 | // QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); |
75 | // QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); | 75 | // QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); |
76 | // QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); | 76 | // QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); |
77 | // QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); | 77 | // QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); |
78 | // QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); | 78 | // QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); |
79 | 79 | ||
80 | 80 | ||
81 | 81 | ||
82 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); | 82 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); |
83 | mSummaryEdit->setFocus(); | 83 | mSummaryEdit->setFocus(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) | 86 | void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) |
87 | { | 87 | { |
88 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 88 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
89 | 89 | ||
90 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 90 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
91 | i18n("Date && Time"),parent); | 91 | i18n("Date && Time"),parent); |
92 | timeLayout->addWidget(timeGroupBox); | 92 | timeLayout->addWidget(timeGroupBox); |
93 | 93 | ||
94 | timeGroupBox->layout()->setSpacing( 0 ); | 94 | timeGroupBox->layout()->setSpacing( 0 ); |
95 | timeGroupBox->layout()->setMargin( 5 ); | 95 | timeGroupBox->layout()->setMargin( 5 ); |
96 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 96 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
97 | 97 | ||
98 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); | 98 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); |
99 | layoutTimeBox->setSpacing(topLayout->spacing()); | 99 | layoutTimeBox->setSpacing(topLayout->spacing()); |
100 | 100 | ||
101 | mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); | 101 | mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); |
102 | layoutTimeBox->addWidget(mStartDateLabel,0,0); | 102 | layoutTimeBox->addWidget(mStartDateLabel,0,0); |
103 | 103 | ||
104 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 104 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
105 | layoutTimeBox->addWidget(mStartDateEdit,0,1); | 105 | layoutTimeBox->addWidget(mStartDateEdit,0,1); |
106 | 106 | ||
107 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 107 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
108 | layoutTimeBox->addWidget(mStartTimeEdit,0,2); | 108 | layoutTimeBox->addWidget(mStartTimeEdit,0,2); |
109 | 109 | ||
110 | 110 | ||
111 | mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); | 111 | mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); |
112 | layoutTimeBox->addWidget(mEndDateLabel,1,0); | 112 | layoutTimeBox->addWidget(mEndDateLabel,1,0); |
113 | 113 | ||
114 | mEndDateEdit = new KDateEdit(timeBoxFrame); | 114 | mEndDateEdit = new KDateEdit(timeBoxFrame); |
115 | layoutTimeBox->addWidget(mEndDateEdit,1,1); | 115 | layoutTimeBox->addWidget(mEndDateEdit,1,1); |
116 | 116 | ||
117 | mEndTimeEdit = new KOTimeEdit(timeBoxFrame); | 117 | mEndTimeEdit = new KOTimeEdit(timeBoxFrame); |
118 | layoutTimeBox->addWidget(mEndTimeEdit,1,2); | 118 | layoutTimeBox->addWidget(mEndTimeEdit,1,2); |
119 | QWidget* duration = new QWidget( timeBoxFrame ); | 119 | QWidget* duration = new QWidget( timeBoxFrame ); |
120 | QHBoxLayout *flagsBox = new QHBoxLayout( duration ); | 120 | QHBoxLayout *flagsBox = new QHBoxLayout( duration ); |
121 | mNoTimeButton = new QCheckBox(i18n("All day event"),duration); | 121 | mNoTimeButton = new QCheckBox(i18n("All day event"),duration); |
122 | flagsBox->addWidget(mNoTimeButton); | 122 | flagsBox->addWidget(mNoTimeButton); |
123 | connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); | 123 | connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); |
124 | mDurationLabel = new QLabel( duration ); | 124 | mDurationLabel = new QLabel( duration ); |
125 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 125 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
126 | //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); | 126 | //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); |
127 | //} else { | 127 | //} else { |
128 | flagsBox->addWidget( mDurationLabel ); | 128 | flagsBox->addWidget( mDurationLabel ); |
129 | //} | 129 | //} |
130 | flagsBox->setStretchFactor(mDurationLabel, 10 ); | 130 | flagsBox->setStretchFactor(mDurationLabel, 10 ); |
131 | mDurationLabel->setAlignment( AlignRight | AlignVCenter); | 131 | mDurationLabel->setAlignment( AlignRight | AlignVCenter); |
132 | layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); | 132 | layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); |
133 | 133 | ||
134 | // time widgets are checked if they contain a valid time | 134 | // time widgets are checked if they contain a valid time |
135 | connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), | 135 | connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), |
136 | this, SLOT(startTimeChanged(QTime))); | 136 | this, SLOT(startTimeChanged(QTime))); |
137 | connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), | 137 | connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), |
138 | this, SLOT(endTimeChanged(QTime))); | 138 | this, SLOT(endTimeChanged(QTime))); |
139 | 139 | ||
140 | // date widgets are checked if they contain a valid date | 140 | // date widgets are checked if they contain a valid date |
141 | connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), | 141 | connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), |
142 | this, SLOT(startDateChanged(QDate))); | 142 | this, SLOT(startDateChanged(QDate))); |
143 | connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), | 143 | connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), |
144 | this, SLOT(endDateChanged(QDate))); | 144 | this, SLOT(endDateChanged(QDate))); |
145 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); | 145 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); |
146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); | 146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); |
147 | } | 147 | } |
148 | 148 | ||
149 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) | 149 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) |
150 | { | 150 | { |
151 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); | 151 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); |
152 | 152 | ||
153 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); | 153 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); |
154 | classLayout->addWidget(freeTimeLabel); | 154 | classLayout->addWidget(freeTimeLabel); |
155 | 155 | ||
156 | mFreeTimeCombo = new QComboBox(false, parent); | 156 | mFreeTimeCombo = new QComboBox(false, parent); |
157 | mFreeTimeCombo->insertItem(i18n("Busy")); | 157 | mFreeTimeCombo->insertItem(i18n("Busy")); |
158 | mFreeTimeCombo->insertItem(i18n("Free")); | 158 | mFreeTimeCombo->insertItem(i18n("Free")); |
159 | classLayout->addWidget(mFreeTimeCombo); | 159 | classLayout->addWidget(mFreeTimeCombo); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) | 162 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) |
163 | { | 163 | { |
164 | mStartTimeEdit->setEnabled( !disable ); | 164 | mStartTimeEdit->setEnabled( !disable ); |
165 | mEndTimeEdit->setEnabled( !disable ); | 165 | mEndTimeEdit->setEnabled( !disable ); |
166 | 166 | ||
167 | setDuration(); | 167 | setDuration(); |
168 | emitDateTimeStr(); | 168 | emitDateTimeStr(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) | 171 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) |
172 | { | 172 | { |
173 | timeStuffDisable(noTime); | 173 | timeStuffDisable(noTime); |
174 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); | 174 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); |
175 | allDayChanged(noTime); | 175 | allDayChanged(noTime); |
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) | 178 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) |
179 | { | 179 | { |
180 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; | 180 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; |
181 | if ( !mTemplate ) | 181 | if ( !mTemplate ) |
182 | mStartDateEdit->setDate(start.date()); | 182 | mStartDateEdit->setDate(start.date()); |
183 | // KTimeEdit seems to emit some signals when setTime() is called. | 183 | // KTimeEdit seems to emit some signals when setTime() is called. |
184 | mStartTimeEdit->blockSignals( true ); | 184 | mStartTimeEdit->blockSignals( true ); |
185 | mStartTimeEdit->setTime(start.time()); | 185 | mStartTimeEdit->setTime(start.time()); |
186 | mStartTimeEdit->blockSignals( false ); | 186 | mStartTimeEdit->blockSignals( false ); |
187 | if ( !mTemplate ) | 187 | if ( !mTemplate ) |
188 | mEndDateEdit->setDate(end.date()); | 188 | mEndDateEdit->setDate(end.date()); |
189 | mEndTimeEdit->setTime(end.time()); | 189 | mEndTimeEdit->setTime(end.time()); |
190 | 190 | ||
191 | mCurrStartDateTime = start; | 191 | mCurrStartDateTime = start; |
192 | mCurrEndDateTime = end; | 192 | mCurrEndDateTime = end; |
193 | 193 | ||
194 | setDuration(); | 194 | setDuration(); |
195 | emitDateTimeStr(); | 195 | emitDateTimeStr(); |
196 | } | 196 | } |
197 | 197 | ||
198 | void KOEditorGeneralEvent::sTimeChanged(QTime ti) | 198 | void KOEditorGeneralEvent::sTimeChanged(QTime ti) |
199 | { | 199 | { |
200 | mStartTimeEdit->setTime( ti ); | 200 | mStartTimeEdit->setTime( ti ); |
201 | startTimeChanged ( ti); | 201 | startTimeChanged ( ti); |
202 | } | 202 | } |
203 | void KOEditorGeneralEvent::eTimeChanged(QTime ti ) | 203 | void KOEditorGeneralEvent::eTimeChanged(QTime ti ) |
204 | { | 204 | { |
205 | mEndTimeEdit->setTime( ti ); | 205 | mEndTimeEdit->setTime( ti ); |
206 | endTimeChanged( ti ); | 206 | endTimeChanged( ti ); |
207 | } | 207 | } |
208 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) | 208 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) |
209 | { | 209 | { |
210 | 210 | ||
211 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); | 211 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); |
212 | 212 | ||
213 | mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); | 213 | mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); |
214 | // adjust end time so that the event has the same duration as before. | 214 | // adjust end time so that the event has the same duration as before. |
215 | if( secsep > 0 ) | 215 | if( secsep > 0 ) |
216 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); | 216 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); |
217 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); | 217 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); |
218 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 218 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
219 | 219 | ||
220 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 220 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
221 | } | 221 | } |
222 | 222 | ||
223 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) | 223 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) |
224 | { | 224 | { |
225 | 225 | ||
226 | mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); | 226 | mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); |
227 | 227 | ||
228 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 228 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
229 | } | 229 | } |
230 | 230 | ||
231 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) | 231 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) |
232 | { | 232 | { |
233 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); | 233 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); |
234 | 234 | ||
235 | mCurrStartDateTime.setDate(newdate); | 235 | mCurrStartDateTime.setDate(newdate); |
236 | 236 | ||
237 | // adjust end date so that the event has the same duration as before | 237 | // adjust end date so that the event has the same duration as before |
238 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); | 238 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); |
239 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 239 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
240 | 240 | qDebug("KOEditorGeneralEvent::startDateChanged "); | |
241 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 241 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
242 | } | 242 | } |
243 | 243 | ||
244 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) | 244 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) |
245 | { | 245 | { |
246 | QDateTime newdt(newdate, mCurrEndDateTime.time()); | 246 | QDateTime newdt(newdate, mCurrEndDateTime.time()); |
247 | 247 | ||
248 | if(newdt < mCurrStartDateTime) { | 248 | if(newdt < mCurrStartDateTime) { |
249 | // oops, we can't let that happen. | 249 | // oops, we can't let that happen. |
250 | newdt = mCurrStartDateTime; | 250 | newdt = mCurrStartDateTime; |
251 | mEndDateEdit->setDate(newdt.date()); | 251 | mEndDateEdit->setDate(newdt.date()); |
252 | mEndTimeEdit->setTime(newdt.time()); | 252 | mEndTimeEdit->setTime(newdt.time()); |
253 | } | 253 | } |
254 | mCurrEndDateTime = newdt; | 254 | mCurrEndDateTime = newdt; |
255 | 255 | ||
256 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 256 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
257 | } | 257 | } |
258 | 258 | ||
259 | void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) | 259 | void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) |
260 | { | 260 | { |
261 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); | 261 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); |
262 | mLocationEdit->load(KOLocationBox::LOCATION); | 262 | mLocationEdit->load(KOLocationBox::LOCATION); |
263 | KOEditorGeneral::setDefaults(allDay); | 263 | KOEditorGeneral::setDefaults(allDay); |
264 | 264 | ||
265 | mNoTimeButton->setChecked(allDay); | 265 | mNoTimeButton->setChecked(allDay); |
266 | timeStuffDisable(allDay); | 266 | timeStuffDisable(allDay); |
267 | mFreeTimeCombo->setCurrentItem( 0 ); | 267 | mFreeTimeCombo->setCurrentItem( 0 ); |
268 | setDateTimes(from,to); | 268 | setDateTimes(from,to); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) | 271 | void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) |
272 | { | 272 | { |
273 | QString tmpStr; | 273 | QString tmpStr; |
274 | 274 | ||
275 | mTemplate = tmpl; | 275 | mTemplate = tmpl; |
276 | // the rest is for the events only | 276 | // the rest is for the events only |
277 | mNoTimeButton->setChecked(event->doesFloat()); | 277 | mNoTimeButton->setChecked(event->doesFloat()); |
278 | timeStuffDisable(event->doesFloat()); | 278 | timeStuffDisable(event->doesFloat()); |
279 | 279 | ||
280 | setDateTimes(event->dtStart(),event->dtEnd()); | 280 | setDateTimes(event->dtStart(),event->dtEnd()); |
281 | 281 | ||
282 | mTemplate = false; | 282 | mTemplate = false; |
283 | switch( event->transparency() ) { | 283 | switch( event->transparency() ) { |
284 | case Event::Transparent: | 284 | case Event::Transparent: |
285 | mFreeTimeCombo->setCurrentItem(1); | 285 | mFreeTimeCombo->setCurrentItem(1); |
286 | break; | 286 | break; |
287 | case Event::Opaque: | 287 | case Event::Opaque: |
288 | mFreeTimeCombo->setCurrentItem(0); | 288 | mFreeTimeCombo->setCurrentItem(0); |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | 291 | ||
292 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); | 292 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); |
293 | mLocationEdit->load(KOLocationBox::LOCATION); | 293 | mLocationEdit->load(KOLocationBox::LOCATION); |
294 | readIncidence(event); | 294 | readIncidence(event); |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOEditorGeneralEvent::writeEvent(Event *event) | 297 | void KOEditorGeneralEvent::writeEvent(Event *event) |
298 | { | 298 | { |
299 | // kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; | 299 | // kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; |
300 | 300 | ||
301 | writeIncidence(event); | 301 | writeIncidence(event); |
302 | 302 | ||
303 | QDate tmpDate; | 303 | QDate tmpDate; |
304 | QTime tmpTime; | 304 | QTime tmpTime; |
305 | QDateTime tmpDT; | 305 | QDateTime tmpDT; |
306 | 306 | ||
307 | // temp. until something better happens. | 307 | // temp. until something better happens. |
308 | QString tmpStr; | 308 | QString tmpStr; |
309 | 309 | ||
310 | if (mNoTimeButton->isChecked()) { | 310 | if (mNoTimeButton->isChecked()) { |
311 | event->setFloats(true); | 311 | event->setFloats(true); |
312 | // need to change this. | 312 | // need to change this. |
313 | tmpDate = mStartDateEdit->date(); | 313 | tmpDate = mStartDateEdit->date(); |
314 | tmpTime.setHMS(0,0,0); | 314 | tmpTime.setHMS(0,0,0); |
315 | tmpDT.setDate(tmpDate); | 315 | tmpDT.setDate(tmpDate); |
316 | tmpDT.setTime(tmpTime); | 316 | tmpDT.setTime(tmpTime); |
317 | event->setDtStart(tmpDT); | 317 | event->setDtStart(tmpDT); |
318 | 318 | ||
319 | tmpDate = mEndDateEdit->date(); | 319 | tmpDate = mEndDateEdit->date(); |
320 | tmpTime.setHMS(0,0,0); | 320 | tmpTime.setHMS(0,0,0); |
321 | tmpDT.setDate(tmpDate); | 321 | tmpDT.setDate(tmpDate); |
322 | tmpDT.setTime(tmpTime); | 322 | tmpDT.setTime(tmpTime); |
323 | event->setDtEnd(tmpDT); | 323 | event->setDtEnd(tmpDT); |
324 | } else { | 324 | } else { |
325 | event->setFloats(false); | 325 | event->setFloats(false); |
326 | 326 | ||
327 | // set date/time end | 327 | // set date/time end |
328 | tmpDate = mEndDateEdit->date(); | 328 | tmpDate = mEndDateEdit->date(); |
329 | tmpTime = mEndTimeEdit->getTime(); | 329 | tmpTime = mEndTimeEdit->getTime(); |
330 | tmpDT.setDate(tmpDate); | 330 | tmpDT.setDate(tmpDate); |
331 | tmpDT.setTime(tmpTime); | 331 | tmpDT.setTime(tmpTime); |
332 | event->setDtEnd(tmpDT); | 332 | event->setDtEnd(tmpDT); |
333 | 333 | ||
334 | // set date/time start | 334 | // set date/time start |
335 | tmpDate = mStartDateEdit->date(); | 335 | tmpDate = mStartDateEdit->date(); |
336 | tmpTime = mStartTimeEdit->getTime(); | 336 | tmpTime = mStartTimeEdit->getTime(); |
337 | tmpDT.setDate(tmpDate); | 337 | tmpDT.setDate(tmpDate); |
338 | tmpDT.setTime(tmpTime); | 338 | tmpDT.setTime(tmpTime); |
339 | event->setDtStart(tmpDT); | 339 | event->setDtStart(tmpDT); |
340 | } // check for float | 340 | } // check for float |
341 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); | 341 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); |
342 | 342 | ||
343 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 | 343 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 |
344 | ? KCal::Event::Transparent | 344 | ? KCal::Event::Transparent |
345 | : KCal::Event::Opaque); | 345 | : KCal::Event::Opaque); |
346 | 346 | ||
347 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; | 347 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; |
348 | } | 348 | } |
349 | 349 | ||
350 | void KOEditorGeneralEvent::setDuration() | 350 | void KOEditorGeneralEvent::setDuration() |
351 | { | 351 | { |
352 | QString tmpStr = "", catStr; | 352 | QString tmpStr = "", catStr; |
353 | int hourdiff, minutediff; | 353 | int hourdiff, minutediff; |
354 | // end<date is an accepted temporary state while typing, but don't show | 354 | // end<date is an accepted temporary state while typing, but don't show |
355 | // any duration if this happens | 355 | // any duration if this happens |
356 | if(mCurrEndDateTime >= mCurrStartDateTime) { | 356 | if(mCurrEndDateTime >= mCurrStartDateTime) { |
357 | 357 | ||
358 | if (mNoTimeButton->isChecked()) { | 358 | if (mNoTimeButton->isChecked()) { |
359 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; | 359 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; |
360 | tmpStr = i18n("Duration: "); | 360 | tmpStr = i18n("Duration: "); |
361 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); | 361 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); |
362 | } else { | 362 | } else { |
363 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); | 363 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); |
364 | hourdiff = secto / 3600; | 364 | hourdiff = secto / 3600; |
365 | minutediff = (secto/60 ) % 60; | 365 | minutediff = (secto/60 ) % 60; |
366 | if (hourdiff || minutediff){ | 366 | if (hourdiff || minutediff){ |
367 | tmpStr = i18n("Duration: "); | 367 | tmpStr = i18n("Duration: "); |
368 | if (hourdiff){ | 368 | if (hourdiff){ |
369 | catStr = i18n("1 h","%n h",hourdiff); | 369 | catStr = i18n("1 h","%n h",hourdiff); |
370 | tmpStr.append(catStr); | 370 | tmpStr.append(catStr); |
371 | } | 371 | } |
372 | if (hourdiff && minutediff){ | 372 | if (hourdiff && minutediff){ |
373 | tmpStr += i18n(", "); | 373 | tmpStr += i18n(", "); |
374 | } | 374 | } |
375 | if (minutediff){ | 375 | if (minutediff){ |
376 | catStr = i18n("1 min","%n min",minutediff); | 376 | catStr = i18n("1 min","%n min",minutediff); |
377 | tmpStr += catStr; | 377 | tmpStr += catStr; |
378 | } | 378 | } |
379 | } else tmpStr = ""; | 379 | } else tmpStr = ""; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | mDurationLabel->setText(tmpStr); | 382 | mDurationLabel->setText(tmpStr); |
383 | } | 383 | } |
384 | 384 | ||
385 | void KOEditorGeneralEvent::emitDateTimeStr() | 385 | void KOEditorGeneralEvent::emitDateTimeStr() |
386 | { | 386 | { |
387 | KLocale *l = KGlobal::locale(); | 387 | KLocale *l = KGlobal::locale(); |
388 | QString startString = ""; | 388 | QString startString = ""; |
389 | if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) { | 389 | if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) { |
390 | if ( mNoTimeButton->isChecked() ) { | 390 | if ( mNoTimeButton->isChecked() ) { |
391 | startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() ); | 391 | startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() ); |
392 | startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date()); | 392 | startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date()); |
393 | 393 | ||
394 | } else { | 394 | } else { |
395 | startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false); | 395 | startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false); |
396 | startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false); | 396 | startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false); |
397 | } | 397 | } |
398 | } else { | 398 | } else { |
399 | if ( mNoTimeButton->isChecked() ) { | 399 | if ( mNoTimeButton->isChecked() ) { |
400 | startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() ); | 400 | startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() ); |
401 | } else { | 401 | } else { |
402 | startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+ | 402 | startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+ |
403 | "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time()); | 403 | "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time()); |
404 | startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true); | 404 | startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | startString +="\n"+mDurationLabel->text(); | 407 | startString +="\n"+mDurationLabel->text(); |
408 | emit dateTimeStrChanged(startString); | 408 | emit dateTimeStrChanged(startString); |
409 | } | 409 | } |
410 | 410 | ||
411 | bool KOEditorGeneralEvent::validateInput() | 411 | bool KOEditorGeneralEvent::validateInput() |
412 | { | 412 | { |
413 | 413 | ||
414 | if (!mStartDateEdit->inputIsValid()) { | 414 | if (!mStartDateEdit->inputIsValid()) { |
415 | KMessageBox::sorry( 0, | 415 | KMessageBox::sorry( 0, |
416 | i18n("Please specify a valid start date,\nfor example '%1'.") | 416 | i18n("Please specify a valid start date,\nfor example '%1'.") |
417 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); | 417 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); |
418 | return false; | 418 | return false; |
419 | } | 419 | } |
420 | 420 | ||
421 | if (!mEndDateEdit->inputIsValid()) { | 421 | if (!mEndDateEdit->inputIsValid()) { |
422 | KMessageBox::sorry( 0, | 422 | KMessageBox::sorry( 0, |
423 | i18n("Please specify a valid end date,\nfor example '%1'.") | 423 | i18n("Please specify a valid end date,\nfor example '%1'.") |
424 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); | 424 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); |
425 | return false; | 425 | return false; |
426 | } | 426 | } |
427 | 427 | ||
428 | QDateTime startDt,endDt; | 428 | QDateTime startDt,endDt; |
429 | startDt.setDate(mStartDateEdit->date()); | 429 | startDt.setDate(mStartDateEdit->date()); |
430 | endDt.setDate(mEndDateEdit->date()); | 430 | endDt.setDate(mEndDateEdit->date()); |
431 | if (!mNoTimeButton->isChecked()) { | 431 | if (!mNoTimeButton->isChecked()) { |
432 | startDt.setTime(mStartTimeEdit->getTime()); | 432 | startDt.setTime(mStartTimeEdit->getTime()); |
diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h index 9649806..d798905 100644 --- a/korganizer/koeditorgeneralevent.h +++ b/korganizer/koeditorgeneralevent.h | |||
@@ -1,111 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 | #ifndef _KOEDITORGENERALEVENT_H | 23 | #ifndef _KOEDITORGENERALEVENT_H |
24 | #define _KOEDITORGENERALEVENT_H | 24 | #define _KOEDITORGENERALEVENT_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | 36 | ||
37 | #include <krestrictedline.h> | 37 | #include <krestrictedline.h> |
38 | 38 | ||
39 | #include "koeditorgeneral.h" | 39 | #include "koeditorgeneral.h" |
40 | 40 | ||
41 | #include "ktimeedit.h" | 41 | #include "ktimeedit.h" |
42 | 42 | ||
43 | class KDateEdit; | 43 | class KDateEdit; |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | class KOEditorGeneralEvent : public KOEditorGeneral | 47 | class KOEditorGeneralEvent : public KOEditorGeneral |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOEditorGeneralEvent (QObject* parent=0,const char* name=0); | 51 | KOEditorGeneralEvent (QObject* parent=0,const char* name=0); |
52 | virtual ~KOEditorGeneralEvent(); | 52 | virtual ~KOEditorGeneralEvent(); |
53 | 53 | ||
54 | void initTime(QWidget *,QBoxLayout *); | 54 | void initTime(QWidget *,QBoxLayout *); |
55 | void initClass(QWidget *,QBoxLayout *); | 55 | void initClass(QWidget *,QBoxLayout *); |
56 | 56 | ||
57 | void finishSetup(); | 57 | void finishSetup(); |
58 | 58 | ||
59 | /** Set widgets to default values */ | 59 | /** Set widgets to default values */ |
60 | void setDefaults(QDateTime from,QDateTime to,bool allDay); | 60 | void setDefaults(QDateTime from,QDateTime to,bool allDay); |
61 | /** | 61 | /** |
62 | Read event object and setup widgets accordingly. If templ is true, the | 62 | Read event object and setup widgets accordingly. If templ is true, the |
63 | event is read as template, i.e. the time and date information isn't set. | 63 | event is read as template, i.e. the time and date information isn't set. |
64 | */ | 64 | */ |
65 | void readEvent( Event *, bool tmpl = false ); | 65 | void readEvent( Event *, bool tmpl = false ); |
66 | /** Write event settings to event object */ | 66 | /** Write event settings to event object */ |
67 | void writeEvent(Event *); | 67 | void writeEvent(Event *); |
68 | 68 | ||
69 | /** Check if the input is valid. */ | 69 | /** Check if the input is valid. */ |
70 | bool validateInput(); | 70 | bool validateInput(); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void setDateTimes(QDateTime start, QDateTime end); | 73 | void setDateTimes(QDateTime start, QDateTime end); |
74 | void setDuration(); | 74 | void setDuration(); |
75 | 75 | ||
76 | protected slots: | 76 | protected slots: |
77 | void timeStuffDisable(bool disable); | 77 | void timeStuffDisable(bool disable); |
78 | void dontAssociateTime(bool noTime); | 78 | void dontAssociateTime(bool noTime); |
79 | 79 | ||
80 | void startTimeChanged(QTime); | 80 | void startTimeChanged(QTime); |
81 | void startDateChanged(QDate); | 81 | void startDateChanged(QDate); |
82 | void endTimeChanged(QTime); | 82 | void endTimeChanged(QTime); |
83 | void endDateChanged(QDate); | 83 | void endDateChanged(QDate); |
84 | 84 | ||
85 | void emitDateTimeStr(); | 85 | void emitDateTimeStr(); |
86 | void sTimeChanged(QTime); | 86 | void sTimeChanged(QTime); |
87 | void eTimeChanged(QTime); | 87 | void eTimeChanged(QTime); |
88 | 88 | ||
89 | signals: | 89 | signals: |
90 | void dateTimesChanged(QDateTime start,QDateTime end); | ||
91 | void allDayChanged(bool); | 90 | void allDayChanged(bool); |
92 | void dateTimeStrChanged(const QString &); | 91 | void dateTimeStrChanged(const QString &); |
93 | 92 | ||
94 | private: | 93 | private: |
95 | bool mTemplate; | 94 | bool mTemplate; |
96 | QLabel *mStartDateLabel; | 95 | QLabel *mStartDateLabel; |
97 | QLabel *mEndDateLabel; | 96 | QLabel *mEndDateLabel; |
98 | KDateEdit *mStartDateEdit; | 97 | KDateEdit *mStartDateEdit; |
99 | KDateEdit *mEndDateEdit; | 98 | KDateEdit *mEndDateEdit; |
100 | KOTimeEdit *mStartTimeEdit; | 99 | KOTimeEdit *mStartTimeEdit; |
101 | KOTimeEdit *mEndTimeEdit; | 100 | KOTimeEdit *mEndTimeEdit; |
102 | QLabel *mDurationLabel; | 101 | QLabel *mDurationLabel; |
103 | QCheckBox *mNoTimeButton; | 102 | QCheckBox *mNoTimeButton; |
104 | QComboBox *mFreeTimeCombo; | 103 | QComboBox *mFreeTimeCombo; |
105 | 104 | ||
106 | // current start and end date and time | 105 | // current start and end date and time |
107 | QDateTime mCurrStartDateTime; | 106 | QDateTime mCurrStartDateTime; |
108 | QDateTime mCurrEndDateTime; | 107 | QDateTime mCurrEndDateTime; |
109 | }; | 108 | }; |
110 | 109 | ||
111 | #endif | 110 | #endif |
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index e86b4d0..0a734ee 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -1,503 +1,508 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
40 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
41 | #include <kfiledialog.h> | 41 | #include <kfiledialog.h> |
42 | #include <kdialog.h> | 42 | #include <kdialog.h> |
43 | 43 | ||
44 | #include <libkcal/todo.h> | 44 | #include <libkcal/todo.h> |
45 | 45 | ||
46 | #include <libkdepim/kdateedit.h> | 46 | #include <libkdepim/kdateedit.h> |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | #include "ktimeedit.h" | 49 | #include "ktimeedit.h" |
50 | 50 | ||
51 | #include "koeditorgeneraltodo.h" | 51 | #include "koeditorgeneraltodo.h" |
52 | #include "kolocationbox.h" | 52 | #include "kolocationbox.h" |
53 | 53 | ||
54 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, | 54 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, |
55 | const char* name) | 55 | const char* name) |
56 | : KOEditorGeneral( parent, name) | 56 | : KOEditorGeneral( parent, name) |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | KOEditorGeneralTodo::~KOEditorGeneralTodo() | 60 | KOEditorGeneralTodo::~KOEditorGeneralTodo() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | void KOEditorGeneralTodo::finishSetup() | 64 | void KOEditorGeneralTodo::finishSetup() |
65 | { | 65 | { |
66 | 66 | ||
67 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); | 67 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); |
68 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); | 68 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); |
69 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); | 69 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); |
70 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); | 70 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); |
71 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); | 71 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); |
72 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); | 72 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); |
73 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); | 73 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); |
74 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); | 74 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); |
75 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); | 75 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); |
76 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); | 76 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); |
77 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); | 77 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); |
78 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); | 78 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); |
79 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); | 79 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); |
80 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); | 80 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); |
81 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 81 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
82 | mSummaryEdit->setFocus(); | 82 | mSummaryEdit->setFocus(); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) | 85 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) |
86 | { | 86 | { |
87 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 87 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
88 | 88 | ||
89 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 89 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
90 | i18n("Date && Time"),parent); | 90 | i18n("Date && Time"),parent); |
91 | timeLayout->addWidget(timeGroupBox); | 91 | timeLayout->addWidget(timeGroupBox); |
92 | timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() ); | 92 | timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() ); |
93 | timeGroupBox->layout()->setMargin( KDialog::marginHint() ); | 93 | timeGroupBox->layout()->setMargin( KDialog::marginHint() ); |
94 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 94 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
95 | 95 | ||
96 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); | 96 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); |
97 | layoutTimeBox->setSpacing(KDialog::spacingHintSmall()); | 97 | layoutTimeBox->setSpacing(KDialog::spacingHintSmall()); |
98 | layoutTimeBox->setColStretch( 1, 1 ); | 98 | layoutTimeBox->setColStretch( 1, 1 ); |
99 | 99 | ||
100 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); | 100 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); |
101 | layoutTimeBox->addWidget(mDueCheck,1,0); | 101 | layoutTimeBox->addWidget(mDueCheck,1,0); |
102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); | 102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); |
103 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); | 103 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); |
104 | 104 | ||
105 | 105 | ||
106 | mDueDateEdit = new KDateEdit(timeBoxFrame); | 106 | mDueDateEdit = new KDateEdit(timeBoxFrame); |
107 | layoutTimeBox->addWidget(mDueDateEdit,1,1); | 107 | layoutTimeBox->addWidget(mDueDateEdit,1,1); |
108 | 108 | ||
109 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); | 109 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); |
110 | layoutTimeBox->addWidget(mDueTimeEdit,1,2); | 110 | layoutTimeBox->addWidget(mDueTimeEdit,1,2); |
111 | 111 | ||
112 | 112 | ||
113 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); | 113 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); |
114 | layoutTimeBox->addWidget(mStartCheck,0,0); | 114 | layoutTimeBox->addWidget(mStartCheck,0,0); |
115 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); | 115 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); |
116 | 116 | ||
117 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 117 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
118 | layoutTimeBox->addWidget(mStartDateEdit,0,1); | 118 | layoutTimeBox->addWidget(mStartDateEdit,0,1); |
119 | 119 | ||
120 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 120 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
121 | layoutTimeBox->addWidget(mStartTimeEdit,0,2); | 121 | layoutTimeBox->addWidget(mStartTimeEdit,0,2); |
122 | 122 | ||
123 | 123 | ||
124 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); | 124 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); |
125 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); | 125 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); |
126 | 126 | ||
127 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); | 127 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); |
128 | connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime))); | 128 | connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime))); |
129 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime))); | 129 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime))); |
130 | 130 | connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), | |
131 | this, SLOT(startDateChanged(QDate))); | ||
131 | // some more layouting | 132 | // some more layouting |
132 | //layoutTimeBox->setColStretch(3,1); | 133 | //layoutTimeBox->setColStretch(3,1); |
133 | } | 134 | } |
134 | 135 | ||
135 | 136 | ||
136 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | 137 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) |
137 | { | 138 | { |
138 | mCompletedCombo = new QComboBox(parent); | 139 | mCompletedCombo = new QComboBox(parent); |
139 | // xgettext:no-c-format | 140 | // xgettext:no-c-format |
140 | mCompletedCombo->insertItem(i18n(" 0 %")); | 141 | mCompletedCombo->insertItem(i18n(" 0 %")); |
141 | // xgettext:no-c-format | 142 | // xgettext:no-c-format |
142 | mCompletedCombo->insertItem(i18n(" 20 %")); | 143 | mCompletedCombo->insertItem(i18n(" 20 %")); |
143 | // xgettext:no-c-format | 144 | // xgettext:no-c-format |
144 | mCompletedCombo->insertItem(i18n(" 40 %")); | 145 | mCompletedCombo->insertItem(i18n(" 40 %")); |
145 | // xgettext:no-c-format | 146 | // xgettext:no-c-format |
146 | mCompletedCombo->insertItem(i18n(" 60 %")); | 147 | mCompletedCombo->insertItem(i18n(" 60 %")); |
147 | // xgettext:no-c-format | 148 | // xgettext:no-c-format |
148 | mCompletedCombo->insertItem(i18n(" 80 %")); | 149 | mCompletedCombo->insertItem(i18n(" 80 %")); |
149 | // xgettext:no-c-format | 150 | // xgettext:no-c-format |
150 | mCompletedCombo->insertItem(i18n("100 %")); | 151 | mCompletedCombo->insertItem(i18n("100 %")); |
151 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 152 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
152 | topLayout->addWidget(mCompletedCombo); | 153 | topLayout->addWidget(mCompletedCombo); |
153 | 154 | ||
154 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 155 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
155 | topLayout->addWidget(mCompletedLabel); | 156 | topLayout->addWidget(mCompletedLabel); |
156 | 157 | ||
157 | mCompleteDateEdit = new KDateEdit(parent); | 158 | mCompleteDateEdit = new KDateEdit(parent); |
158 | topLayout->addWidget(mCompleteDateEdit ); | 159 | topLayout->addWidget(mCompleteDateEdit ); |
159 | 160 | ||
160 | mCompleteTimeEdit = new KOTimeEdit(parent); | 161 | mCompleteTimeEdit = new KOTimeEdit(parent); |
161 | topLayout->addWidget( mCompleteTimeEdit); | 162 | topLayout->addWidget( mCompleteTimeEdit); |
162 | 163 | ||
163 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | 164 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); |
164 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | 165 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); |
165 | connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime))); | 166 | connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime))); |
166 | 167 | ||
167 | if ( QApplication::desktop()->width() <= 480 ) { | 168 | if ( QApplication::desktop()->width() <= 480 ) { |
168 | if ( QApplication::desktop()->width() < 320 ) | 169 | if ( QApplication::desktop()->width() < 320 ) |
169 | mCompleteDateEdit->setMaximumWidth( 85 ); | 170 | mCompleteDateEdit->setMaximumWidth( 85 ); |
170 | else | 171 | else |
171 | mCompleteDateEdit->setMaximumWidth( 140 ); | 172 | mCompleteDateEdit->setMaximumWidth( 140 ); |
172 | topLayout->setSpacing( 0 ); | 173 | topLayout->setSpacing( 0 ); |
173 | } | 174 | } |
174 | } | 175 | } |
175 | 176 | ||
176 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 177 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
177 | { | 178 | { |
178 | 179 | ||
179 | QHBox* h = new QHBox ( parent ); | 180 | QHBox* h = new QHBox ( parent ); |
180 | topLayout->addWidget( h ); | 181 | topLayout->addWidget( h ); |
181 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 182 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
182 | // topLayout->addWidget(priorityLabel); | 183 | // topLayout->addWidget(priorityLabel); |
183 | mPriorityCombo = new QComboBox( h ); | 184 | mPriorityCombo = new QComboBox( h ); |
184 | mPriorityCombo->insertItem(i18n("1 (high)")); | 185 | mPriorityCombo->insertItem(i18n("1 (high)")); |
185 | mPriorityCombo->insertItem(i18n("2")); | 186 | mPriorityCombo->insertItem(i18n("2")); |
186 | mPriorityCombo->insertItem(i18n("3")); | 187 | mPriorityCombo->insertItem(i18n("3")); |
187 | mPriorityCombo->insertItem(i18n("4")); | 188 | mPriorityCombo->insertItem(i18n("4")); |
188 | mPriorityCombo->insertItem(i18n("5 (low)")); | 189 | mPriorityCombo->insertItem(i18n("5 (low)")); |
189 | //topLayout->addWidget(mPriorityCombo); | 190 | //topLayout->addWidget(mPriorityCombo); |
190 | } | 191 | } |
191 | 192 | ||
192 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 193 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
193 | { | 194 | { |
194 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 195 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
195 | 196 | ||
196 | initCompletion( parent, statusLayout ); | 197 | initCompletion( parent, statusLayout ); |
197 | 198 | ||
198 | statusLayout->addStretch( 1 ); | 199 | statusLayout->addStretch( 1 ); |
199 | 200 | ||
200 | initPriority( parent, statusLayout ); | 201 | initPriority( parent, statusLayout ); |
201 | } | 202 | } |
202 | 203 | ||
203 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) | 204 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) |
204 | { | 205 | { |
205 | 206 | ||
206 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 207 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
207 | mLocationEdit->load(KOLocationBox::LOCATION); | 208 | mLocationEdit->load(KOLocationBox::LOCATION); |
208 | KOEditorGeneral::setDefaults(allDay); | 209 | KOEditorGeneral::setDefaults(allDay); |
209 | 210 | ||
210 | mTimeButton->setChecked( !allDay ); | 211 | mTimeButton->setChecked( !allDay ); |
211 | if(mTimeButton->isChecked()) { | 212 | if(mTimeButton->isChecked()) { |
212 | mTimeButton->setEnabled(true); | 213 | mTimeButton->setEnabled(true); |
213 | } | 214 | } |
214 | else { | 215 | else { |
215 | mTimeButton->setEnabled(false); | 216 | mTimeButton->setEnabled(false); |
216 | } | 217 | } |
217 | 218 | ||
218 | enableTimeEdits( !allDay ); | 219 | enableTimeEdits( !allDay ); |
219 | if ( due.isValid() ) { | 220 | if ( due.isValid() ) { |
220 | mDueCheck->setChecked(true); | 221 | mDueCheck->setChecked(true); |
221 | enableDueEdit(true); | 222 | enableDueEdit(true); |
222 | alarmDisable(false); | 223 | alarmDisable(false); |
223 | } else { | 224 | } else { |
224 | mDueCheck->setChecked(false); | 225 | mDueCheck->setChecked(false); |
225 | enableDueEdit(false); | 226 | enableDueEdit(false); |
226 | due = QDateTime::currentDateTime().addDays(7); | 227 | due = QDateTime::currentDateTime().addDays(7); |
227 | alarmDisable(true); | 228 | alarmDisable(true); |
228 | } | 229 | } |
229 | 230 | ||
230 | 231 | ||
231 | mStartCheck->setChecked(false); | 232 | mStartCheck->setChecked(false); |
232 | enableStartEdit(false); | 233 | enableStartEdit(false); |
233 | 234 | ||
234 | mDueDateEdit->setDate(due.date()); | 235 | mDueDateEdit->setDate(due.date()); |
235 | mDueTimeEdit->setTime(due.time()); | 236 | mDueTimeEdit->setTime(due.time()); |
236 | due = due.addDays(-7); | 237 | due = due.addDays(-7); |
237 | mStartDateEdit->setDate(due.date()); | 238 | mStartDateEdit->setDate(due.date()); |
238 | mStartTimeEdit->setTime(due.time()); | 239 | mStartTimeEdit->setTime(due.time()); |
239 | 240 | ||
240 | mPriorityCombo->setCurrentItem(2); | 241 | mPriorityCombo->setCurrentItem(2); |
241 | mCompletedLabel->setText(i18n(" completed"));; | 242 | mCompletedLabel->setText(i18n(" completed"));; |
242 | mCompletedCombo->setCurrentItem(0); | 243 | mCompletedCombo->setCurrentItem(0); |
243 | mCompleteDateEdit->hide(); | 244 | mCompleteDateEdit->hide(); |
244 | mCompleteTimeEdit->hide(); | 245 | mCompleteTimeEdit->hide(); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KOEditorGeneralTodo::readTodo(Todo *todo) | 248 | void KOEditorGeneralTodo::readTodo(Todo *todo) |
248 | { | 249 | { |
249 | 250 | ||
250 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 251 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
251 | mLocationEdit->load(KOLocationBox::LOCATION); | 252 | mLocationEdit->load(KOLocationBox::LOCATION); |
252 | KOEditorGeneral::readIncidence(todo); | 253 | KOEditorGeneral::readIncidence(todo); |
253 | 254 | ||
254 | QDateTime dueDT; | 255 | QDateTime dueDT; |
255 | 256 | ||
256 | if (todo->hasDueDate()) { | 257 | if (todo->hasDueDate()) { |
257 | enableAlarmEdit(true); | 258 | enableAlarmEdit(true); |
258 | dueDT = todo->dtDue(); | 259 | dueDT = todo->dtDue(); |
259 | mDueDateEdit->setDate(todo->dtDue().date()); | 260 | mDueDateEdit->setDate(todo->dtDue().date()); |
260 | mDueTimeEdit->setTime(todo->dtDue().time()); | 261 | mDueTimeEdit->setTime(todo->dtDue().time()); |
261 | mDueCheck->setChecked(true); | 262 | mDueCheck->setChecked(true); |
262 | } else { | 263 | } else { |
263 | alarmDisable(true); | 264 | alarmDisable(true); |
264 | mDueDateEdit->setEnabled(false); | 265 | mDueDateEdit->setEnabled(false); |
265 | mDueTimeEdit->setEnabled(false); | 266 | mDueTimeEdit->setEnabled(false); |
266 | mDueDateEdit->setDate(QDate::currentDate()); | 267 | mDueDateEdit->setDate(QDate::currentDate()); |
267 | mDueTimeEdit->setTime(QTime::currentTime()); | 268 | mDueTimeEdit->setTime(QTime::currentTime()); |
268 | mDueCheck->setChecked(false); | 269 | mDueCheck->setChecked(false); |
269 | } | 270 | } |
270 | 271 | ||
271 | if (todo->hasStartDate()) { | 272 | if (todo->hasStartDate()) { |
272 | mStartDateEdit->setDate(todo->dtStart().date()); | 273 | mStartDateEdit->setDate(todo->dtStart().date()); |
273 | mStartTimeEdit->setTime(todo->dtStart().time()); | 274 | mStartTimeEdit->setTime(todo->dtStart().time()); |
274 | mStartCheck->setChecked(true); | 275 | mStartCheck->setChecked(true); |
275 | } else { | 276 | } else { |
276 | mStartDateEdit->setEnabled(false); | 277 | mStartDateEdit->setEnabled(false); |
277 | mStartTimeEdit->setEnabled(false); | 278 | mStartTimeEdit->setEnabled(false); |
278 | mStartDateEdit->setDate(QDate::currentDate()); | 279 | mStartDateEdit->setDate(QDate::currentDate()); |
279 | mStartTimeEdit->setTime(QTime::currentTime()); | 280 | mStartTimeEdit->setTime(QTime::currentTime()); |
280 | mStartCheck->setChecked(false); | 281 | mStartCheck->setChecked(false); |
281 | } | 282 | } |
282 | 283 | ||
283 | mTimeButton->setChecked( !todo->doesFloat() ); | 284 | mTimeButton->setChecked( !todo->doesFloat() ); |
284 | 285 | ||
285 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 286 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
286 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 287 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
287 | mCompleted = todo->completed(); | 288 | mCompleted = todo->completed(); |
288 | } | 289 | } |
289 | setCompletedDate(); | 290 | setCompletedDate(); |
290 | 291 | ||
291 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 292 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
292 | } | 293 | } |
293 | 294 | ||
294 | void KOEditorGeneralTodo::writeTodo(Todo *todo) | 295 | void KOEditorGeneralTodo::writeTodo(Todo *todo) |
295 | { | 296 | { |
296 | KOEditorGeneral::writeIncidence(todo); | 297 | KOEditorGeneral::writeIncidence(todo); |
297 | 298 | ||
298 | // temp. until something better happens. | 299 | // temp. until something better happens. |
299 | QString tmpStr; | 300 | QString tmpStr; |
300 | 301 | ||
301 | todo->setHasDueDate(mDueCheck->isChecked()); | 302 | todo->setHasDueDate(mDueCheck->isChecked()); |
302 | todo->setHasStartDate(mStartCheck->isChecked()); | 303 | todo->setHasStartDate(mStartCheck->isChecked()); |
303 | 304 | ||
304 | QDate tmpDate; | 305 | QDate tmpDate; |
305 | QTime tmpTime; | 306 | QTime tmpTime; |
306 | QDateTime tmpDT; | 307 | QDateTime tmpDT; |
307 | if ( mTimeButton->isChecked() ) { | 308 | if ( mTimeButton->isChecked() ) { |
308 | todo->setFloats(false); | 309 | todo->setFloats(false); |
309 | 310 | ||
310 | // set due date/time | 311 | // set due date/time |
311 | tmpDate = mDueDateEdit->date(); | 312 | tmpDate = mDueDateEdit->date(); |
312 | tmpTime = mDueTimeEdit->getTime(); | 313 | tmpTime = mDueTimeEdit->getTime(); |
313 | tmpDT.setDate(tmpDate); | 314 | tmpDT.setDate(tmpDate); |
314 | tmpDT.setTime(tmpTime); | 315 | tmpDT.setTime(tmpTime); |
315 | todo->setDtDue(tmpDT); | 316 | todo->setDtDue(tmpDT); |
316 | 317 | ||
317 | // set start date/time | 318 | // set start date/time |
318 | tmpDate = mStartDateEdit->date(); | 319 | tmpDate = mStartDateEdit->date(); |
319 | tmpTime = mStartTimeEdit->getTime(); | 320 | tmpTime = mStartTimeEdit->getTime(); |
320 | tmpDT.setDate(tmpDate); | 321 | tmpDT.setDate(tmpDate); |
321 | tmpDT.setTime(tmpTime); | 322 | tmpDT.setTime(tmpTime); |
322 | todo->setDtStart(tmpDT); | 323 | todo->setDtStart(tmpDT); |
323 | } else { | 324 | } else { |
324 | todo->setFloats(true); | 325 | todo->setFloats(true); |
325 | 326 | ||
326 | // need to change this. | 327 | // need to change this. |
327 | tmpDate = mDueDateEdit->date(); | 328 | tmpDate = mDueDateEdit->date(); |
328 | tmpTime.setHMS(0,0,0); | 329 | tmpTime.setHMS(0,0,0); |
329 | tmpDT.setDate(tmpDate); | 330 | tmpDT.setDate(tmpDate); |
330 | tmpDT.setTime(tmpTime); | 331 | tmpDT.setTime(tmpTime); |
331 | todo->setDtDue(tmpDT); | 332 | todo->setDtDue(tmpDT); |
332 | 333 | ||
333 | tmpDate = mStartDateEdit->date(); | 334 | tmpDate = mStartDateEdit->date(); |
334 | tmpTime.setHMS(0,0,0); | 335 | tmpTime.setHMS(0,0,0); |
335 | tmpDT.setDate(tmpDate); | 336 | tmpDT.setDate(tmpDate); |
336 | tmpDT.setTime(tmpTime); | 337 | tmpDT.setTime(tmpTime); |
337 | todo->setDtStart(tmpDT); | 338 | todo->setDtStart(tmpDT); |
338 | } | 339 | } |
339 | todo->setPriority(mPriorityCombo->currentItem()+1); | 340 | todo->setPriority(mPriorityCombo->currentItem()+1); |
340 | 341 | ||
341 | // set completion state | 342 | // set completion state |
342 | if ( mCompletedCombo->currentItem() == 5 ) { | 343 | if ( mCompletedCombo->currentItem() == 5 ) { |
343 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | 344 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); |
344 | if ( comp.isValid () ) { | 345 | if ( comp.isValid () ) { |
345 | todo->setPercentComplete(100); | 346 | todo->setPercentComplete(100); |
346 | todo->setCompleted(comp); | 347 | todo->setCompleted(comp); |
347 | } else { | 348 | } else { |
348 | todo->setPercentComplete( 100 ); | 349 | todo->setPercentComplete( 100 ); |
349 | if ( mCompleted.isValid() ) | 350 | if ( mCompleted.isValid() ) |
350 | todo->setCompleted(mCompleted); | 351 | todo->setCompleted(mCompleted); |
351 | } | 352 | } |
352 | } else { | 353 | } else { |
353 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 354 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
354 | } | 355 | } |
355 | 356 | ||
356 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 357 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
357 | } | 358 | } |
358 | 359 | ||
359 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 360 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
360 | { | 361 | { |
361 | mDueDateEdit->setEnabled( enable ); | 362 | mDueDateEdit->setEnabled( enable ); |
362 | 363 | ||
363 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 364 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
364 | mTimeButton->setEnabled(true); | 365 | mTimeButton->setEnabled(true); |
365 | } | 366 | } |
366 | else { | 367 | else { |
367 | mTimeButton->setEnabled(false); | 368 | mTimeButton->setEnabled(false); |
368 | mTimeButton->setChecked(false); | 369 | mTimeButton->setChecked(false); |
369 | } | 370 | } |
370 | 371 | ||
371 | if (enable) { | 372 | if (enable) { |
372 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 373 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
373 | } else { | 374 | } else { |
374 | mDueTimeEdit->setEnabled( false ); | 375 | mDueTimeEdit->setEnabled( false ); |
375 | } | 376 | } |
376 | emit datesChecked(); | 377 | emit datesChecked(); |
377 | } | 378 | } |
378 | 379 | ||
379 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 380 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
380 | { | 381 | { |
381 | mStartDateEdit->setEnabled( enable ); | 382 | mStartDateEdit->setEnabled( enable ); |
382 | 383 | ||
383 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 384 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
384 | mTimeButton->setEnabled(true); | 385 | mTimeButton->setEnabled(true); |
385 | } | 386 | } |
386 | else { | 387 | else { |
387 | mTimeButton->setEnabled(false); | 388 | mTimeButton->setEnabled(false); |
388 | mTimeButton->setChecked(false); | 389 | mTimeButton->setChecked(false); |
389 | } | 390 | } |
390 | 391 | ||
391 | if (enable) { | 392 | if (enable) { |
392 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 393 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
393 | } else { | 394 | } else { |
394 | mStartTimeEdit->setEnabled( false ); | 395 | mStartTimeEdit->setEnabled( false ); |
395 | } | 396 | } |
396 | emit datesChecked(); | 397 | emit datesChecked(); |
397 | } | 398 | } |
398 | 399 | void KOEditorGeneralTodo::startDateChanged(QDate newdate) | |
400 | { | ||
401 | if ( mDueCheck->isChecked() ) | ||
402 | emit dateTimesChanged(newdate,mDueDateEdit->date()); | ||
403 | } | ||
399 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 404 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
400 | { | 405 | { |
401 | if(mStartCheck->isChecked()) { | 406 | if(mStartCheck->isChecked()) { |
402 | mStartTimeEdit->setEnabled( enable ); | 407 | mStartTimeEdit->setEnabled( enable ); |
403 | } | 408 | } |
404 | if(mDueCheck->isChecked()) { | 409 | if(mDueCheck->isChecked()) { |
405 | mDueTimeEdit->setEnabled( enable ); | 410 | mDueTimeEdit->setEnabled( enable ); |
406 | } | 411 | } |
407 | } | 412 | } |
408 | 413 | ||
409 | void KOEditorGeneralTodo::showAlarm() | 414 | void KOEditorGeneralTodo::showAlarm() |
410 | { | 415 | { |
411 | if ( mDueCheck->isChecked() ) { | 416 | if ( mDueCheck->isChecked() ) { |
412 | alarmDisable(false); | 417 | alarmDisable(false); |
413 | } | 418 | } |
414 | else { | 419 | else { |
415 | alarmDisable(true); | 420 | alarmDisable(true); |
416 | } | 421 | } |
417 | } | 422 | } |
418 | 423 | ||
419 | bool KOEditorGeneralTodo::validateInput() | 424 | bool KOEditorGeneralTodo::validateInput() |
420 | { | 425 | { |
421 | if (mDueCheck->isChecked()) { | 426 | if (mDueCheck->isChecked()) { |
422 | if (!mDueDateEdit->inputIsValid()) { | 427 | if (!mDueDateEdit->inputIsValid()) { |
423 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 428 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
424 | return false; | 429 | return false; |
425 | } | 430 | } |
426 | } | 431 | } |
427 | 432 | ||
428 | if (mStartCheck->isChecked()) { | 433 | if (mStartCheck->isChecked()) { |
429 | if (!mStartDateEdit->inputIsValid()) { | 434 | if (!mStartDateEdit->inputIsValid()) { |
430 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); | 435 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); |
431 | return false; | 436 | return false; |
432 | } | 437 | } |
433 | } | 438 | } |
434 | 439 | ||
435 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { | 440 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { |
436 | QDateTime startDate; | 441 | QDateTime startDate; |
437 | QDateTime dueDate; | 442 | QDateTime dueDate; |
438 | startDate.setDate(mStartDateEdit->date()); | 443 | startDate.setDate(mStartDateEdit->date()); |
439 | dueDate.setDate(mDueDateEdit->date()); | 444 | dueDate.setDate(mDueDateEdit->date()); |
440 | if (mTimeButton->isChecked()) { | 445 | if (mTimeButton->isChecked()) { |
441 | startDate.setTime(mStartTimeEdit->getTime()); | 446 | startDate.setTime(mStartTimeEdit->getTime()); |
442 | dueDate.setTime(mDueTimeEdit->getTime()); | 447 | dueDate.setTime(mDueTimeEdit->getTime()); |
443 | } | 448 | } |
444 | if (startDate > dueDate) { | 449 | if (startDate > dueDate) { |
445 | KMessageBox::sorry(0, | 450 | KMessageBox::sorry(0, |
446 | i18n("The start date cannot be after the due date.")); | 451 | i18n("The start date cannot be after the due date.")); |
447 | return false; | 452 | return false; |
448 | } | 453 | } |
449 | } | 454 | } |
450 | 455 | ||
451 | return KOEditorGeneral::validateInput(); | 456 | return KOEditorGeneral::validateInput(); |
452 | } | 457 | } |
453 | 458 | ||
454 | void KOEditorGeneralTodo::completedChanged(int index) | 459 | void KOEditorGeneralTodo::completedChanged(int index) |
455 | { | 460 | { |
456 | if (index == 5) { | 461 | if (index == 5) { |
457 | //get rid of milli sec | 462 | //get rid of milli sec |
458 | mCompleted = QDateTime::currentDateTime(); | 463 | mCompleted = QDateTime::currentDateTime(); |
459 | } | 464 | } |
460 | setCompletedDate(); | 465 | setCompletedDate(); |
461 | } | 466 | } |
462 | 467 | ||
463 | void KOEditorGeneralTodo::setCompletedDate() | 468 | void KOEditorGeneralTodo::setCompletedDate() |
464 | { | 469 | { |
465 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 470 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
466 | if ( QApplication::desktop()->width() < 480 ) { | 471 | if ( QApplication::desktop()->width() < 480 ) { |
467 | mCompletedLabel->setText(i18n(" on")); | 472 | mCompletedLabel->setText(i18n(" on")); |
468 | } | 473 | } |
469 | else | 474 | else |
470 | mCompletedLabel->setText(i18n(" completed on ")); | 475 | mCompletedLabel->setText(i18n(" completed on ")); |
471 | mCompleteDateEdit->show(); | 476 | mCompleteDateEdit->show(); |
472 | mCompleteTimeEdit->show(); | 477 | mCompleteTimeEdit->show(); |
473 | mCompleteTimeEdit->setTime( mCompleted.time() ); | 478 | mCompleteTimeEdit->setTime( mCompleted.time() ); |
474 | mCompleteDateEdit->setDate( mCompleted.date() ); | 479 | mCompleteDateEdit->setDate( mCompleted.date() ); |
475 | } else { | 480 | } else { |
476 | mCompletedLabel->setText(i18n(" completed")); | 481 | mCompletedLabel->setText(i18n(" completed")); |
477 | mCompleteDateEdit->hide(); | 482 | mCompleteDateEdit->hide(); |
478 | mCompleteTimeEdit->hide(); | 483 | mCompleteTimeEdit->hide(); |
479 | } | 484 | } |
480 | } | 485 | } |
481 | 486 | ||
482 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 487 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
483 | { | 488 | { |
484 | switch (modification) { | 489 | switch (modification) { |
485 | case KOGlobals::PRIORITY_MODIFIED: | 490 | case KOGlobals::PRIORITY_MODIFIED: |
486 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 491 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
487 | break; | 492 | break; |
488 | case KOGlobals::COMPLETION_MODIFIED: | 493 | case KOGlobals::COMPLETION_MODIFIED: |
489 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 494 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
490 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 495 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
491 | mCompleted = todo->completed(); | 496 | mCompleted = todo->completed(); |
492 | } | 497 | } |
493 | setCompletedDate(); | 498 | setCompletedDate(); |
494 | break; | 499 | break; |
495 | case KOGlobals::CATEGORY_MODIFIED: | 500 | case KOGlobals::CATEGORY_MODIFIED: |
496 | setCategories (todo->categoriesStr ()); | 501 | setCategories (todo->categoriesStr ()); |
497 | break; | 502 | break; |
498 | case KOGlobals::UNKNOWN_MODIFIED: // fall through | 503 | case KOGlobals::UNKNOWN_MODIFIED: // fall through |
499 | default: | 504 | default: |
500 | readTodo( todo ); | 505 | readTodo( todo ); |
501 | break; | 506 | break; |
502 | } | 507 | } |
503 | } | 508 | } |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index b198539..2e56a7a 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -1,109 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 | #ifndef _KOEDITORGENERALTODO_H | 23 | #ifndef _KOEDITORGENERALTODO_H |
24 | #define _KOEDITORGENERALTODO_H | 24 | #define _KOEDITORGENERALTODO_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | 36 | ||
37 | #include "koeditorgeneral.h" | 37 | #include "koeditorgeneral.h" |
38 | #include "koglobals.h" | 38 | #include "koglobals.h" |
39 | 39 | ||
40 | class KRestrictedLine; | 40 | class KRestrictedLine; |
41 | 41 | ||
42 | class KDateEdit; | 42 | 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 | void datesChecked(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void startDateChanged(QDate newdate); | ||
78 | void completedChanged(int); | 79 | void completedChanged(int); |
79 | 80 | ||
80 | void enableDueEdit( bool enable ); | 81 | void enableDueEdit( bool enable ); |
81 | void enableStartEdit( bool enable ); | 82 | void enableStartEdit( bool enable ); |
82 | void enableTimeEdits( bool enable ); | 83 | void enableTimeEdits( bool enable ); |
83 | void showAlarm(); | 84 | void showAlarm(); |
84 | 85 | ||
85 | protected: | 86 | protected: |
86 | void setCompletedDate(); | 87 | void setCompletedDate(); |
87 | 88 | ||
88 | private: | 89 | private: |
89 | friend class KOTodoEditor; | 90 | friend class KOTodoEditor; |
90 | KDateEdit *mStartDateEdit; | 91 | KDateEdit *mStartDateEdit; |
91 | KOTimeEdit *mStartTimeEdit; | 92 | KOTimeEdit *mStartTimeEdit; |
92 | KDateEdit *mCompleteDateEdit; | 93 | KDateEdit *mCompleteDateEdit; |
93 | KOTimeEdit *mCompleteTimeEdit; | 94 | KOTimeEdit *mCompleteTimeEdit; |
94 | QCheckBox *mTimeButton; | 95 | QCheckBox *mTimeButton; |
95 | QCheckBox *mDueCheck; | 96 | QCheckBox *mDueCheck; |
96 | KDateEdit *mDueDateEdit; | 97 | KDateEdit *mDueDateEdit; |
97 | KOTimeEdit *mDueTimeEdit; | 98 | KOTimeEdit *mDueTimeEdit; |
98 | QComboBox *mCompletedCombo; | 99 | QComboBox *mCompletedCombo; |
99 | QLabel *mCompletedLabel; | 100 | QLabel *mCompletedLabel; |
100 | QLabel *mPriorityLabel; | 101 | QLabel *mPriorityLabel; |
101 | QComboBox *mPriorityCombo; | 102 | QComboBox *mPriorityCombo; |
102 | 103 | ||
103 | QCheckBox *mStartCheck; | 104 | QCheckBox *mStartCheck; |
104 | 105 | ||
105 | QDateTime mCompleted; | 106 | QDateTime mCompleted; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | 109 | ||
109 | #endif | 110 | #endif |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index dea8981..de4e4f7 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -646,463 +646,475 @@ void RecurrenceRangeDialog::setEndDate( const QDate &date ) | |||
646 | 646 | ||
647 | QDate RecurrenceRangeDialog::endDate() | 647 | QDate RecurrenceRangeDialog::endDate() |
648 | { | 648 | { |
649 | return mRecurrenceRangeWidget->endDate(); | 649 | return mRecurrenceRangeWidget->endDate(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
653 | const QDateTime &end ) | 653 | const QDateTime &end ) |
654 | { | 654 | { |
655 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 655 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
656 | } | 656 | } |
657 | 657 | ||
658 | //////////////////////////// RecurrenceChooser //////////////////////// | 658 | //////////////////////////// RecurrenceChooser //////////////////////// |
659 | 659 | ||
660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
661 | QWidget( parent, name ) | 661 | QWidget( parent, name ) |
662 | { | 662 | { |
663 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 663 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
664 | 664 | ||
665 | mTypeCombo = new QComboBox( this ); | 665 | mTypeCombo = new QComboBox( this ); |
666 | mTypeCombo->insertItem( i18n("Daily") ); | 666 | mTypeCombo->insertItem( i18n("Daily") ); |
667 | mTypeCombo->insertItem( i18n("Weekly") ); | 667 | mTypeCombo->insertItem( i18n("Weekly") ); |
668 | mTypeCombo->insertItem( i18n("Monthly") ); | 668 | mTypeCombo->insertItem( i18n("Monthly") ); |
669 | mTypeCombo->insertItem( i18n("Yearly") ); | 669 | mTypeCombo->insertItem( i18n("Yearly") ); |
670 | 670 | ||
671 | topLayout->addWidget( mTypeCombo ); | 671 | topLayout->addWidget( mTypeCombo ); |
672 | 672 | ||
673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
674 | 674 | ||
675 | } | 675 | } |
676 | 676 | ||
677 | int RecurrenceChooser::type() | 677 | int RecurrenceChooser::type() |
678 | { | 678 | { |
679 | if ( mTypeCombo ) { | 679 | if ( mTypeCombo ) { |
680 | return mTypeCombo->currentItem(); | 680 | return mTypeCombo->currentItem(); |
681 | } else { | 681 | } else { |
682 | if ( mDailyButton->isChecked() ) return Daily; | 682 | if ( mDailyButton->isChecked() ) return Daily; |
683 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 683 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
684 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 684 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
685 | else return Yearly; | 685 | else return Yearly; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | void RecurrenceChooser::setType( int type ) | 689 | void RecurrenceChooser::setType( int type ) |
690 | { | 690 | { |
691 | if ( mTypeCombo ) { | 691 | if ( mTypeCombo ) { |
692 | mTypeCombo->setCurrentItem( type ); | 692 | mTypeCombo->setCurrentItem( type ); |
693 | } else { | 693 | } else { |
694 | switch ( type ) { | 694 | switch ( type ) { |
695 | case Daily: | 695 | case Daily: |
696 | mDailyButton->setChecked( true ); | 696 | mDailyButton->setChecked( true ); |
697 | break; | 697 | break; |
698 | case Weekly: | 698 | case Weekly: |
699 | mWeeklyButton->setChecked( true ); | 699 | mWeeklyButton->setChecked( true ); |
700 | break; | 700 | break; |
701 | case Monthly: | 701 | case Monthly: |
702 | mMonthlyButton->setChecked( true ); | 702 | mMonthlyButton->setChecked( true ); |
703 | break; | 703 | break; |
704 | case Yearly: | 704 | case Yearly: |
705 | default: | 705 | default: |
706 | mYearlyButton->setChecked( true ); | 706 | mYearlyButton->setChecked( true ); |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void RecurrenceChooser::emitChoice() | 712 | void RecurrenceChooser::emitChoice() |
713 | { | 713 | { |
714 | emit chosen ( type() ); | 714 | emit chosen ( type() ); |
715 | } | 715 | } |
716 | 716 | ||
717 | /////////////////////////////// Main Widget ///////////////////////////// | 717 | /////////////////////////////// Main Widget ///////////////////////////// |
718 | 718 | ||
719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
720 | QWidget( parent, name ) | 720 | QWidget( parent, name ) |
721 | { | 721 | { |
722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
723 | topLayout->setSpacing( KDialog::spacingHint() ); | 723 | topLayout->setSpacing( KDialog::spacingHint() ); |
724 | topLayout->setMargin( KDialog::marginHintSmall() ); | 724 | topLayout->setMargin( KDialog::marginHintSmall() ); |
725 | 725 | ||
726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
728 | SLOT( setEnabled( bool ) ) ); | 728 | SLOT( setEnabled( bool ) ) ); |
729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
730 | 730 | ||
731 | 731 | ||
732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), | 732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), |
733 | this ); | 733 | this ); |
734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
735 | 735 | ||
736 | if ( QApplication::desktop()->width() <= 640 ) { | 736 | if ( QApplication::desktop()->width() <= 640 ) { |
737 | mTimeGroupBox->hide(); | 737 | mTimeGroupBox->hide(); |
738 | } | 738 | } |
739 | 739 | ||
740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
743 | 743 | ||
744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
745 | // mDateTimeLabel = new QLabel( timeFrame ); | 745 | // mDateTimeLabel = new QLabel( timeFrame ); |
746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); | 748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); |
749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); | 749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); |
750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
753 | SLOT( showCurrentRule( int ) ) ); | 753 | SLOT( showCurrentRule( int ) ) ); |
754 | 754 | ||
755 | 755 | ||
756 | mRuleStack = new QWidgetStack( mRuleBox ); | 756 | mRuleStack = new QWidgetStack( mRuleBox ); |
757 | 757 | ||
758 | mDaily = new RecurDaily( mRuleStack ); | 758 | mDaily = new RecurDaily( mRuleStack ); |
759 | mRuleStack->addWidget( mDaily, 0 ); | 759 | mRuleStack->addWidget( mDaily, 0 ); |
760 | 760 | ||
761 | mWeekly = new RecurWeekly( mRuleStack ); | 761 | mWeekly = new RecurWeekly( mRuleStack ); |
762 | mRuleStack->addWidget( mWeekly, 0 ); | 762 | mRuleStack->addWidget( mWeekly, 0 ); |
763 | 763 | ||
764 | mMonthly = new RecurMonthly( mRuleStack ); | 764 | mMonthly = new RecurMonthly( mRuleStack ); |
765 | mRuleStack->addWidget( mMonthly, 0 ); | 765 | mRuleStack->addWidget( mMonthly, 0 ); |
766 | 766 | ||
767 | mYearly = new RecurYearly( mRuleStack ); | 767 | mYearly = new RecurYearly( mRuleStack ); |
768 | mRuleStack->addWidget( mYearly, 0 ); | 768 | mRuleStack->addWidget( mYearly, 0 ); |
769 | 769 | ||
770 | showCurrentRule( mRecurrenceChooser->type() ); | 770 | showCurrentRule( mRecurrenceChooser->type() ); |
771 | mRecurrenceRangeWidget = 0; | 771 | mRecurrenceRangeWidget = 0; |
772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
773 | mRecurrenceRange = mRecurrenceRangeDialog; | 773 | mRecurrenceRange = mRecurrenceRangeDialog; |
774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
775 | this ); | 775 | this ); |
776 | 776 | ||
777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
778 | SLOT( showRecurrenceRangeDialog() ) ); | 778 | SLOT( showRecurrenceRangeDialog() ) ); |
779 | 779 | ||
780 | mExceptionsWidget = 0; | 780 | mExceptionsWidget = 0; |
781 | mExceptionsDialog = new ExceptionsDialog( this ); | 781 | mExceptionsDialog = new ExceptionsDialog( this ); |
782 | mExceptions = mExceptionsDialog; | 782 | mExceptions = mExceptionsDialog; |
783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
784 | if ( QApplication::desktop()->width() < 320 ) { | 784 | if ( QApplication::desktop()->width() < 320 ) { |
785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
787 | } else { | 787 | } else { |
788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
790 | } | 790 | } |
791 | connect( mExceptionsButton, SIGNAL( clicked() ), | 791 | connect( mExceptionsButton, SIGNAL( clicked() ), |
792 | SLOT( showExceptionsDialog() ) ); | 792 | SLOT( showExceptionsDialog() ) ); |
793 | } | 793 | } |
794 | 794 | ||
795 | KOEditorRecurrence::~KOEditorRecurrence() | 795 | KOEditorRecurrence::~KOEditorRecurrence() |
796 | { | 796 | { |
797 | } | 797 | } |
798 | 798 | ||
799 | void KOEditorRecurrence::setEnabled( bool enabled ) | 799 | void KOEditorRecurrence::setEnabled( bool enabled ) |
800 | { | 800 | { |
801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
802 | 802 | ||
803 | mTimeGroupBox->setEnabled( enabled ); | 803 | mTimeGroupBox->setEnabled( enabled ); |
804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
808 | mRuleBox->setEnabled( enabled ); | 808 | mRuleBox->setEnabled( enabled ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KOEditorRecurrence::showCurrentRule( int current ) | 811 | void KOEditorRecurrence::showCurrentRule( int current ) |
812 | { | 812 | { |
813 | switch ( current ) { | 813 | switch ( current ) { |
814 | case Daily: | 814 | case Daily: |
815 | mRuleStack->raiseWidget( mDaily ); | 815 | mRuleStack->raiseWidget( mDaily ); |
816 | break; | 816 | break; |
817 | case Weekly: | 817 | case Weekly: |
818 | mRuleStack->raiseWidget( mWeekly ); | 818 | mRuleStack->raiseWidget( mWeekly ); |
819 | break; | 819 | break; |
820 | case Monthly: | 820 | case Monthly: |
821 | mRuleStack->raiseWidget( mMonthly ); | 821 | mRuleStack->raiseWidget( mMonthly ); |
822 | break; | 822 | break; |
823 | default: | 823 | default: |
824 | case Yearly: | 824 | case Yearly: |
825 | mRuleStack->raiseWidget( mYearly ); | 825 | mRuleStack->raiseWidget( mYearly ); |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | 838 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) | |
839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 839 | { |
840 | setDateTimes( from, to ); | ||
841 | QBitArray days( 7 ); | ||
842 | days.fill( 0 ); | ||
843 | days.setBit( from.date().dayOfWeek()- 1); | ||
844 | mWeekly->setDays( days ); | ||
845 | bool byPos = mMonthly->byPos(); | ||
846 | if ( byPos ) | ||
847 | mMonthly->setByDay( from.date().day()-1 ); | ||
848 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
849 | if ( ! byPos) | ||
850 | mMonthly->setByDay( from.date().day()-1 ); | ||
851 | |||
852 | bool byDay = mYearly->byDay(); | ||
853 | if ( ! byDay ) | ||
854 | mYearly->setByDay( from.date().dayOfYear() ); | ||
855 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
856 | if ( byDay ) | ||
857 | mYearly->setByDay( from.date().dayOfYear() ); | ||
858 | } | ||
859 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) | ||
840 | { | 860 | { |
841 | 861 | ||
842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 862 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
843 | setDateTimes( from, to ); | 863 | //setDateTimes( from, to ); |
844 | 864 | ||
845 | bool enabled = false; | 865 | bool enabled = false; |
846 | mEnabledCheck->setChecked( enabled ); | 866 | mEnabledCheck->setChecked( enabled ); |
847 | setEnabled( enabled ); | 867 | setEnabled( enabled ); |
848 | 868 | ||
849 | mExceptions->setDefaults( to ); | 869 | mExceptions->setDefaults( to ); |
850 | mRecurrenceRange->setDefaults( to ); | 870 | mRecurrenceRange->setDefaults( to ); |
851 | 871 | ||
852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 872 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
853 | showCurrentRule( mRecurrenceChooser->type() ); | 873 | showCurrentRule( mRecurrenceChooser->type() ); |
854 | 874 | ||
855 | mDaily->setFrequency( 1 ); | 875 | mDaily->setFrequency( 1 ); |
856 | |||
857 | mWeekly->setFrequency( 1 ); | 876 | mWeekly->setFrequency( 1 ); |
858 | QBitArray days( 7 ); | ||
859 | days.fill( 0 ); | ||
860 | days.setBit( from.date().dayOfWeek()- 1); | ||
861 | mWeekly->setDays( days ); | ||
862 | mMonthly->setFrequency( 1 ); | 877 | mMonthly->setFrequency( 1 ); |
863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
864 | mMonthly->setByDay( from.date().day()-1 ); | ||
865 | mYearly->setFrequency( 1 ); | 878 | mYearly->setFrequency( 1 ); |
866 | mYearly->setByDay( from.date().dayOfYear() ); | 879 | setDefaultsDates( from, to ); |
867 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
868 | } | 880 | } |
869 | 881 | ||
870 | void KOEditorRecurrence::readEvent(Incidence *event) | 882 | void KOEditorRecurrence::readEvent(Incidence *event) |
871 | { | 883 | { |
872 | 884 | ||
873 | QDateTime dtEnd; | 885 | QDateTime dtEnd; |
874 | if ( event->typeID() == eventID ) | 886 | if ( event->typeID() == eventID ) |
875 | dtEnd = ((Event*)event)->dtEnd(); | 887 | dtEnd = ((Event*)event)->dtEnd(); |
876 | else | 888 | else |
877 | dtEnd = ((Todo*)event)->dtDue(); | 889 | dtEnd = ((Todo*)event)->dtDue(); |
878 | 890 | ||
879 | setDefaults( event->dtStart(), dtEnd, true ); | 891 | setDefaults( event->dtStart(), dtEnd ); |
880 | QBitArray rDays( 7 ); | 892 | QBitArray rDays( 7 ); |
881 | QPtrList<Recurrence::rMonthPos> rmp; | 893 | QPtrList<Recurrence::rMonthPos> rmp; |
882 | QPtrList<int> rmd; | 894 | QPtrList<int> rmd; |
883 | int day = 0; | 895 | int day = 0; |
884 | int count = 0; | 896 | int count = 0; |
885 | int month = 0; | 897 | int month = 0; |
886 | setDateTimes( event->dtStart(), dtEnd ); | 898 | setDateTimes( event->dtStart(), dtEnd ); |
887 | 899 | ||
888 | Recurrence *r = event->recurrence(); | 900 | Recurrence *r = event->recurrence(); |
889 | int f = r->frequency(); | 901 | int f = r->frequency(); |
890 | 902 | ||
891 | int recurs = r->doesRecur(); | 903 | int recurs = r->doesRecur(); |
892 | 904 | ||
893 | mEnabledCheck->setChecked( recurs ); | 905 | mEnabledCheck->setChecked( recurs ); |
894 | setEnabled( recurs ); | 906 | setEnabled( recurs ); |
895 | 907 | ||
896 | int recurrenceType = RecurrenceChooser::Weekly; | 908 | int recurrenceType = RecurrenceChooser::Weekly; |
897 | 909 | ||
898 | switch ( recurs ) { | 910 | switch ( recurs ) { |
899 | case Recurrence::rNone: | 911 | case Recurrence::rNone: |
900 | setDefaults( event->dtStart(), dtEnd, true ); | 912 | setDefaults( event->dtStart(), dtEnd ); |
901 | break; | 913 | break; |
902 | case Recurrence::rDaily: | 914 | case Recurrence::rDaily: |
903 | recurrenceType = RecurrenceChooser::Daily; | 915 | recurrenceType = RecurrenceChooser::Daily; |
904 | mDaily->setFrequency( f ); | 916 | mDaily->setFrequency( f ); |
905 | break; | 917 | break; |
906 | case Recurrence::rWeekly: | 918 | case Recurrence::rWeekly: |
907 | recurrenceType = RecurrenceChooser::Weekly; | 919 | recurrenceType = RecurrenceChooser::Weekly; |
908 | mWeekly->setFrequency( f ); | 920 | mWeekly->setFrequency( f ); |
909 | mWeekly->setDays( r->days() ); | 921 | mWeekly->setDays( r->days() ); |
910 | break; | 922 | break; |
911 | case Recurrence::rMonthlyPos: | 923 | case Recurrence::rMonthlyPos: |
912 | // we only handle one possibility in the list right now, | 924 | // we only handle one possibility in the list right now, |
913 | // so I have hardcoded calls with first(). If we make the GUI | 925 | // so I have hardcoded calls with first(). If we make the GUI |
914 | // more extended, this can be changed. | 926 | // more extended, this can be changed. |
915 | recurrenceType = RecurrenceChooser::Monthly; | 927 | recurrenceType = RecurrenceChooser::Monthly; |
916 | 928 | ||
917 | rmp = r->monthPositions(); | 929 | rmp = r->monthPositions(); |
918 | if ( rmp.first()->negative ) | 930 | if ( rmp.first()->negative ) |
919 | count = 5 - rmp.first()->rPos - 1; | 931 | count = 5 - rmp.first()->rPos - 1; |
920 | else | 932 | else |
921 | count = rmp.first()->rPos - 1; | 933 | count = rmp.first()->rPos - 1; |
922 | day = 0; | 934 | day = 0; |
923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 935 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
924 | mMonthly->setByPos( count, day ); | 936 | mMonthly->setByPos( count, day ); |
925 | 937 | ||
926 | mMonthly->setFrequency( f ); | 938 | mMonthly->setFrequency( f ); |
927 | 939 | ||
928 | break; | 940 | break; |
929 | case Recurrence::rMonthlyDay: | 941 | case Recurrence::rMonthlyDay: |
930 | recurrenceType = RecurrenceChooser::Monthly; | 942 | recurrenceType = RecurrenceChooser::Monthly; |
931 | 943 | ||
932 | rmd = r->monthDays(); | 944 | rmd = r->monthDays(); |
933 | day = *rmd.first() - 1; | 945 | day = *rmd.first() - 1; |
934 | mMonthly->setByDay( day ); | 946 | mMonthly->setByDay( day ); |
935 | 947 | ||
936 | mMonthly->setFrequency( f ); | 948 | mMonthly->setFrequency( f ); |
937 | 949 | ||
938 | break; | 950 | break; |
939 | case Recurrence::rYearlyMonth: | 951 | case Recurrence::rYearlyMonth: |
940 | { | 952 | { |
941 | recurrenceType = RecurrenceChooser::Yearly; | 953 | recurrenceType = RecurrenceChooser::Yearly; |
942 | //qDebug("Recurrence::rYearlyMonth: "); | 954 | //qDebug("Recurrence::rYearlyMonth: "); |
943 | day = event->dtStart().date().day(); | 955 | day = event->dtStart().date().day(); |
944 | rmd = r->yearNums(); | 956 | rmd = r->yearNums(); |
945 | if ( rmd.count() > 0 ) | 957 | if ( rmd.count() > 0 ) |
946 | month = *rmd.first(); | 958 | month = *rmd.first(); |
947 | else | 959 | else |
948 | month = event->dtStart().date().month() ; | 960 | month = event->dtStart().date().month() ; |
949 | mYearly->setByMonth( month, day ); | 961 | mYearly->setByMonth( month, day ); |
950 | #if 0 | 962 | #if 0 |
951 | //qDebug("2day = %d ",day ); | 963 | //qDebug("2day = %d ",day ); |
952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 964 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
953 | int month; | 965 | int month; |
954 | if ( !monthlist.isEmpty() ) { | 966 | if ( !monthlist.isEmpty() ) { |
955 | month = monthlist.first()->rPos ; | 967 | month = monthlist.first()->rPos ; |
956 | } else { | 968 | } else { |
957 | month = event->dtStart().date().month() ; | 969 | month = event->dtStart().date().month() ; |
958 | } | 970 | } |
959 | mYearly->setByMonth( day, month ); | 971 | mYearly->setByMonth( day, month ); |
960 | #endif | 972 | #endif |
961 | mYearly->setFrequency( f ); | 973 | mYearly->setFrequency( f ); |
962 | } | 974 | } |
963 | 975 | ||
964 | break; | 976 | break; |
965 | case Recurrence::rYearlyDay: | 977 | case Recurrence::rYearlyDay: |
966 | //qDebug("Recurrence::rYearlyDay: "); | 978 | //qDebug("Recurrence::rYearlyDay: "); |
967 | recurrenceType = RecurrenceChooser::Yearly; | 979 | recurrenceType = RecurrenceChooser::Yearly; |
968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 980 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
969 | mYearly->setFrequency( f ); | 981 | mYearly->setFrequency( f ); |
970 | break; | 982 | break; |
971 | default: | 983 | default: |
972 | setDefaults( event->dtStart(), dtEnd, true ); | 984 | setDefaults( event->dtStart(), dtEnd ); |
973 | break; | 985 | break; |
974 | } | 986 | } |
975 | 987 | ||
976 | mRecurrenceChooser->setType( recurrenceType ); | 988 | mRecurrenceChooser->setType( recurrenceType ); |
977 | showCurrentRule( recurrenceType ); | 989 | showCurrentRule( recurrenceType ); |
978 | 990 | ||
979 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 991 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
980 | 992 | ||
981 | if ( r->doesRecur() ) { | 993 | if ( r->doesRecur() ) { |
982 | mRecurrenceRange->setDuration( r->duration() ); | 994 | mRecurrenceRange->setDuration( r->duration() ); |
983 | if ( r->duration() == 0 ) | 995 | if ( r->duration() == 0 ) |
984 | { | 996 | { |
985 | if ( r->endDate() < event->dtStart().date() ) | 997 | if ( r->endDate() < event->dtStart().date() ) |
986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 998 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
987 | else | 999 | else |
988 | mRecurrenceRange->setEndDate( r->endDate() ); | 1000 | mRecurrenceRange->setEndDate( r->endDate() ); |
989 | } else | 1001 | } else |
990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1002 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
991 | } | 1003 | } |
992 | 1004 | ||
993 | mExceptions->setDates( event->exDates() ); | 1005 | mExceptions->setDates( event->exDates() ); |
994 | } | 1006 | } |
995 | 1007 | ||
996 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 1008 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
997 | { | 1009 | { |
998 | Recurrence *r = event->recurrence(); | 1010 | Recurrence *r = event->recurrence(); |
999 | 1011 | ||
1000 | // clear out any old settings; | 1012 | // clear out any old settings; |
1001 | r->unsetRecurs(); | 1013 | r->unsetRecurs(); |
1002 | 1014 | ||
1003 | if ( mEnabledCheck->isChecked() ) { | 1015 | if ( mEnabledCheck->isChecked() ) { |
1004 | int duration = mRecurrenceRange->duration(); | 1016 | int duration = mRecurrenceRange->duration(); |
1005 | QDate endDate; | 1017 | QDate endDate; |
1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1018 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1007 | 1019 | ||
1008 | int recurrenceType = mRecurrenceChooser->type(); | 1020 | int recurrenceType = mRecurrenceChooser->type(); |
1009 | 1021 | ||
1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1022 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1011 | int freq = mDaily->frequency(); | 1023 | int freq = mDaily->frequency(); |
1012 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1024 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1013 | else r->setDaily( freq, endDate ); | 1025 | else r->setDaily( freq, endDate ); |
1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1026 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1015 | int freq = mWeekly->frequency(); | 1027 | int freq = mWeekly->frequency(); |
1016 | QBitArray days = mWeekly->days(); | 1028 | QBitArray days = mWeekly->days(); |
1017 | int j; | 1029 | int j; |
1018 | bool found = false; | 1030 | bool found = false; |
1019 | for (j = 0; j < 7 ; ++j ) { | 1031 | for (j = 0; j < 7 ; ++j ) { |
1020 | found |=days.at(j); | 1032 | found |=days.at(j); |
1021 | } | 1033 | } |
1022 | if ( !found ) { | 1034 | if ( !found ) { |
1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1035 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1036 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1025 | } | 1037 | } |
1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1038 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1027 | else r->setWeekly( freq, days, endDate ); | 1039 | else r->setWeekly( freq, days, endDate ); |
1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1040 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1029 | int freq = mMonthly->frequency(); | 1041 | int freq = mMonthly->frequency(); |
1030 | if ( mMonthly->byPos() ) { | 1042 | if ( mMonthly->byPos() ) { |
1031 | int pos = mMonthly->count(); | 1043 | int pos = mMonthly->count(); |
1032 | 1044 | ||
1033 | QBitArray days( 7 ); | 1045 | QBitArray days( 7 ); |
1034 | days.fill( false ); | 1046 | days.fill( false ); |
1035 | 1047 | ||
1036 | days.setBit( mMonthly->weekday() ); | 1048 | days.setBit( mMonthly->weekday() ); |
1037 | if ( duration != 0 ) | 1049 | if ( duration != 0 ) |
1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1050 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1039 | else | 1051 | else |
1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1052 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1041 | r->addMonthlyPos( pos, days ); | 1053 | r->addMonthlyPos( pos, days ); |
1042 | } else { | 1054 | } else { |
1043 | // it's by day | 1055 | // it's by day |
1044 | int day = mMonthly->day(); | 1056 | int day = mMonthly->day(); |
1045 | 1057 | ||
1046 | if ( duration != 0 ) { | 1058 | if ( duration != 0 ) { |
1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1059 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1048 | } else { | 1060 | } else { |
1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1061 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1050 | } | 1062 | } |
1051 | r->addMonthlyDay( day ); | 1063 | r->addMonthlyDay( day ); |
1052 | } | 1064 | } |
1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1065 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1054 | //qDebug("RecurrenceChooser::Yearly "); | 1066 | //qDebug("RecurrenceChooser::Yearly "); |
1055 | int freq = mYearly->frequency(); | 1067 | int freq = mYearly->frequency(); |
1056 | if ( mYearly->byDay() ) { | 1068 | if ( mYearly->byDay() ) { |
1057 | if ( duration != 0 ) { | 1069 | if ( duration != 0 ) { |
1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1070 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1059 | } else { | 1071 | } else { |
1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1072 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1061 | } | 1073 | } |
1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1074 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1063 | } else { | 1075 | } else { |
1064 | if ( duration != 0 ) { | 1076 | if ( duration != 0 ) { |
1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1077 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1066 | } else { | 1078 | } else { |
1067 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1079 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1068 | } | 1080 | } |
1069 | r->addYearlyNum( mYearly->month() ); | 1081 | r->addYearlyNum( mYearly->month() ); |
1070 | } | 1082 | } |
1071 | 1083 | ||
1072 | } | 1084 | } |
1073 | 1085 | ||
1074 | event->setExDates( mExceptions->dates() ); | 1086 | event->setExDates( mExceptions->dates() ); |
1075 | } | 1087 | } |
1076 | } | 1088 | } |
1077 | 1089 | ||
1078 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1090 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1079 | { | 1091 | { |
1080 | mDateTimeLabel->setText( str ); | 1092 | mDateTimeLabel->setText( str ); |
1081 | } | 1093 | } |
1082 | 1094 | ||
1083 | bool KOEditorRecurrence::validateInput() | 1095 | bool KOEditorRecurrence::validateInput() |
1084 | { | 1096 | { |
1085 | // Check input here | 1097 | // Check input here |
1086 | 1098 | ||
1087 | return true; | 1099 | return true; |
1088 | } | 1100 | } |
1089 | 1101 | ||
1090 | void KOEditorRecurrence::showExceptionsDialog() | 1102 | void KOEditorRecurrence::showExceptionsDialog() |
1091 | { | 1103 | { |
1092 | DateList dates = mExceptions->dates(); | 1104 | DateList dates = mExceptions->dates(); |
1093 | int result = mExceptionsDialog->exec(); | 1105 | int result = mExceptionsDialog->exec(); |
1094 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1106 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1095 | } | 1107 | } |
1096 | 1108 | ||
1097 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1109 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1098 | { | 1110 | { |
1099 | int duration = mRecurrenceRange->duration(); | 1111 | int duration = mRecurrenceRange->duration(); |
1100 | QDate endDate = mRecurrenceRange->endDate(); | 1112 | QDate endDate = mRecurrenceRange->endDate(); |
1101 | 1113 | ||
1102 | int result = mRecurrenceRangeDialog->exec(); | 1114 | int result = mRecurrenceRangeDialog->exec(); |
1103 | if ( result == QDialog::Rejected ) { | 1115 | if ( result == QDialog::Rejected ) { |
1104 | mRecurrenceRange->setDuration( duration ); | 1116 | mRecurrenceRange->setDuration( duration ); |
1105 | mRecurrenceRange->setEndDate( endDate ); | 1117 | mRecurrenceRange->setEndDate( endDate ); |
1106 | } | 1118 | } |
1107 | 1119 | ||
1108 | } | 1120 | } |
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index a15afcb..f398f62 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -82,243 +82,243 @@ class RecurWeekly : public RecurBase | |||
82 | class RecurMonthly : public RecurBase | 82 | class RecurMonthly : public RecurBase |
83 | { | 83 | { |
84 | public: | 84 | public: |
85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); | 85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); |
86 | 86 | ||
87 | void setByDay( int day ); | 87 | void setByDay( int day ); |
88 | void setByPos( int count, int weekday ); | 88 | void setByPos( int count, int weekday ); |
89 | 89 | ||
90 | bool byDay(); | 90 | bool byDay(); |
91 | bool byPos(); | 91 | bool byPos(); |
92 | 92 | ||
93 | int day(); | 93 | int day(); |
94 | 94 | ||
95 | int count(); | 95 | int count(); |
96 | int weekday(); | 96 | int weekday(); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | QRadioButton *mByDayRadio; | 99 | QRadioButton *mByDayRadio; |
100 | QComboBox *mByDayCombo; | 100 | QComboBox *mByDayCombo; |
101 | 101 | ||
102 | QRadioButton *mByPosRadio; | 102 | QRadioButton *mByPosRadio; |
103 | QComboBox *mByPosCountCombo; | 103 | QComboBox *mByPosCountCombo; |
104 | QComboBox *mByPosWeekdayCombo; | 104 | QComboBox *mByPosWeekdayCombo; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class RecurYearly : public RecurBase | 107 | class RecurYearly : public RecurBase |
108 | { | 108 | { |
109 | public: | 109 | public: |
110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); | 110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); |
111 | 111 | ||
112 | void setByDay( int doy ); | 112 | void setByDay( int doy ); |
113 | void setByMonth( int month, int day ); | 113 | void setByMonth( int month, int day ); |
114 | 114 | ||
115 | bool byMonth(); | 115 | bool byMonth(); |
116 | bool byDay(); | 116 | bool byDay(); |
117 | 117 | ||
118 | int month(); | 118 | int month(); |
119 | int day(); | 119 | int day(); |
120 | 120 | ||
121 | private: | 121 | private: |
122 | int mDay; | 122 | int mDay; |
123 | QRadioButton *mByMonthRadio; | 123 | QRadioButton *mByMonthRadio; |
124 | QComboBox *mByMonthCombo; | 124 | QComboBox *mByMonthCombo; |
125 | QLabel* mByDayLabel; | 125 | QLabel* mByDayLabel; |
126 | QLabel* mDayOfLabel; | 126 | QLabel* mDayOfLabel; |
127 | QRadioButton *mByDayRadio; | 127 | QRadioButton *mByDayRadio; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | class RecurrenceChooser : public QWidget | 130 | class RecurrenceChooser : public QWidget |
131 | { | 131 | { |
132 | Q_OBJECT | 132 | Q_OBJECT |
133 | public: | 133 | public: |
134 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); | 134 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); |
135 | 135 | ||
136 | enum { Daily, Weekly, Monthly, Yearly }; | 136 | enum { Daily, Weekly, Monthly, Yearly }; |
137 | 137 | ||
138 | void setType( int ); | 138 | void setType( int ); |
139 | int type(); | 139 | int type(); |
140 | 140 | ||
141 | signals: | 141 | signals: |
142 | void chosen( int ); | 142 | void chosen( int ); |
143 | 143 | ||
144 | protected slots: | 144 | protected slots: |
145 | void emitChoice(); | 145 | void emitChoice(); |
146 | 146 | ||
147 | private: | 147 | private: |
148 | QComboBox *mTypeCombo; | 148 | QComboBox *mTypeCombo; |
149 | 149 | ||
150 | QRadioButton *mDailyButton; | 150 | QRadioButton *mDailyButton; |
151 | QRadioButton *mWeeklyButton; | 151 | QRadioButton *mWeeklyButton; |
152 | QRadioButton *mMonthlyButton; | 152 | QRadioButton *mMonthlyButton; |
153 | QRadioButton *mYearlyButton; | 153 | QRadioButton *mYearlyButton; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | class ExceptionsBase | 156 | class ExceptionsBase |
157 | { | 157 | { |
158 | public: | 158 | public: |
159 | virtual void setDefaults( const QDateTime &from ) = 0; | 159 | virtual void setDefaults( const QDateTime &from ) = 0; |
160 | virtual void setDates( const DateList & ) = 0; | 160 | virtual void setDates( const DateList & ) = 0; |
161 | virtual DateList dates() = 0; | 161 | virtual DateList dates() = 0; |
162 | }; | 162 | }; |
163 | 163 | ||
164 | class ExceptionsWidget : public QWidget, public ExceptionsBase | 164 | class ExceptionsWidget : public QWidget, public ExceptionsBase |
165 | { | 165 | { |
166 | Q_OBJECT | 166 | Q_OBJECT |
167 | public: | 167 | public: |
168 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); | 168 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); |
169 | 169 | ||
170 | void setDefaults( const QDateTime &from ); | 170 | void setDefaults( const QDateTime &from ); |
171 | 171 | ||
172 | void setDates( const DateList & ); | 172 | void setDates( const DateList & ); |
173 | DateList dates(); | 173 | DateList dates(); |
174 | 174 | ||
175 | protected slots: | 175 | protected slots: |
176 | void addException(); | 176 | void addException(); |
177 | void changeException(); | 177 | void changeException(); |
178 | void deleteException(); | 178 | void deleteException(); |
179 | 179 | ||
180 | private: | 180 | private: |
181 | KDateEdit *mExceptionDateEdit; | 181 | KDateEdit *mExceptionDateEdit; |
182 | QListBox *mExceptionList; | 182 | QListBox *mExceptionList; |
183 | DateList mExceptionDates; | 183 | DateList mExceptionDates; |
184 | }; | 184 | }; |
185 | 185 | ||
186 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase | 186 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase |
187 | { | 187 | { |
188 | public: | 188 | public: |
189 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); | 189 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); |
190 | 190 | ||
191 | void setDefaults( const QDateTime &from ); | 191 | void setDefaults( const QDateTime &from ); |
192 | 192 | ||
193 | void setDates( const DateList & ); | 193 | void setDates( const DateList & ); |
194 | DateList dates(); | 194 | DateList dates(); |
195 | 195 | ||
196 | private: | 196 | private: |
197 | ExceptionsWidget *mExceptions; | 197 | ExceptionsWidget *mExceptions; |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class RecurrenceRangeBase | 200 | class RecurrenceRangeBase |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | virtual void setDefaults( const QDateTime &from ) = 0; | 203 | virtual void setDefaults( const QDateTime &from ) = 0; |
204 | 204 | ||
205 | virtual void setDuration( int ) = 0; | 205 | virtual void setDuration( int ) = 0; |
206 | virtual int duration() = 0; | 206 | virtual int duration() = 0; |
207 | 207 | ||
208 | virtual void setEndDate( const QDate & ) = 0; | 208 | virtual void setEndDate( const QDate & ) = 0; |
209 | virtual QDate endDate() = 0; | 209 | virtual QDate endDate() = 0; |
210 | 210 | ||
211 | virtual void setDateTimes( const QDateTime &start, | 211 | virtual void setDateTimes( const QDateTime &start, |
212 | const QDateTime &end = QDateTime() ) = 0; | 212 | const QDateTime &end = QDateTime() ) = 0; |
213 | }; | 213 | }; |
214 | 214 | ||
215 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase | 215 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase |
216 | { | 216 | { |
217 | Q_OBJECT | 217 | Q_OBJECT |
218 | public: | 218 | public: |
219 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); | 219 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); |
220 | 220 | ||
221 | void setDefaults( const QDateTime &from ); | 221 | void setDefaults( const QDateTime &from ); |
222 | 222 | ||
223 | void setDuration( int ); | 223 | void setDuration( int ); |
224 | int duration(); | 224 | int duration(); |
225 | 225 | ||
226 | void setEndDate( const QDate & ); | 226 | void setEndDate( const QDate & ); |
227 | QDate endDate(); | 227 | QDate endDate(); |
228 | 228 | ||
229 | void setDateTimes( const QDateTime &start, | 229 | void setDateTimes( const QDateTime &start, |
230 | const QDateTime &end = QDateTime() ); | 230 | const QDateTime &end = QDateTime() ); |
231 | 231 | ||
232 | protected slots: | 232 | protected slots: |
233 | void showCurrentRange(); | 233 | void showCurrentRange(); |
234 | 234 | ||
235 | private: | 235 | private: |
236 | QGroupBox *mRangeGroupBox; | 236 | QGroupBox *mRangeGroupBox; |
237 | QLabel *mStartDateLabel; | 237 | QLabel *mStartDateLabel; |
238 | QRadioButton *mNoEndDateButton; | 238 | QRadioButton *mNoEndDateButton; |
239 | QRadioButton *mEndDurationButton; | 239 | QRadioButton *mEndDurationButton; |
240 | QSpinBox *mEndDurationEdit; | 240 | QSpinBox *mEndDurationEdit; |
241 | QRadioButton *mEndDateButton; | 241 | QRadioButton *mEndDateButton; |
242 | KDateEdit *mEndDateEdit; | 242 | KDateEdit *mEndDateEdit; |
243 | }; | 243 | }; |
244 | 244 | ||
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 */ | ||
275 | void setDefaults( QDateTime from, QDateTime to, bool allday ); | ||
276 | /** Read event object and setup widgets accordingly */ | 274 | /** Read event object and setup widgets accordingly */ |
277 | void readEvent( Incidence * ); | 275 | void readEvent( Incidence * ); |
278 | /** Write event settings to event object */ | 276 | /** Write event settings to event object */ |
279 | void writeEvent( Incidence * ); | 277 | void writeEvent( Incidence * ); |
280 | 278 | ||
281 | /** Check if the input is valid. */ | 279 | /** Check if the input is valid. */ |
282 | bool validateInput(); | 280 | bool validateInput(); |
283 | 281 | ||
284 | public slots: | 282 | public slots: |
283 | void setDefaultsDates( QDateTime from, QDateTime to ); | ||
284 | void setDefaults( QDateTime from, QDateTime to ); | ||
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 | ||
312 | RecurrenceRangeBase *mRecurrenceRange; | 312 | RecurrenceRangeBase *mRecurrenceRange; |
313 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 313 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
314 | RecurrenceRangeDialog *mRecurrenceRangeDialog; | 314 | RecurrenceRangeDialog *mRecurrenceRangeDialog; |
315 | QPushButton *mRecurrenceRangeButton; | 315 | QPushButton *mRecurrenceRangeButton; |
316 | 316 | ||
317 | ExceptionsBase *mExceptions; | 317 | ExceptionsBase *mExceptions; |
318 | ExceptionsDialog *mExceptionsDialog; | 318 | ExceptionsDialog *mExceptionsDialog; |
319 | ExceptionsWidget *mExceptionsWidget; | 319 | ExceptionsWidget *mExceptionsWidget; |
320 | QPushButton *mExceptionsButton; | 320 | QPushButton *mExceptionsButton; |
321 | 321 | ||
322 | }; | 322 | }; |
323 | 323 | ||
324 | #endif | 324 | #endif |
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 02d4a78..75dae34 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp | |||
@@ -1,378 +1,378 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <libkcal/calendarresources.h> | 39 | #include <libkcal/calendarresources.h> |
40 | #include <libkcal/resourcecalendar.h> | 40 | #include <libkcal/resourcecalendar.h> |
41 | #include <kresources/resourceselectdialog.h> | 41 | #include <kresources/resourceselectdialog.h> |
42 | 42 | ||
43 | #include <libkdepim/categoryselectdialog.h> | 43 | #include <libkdepim/categoryselectdialog.h> |
44 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koeventeditor.h" | 49 | #include "koeventeditor.h" |
50 | extern int globalFlagBlockAgenda; | 50 | extern int globalFlagBlockAgenda; |
51 | 51 | ||
52 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : | 52 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : |
53 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) | 53 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) |
54 | { | 54 | { |
55 | mEvent = 0; | 55 | mEvent = 0; |
56 | init(); | 56 | init(); |
57 | if ( QApplication::desktop()->height() <= 240 ) | 57 | if ( QApplication::desktop()->height() <= 240 ) |
58 | hideButtons(); | 58 | hideButtons(); |
59 | } | 59 | } |
60 | 60 | ||
61 | KOEventEditor::~KOEventEditor() | 61 | KOEventEditor::~KOEventEditor() |
62 | { | 62 | { |
63 | //emit dialogClose( mEvent ); | 63 | //emit dialogClose( mEvent ); |
64 | } | 64 | } |
65 | 65 | ||
66 | void KOEventEditor::init() | 66 | void KOEventEditor::init() |
67 | { | 67 | { |
68 | 68 | ||
69 | setupGeneral(); | 69 | setupGeneral(); |
70 | setupAttendeesTab(); | 70 | setupAttendeesTab(); |
71 | setupRecurrence(); | 71 | setupRecurrence(); |
72 | 72 | ||
73 | // Propagate date time settings to recurrence tab | 73 | // Propagate date time settings to recurrence tab |
74 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 74 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
75 | mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime))); | 75 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); |
76 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), | 76 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), |
77 | mRecurrence,SLOT(setDateTimeStr(const QString &))); | 77 | mRecurrence,SLOT(setDateTimeStr(const QString &))); |
78 | 78 | ||
79 | // Category dialog | 79 | // Category dialog |
80 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 80 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
81 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), | 81 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), |
82 | // mGeneral,SLOT(setCategories(const QString &))); | 82 | // mGeneral,SLOT(setCategories(const QString &))); |
83 | 83 | ||
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | void KOEventEditor::reload() | 87 | void KOEventEditor::reload() |
88 | { | 88 | { |
89 | if ( mEvent ) readEvent( mEvent ); | 89 | if ( mEvent ) readEvent( mEvent ); |
90 | } | 90 | } |
91 | 91 | ||
92 | void KOEventEditor::setSecrecy( int sec ) | 92 | void KOEventEditor::setSecrecy( int sec ) |
93 | { | 93 | { |
94 | mGeneral->setSecrecy( sec ); | 94 | mGeneral->setSecrecy( sec ); |
95 | } | 95 | } |
96 | void KOEventEditor::setCategories( QString s ) | 96 | void KOEventEditor::setCategories( QString s ) |
97 | { | 97 | { |
98 | mGeneral->setCategories(s); | 98 | mGeneral->setCategories(s); |
99 | 99 | ||
100 | } | 100 | } |
101 | void KOEventEditor::setupGeneral() | 101 | void KOEventEditor::setupGeneral() |
102 | { | 102 | { |
103 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); | 103 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); |
104 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 104 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
105 | 105 | ||
106 | if( KOPrefs::instance()->mCompactDialogs ) { | 106 | if( KOPrefs::instance()->mCompactDialogs ) { |
107 | QFrame *topFrame = addPage(i18n("General")); | 107 | QFrame *topFrame = addPage(i18n("General")); |
108 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 108 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
109 | topLayout->setSpacing(spacingHint()-1); | 109 | topLayout->setSpacing(spacingHint()-1); |
110 | topLayout->setMargin(marginHint()-1); | 110 | topLayout->setMargin(marginHint()-1); |
111 | mGeneral->initHeader(topFrame,topLayout); | 111 | mGeneral->initHeader(topFrame,topLayout); |
112 | mGeneral->initTime(topFrame,topLayout); | 112 | mGeneral->initTime(topFrame,topLayout); |
113 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 113 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
114 | mGeneral->initAlarm(topFrame,topLayout); | 114 | mGeneral->initAlarm(topFrame,topLayout); |
115 | mGeneral->enableAlarm( false ); | 115 | mGeneral->enableAlarm( false ); |
116 | 116 | ||
117 | QBoxLayout *buttonLayout; | 117 | QBoxLayout *buttonLayout; |
118 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) | 118 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) |
119 | buttonLayout = new QVBoxLayout( topLayout ); | 119 | buttonLayout = new QVBoxLayout( topLayout ); |
120 | else | 120 | else |
121 | buttonLayout = new QHBoxLayout( topLayout ); | 121 | buttonLayout = new QHBoxLayout( topLayout ); |
122 | QHBox* buttonWidget = new QHBox (topFrame); | 122 | QHBox* buttonWidget = new QHBox (topFrame); |
123 | QIconSet icon; | 123 | QIconSet icon; |
124 | if ( QApplication::desktop()->width() < 321 ) | 124 | if ( QApplication::desktop()->width() < 321 ) |
125 | icon = SmallIcon("fileexport16"); | 125 | icon = SmallIcon("fileexport16"); |
126 | else | 126 | else |
127 | icon = SmallIcon("fileexport"); | 127 | icon = SmallIcon("fileexport"); |
128 | QPushButton * loadTemplate = new QPushButton( buttonWidget); | 128 | QPushButton * loadTemplate = new QPushButton( buttonWidget); |
129 | QPushButton * saveTemplate = new QPushButton( buttonWidget); | 129 | QPushButton * saveTemplate = new QPushButton( buttonWidget); |
130 | saveTemplate->setIconSet (icon ) ; | 130 | saveTemplate->setIconSet (icon ) ; |
131 | int size = saveTemplate->sizeHint().height(); | 131 | int size = saveTemplate->sizeHint().height(); |
132 | saveTemplate->setFixedSize( size, size ); | 132 | saveTemplate->setFixedSize( size, size ); |
133 | if ( QApplication::desktop()->width() < 321 ) | 133 | if ( QApplication::desktop()->width() < 321 ) |
134 | icon = SmallIcon("fileimport16"); | 134 | icon = SmallIcon("fileimport16"); |
135 | else | 135 | else |
136 | icon = SmallIcon("fileimport"); | 136 | icon = SmallIcon("fileimport"); |
137 | loadTemplate->setIconSet (icon ) ; | 137 | loadTemplate->setIconSet (icon ) ; |
138 | loadTemplate->setFixedSize( size, size ); | 138 | loadTemplate->setFixedSize( size, size ); |
139 | buttonLayout->addWidget( buttonWidget ); | 139 | buttonLayout->addWidget( buttonWidget ); |
140 | mGeneral->initCategories( topFrame, buttonLayout ); | 140 | mGeneral->initCategories( topFrame, buttonLayout ); |
141 | 141 | ||
142 | topLayout->addStretch( 1 ); | 142 | topLayout->addStretch( 1 ); |
143 | 143 | ||
144 | QFrame *topFrame2 = addPage(i18n("Details")); | 144 | QFrame *topFrame2 = addPage(i18n("Details")); |
145 | 145 | ||
146 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 146 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
147 | topLayout2->setSpacing(spacingHint()); | 147 | topLayout2->setSpacing(spacingHint()); |
148 | 148 | ||
149 | mGeneral->initClass(topFrame2,topLayout2); | 149 | mGeneral->initClass(topFrame2,topLayout2); |
150 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 150 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
151 | mGeneral->initDescription(topFrame2,topLayout2); | 151 | mGeneral->initDescription(topFrame2,topLayout2); |
152 | 152 | ||
153 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 153 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
154 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 154 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
155 | } else { | 155 | } else { |
156 | QFrame *topFrame = addPage(i18n("General")); | 156 | QFrame *topFrame = addPage(i18n("General")); |
157 | 157 | ||
158 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 158 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
159 | topLayout->setSpacing(spacingHint()); | 159 | topLayout->setSpacing(spacingHint()); |
160 | 160 | ||
161 | mGeneral->initHeader(topFrame,topLayout); | 161 | mGeneral->initHeader(topFrame,topLayout); |
162 | mGeneral->initTime(topFrame,topLayout); | 162 | mGeneral->initTime(topFrame,topLayout); |
163 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 163 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
164 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 164 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
165 | mGeneral->initClass(topFrame,alarmLineLayout); | 165 | mGeneral->initClass(topFrame,alarmLineLayout); |
166 | mGeneral->initDescription(topFrame,topLayout); | 166 | mGeneral->initDescription(topFrame,topLayout); |
167 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 167 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
168 | mGeneral->initCategories( topFrame, detailsLayout ); | 168 | mGeneral->initCategories( topFrame, detailsLayout ); |
169 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 169 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
170 | } | 170 | } |
171 | 171 | ||
172 | mGeneral->finishSetup(); | 172 | mGeneral->finishSetup(); |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
176 | void KOEventEditor::setupRecurrence() | 176 | void KOEventEditor::setupRecurrence() |
177 | { | 177 | { |
178 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 178 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
179 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 179 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
180 | 180 | ||
181 | mRecurrence = new KOEditorRecurrence( topFrame ); | 181 | mRecurrence = new KOEditorRecurrence( topFrame ); |
182 | topLayout->addWidget( mRecurrence ); | 182 | topLayout->addWidget( mRecurrence ); |
183 | } | 183 | } |
184 | 184 | ||
185 | void KOEventEditor::editEvent(Event *event, bool showDescription) | 185 | void KOEventEditor::editEvent(Event *event, bool showDescription) |
186 | { | 186 | { |
187 | // init(); | 187 | // init(); |
188 | 188 | ||
189 | mEvent = event; | 189 | mEvent = event; |
190 | readEvent(mEvent); | 190 | readEvent(mEvent); |
191 | if ( showDescription ) { | 191 | if ( showDescription ) { |
192 | showPage( 1 ); | 192 | showPage( 1 ); |
193 | mGeneral->setFocusOn( 1 ); | 193 | mGeneral->setFocusOn( 1 ); |
194 | } else { | 194 | } else { |
195 | showPage( 0 ); | 195 | showPage( 0 ); |
196 | mGeneral->setFocusOn( 2 ); | 196 | mGeneral->setFocusOn( 2 ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) | 200 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) |
201 | { | 201 | { |
202 | // init(); | 202 | // init(); |
203 | 203 | ||
204 | mEvent = 0; | 204 | mEvent = 0; |
205 | setDefaults(from,to,allDay); | 205 | setDefaults(from,to,allDay); |
206 | } | 206 | } |
207 | 207 | ||
208 | void KOEventEditor::loadDefaults() | 208 | void KOEventEditor::loadDefaults() |
209 | { | 209 | { |
210 | int fmt = KOPrefs::instance()->mStartTime; | 210 | int fmt = KOPrefs::instance()->mStartTime; |
211 | 211 | ||
212 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); | 212 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); |
213 | QDateTime to(QDate::currentDate(), | 213 | QDateTime to(QDate::currentDate(), |
214 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); | 214 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); |
215 | 215 | ||
216 | setDefaults(from,to,false); | 216 | setDefaults(from,to,false); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool KOEventEditor::processInput( bool emitTime ) | 219 | bool KOEventEditor::processInput( bool emitTime ) |
220 | { | 220 | { |
221 | if (!validateInput()) return false; | 221 | if (!validateInput()) return false; |
222 | 222 | ||
223 | Event *event = 0; | 223 | Event *event = 0; |
224 | 224 | ||
225 | if (mEvent) event = mEvent; | 225 | if (mEvent) event = mEvent; |
226 | else { | 226 | else { |
227 | event = new Event; | 227 | event = new Event; |
228 | event->setOrganizer(KOPrefs::instance()->email()); | 228 | event->setOrganizer(KOPrefs::instance()->email()); |
229 | } | 229 | } |
230 | 230 | ||
231 | writeEvent(event); | 231 | writeEvent(event); |
232 | if ( emitTime ) { | 232 | if ( emitTime ) { |
233 | globalFlagBlockAgenda = 1; | 233 | globalFlagBlockAgenda = 1; |
234 | emit showAgendaView( false ); | 234 | emit showAgendaView( false ); |
235 | emit jumpToTime( event->dtStart().date() ); | 235 | emit jumpToTime( event->dtStart().date() ); |
236 | globalFlagBlockAgenda = 2; | 236 | globalFlagBlockAgenda = 2; |
237 | 237 | ||
238 | } | 238 | } |
239 | if (mEvent) { | 239 | if (mEvent) { |
240 | event->setRevision(event->revision()+1); | 240 | event->setRevision(event->revision()+1); |
241 | emit eventChanged(event); | 241 | emit eventChanged(event); |
242 | } else { | 242 | } else { |
243 | mCalendar->addEvent(event); | 243 | mCalendar->addEvent(event); |
244 | mEvent = event; | 244 | mEvent = event; |
245 | emit eventAdded(event); | 245 | emit eventAdded(event); |
246 | } | 246 | } |
247 | 247 | ||
248 | return true; | 248 | return true; |
249 | } | 249 | } |
250 | 250 | ||
251 | void KOEventEditor::deleteEvent() | 251 | void KOEventEditor::deleteEvent() |
252 | { | 252 | { |
253 | kdDebug() << "Delete event" << endl; | 253 | kdDebug() << "Delete event" << endl; |
254 | 254 | ||
255 | if (mEvent) { | 255 | if (mEvent) { |
256 | if (KOPrefs::instance()->mConfirm) { | 256 | if (KOPrefs::instance()->mConfirm) { |
257 | switch (msgItemDelete()) { | 257 | switch (msgItemDelete()) { |
258 | case KMessageBox::Continue: // OK | 258 | case KMessageBox::Continue: // OK |
259 | emit eventToBeDeleted(mEvent); | 259 | emit eventToBeDeleted(mEvent); |
260 | emit dialogClose(mEvent); | 260 | emit dialogClose(mEvent); |
261 | mCalendar->deleteEvent(mEvent); | 261 | mCalendar->deleteEvent(mEvent); |
262 | emit eventDeleted(); | 262 | emit eventDeleted(); |
263 | reject(); | 263 | reject(); |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | else { | 267 | else { |
268 | emit eventToBeDeleted(mEvent); | 268 | emit eventToBeDeleted(mEvent); |
269 | emit dialogClose(mEvent); | 269 | emit dialogClose(mEvent); |
270 | mCalendar->deleteEvent(mEvent); | 270 | mCalendar->deleteEvent(mEvent); |
271 | emit eventDeleted(); | 271 | emit eventDeleted(); |
272 | reject(); | 272 | reject(); |
273 | } | 273 | } |
274 | } else { | 274 | } else { |
275 | reject(); | 275 | reject(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) | 279 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) |
280 | { | 280 | { |
281 | mGeneral->setDefaults(from,to,allDay); | 281 | mGeneral->setDefaults(from,to,allDay); |
282 | mDetails->setDefaults(); | 282 | mDetails->setDefaults(); |
283 | mRecurrence->setDefaults(from,to,allDay); | 283 | mRecurrence->setDefaults(from,to); |
284 | showPage( 0 ); | 284 | showPage( 0 ); |
285 | mGeneral->setFocusOn( 2 ); | 285 | mGeneral->setFocusOn( 2 ); |
286 | } | 286 | } |
287 | 287 | ||
288 | void KOEventEditor::readEvent( Event *event, bool tmpl ) | 288 | void KOEventEditor::readEvent( Event *event, bool tmpl ) |
289 | { | 289 | { |
290 | mGeneral->readEvent( event, tmpl ); | 290 | mGeneral->readEvent( event, tmpl ); |
291 | mDetails->readEvent( event ); | 291 | mDetails->readEvent( event ); |
292 | mRecurrence->readEvent( event ); | 292 | mRecurrence->readEvent( event ); |
293 | 293 | ||
294 | // categories | 294 | // categories |
295 | //mCategoryDialog->setSelected( event->categories() ); | 295 | //mCategoryDialog->setSelected( event->categories() ); |
296 | } | 296 | } |
297 | 297 | ||
298 | void KOEventEditor::writeEvent(Event *event) | 298 | void KOEventEditor::writeEvent(Event *event) |
299 | { | 299 | { |
300 | mGeneral->writeEvent( event ); | 300 | mGeneral->writeEvent( event ); |
301 | mDetails->writeEvent( event ); | 301 | mDetails->writeEvent( event ); |
302 | 302 | ||
303 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 303 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
304 | Event *ev = new Event( *event ); | 304 | Event *ev = new Event( *event ); |
305 | ev->registerObserver(0); | 305 | ev->registerObserver(0); |
306 | mDetails->cancelAttendeeEvent( ev ); | 306 | mDetails->cancelAttendeeEvent( ev ); |
307 | if ( ev->attendeeCount() > 0 ) { | 307 | if ( ev->attendeeCount() > 0 ) { |
308 | emit deleteAttendee( ev ); | 308 | emit deleteAttendee( ev ); |
309 | } | 309 | } |
310 | delete(ev); | 310 | delete(ev); |
311 | } | 311 | } |
312 | 312 | ||
313 | mRecurrence->writeEvent(event); | 313 | mRecurrence->writeEvent(event); |
314 | } | 314 | } |
315 | 315 | ||
316 | bool KOEventEditor::validateInput() | 316 | bool KOEventEditor::validateInput() |
317 | { | 317 | { |
318 | if (!mGeneral->validateInput()) return false; | 318 | if (!mGeneral->validateInput()) return false; |
319 | if (!mDetails->validateInput()) return false; | 319 | if (!mDetails->validateInput()) return false; |
320 | if (!mRecurrence->validateInput()) return false; | 320 | if (!mRecurrence->validateInput()) return false; |
321 | return true; | 321 | return true; |
322 | } | 322 | } |
323 | 323 | ||
324 | int KOEventEditor::msgItemDelete() | 324 | int KOEventEditor::msgItemDelete() |
325 | { | 325 | { |
326 | return KMessageBox::warningContinueCancel(this, | 326 | return KMessageBox::warningContinueCancel(this, |
327 | i18n("This item will be permanently deleted."), | 327 | i18n("This item will be permanently deleted."), |
328 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 328 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
329 | } | 329 | } |
330 | 330 | ||
331 | void KOEventEditor::slotLoadTemplate() | 331 | void KOEventEditor::slotLoadTemplate() |
332 | { | 332 | { |
333 | 333 | ||
334 | QString fileName =locateLocal( "templates", "events" ); | 334 | QString fileName =locateLocal( "templates", "events" ); |
335 | QDir t_dir; | 335 | QDir t_dir; |
336 | if ( !t_dir.exists(fileName) ) | 336 | if ( !t_dir.exists(fileName) ) |
337 | t_dir.mkdir ( fileName ); | 337 | t_dir.mkdir ( fileName ); |
338 | fileName += "/event"; | 338 | fileName += "/event"; |
339 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); | 339 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); |
340 | if ( fileName.length() == 0 ) | 340 | if ( fileName.length() == 0 ) |
341 | return; | 341 | return; |
342 | CalendarLocal cal; | 342 | CalendarLocal cal; |
343 | ICalFormat format; | 343 | ICalFormat format; |
344 | if ( !format.load( &cal, fileName ) ) { | 344 | if ( !format.load( &cal, fileName ) ) { |
345 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 345 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
346 | .arg( fileName ) ); | 346 | .arg( fileName ) ); |
347 | return ; | 347 | return ; |
348 | } | 348 | } |
349 | QPtrList<Event> events = cal.events(); | 349 | QPtrList<Event> events = cal.events(); |
350 | Event* event = events.first(); | 350 | Event* event = events.first(); |
351 | if ( !event ) { | 351 | if ( !event ) { |
352 | KMessageBox::error( this, | 352 | KMessageBox::error( this, |
353 | i18n("Template does not contain\na valid Event.")); | 353 | i18n("Template does not contain\na valid Event.")); |
354 | } else { | 354 | } else { |
355 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; | 355 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; |
356 | readEvent( event, true ); | 356 | readEvent( event, true ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
361 | void KOEventEditor::slotSaveTemplate() | 361 | void KOEventEditor::slotSaveTemplate() |
362 | { | 362 | { |
363 | QString fileName =locateLocal( "templates", "events" ); | 363 | QString fileName =locateLocal( "templates", "events" ); |
364 | QDir t_dir; | 364 | QDir t_dir; |
365 | if ( !t_dir.exists(fileName) ) | 365 | if ( !t_dir.exists(fileName) ) |
366 | t_dir.mkdir ( fileName ); | 366 | t_dir.mkdir ( fileName ); |
367 | fileName += "/event"; | 367 | fileName += "/event"; |
368 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); | 368 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); |
369 | if ( fileName.length() > 0 ) | 369 | if ( fileName.length() > 0 ) |
370 | saveTemplate( fileName ); | 370 | saveTemplate( fileName ); |
371 | } | 371 | } |
372 | 372 | ||
373 | void KOEventEditor::saveTemplate( const QString &templateName ) | 373 | void KOEventEditor::saveTemplate( const QString &templateName ) |
374 | { | 374 | { |
375 | Event *event = new Event; | 375 | Event *event = new Event; |
376 | writeEvent( event ); | 376 | writeEvent( event ); |
377 | saveAsTemplate( event, templateName ); | 377 | saveAsTemplate( event, templateName ); |
378 | } | 378 | } |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 9073bca..8b90ae5 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,446 +1,448 @@ | |||
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 | #include <qtabwidget.h> |
34 | 34 | ||
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
51 | 51 | ||
52 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
54 | 54 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 57 | { |
58 | mTodo = 0; | 58 | mTodo = 0; |
59 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
61 | init(); | 61 | init(); |
62 | if ( QApplication::desktop()->height() <= 240 ) | 62 | if ( QApplication::desktop()->height() <= 240 ) |
63 | hideButtons(); | 63 | hideButtons(); |
64 | } | 64 | } |
65 | 65 | ||
66 | KOTodoEditor::~KOTodoEditor() | 66 | KOTodoEditor::~KOTodoEditor() |
67 | { | 67 | { |
68 | emit dialogClose( mTodo ); | 68 | emit dialogClose( mTodo ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void KOTodoEditor::init() | 71 | void KOTodoEditor::init() |
72 | { | 72 | { |
73 | setupGeneral(); | 73 | setupGeneral(); |
74 | setupAttendeesTab(); | 74 | setupAttendeesTab(); |
75 | setupRecurrence(); | 75 | setupRecurrence(); |
76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
78 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | ||
79 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | ||
78 | } | 80 | } |
79 | void KOTodoEditor::setupRecurrence() | 81 | void KOTodoEditor::setupRecurrence() |
80 | { | 82 | { |
81 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 83 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
82 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 84 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
83 | 85 | ||
84 | mRecurrence = new KOEditorRecurrence( topFrame ); | 86 | mRecurrence = new KOEditorRecurrence( topFrame ); |
85 | topLayout->addWidget( mRecurrence ); | 87 | topLayout->addWidget( mRecurrence ); |
86 | } | 88 | } |
87 | 89 | ||
88 | void KOTodoEditor::setCategories( QString s ) | 90 | void KOTodoEditor::setCategories( QString s ) |
89 | { | 91 | { |
90 | mGeneral->setCategories(s); | 92 | mGeneral->setCategories(s); |
91 | } | 93 | } |
92 | void KOTodoEditor::setSecrecy( int sec ) | 94 | void KOTodoEditor::setSecrecy( int sec ) |
93 | { | 95 | { |
94 | mGeneral->setSecrecy( sec ); | 96 | mGeneral->setSecrecy( sec ); |
95 | } | 97 | } |
96 | void KOTodoEditor::reload() | 98 | void KOTodoEditor::reload() |
97 | { | 99 | { |
98 | if ( mTodo ) readTodo( mTodo ); | 100 | if ( mTodo ) readTodo( mTodo ); |
99 | } | 101 | } |
100 | 102 | ||
101 | void KOTodoEditor::setupGeneral() | 103 | void KOTodoEditor::setupGeneral() |
102 | { | 104 | { |
103 | mGeneral = new KOEditorGeneralTodo(this); | 105 | mGeneral = new KOEditorGeneralTodo(this); |
104 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 106 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
105 | 107 | ||
106 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 108 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
107 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 109 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
108 | // mGeneral,SLOT(setCategories(const QString &))); | 110 | // mGeneral,SLOT(setCategories(const QString &))); |
109 | 111 | ||
110 | if (KOPrefs::instance()->mCompactDialogs) { | 112 | if (KOPrefs::instance()->mCompactDialogs) { |
111 | QFrame *topFrame = addPage(i18n("General")); | 113 | QFrame *topFrame = addPage(i18n("General")); |
112 | 114 | ||
113 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 115 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
114 | if ( QApplication::desktop()->width() < 480 ) { | 116 | if ( QApplication::desktop()->width() < 480 ) { |
115 | topLayout->setMargin(marginHintSmall()); | 117 | topLayout->setMargin(marginHintSmall()); |
116 | topLayout->setSpacing(spacingHintSmall()); | 118 | topLayout->setSpacing(spacingHintSmall()); |
117 | } else { | 119 | } else { |
118 | topLayout->setMargin(marginHint()); | 120 | topLayout->setMargin(marginHint()); |
119 | topLayout->setSpacing(spacingHint()); | 121 | topLayout->setSpacing(spacingHint()); |
120 | } | 122 | } |
121 | mGeneral->initHeader(topFrame,topLayout); | 123 | mGeneral->initHeader(topFrame,topLayout); |
122 | mGeneral->initTime(topFrame,topLayout); | 124 | mGeneral->initTime(topFrame,topLayout); |
123 | mGeneral->initAlarm(topFrame,topLayout); | 125 | mGeneral->initAlarm(topFrame,topLayout); |
124 | mGeneral->enableAlarm( false ); | 126 | mGeneral->enableAlarm( false ); |
125 | 127 | ||
126 | 128 | ||
127 | QBoxLayout *priorityLayout; | 129 | QBoxLayout *priorityLayout; |
128 | if ( QApplication::desktop()->width() < 500 ) | 130 | if ( QApplication::desktop()->width() < 500 ) |
129 | priorityLayout = new QVBoxLayout( topLayout ); | 131 | priorityLayout = new QVBoxLayout( topLayout ); |
130 | else | 132 | else |
131 | priorityLayout = new QHBoxLayout( topLayout ); | 133 | priorityLayout = new QHBoxLayout( topLayout ); |
132 | QWidget* prioWidget = new QWidget (topFrame); | 134 | QWidget* prioWidget = new QWidget (topFrame); |
133 | priorityLayout->addWidget( prioWidget ); | 135 | priorityLayout->addWidget( prioWidget ); |
134 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 136 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
135 | 137 | ||
136 | 138 | ||
137 | QIconSet icon; | 139 | QIconSet icon; |
138 | if ( QApplication::desktop()->width() < 321 ) | 140 | if ( QApplication::desktop()->width() < 321 ) |
139 | icon = SmallIcon("fileimport16"); | 141 | icon = SmallIcon("fileimport16"); |
140 | else | 142 | else |
141 | icon = SmallIcon("fileimport"); | 143 | icon = SmallIcon("fileimport"); |
142 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 144 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
143 | loadTemplate->setIconSet (icon ) ; | 145 | loadTemplate->setIconSet (icon ) ; |
144 | int size = loadTemplate->sizeHint().height(); | 146 | int size = loadTemplate->sizeHint().height(); |
145 | loadTemplate->setFixedSize( size, size ); | 147 | loadTemplate->setFixedSize( size, size ); |
146 | if ( QApplication::desktop()->width() < 321 ) | 148 | if ( QApplication::desktop()->width() < 321 ) |
147 | icon = SmallIcon("fileexport16"); | 149 | icon = SmallIcon("fileexport16"); |
148 | else | 150 | else |
149 | icon = SmallIcon("fileexport"); | 151 | icon = SmallIcon("fileexport"); |
150 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 152 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
151 | saveTemplate->setIconSet (icon ) ; | 153 | saveTemplate->setIconSet (icon ) ; |
152 | saveTemplate->setFixedSize( size, size ); | 154 | saveTemplate->setFixedSize( size, size ); |
153 | 155 | ||
154 | priorityLayout2->addWidget(loadTemplate); | 156 | priorityLayout2->addWidget(loadTemplate); |
155 | priorityLayout2->addWidget(saveTemplate); | 157 | priorityLayout2->addWidget(saveTemplate); |
156 | mGeneral->initPriority(prioWidget,priorityLayout2); | 158 | mGeneral->initPriority(prioWidget,priorityLayout2); |
157 | mGeneral->initCategories( topFrame, priorityLayout ); | 159 | mGeneral->initCategories( topFrame, priorityLayout ); |
158 | topLayout->addStretch(1); | 160 | topLayout->addStretch(1); |
159 | 161 | ||
160 | QFrame *topFrame2 = addPage(i18n("Details")); | 162 | QFrame *topFrame2 = addPage(i18n("Details")); |
161 | 163 | ||
162 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 164 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
163 | topLayout2->setMargin(marginHint()); | 165 | topLayout2->setMargin(marginHint()); |
164 | topLayout2->setSpacing(spacingHint()); | 166 | topLayout2->setSpacing(spacingHint()); |
165 | 167 | ||
166 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 168 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
167 | mGeneral->initCompletion(topFrame2,completionLayout); | 169 | mGeneral->initCompletion(topFrame2,completionLayout); |
168 | 170 | ||
169 | 171 | ||
170 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 172 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
171 | mGeneral->initDescription(topFrame2,topLayout2); | 173 | mGeneral->initDescription(topFrame2,topLayout2); |
172 | 174 | ||
173 | // QHBox * hb = new QHBox ( topFrame2 ); | 175 | // QHBox * hb = new QHBox ( topFrame2 ); |
174 | // topLayout2->addWidget(hb); | 176 | // topLayout2->addWidget(hb); |
175 | // hb->setSpacing( 3 ); | 177 | // hb->setSpacing( 3 ); |
176 | 178 | ||
177 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 179 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
178 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 180 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
179 | 181 | ||
180 | } else { | 182 | } else { |
181 | QFrame *topFrame = addPage(i18n("General")); | 183 | QFrame *topFrame = addPage(i18n("General")); |
182 | 184 | ||
183 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 185 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
184 | topLayout->setSpacing(spacingHint()); | 186 | topLayout->setSpacing(spacingHint()); |
185 | 187 | ||
186 | mGeneral->initHeader(topFrame,topLayout); | 188 | mGeneral->initHeader(topFrame,topLayout); |
187 | mGeneral->initTime(topFrame,topLayout); | 189 | mGeneral->initTime(topFrame,topLayout); |
188 | mGeneral->initStatus(topFrame,topLayout); | 190 | mGeneral->initStatus(topFrame,topLayout); |
189 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 191 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
190 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 192 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
191 | mGeneral->initDescription(topFrame,topLayout); | 193 | mGeneral->initDescription(topFrame,topLayout); |
192 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 194 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
193 | mGeneral->initCategories( topFrame, detailsLayout ); | 195 | mGeneral->initCategories( topFrame, detailsLayout ); |
194 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 196 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
195 | } | 197 | } |
196 | mGeneral->finishSetup(); | 198 | mGeneral->finishSetup(); |
197 | 199 | ||
198 | } | 200 | } |
199 | 201 | ||
200 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 202 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
201 | { | 203 | { |
202 | //init(); | 204 | //init(); |
203 | 205 | ||
204 | mTodo = todo; | 206 | mTodo = todo; |
205 | readTodo(mTodo); | 207 | readTodo(mTodo); |
206 | if ( editDescription ) { | 208 | if ( editDescription ) { |
207 | showPage( 1 ); | 209 | showPage( 1 ); |
208 | mGeneral->setFocusOn( 1 ); | 210 | mGeneral->setFocusOn( 1 ); |
209 | } else { | 211 | } else { |
210 | showPage( 0 ); | 212 | showPage( 0 ); |
211 | mGeneral->setFocusOn( 2 ); | 213 | mGeneral->setFocusOn( 2 ); |
212 | } | 214 | } |
213 | checkRecurrence(); | 215 | checkRecurrence(); |
214 | } | 216 | } |
215 | 217 | ||
216 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 218 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
217 | { | 219 | { |
218 | //init(); | 220 | //init(); |
219 | 221 | ||
220 | mTodo = 0; | 222 | mTodo = 0; |
221 | setDefaults(due,relatedTodo,allDay); | 223 | setDefaults(due,relatedTodo,allDay); |
222 | } | 224 | } |
223 | 225 | ||
224 | void KOTodoEditor::loadDefaults() | 226 | void KOTodoEditor::loadDefaults() |
225 | { | 227 | { |
226 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 228 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
227 | } | 229 | } |
228 | 230 | ||
229 | bool KOTodoEditor::processInput( bool emitTime ) | 231 | bool KOTodoEditor::processInput( bool emitTime ) |
230 | { | 232 | { |
231 | if (!validateInput()) return false; | 233 | if (!validateInput()) return false; |
232 | 234 | ||
233 | Todo *todo = 0; | 235 | Todo *todo = 0; |
234 | 236 | ||
235 | if (mTodo) todo = mTodo; | 237 | if (mTodo) todo = mTodo; |
236 | else { | 238 | else { |
237 | todo = new Todo; | 239 | todo = new Todo; |
238 | todo->setOrganizer(KOPrefs::instance()->email()); | 240 | todo->setOrganizer(KOPrefs::instance()->email()); |
239 | } | 241 | } |
240 | 242 | ||
241 | writeTodo(todo); | 243 | writeTodo(todo); |
242 | if ( emitTime ) { | 244 | if ( emitTime ) { |
243 | globalFlagBlockAgenda = 1; | 245 | globalFlagBlockAgenda = 1; |
244 | emit showAgendaView( false ); | 246 | emit showAgendaView( false ); |
245 | if ( todo->hasDueDate() ) | 247 | if ( todo->hasDueDate() ) |
246 | emit jumpToTime( todo->dtDue().date() ); | 248 | emit jumpToTime( todo->dtDue().date() ); |
247 | globalFlagBlockAgenda = 2; | 249 | globalFlagBlockAgenda = 2; |
248 | } | 250 | } |
249 | if (mTodo) { | 251 | if (mTodo) { |
250 | todo->setRevision(todo->revision()+1); | 252 | todo->setRevision(todo->revision()+1); |
251 | emit todoChanged(todo); | 253 | emit todoChanged(todo); |
252 | } else { | 254 | } else { |
253 | mCalendar->addTodo(todo); | 255 | mCalendar->addTodo(todo); |
254 | mTodo = todo; | 256 | mTodo = todo; |
255 | emit todoAdded(todo); | 257 | emit todoAdded(todo); |
256 | } | 258 | } |
257 | 259 | ||
258 | return true; | 260 | return true; |
259 | } | 261 | } |
260 | 262 | ||
261 | void KOTodoEditor::deleteTodo() | 263 | void KOTodoEditor::deleteTodo() |
262 | { | 264 | { |
263 | if (mTodo) { | 265 | if (mTodo) { |
264 | if (KOPrefs::instance()->mConfirm) { | 266 | if (KOPrefs::instance()->mConfirm) { |
265 | switch (msgItemDelete()) { | 267 | switch (msgItemDelete()) { |
266 | case KMessageBox::Continue: // OK | 268 | case KMessageBox::Continue: // OK |
267 | emit todoToBeDeleted(mTodo); | 269 | emit todoToBeDeleted(mTodo); |
268 | emit dialogClose(mTodo); | 270 | emit dialogClose(mTodo); |
269 | mCalendar->deleteTodo(mTodo); | 271 | mCalendar->deleteTodo(mTodo); |
270 | emit todoDeleted(); | 272 | emit todoDeleted(); |
271 | reject(); | 273 | reject(); |
272 | break; | 274 | break; |
273 | } | 275 | } |
274 | } | 276 | } |
275 | else { | 277 | else { |
276 | emit todoToBeDeleted(mTodo); | 278 | emit todoToBeDeleted(mTodo); |
277 | emit dialogClose(mTodo); | 279 | emit dialogClose(mTodo); |
278 | mCalendar->deleteTodo(mTodo); | 280 | mCalendar->deleteTodo(mTodo); |
279 | emit todoDeleted(); | 281 | emit todoDeleted(); |
280 | reject(); | 282 | reject(); |
281 | } | 283 | } |
282 | } else { | 284 | } else { |
283 | reject(); | 285 | reject(); |
284 | } | 286 | } |
285 | } | 287 | } |
286 | 288 | ||
287 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 289 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
288 | { | 290 | { |
289 | mRelatedTodo = relatedEvent; | 291 | mRelatedTodo = relatedEvent; |
290 | 292 | ||
291 | mGeneral->setDefaults(due,allDay); | 293 | mGeneral->setDefaults(due,allDay); |
292 | mDetails->setDefaults(); | 294 | mDetails->setDefaults(); |
293 | showPage( 0 ); | 295 | showPage( 0 ); |
294 | if ( mRelatedTodo ) { | 296 | if ( mRelatedTodo ) { |
295 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 297 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
296 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 298 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
297 | if ( mRelatedTodo->priority() < 3 ) | 299 | if ( mRelatedTodo->priority() < 3 ) |
298 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 300 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
299 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 301 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
300 | int len = mRelatedTodo->summary().length(); | 302 | int len = mRelatedTodo->summary().length(); |
301 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 303 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
302 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 304 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
303 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 305 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
304 | 306 | ||
305 | } else | 307 | } else |
306 | mGeneral->setFocusOn( 2 ); | 308 | mGeneral->setFocusOn( 2 ); |
307 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 309 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
308 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 310 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
309 | } | 311 | } |
310 | void KOTodoEditor::checkRecurrence() | 312 | void KOTodoEditor::checkRecurrence() |
311 | { | 313 | { |
312 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 314 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
313 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 315 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
314 | 316 | ||
315 | if ( mTodo ) | 317 | if ( mTodo ) |
316 | mRecurrence->readEvent( mTodo ); | 318 | mRecurrence->readEvent( mTodo ); |
317 | else { | 319 | else { |
318 | bool time = mGeneral->mTimeButton->isChecked(); | 320 | bool time = mGeneral->mTimeButton->isChecked(); |
319 | QDateTime from,to; | 321 | QDateTime from,to; |
320 | if ( time ) { | 322 | if ( time ) { |
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 323 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 324 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
323 | } else { | 325 | } else { |
324 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 326 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
325 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 327 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
326 | } | 328 | } |
327 | if ( to < from ) | 329 | if ( to < from ) |
328 | to = from; | 330 | to = from; |
329 | mRecurrence->setDefaults(from,to,!time); | 331 | mRecurrence->setDefaults(from,to); |
330 | } | 332 | } |
331 | } else { | 333 | } else { |
332 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 334 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
333 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 335 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
334 | } | 336 | } |
335 | } | 337 | } |
336 | void KOTodoEditor::readTodo(Todo *todo) | 338 | void KOTodoEditor::readTodo(Todo *todo) |
337 | { | 339 | { |
338 | mGeneral->readTodo(todo); | 340 | mGeneral->readTodo(todo); |
339 | mDetails->readEvent(todo); | 341 | mDetails->readEvent(todo); |
340 | mRelatedTodo = 0;//todo->relatedTo(); | 342 | mRelatedTodo = 0;//todo->relatedTo(); |
341 | // categories | 343 | // categories |
342 | // mCategoryDialog->setSelected(todo->categories()); | 344 | // mCategoryDialog->setSelected(todo->categories()); |
343 | 345 | ||
344 | // We should handle read-only events here. | 346 | // We should handle read-only events here. |
345 | } | 347 | } |
346 | 348 | ||
347 | void KOTodoEditor::writeTodo(Todo *event) | 349 | void KOTodoEditor::writeTodo(Todo *event) |
348 | { | 350 | { |
349 | bool maybeComputeRecurrenceTime = false; | 351 | bool maybeComputeRecurrenceTime = false; |
350 | if( event->hasRecurrenceID() && event->percentComplete() < 100) | 352 | if( event->hasRecurrenceID() && event->percentComplete() < 100) |
351 | maybeComputeRecurrenceTime = true; | 353 | maybeComputeRecurrenceTime = true; |
352 | event->setHasRecurrenceID( false ); | 354 | event->setHasRecurrenceID( false ); |
353 | mGeneral->writeTodo(event); | 355 | mGeneral->writeTodo(event); |
354 | mDetails->writeEvent(event); | 356 | mDetails->writeEvent(event); |
355 | 357 | ||
356 | // set related event, i.e. parent to-do in this case. | 358 | // set related event, i.e. parent to-do in this case. |
357 | if (mRelatedTodo) { | 359 | if (mRelatedTodo) { |
358 | event->setRelatedTo(mRelatedTodo); | 360 | event->setRelatedTo(mRelatedTodo); |
359 | } | 361 | } |
360 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 362 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
361 | mRecurrence->writeEvent(event); | 363 | mRecurrence->writeEvent(event); |
362 | if ( event->doesRecur() ) { | 364 | if ( event->doesRecur() ) { |
363 | int addSec = -1 ; | 365 | int addSec = -1 ; |
364 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) | 366 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) |
365 | addSec = 1; | 367 | addSec = 1; |
366 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); | 368 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); |
367 | event->setRecurDates(); | 369 | event->setRecurDates(); |
368 | } else { | 370 | } else { |
369 | event->setHasRecurrenceID( false ); | 371 | event->setHasRecurrenceID( false ); |
370 | } | 372 | } |
371 | } else { | 373 | } else { |
372 | event->setHasRecurrenceID( false ); | 374 | event->setHasRecurrenceID( false ); |
373 | event->recurrence()->unsetRecurs(); | 375 | event->recurrence()->unsetRecurs(); |
374 | } | 376 | } |
375 | } | 377 | } |
376 | 378 | ||
377 | bool KOTodoEditor::validateInput() | 379 | bool KOTodoEditor::validateInput() |
378 | { | 380 | { |
379 | if (!mGeneral->validateInput()) return false; | 381 | if (!mGeneral->validateInput()) return false; |
380 | if (!mDetails->validateInput()) return false; | 382 | if (!mDetails->validateInput()) return false; |
381 | return true; | 383 | return true; |
382 | } | 384 | } |
383 | 385 | ||
384 | int KOTodoEditor::msgItemDelete() | 386 | int KOTodoEditor::msgItemDelete() |
385 | { | 387 | { |
386 | return KMessageBox::warningContinueCancel(this, | 388 | return KMessageBox::warningContinueCancel(this, |
387 | i18n("This item will be permanently deleted."), | 389 | i18n("This item will be permanently deleted."), |
388 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 390 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
389 | } | 391 | } |
390 | 392 | ||
391 | void KOTodoEditor::modified (int modification) | 393 | void KOTodoEditor::modified (int modification) |
392 | { | 394 | { |
393 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 395 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
394 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 396 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
395 | // mCategoryDialog->setSelected (mTodo->categories ()); | 397 | // mCategoryDialog->setSelected (mTodo->categories ()); |
396 | mGeneral->modified (mTodo, modification); | 398 | mGeneral->modified (mTodo, modification); |
397 | 399 | ||
398 | } | 400 | } |
399 | 401 | ||
400 | void KOTodoEditor::slotLoadTemplate() | 402 | void KOTodoEditor::slotLoadTemplate() |
401 | { | 403 | { |
402 | 404 | ||
403 | QString fileName =locateLocal( "templates", "todos" ); | 405 | QString fileName =locateLocal( "templates", "todos" ); |
404 | QDir t_dir; | 406 | QDir t_dir; |
405 | if ( !t_dir.exists(fileName) ) | 407 | if ( !t_dir.exists(fileName) ) |
406 | t_dir.mkdir ( fileName ); | 408 | t_dir.mkdir ( fileName ); |
407 | fileName += "/todo"; | 409 | fileName += "/todo"; |
408 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 410 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
409 | if ( fileName.length() == 0 ) | 411 | if ( fileName.length() == 0 ) |
410 | return; | 412 | return; |
411 | CalendarLocal cal; | 413 | CalendarLocal cal; |
412 | ICalFormat format; | 414 | ICalFormat format; |
413 | if ( !format.load( &cal, fileName ) ) { | 415 | if ( !format.load( &cal, fileName ) ) { |
414 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 416 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
415 | .arg( fileName ) ); | 417 | .arg( fileName ) ); |
416 | return ; | 418 | return ; |
417 | } | 419 | } |
418 | QPtrList<Todo> todos = cal.todos(); | 420 | QPtrList<Todo> todos = cal.todos(); |
419 | Todo * todo = todos.first(); | 421 | Todo * todo = todos.first(); |
420 | if ( !todo ) { | 422 | if ( !todo ) { |
421 | KMessageBox::error( this, | 423 | KMessageBox::error( this, |
422 | i18n("Template does not\ncontain a valid Todo.")); | 424 | i18n("Template does not\ncontain a valid Todo.")); |
423 | } else { | 425 | } else { |
424 | readTodo( todo ); | 426 | readTodo( todo ); |
425 | } | 427 | } |
426 | 428 | ||
427 | } | 429 | } |
428 | 430 | ||
429 | void KOTodoEditor::slotSaveTemplate() | 431 | void KOTodoEditor::slotSaveTemplate() |
430 | { | 432 | { |
431 | QString fileName =locateLocal( "templates", "todos" ); | 433 | QString fileName =locateLocal( "templates", "todos" ); |
432 | QDir t_dir; | 434 | QDir t_dir; |
433 | if ( !t_dir.exists(fileName) ) | 435 | if ( !t_dir.exists(fileName) ) |
434 | t_dir.mkdir ( fileName ); | 436 | t_dir.mkdir ( fileName ); |
435 | fileName += "/todo"; | 437 | fileName += "/todo"; |
436 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 438 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
437 | if ( fileName.length() > 0 ) | 439 | if ( fileName.length() > 0 ) |
438 | saveTemplate( fileName ); | 440 | saveTemplate( fileName ); |
439 | } | 441 | } |
440 | 442 | ||
441 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 443 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
442 | { | 444 | { |
443 | Todo *todo = new Todo; | 445 | Todo *todo = new Todo; |
444 | writeTodo( todo ); | 446 | writeTodo( todo ); |
445 | saveAsTemplate( todo, templateName ); | 447 | saveAsTemplate( todo, templateName ); |
446 | } | 448 | } |