summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt4
-rw-r--r--korganizer/komonthview.cpp2
-rw-r--r--korganizer/kotodoviewitem.cpp26
-rw-r--r--korganizer/mainwindow.cpp11
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/todo.cpp32
-rw-r--r--libkcal/todo.h12
7 files changed, 69 insertions, 20 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 14dcdac..9ba4f3e 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,276 +1,278 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.3 ************ 3********** VERSION 2.0.3 ************
4 4
5KO/Pi: 5KO/Pi:
6Added feature for changing alarm settings for many items at once: 6Added feature for changing alarm settings for many items at once:
7Open list view (or search dialog), select the desired items and choose in 7Open list view (or search dialog), select the desired items and choose in
8the popup menu: Set alarm for selected... 8the popup menu: Set alarm for selected...
9 9
10Added to the event/todo viewer the option to send an email to 10Added to the event/todo viewer the option to send an email to
11all attendees or all selected (with RSVP) attendees. 11all attendees or all selected (with RSVP) attendees.
12 12
13Made the week-month mode changing in month view faster. 13Made the week-month mode changing in month view faster.
14 14
15Made month view better useable with keyboard. 15Made month view better useable with keyboard.
16Now TAB key jumps to next cell with an event/todo. 16Now TAB key jumps to next cell with an event/todo.
17Scroll in cell with coursor keys, scroll in time (next week) with 17Scroll in cell with coursor keys, scroll in time (next week) with
18Shift/Control + coursorkeys. 18Shift/Control + coursorkeys.
19 19
20Fixeg bug that the todo view flat mode was reset after first view update. 20Fixed bug that the todo view flat mode was reset after first view update.
21
22If a todo is displayed closed in the todo view, it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties.
21 23
22********** VERSION 2.0.2 ************ 24********** VERSION 2.0.2 ************
23 25
24KO/Pi: 26KO/Pi:
25Fixed the layout problem of the day label buttons 27Fixed the layout problem of the day label buttons
26of the agenda view introduced in version 2.0.1. 28of the agenda view introduced in version 2.0.1.
27 29
28Added WhatsThis support for the todo view and the list view. 30Added WhatsThis support for the todo view and the list view.
29 31
30Added a quite useful feature to the montview. 32Added a quite useful feature to the montview.
31Just click on the week numbers on the left. 33Just click on the week numbers on the left.
32And in the top right corner of month view/agenda view 34And in the top right corner of month view/agenda view
33there is now a "week number quick selector". 35there is now a "week number quick selector".
34(Click on the black triangle). 36(Click on the black triangle).
35 37
36Made the quite difficult timezone change in KO/Pi easy. 38Made the quite difficult timezone change in KO/Pi easy.
37 39
38OM/Pi: 40OM/Pi:
39Fixed too small icons on desktop. 41Fixed too small icons on desktop.
40Fixed non visible icons in mainwindow on Z with fastload enabled. 42Fixed non visible icons in mainwindow on Z with fastload enabled.
41Added signature file setting to smtp account config. 43Added signature file setting to smtp account config.
42And the signature can be edited and saved in the edit mail dialog. 44And the signature can be edited and saved in the edit mail dialog.
43That does mean: 45That does mean:
44Simply edit the signature for the selected smtp account in the 46Simply edit the signature for the selected smtp account in the
45edit new mail dialog and press the "save signature" button there. 47edit new mail dialog and press the "save signature" button there.
46Then the signature is saved to the file specified in the smtp account settings. 48Then the signature is saved to the file specified in the smtp account settings.
47If there is no file specified, it is saved automatically to the file 49If there is no file specified, it is saved automatically to the file
48kdepim/apps/kopiemail/<accountname>.sig. 50kdepim/apps/kopiemail/<accountname>.sig.
49 51
50 52
51 53
52********** VERSION 2.0.1 ************ 54********** VERSION 2.0.1 ************
53 55
54Oooops ... I forgot to test on the Zaurus 5500 ... 56Oooops ... I forgot to test on the Zaurus 5500 ...
55 57
56Fixed many problems of new (english) strings (and german translations) 58Fixed many problems of new (english) strings (and german translations)
57introduced in the latest versions, where the text was not fitting on the 59introduced in the latest versions, where the text was not fitting on the
58240x320 display of the Zaurus 5500. 60240x320 display of the Zaurus 5500.
59 61
60KO/Pi: 62KO/Pi:
61Added a popup menu ( press pen and hold to get popup ) to the agenda view 63Added a popup menu ( press pen and hold to get popup ) to the agenda view
62with many useful items (add event/todo, show next week, two weeks, month, journal). 64with many useful items (add event/todo, show next week, two weeks, month, journal).
63 65
64Added items to the todolist popup menu for: 66Added items to the todolist popup menu for:
65Display all opened, all closed or all todos flat. 67Display all opened, all closed or all todos flat.
66The "flat" view makes is possible to sort all todos after ,e.g., prio or date. 68The "flat" view makes is possible to sort all todos after ,e.g., prio or date.
67Made the reparenting of todos on the desktop possible via Drag&Drop. 69Made the reparenting of todos on the desktop possible via Drag&Drop.
68Fixed several bugs in setting the completed datetime for todos. 70Fixed several bugs in setting the completed datetime for todos.
69Added info about completed datetime of todos to the todo viewer. 71Added info about completed datetime of todos to the todo viewer.
70Now displaying a completed todo (with completed datetime set) in the agenda view 72Now displaying a completed todo (with completed datetime set) in the agenda view
71at the time of the completion. Such that now it is possible to see in the agenda view 73at the time of the completion. Such that now it is possible to see in the agenda view
72when what todo was completed. 74when what todo was completed.
73Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. 75Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos.
74Now the behaviour is: 76Now the behaviour is:
75Setting a parent to complete sets all (sub)childs to complete. 77Setting a parent to complete sets all (sub)childs to complete.
76Setting a parent to uncomplete does not change the childs. 78Setting a parent to uncomplete does not change the childs.
77Setting a child to uncomplete sets all parent to uncomplete. 79Setting a child to uncomplete sets all parent to uncomplete.
78Setting a child to complete does not change the parents. 80Setting a child to complete does not change the parents.
79 81
80Smart updating and double buffering of the daymatrix. 82Smart updating and double buffering of the daymatrix.
81Showing holidays in the day matrix. 83Showing holidays in the day matrix.
82Many other small performance updates. 84Many other small performance updates.
83 85
84Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode. 86Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode.
85 87
86Now the translation file usertranslation.txt is supposed to be in utf8 format. 88Now the translation file usertranslation.txt is supposed to be in utf8 format.
87If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu. 89If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu.
88 90
89 91
90********** VERSION 2.0.0 ************ 92********** VERSION 2.0.0 ************
91 93
92Stable release 2.0.0! 94Stable release 2.0.0!
93 95
94KO/Pi: 96KO/Pi:
95Fixed problem in edit dialog recreation at startup. 97Fixed problem in edit dialog recreation at startup.
96Made "toggle view*" menu items enabled context sensitive. 98Made "toggle view*" menu items enabled context sensitive.
97Changed agenda size menu to items 1-10. 99Changed agenda size menu to items 1-10.
98Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. 100Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down.
99Usebility enhancements in the KO/Pi menus. 101Usebility enhancements in the KO/Pi menus.
100Birthday import now adds year to summary. 102Birthday import now adds year to summary.
101What's Next view shows age in years for birthday. 103What's Next view shows age in years for birthday.
102 104
103OM/Pi: 105OM/Pi:
104Added three info lines to display subject, from and to of selected mails. 106Added three info lines to display subject, from and to of selected mails.
105 107
106KA/Pi: 108KA/Pi:
107Fixed jump bar behaviour on Zaurus. 109Fixed jump bar behaviour on Zaurus.
108Now KA/Pi search field supports searching for a range of starting characters. 110Now KA/Pi search field supports searching for a range of starting characters.
109E.g. to search for all contact beginning with b to n, type 111E.g. to search for all contact beginning with b to n, type
110b-n 112b-n
111in the search field. 113in the search field.
112 114
113********** VERSION 1.9.20 ************ 115********** VERSION 1.9.20 ************
114 116
115KO/Pi: 117KO/Pi:
116Added for the "dislplay one day" agenda mode 118Added for the "dislplay one day" agenda mode
117info in the caption and in the day lables: 119info in the caption and in the day lables:
118Now it is displayed, if the selected day is from "day before yesterday" 120Now it is displayed, if the selected day is from "day before yesterday"
119to "day after tomorrow". 121to "day after tomorrow".
120Made it possible to delete a Todo, which has sub-todos. 122Made it possible to delete a Todo, which has sub-todos.
121Fixed two small problems in the todo view. 123Fixed two small problems in the todo view.
122Added missing German translation for filter edit and print dialog. 124Added missing German translation for filter edit and print dialog.
123Made search dialog closeable by cancel key. 125Made search dialog closeable by cancel key.
124 126
125Made it possible to select in the date picker the (ligt grey ) 127Made it possible to select in the date picker the (ligt grey )
126dates of the prev./next month with the mouse. 128dates of the prev./next month with the mouse.
127 129
128OM/Pi: 130OM/Pi:
129"Delete mail" icon in main window now deletes all selected mails. 131"Delete mail" icon in main window now deletes all selected mails.
130Fixed the problem, that the state flag of imap mails was ignored. 132Fixed the problem, that the state flag of imap mails was ignored.
131Now mails with "FLAG_SEEN" on the imap server get no icon in the list view 133Now mails with "FLAG_SEEN" on the imap server get no icon in the list view
132to indecate that they are already seen. 134to indecate that they are already seen.
133Fixed the problem that the body of some mails was not displayed in the 135Fixed the problem that the body of some mails was not displayed in the
134mail viewer when fetching them from the imap server directly to read them. 136mail viewer when fetching them from the imap server directly to read them.
135Made it (configurable) possible to show the "To:" field in the list view. 137Made it (configurable) possible to show the "To:" field in the list view.
136Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. 138Added to the mail viewer the option "View Source" to make it possible to see the raw mail data.
137Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the 139Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the
138local storage folder (specified in account settings) of the account of the mail. 140local storage folder (specified in account settings) of the account of the mail.
139Removed some memory leaks in OM/Pi. 141Removed some memory leaks in OM/Pi.
140 142
141 143
142********** VERSION 1.9.19 ************ 144********** VERSION 1.9.19 ************
143 145
144Added a lot of missing translations to KA/Pi, 146Added a lot of missing translations to KA/Pi,
145Added some missing translations to KO/Pi and OM/Pi. 147Added some missing translations to KO/Pi and OM/Pi.
146 148
147Fixed some minor problems in KA/Pi + KO/Pi. 149Fixed some minor problems in KA/Pi + KO/Pi.
148 150
149Fixed a crash when closing PwM/Pi. 151Fixed a crash when closing PwM/Pi.
150Added German translation for PwM/Pi. 152Added German translation for PwM/Pi.
151 153
152Made view change and Month View update faster in KO/Pi. 154Made view change and Month View update faster in KO/Pi.
153 155
154 156
155********** VERSION 1.9.18 ************ 157********** VERSION 1.9.18 ************
156 158
157FYI: The VERSION 1.9.17 was a testing release only. 159FYI: The VERSION 1.9.17 was a testing release only.
158Please read the changelog of VERSION 1.9.17 as well. 160Please read the changelog of VERSION 1.9.17 as well.
159 161
160Cleaned up the syncing config dialog. 162Cleaned up the syncing config dialog.
161Added sync config options for date range for events. 163Added sync config options for date range for events.
162Added sync config options for filters on incoming data. 164Added sync config options for filters on incoming data.
163Added sync config options for filters on outgoing data. 165Added sync config options for filters on outgoing data.
164Please read the updated SyncHowTo about the new filter settings. 166Please read the updated SyncHowTo about the new filter settings.
165These filter settings make it now possible to sync with shared 167These filter settings make it now possible to sync with shared
166calendars without writing back private or confidential data 168calendars without writing back private or confidential data
167(via the outgoing filters). 169(via the outgoing filters).
168To sync only with particular parts of a shared calendar, 170To sync only with particular parts of a shared calendar,
169the incoming filter settings can be used. 171the incoming filter settings can be used.
170An example can be found in the SyncHowTo. 172An example can be found in the SyncHowTo.
171Same for shared addressbooks. 173Same for shared addressbooks.
172 174
173Added a setting for the global kdepim data storage. 175Added a setting for the global kdepim data storage.
174Usually the data is stored in (yourhomedir/kdepim). 176Usually the data is stored in (yourhomedir/kdepim).
175Now you can set in the Global config dialog TAB, subTAB "Data storage path" 177Now you can set in the Global config dialog TAB, subTAB "Data storage path"
176a directory where all the kdepim data is stored. 178a directory where all the kdepim data is stored.
177That makes it easy to save all kdepim data on a SD card on the Z, for example. 179That makes it easy to save all kdepim data on a SD card on the Z, for example.
178 180
179KO/Pi: 181KO/Pi:
180The timeedit input has a pulldown list for times. 182The timeedit input has a pulldown list for times.
181If opened, this pulldown list should now has the right time highlighted. 183If opened, this pulldown list should now has the right time highlighted.
182Added the possibility to exclude events/todos/journals in a filter. 184Added the possibility to exclude events/todos/journals in a filter.
183You should exclude journals, if you do not want them to sync with a public calendar. 185You should exclude journals, if you do not want them to sync with a public calendar.
184 186
185KA/Pi: 187KA/Pi:
186Added the possibility to in/exclude public/private/confidential contacts to a filter. 188Added the possibility to in/exclude public/private/confidential contacts to a filter.
187If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ... 189If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ...
188Added printing of card view and details view on desktop. 190Added printing of card view and details view on desktop.
189Printing of list view is not working... 191Printing of list view is not working...
190Added button for removing pictures in contact editor. 192Added button for removing pictures in contact editor.
191Parsing data fix of KA/Pi version 1.9.17. 193Parsing data fix of KA/Pi version 1.9.17.
192Fixed the "parse name automatically" problem of KA/Pi version 1.9.17. 194Fixed the "parse name automatically" problem of KA/Pi version 1.9.17.
193Fixed some syncing merging problems. 195Fixed some syncing merging problems.
194 196
195 197
196********** VERSION 1.9.17 ************ 198********** VERSION 1.9.17 ************
197 199
198KO/Pi: 200KO/Pi:
199Fixed that tooltips were not updated after moving an item in agenda view. 201Fixed that tooltips were not updated after moving an item in agenda view.
200Fixed a bug in sorting start date for recurring events in list view. 202Fixed a bug in sorting start date for recurring events in list view.
201Changed the left button in todo viewer from "Agenda" to "Set completed". 203Changed the left button in todo viewer from "Agenda" to "Set completed".
202This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. 204This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View.
203Added more info in the todo viewer: Startdate, parent/sub todos. 205Added more info in the todo viewer: Startdate, parent/sub todos.
204 206
205 207
206KA/Pi: 208KA/Pi:
207All fields search does now actually search all the (possible) fields, 209All fields search does now actually search all the (possible) fields,
208not only those listed in the contact list. 210not only those listed in the contact list.
209Made is possible to inline a picture in a vcard on the Z. 211Made is possible to inline a picture in a vcard on the Z.
210This was only possible on the desktop, now is it possible on the Z as well. 212This was only possible on the desktop, now is it possible on the Z as well.
211Fixed of missing save settings after filter configuration. 213Fixed of missing save settings after filter configuration.
212Made saving of addressbook much faster. 214Made saving of addressbook much faster.
213Fixed extension widget layout problem. 215Fixed extension widget layout problem.
214Fixed saving of default formatted name settings. 216Fixed saving of default formatted name settings.
215Fixed formatted name handling in edit dialog. 217Fixed formatted name handling in edit dialog.
216Added an option for changing formatted names of many contacts 218Added an option for changing formatted names of many contacts
217(menu: File - Change - Set formatted name). 219(menu: File - Change - Set formatted name).
218 220
219QWhatsThis was not working on the Z ( only black rectangle was shown). 221QWhatsThis was not working on the Z ( only black rectangle was shown).
220This is Fixed. 222This is Fixed.
221 223
222KDE-Sync: 224KDE-Sync:
223Now readonly KDE resources are synced as well. 225Now readonly KDE resources are synced as well.
224(They are not changed in KDE itself, of course). 226(They are not changed in KDE itself, of course).
225 227
226 228
227 229
228********** VERSION 1.9.16 ************ 230********** VERSION 1.9.16 ************
229 231
230KO/Pi: 232KO/Pi:
231Fixed search dialog size on Z 6000 (480x640 display). 233Fixed search dialog size on Z 6000 (480x640 display).
232Added setting to hide/show time in agenda items. 234Added setting to hide/show time in agenda items.
233Added setting to hide not running todos in todo view. 235Added setting to hide not running todos in todo view.
234Added columns for start date/time in todo view. 236Added columns for start date/time in todo view.
235Replaced the solid half-hour lines in agenda view by dot lines. 237Replaced the solid half-hour lines in agenda view by dot lines.
236Added possibility of printing the What's Next View on the desktop 238Added possibility of printing the What's Next View on the desktop
237(i.e. Windows and Linux). 239(i.e. Windows and Linux).
238Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. 240Fixed a crash in KO/Pi when starting KO/Pi with What's Next view.
239Added tooltips in month view.(Tooltips only available on desktop) 241Added tooltips in month view.(Tooltips only available on desktop)
240 242
241Fixed a strange problem in KO/Pi alarm applet. 243Fixed a strange problem in KO/Pi alarm applet.
242Did not find the actual problem, 244Did not find the actual problem,
243such that now Qtopia reboots again if deinstalling the alarm applet. 245such that now Qtopia reboots again if deinstalling the alarm applet.
244But the alarm applet should work again. 246But the alarm applet should work again.
245 247
246KA/Pi: 248KA/Pi:
247Fixed the problem, that internal pictures were not saved. 249Fixed the problem, that internal pictures were not saved.
248 250
249Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. 251Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes.
250 252
251Fixed some minor problems. (Like word wrap in help text windows). 253Fixed some minor problems. (Like word wrap in help text windows).
252 254
253Fixed a compiling problem in microkde/kresources. 255Fixed a compiling problem in microkde/kresources.
254 256
255KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. 257KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM.
256This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) 258This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9)
257such that now syncing KO/Pi with Sharp DTM should work on the 259such that now syncing KO/Pi with Sharp DTM should work on the
258Zaurus C 3000 model. 260Zaurus C 3000 model.
259 261
260********** VERSION 1.9.15 ************ 262********** VERSION 1.9.15 ************
261 263
262Usebilty enhancements in KO/Pi: 264Usebilty enhancements in KO/Pi:
263When clicking on the date in a month view cell, the day view is shown. 265When clicking on the date in a month view cell, the day view is shown.
264Old behaviour was, that the "new event" dialog popped up. 266Old behaviour was, that the "new event" dialog popped up.
265 267
266Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). 268Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu).
267That means, you can restore the latest 269That means, you can restore the latest
268event/todo/journal you have deleted. 270event/todo/journal you have deleted.
269A journal is deleted, if you clear all the text of the journal. 271A journal is deleted, if you clear all the text of the journal.
270 272
271Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. 273Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14.
272 274
273KA/Pi starting in 480x640 resolution: 275KA/Pi starting in 480x640 resolution:
274Hide the filter action in toolbar 276Hide the filter action in toolbar
275and added icons for undo/delete/redo in toolbar. 277and added icons for undo/delete/redo in toolbar.
276 278
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 31c5659..cb519b2 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -949,513 +949,513 @@ void KOMonthView::switchView()
949 if ( clPending ) { 949 if ( clPending ) {
950 computeLayout(); 950 computeLayout();
951 updateConfig(); 951 updateConfig();
952 } 952 }
953 if ( mShowWeekView ) 953 if ( mShowWeekView )
954 mWidStack->raiseWidget( mWeekView ); 954 mWidStack->raiseWidget( mWeekView );
955 else 955 else
956 mWidStack->raiseWidget( mMonthView ); 956 mWidStack->raiseWidget( mMonthView );
957 clPending = false; 957 clPending = false;
958} 958}
959 959
960int KOMonthView::maxDatesHint() 960int KOMonthView::maxDatesHint()
961{ 961{
962 return mNumCells; 962 return mNumCells;
963} 963}
964 964
965int KOMonthView::currentDateCount() 965int KOMonthView::currentDateCount()
966{ 966{
967 return mNumCells; 967 return mNumCells;
968} 968}
969 969
970QPtrList<Incidence> KOMonthView::selectedIncidences() 970QPtrList<Incidence> KOMonthView::selectedIncidences()
971{ 971{
972 QPtrList<Incidence> selected; 972 QPtrList<Incidence> selected;
973 973
974 if ( mSelectedCell ) { 974 if ( mSelectedCell ) {
975 Incidence *incidence = mSelectedCell->selectedIncidence(); 975 Incidence *incidence = mSelectedCell->selectedIncidence();
976 if ( incidence ) selected.append( incidence ); 976 if ( incidence ) selected.append( incidence );
977 } 977 }
978 978
979 return selected; 979 return selected;
980} 980}
981 981
982DateList KOMonthView::selectedDates() 982DateList KOMonthView::selectedDates()
983{ 983{
984 DateList selected; 984 DateList selected;
985 985
986 if ( mSelectedCell ) { 986 if ( mSelectedCell ) {
987 QDate qd = mSelectedCell->selectedIncidenceDate(); 987 QDate qd = mSelectedCell->selectedIncidenceDate();
988 if ( qd.isValid() ) selected.append( qd ); 988 if ( qd.isValid() ) selected.append( qd );
989 } 989 }
990 990
991 return selected; 991 return selected;
992} 992}
993 993
994void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 994void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
995 const QDate &td) 995 const QDate &td)
996{ 996{
997#ifndef KORG_NOPRINTER 997#ifndef KORG_NOPRINTER
998 calPrinter->preview(CalPrinter::Month, fd, td); 998 calPrinter->preview(CalPrinter::Month, fd, td);
999#endif 999#endif
1000} 1000}
1001 1001
1002void KOMonthView::updateConfig() 1002void KOMonthView::updateConfig()
1003{ 1003{
1004 1004
1005 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1005 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1006 1006
1007 if ( mShowWeekView ) { 1007 if ( mShowWeekView ) {
1008 mWeekStartsMonday = true; 1008 mWeekStartsMonday = true;
1009 } 1009 }
1010 QFontMetrics fontmetric(mDayLabels[0]->font()); 1010 QFontMetrics fontmetric(mDayLabels[0]->font());
1011 mWidthLongDayLabel = 0; 1011 mWidthLongDayLabel = 0;
1012 1012
1013 for (int i = 0; i < 7; i++) { 1013 for (int i = 0; i < 7; i++) {
1014 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1014 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1015 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1015 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1016 } 1016 }
1017 bool temp = mShowSatSunComp ; 1017 bool temp = mShowSatSunComp ;
1018 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1018 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1019 if ( ! mShowWeekView ) { 1019 if ( ! mShowWeekView ) {
1020 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1020 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1021 computeLayout(); 1021 computeLayout();
1022 } 1022 }
1023 updateDayLabels(); 1023 updateDayLabels();
1024 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1024 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1025 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1025 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1026 //resizeEvent( 0 ); 1026 //resizeEvent( 0 );
1027 for (uint i = 0; i < mCells.count(); ++i) { 1027 for (uint i = 0; i < mCells.count(); ++i) {
1028 mCells[i]->updateConfig(); 1028 mCells[i]->updateConfig();
1029 } 1029 }
1030 1030
1031 for (uint i = 0; i < mCellsW.count(); ++i) { 1031 for (uint i = 0; i < mCellsW.count(); ++i) {
1032 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1032 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1033 } 1033 }
1034#ifdef DESKTOP_VERSION 1034#ifdef DESKTOP_VERSION
1035 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1035 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1036#endif 1036#endif
1037 updateView(); 1037 updateView();
1038} 1038}
1039 1039
1040void KOMonthView::updateDayLabels() 1040void KOMonthView::updateDayLabels()
1041{ 1041{
1042 1042
1043 QPtrVector<QLabel> *mDayLabelsT; 1043 QPtrVector<QLabel> *mDayLabelsT;
1044#if 0 1044#if 0
1045 if (mShowWeekView ) 1045 if (mShowWeekView )
1046 mDayLabelsT = &mDayLabelsW; 1046 mDayLabelsT = &mDayLabelsW;
1047 else 1047 else
1048 mDayLabelsT = &mDayLabels; 1048 mDayLabelsT = &mDayLabels;
1049#endif 1049#endif
1050 1050
1051 mDayLabelsT = &mDayLabelsW; 1051 mDayLabelsT = &mDayLabelsW;
1052 for (int i = 0; i < 7; i++) { 1052 for (int i = 0; i < 7; i++) {
1053 if (mWeekStartsMonday) { 1053 if (mWeekStartsMonday) {
1054 bool show = mShortDayLabels; 1054 bool show = mShortDayLabels;
1055 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1055 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1056 show = true; 1056 show = true;
1057 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1057 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1058 } else { 1058 } else {
1059 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1059 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1060 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1060 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1061 1061
1062 } 1062 }
1063 } 1063 }
1064 mDayLabelsT = &mDayLabels; 1064 mDayLabelsT = &mDayLabels;
1065 for (int i = 0; i < 7; i++) { 1065 for (int i = 0; i < 7; i++) {
1066 if (mWeekStartsMonday) { 1066 if (mWeekStartsMonday) {
1067 bool show = mShortDayLabels; 1067 bool show = mShortDayLabels;
1068 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1068 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1069 show = true; 1069 show = true;
1070 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1070 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1071 } else { 1071 } else {
1072 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1072 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1073 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1073 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1074 1074
1075 } 1075 }
1076 } 1076 }
1077 1077
1078} 1078}
1079 1079
1080void KOMonthView::showDates(const QDate &start, const QDate &) 1080void KOMonthView::showDates(const QDate &start, const QDate &)
1081{ 1081{
1082 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1082 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1083 1083
1084 QPtrVector<MonthViewCell> *cells; 1084 QPtrVector<MonthViewCell> *cells;
1085 QPtrVector<QLabel> *dayLabels; 1085 QPtrVector<QLabel> *dayLabels;
1086 QPtrVector<KOWeekButton> *weekLabels; 1086 QPtrVector<KOWeekButton> *weekLabels;
1087 int weekNum = 6; 1087 int weekNum = 6;
1088 if ( mShowWeekView ) { 1088 if ( mShowWeekView ) {
1089 weekNum = 1; 1089 weekNum = 1;
1090 cells = &mCellsW; 1090 cells = &mCellsW;
1091 dayLabels = &mDayLabelsW; 1091 dayLabels = &mDayLabelsW;
1092 weekLabels = &mWeekLabelsW; 1092 weekLabels = &mWeekLabelsW;
1093 } else { 1093 } else {
1094 cells = &mCells; 1094 cells = &mCells;
1095 dayLabels = &mDayLabels; 1095 dayLabels = &mDayLabels;
1096 weekLabels = &mWeekLabels; 1096 weekLabels = &mWeekLabels;
1097 } 1097 }
1098 1098
1099 mStartDate = start; 1099 mStartDate = start;
1100 1100
1101 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1101 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1102 1102
1103 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1103 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1104 mStartDate = mStartDate.addDays( -1 ); 1104 mStartDate = mStartDate.addDays( -1 );
1105 } 1105 }
1106 1106
1107 bool primary = false; 1107 bool primary = false;
1108 uint i; 1108 uint i;
1109 for( i = 0; i < (*cells).size(); ++i ) { 1109 for( i = 0; i < (*cells).size(); ++i ) {
1110 QDate date = mStartDate.addDays( i ); 1110 QDate date = mStartDate.addDays( i );
1111 (*cells)[i]->setDate( date ); 1111 (*cells)[i]->setDate( date );
1112 1112
1113#ifndef KORG_NOPLUGINS 1113#ifndef KORG_NOPLUGINS
1114 // add holiday, if present 1114 // add holiday, if present
1115 QString hstring(KOCore::self()->holiday(date)); 1115 QString hstring(KOCore::self()->holiday(date));
1116 (*cells)[i]->setHoliday( hstring ); 1116 (*cells)[i]->setHoliday( hstring );
1117#endif 1117#endif
1118 1118
1119 } 1119 }
1120 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1120 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1121 for( i = 0; i < weekNum; ++i ) { 1121 for( i = 0; i < weekNum; ++i ) {
1122 int wno; 1122 int wno;
1123 // remember, according to ISO 8601, the first week of the year is the 1123 // remember, according to ISO 8601, the first week of the year is the
1124 // first week that contains a thursday. Thus we must subtract off 4, 1124 // first week that contains a thursday. Thus we must subtract off 4,
1125 // not just 1. 1125 // not just 1.
1126 int dayOfYear = date.dayOfYear(); 1126 int dayOfYear = date.dayOfYear();
1127 if (dayOfYear % 7 != 0) 1127 if (dayOfYear % 7 != 0)
1128 wno = dayOfYear / 7 + 1; 1128 wno = dayOfYear / 7 + 1;
1129 else 1129 else
1130 wno =dayOfYear / 7; 1130 wno =dayOfYear / 7;
1131 (*weekLabels)[i]->setWeekNum( wno ); 1131 (*weekLabels)[i]->setWeekNum( wno );
1132 date = date.addDays( 7 ); 1132 date = date.addDays( 7 );
1133 } 1133 }
1134 updateView(); 1134 updateView();
1135} 1135}
1136 1136
1137void KOMonthView::showEvents(QPtrList<Event>) 1137void KOMonthView::showEvents(QPtrList<Event>)
1138{ 1138{
1139 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1139 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1140} 1140}
1141 1141
1142void KOMonthView::changeEventDisplay(Event *, int) 1142void KOMonthView::changeEventDisplay(Event *, int)
1143{ 1143{
1144 // this should be re-written to be much more efficient, but this 1144 // this should be re-written to be much more efficient, but this
1145 // quick-and-dirty-hack gets the job done for right now. 1145 // quick-and-dirty-hack gets the job done for right now.
1146 updateView(); 1146 updateView();
1147} 1147}
1148 1148
1149void KOMonthView::updateView() 1149void KOMonthView::updateView()
1150{ 1150{
1151 1151
1152 if ( !updatePossible ) 1152 if ( !updatePossible )
1153 return; 1153 return;
1154 //QTime ti; 1154 //QTime ti;
1155 //ti.start(); 1155 //ti.start();
1156 QPtrVector<MonthViewCell> *cells; 1156 QPtrVector<MonthViewCell> *cells;
1157 if ( mShowWeekView ) { 1157 if ( mShowWeekView ) {
1158 cells = &mCellsW; 1158 cells = &mCellsW;
1159 } else { 1159 } else {
1160 cells = &mCells; 1160 cells = &mCells;
1161 } 1161 }
1162#if 1 1162#if 1
1163 int i; 1163 int i;
1164 int timeSpan = (*cells).size()-1; 1164 int timeSpan = (*cells).size()-1;
1165 if ( KOPrefs::instance()->mMonthViewWeek ) 1165 if ( KOPrefs::instance()->mMonthViewWeek )
1166 timeSpan = 6; 1166 timeSpan = 6;
1167 for( i = 0; i < timeSpan + 1; ++i ) { 1167 for( i = 0; i < timeSpan + 1; ++i ) {
1168 (*cells)[i]->startUpdateCell(); 1168 (*cells)[i]->startUpdateCell();
1169 } 1169 }
1170 1170
1171 QPtrList<Event> events = calendar()->events(); 1171 QPtrList<Event> events = calendar()->events();
1172 Event *event; 1172 Event *event;
1173 QDateTime dt; 1173 QDateTime dt;
1174 bool ok; 1174 bool ok;
1175 QDate endDate = mStartDate.addDays( timeSpan ); 1175 QDate endDate = mStartDate.addDays( timeSpan );
1176 for( event = events.first(); event; event = events.next() ) { // for event 1176 for( event = events.first(); event; event = events.next() ) { // for event
1177 if ( event->doesRecur() ) { 1177 if ( event->doesRecur() ) {
1178 bool last; 1178 bool last;
1179 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1179 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1180 QDateTime incidenceEnd; 1180 QDateTime incidenceEnd;
1181 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1181 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1182 bool invalid = false; 1182 bool invalid = false;
1183 while( true ) { 1183 while( true ) {
1184 if ( incidenceStart.isValid() ) { 1184 if ( incidenceStart.isValid() ) {
1185 incidenceEnd = incidenceStart.addDays( eventlen ); 1185 incidenceEnd = incidenceStart.addDays( eventlen );
1186 int st = incidenceStart.date().daysTo( endDate ); 1186 int st = incidenceStart.date().daysTo( endDate );
1187 if ( st >= 0 ) { // start before timeend 1187 if ( st >= 0 ) { // start before timeend
1188 int end = mStartDate.daysTo( incidenceEnd.date() ); 1188 int end = mStartDate.daysTo( incidenceEnd.date() );
1189 if ( end >= 0 ) { // end after timestart --- got one! 1189 if ( end >= 0 ) { // end after timestart --- got one!
1190 //normalize 1190 //normalize
1191 st = timeSpan - st; 1191 st = timeSpan - st;
1192 if ( st < 0 ) st = 0; 1192 if ( st < 0 ) st = 0;
1193 if ( end > timeSpan ) end = timeSpan; 1193 if ( end > timeSpan ) end = timeSpan;
1194 int iii; 1194 int iii;
1195 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1195 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1196 for ( iii = st;iii<= end;++iii) 1196 for ( iii = st;iii<= end;++iii)
1197 (*cells)[iii]->insertEvent( event ); 1197 (*cells)[iii]->insertEvent( event );
1198 } 1198 }
1199 } 1199 }
1200 } else { 1200 } else {
1201 if ( invalid ) 1201 if ( invalid )
1202 break; 1202 break;
1203 invalid = true; 1203 invalid = true;
1204 //qDebug("invalid %s", event->summary().latin1()); 1204 //qDebug("invalid %s", event->summary().latin1());
1205 incidenceStart = QDateTime( mStartDate ); 1205 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1206 } 1206 }
1207 if ( last ) 1207 if ( last )
1208 break; 1208 break;
1209 bool ok; 1209 bool ok;
1210 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1210 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1211 if ( ! ok ) 1211 if ( ! ok )
1212 break; 1212 break;
1213 if ( incidenceStart.date() > endDate ) 1213 if ( incidenceStart.date() > endDate )
1214 break; 1214 break;
1215 } 1215 }
1216 } else { // no recur 1216 } else { // no recur
1217 int st = event->dtStart().date().daysTo( endDate ); 1217 int st = event->dtStart().date().daysTo( endDate );
1218 if ( st >= 0 ) { // start before timeend 1218 if ( st >= 0 ) { // start before timeend
1219 int end = mStartDate.daysTo( event->dtEnd().date() ); 1219 int end = mStartDate.daysTo( event->dtEnd().date() );
1220 if ( end >= 0 ) { // end after timestart --- got one! 1220 if ( end >= 0 ) { // end after timestart --- got one!
1221 //normalize 1221 //normalize
1222 st = timeSpan - st; 1222 st = timeSpan - st;
1223 if ( st < 0 ) st = 0; 1223 if ( st < 0 ) st = 0;
1224 if ( end > timeSpan ) end = timeSpan; 1224 if ( end > timeSpan ) end = timeSpan;
1225 int iii; 1225 int iii;
1226 for ( iii = st;iii<= end;++iii) 1226 for ( iii = st;iii<= end;++iii)
1227 (*cells)[iii]->insertEvent( event ); 1227 (*cells)[iii]->insertEvent( event );
1228 } 1228 }
1229 } 1229 }
1230 } 1230 }
1231 } 1231 }
1232 // insert due todos 1232 // insert due todos
1233 QPtrList<Todo> todos = calendar()->todos( ); 1233 QPtrList<Todo> todos = calendar()->todos( );
1234 Todo *todo; 1234 Todo *todo;
1235 for(todo = todos.first(); todo; todo = todos.next()) { 1235 for(todo = todos.first(); todo; todo = todos.next()) {
1236 //insertTodo( todo ); 1236 //insertTodo( todo );
1237 if ( todo->hasDueDate() ) { 1237 if ( todo->hasDueDate() ) {
1238 int day = mStartDate.daysTo( todo->dtDue().date() ); 1238 int day = mStartDate.daysTo( todo->dtDue().date() );
1239 if ( day >= 0 && day < timeSpan + 1) { 1239 if ( day >= 0 && day < timeSpan + 1) {
1240 (*cells)[day]->insertTodo( todo ); 1240 (*cells)[day]->insertTodo( todo );
1241 } 1241 }
1242 } 1242 }
1243 } 1243 }
1244 1244
1245 for( i = 0; i < timeSpan+1; ++i ) { 1245 for( i = 0; i < timeSpan+1; ++i ) {
1246 (*cells)[i]->finishUpdateCell(); 1246 (*cells)[i]->finishUpdateCell();
1247 } 1247 }
1248 processSelectionChange(); 1248 processSelectionChange();
1249 (*cells)[0]->setFocus(); 1249 (*cells)[0]->setFocus();
1250 1250
1251 1251
1252#else 1252#else
1253 // old code 1253 // old code
1254 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1254 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1255 int i; 1255 int i;
1256 for( i = 0; i < (*cells).count(); ++i ) { 1256 for( i = 0; i < (*cells).count(); ++i ) {
1257 (*cells)[i]->updateCell(); 1257 (*cells)[i]->updateCell();
1258 } 1258 }
1259 1259
1260 //qDebug("KOMonthView::updateView() "); 1260 //qDebug("KOMonthView::updateView() ");
1261 processSelectionChange(); 1261 processSelectionChange();
1262 // qDebug("---------------------------------------------------------------------+ "); 1262 // qDebug("---------------------------------------------------------------------+ ");
1263 (*cells)[0]->setFocus(); 1263 (*cells)[0]->setFocus();
1264#endif 1264#endif
1265 1265
1266 //qDebug("update time %d ", ti.elapsed()); 1266 //qDebug("update time %d ", ti.elapsed());
1267} 1267}
1268 1268
1269void KOMonthView::resizeEvent(QResizeEvent * e) 1269void KOMonthView::resizeEvent(QResizeEvent * e)
1270{ 1270{
1271 computeLayout(); 1271 computeLayout();
1272 clPending = true; 1272 clPending = true;
1273 if ( mShowWeekView ) 1273 if ( mShowWeekView )
1274 mCellsW[0]->setFocus(); 1274 mCellsW[0]->setFocus();
1275 else 1275 else
1276 mCells[0]->setFocus(); 1276 mCells[0]->setFocus();
1277} 1277}
1278void KOMonthView::computeLayoutWeek() 1278void KOMonthView::computeLayoutWeek()
1279{ 1279{
1280 1280
1281 int daysToShow; 1281 int daysToShow;
1282 bool combinedSatSun = false; 1282 bool combinedSatSun = false;
1283 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1283 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1284 daysToShow = 6; 1284 daysToShow = 6;
1285 combinedSatSun = true; 1285 combinedSatSun = true;
1286 } 1286 }
1287 int tWid = topLevelWidget()->size().width(); 1287 int tWid = topLevelWidget()->size().width();
1288 int tHei = topLevelWidget()->size().height(); 1288 int tHei = topLevelWidget()->size().height();
1289 1289
1290 int wid = size().width();//e 1290 int wid = size().width();//e
1291 int hei = size().height()-1; 1291 int hei = size().height()-1;
1292 1292
1293 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1293 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1294 return; 1294 return;
1295 1295
1296 if ( wid < hei ) 1296 if ( wid < hei )
1297 daysToShow = 2; 1297 daysToShow = 2;
1298 else 1298 else
1299 daysToShow = 3; 1299 daysToShow = 3;
1300 mShowSatSunComp = true; 1300 mShowSatSunComp = true;
1301 combinedSatSun = true; 1301 combinedSatSun = true;
1302 1302
1303 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1303 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1304 QFontMetrics fm ( mWeekLabels[0]->font() ); 1304 QFontMetrics fm ( mWeekLabels[0]->font() );
1305 int weeklabelwid = fm.width( "888" ); 1305 int weeklabelwid = fm.width( "888" );
1306 wid -= weeklabelwid; 1306 wid -= weeklabelwid;
1307 1307
1308 int colWid = wid / daysToShow; 1308 int colWid = wid / daysToShow;
1309 int lastCol = wid - ( colWid*6 ); 1309 int lastCol = wid - ( colWid*6 );
1310 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1310 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1311 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1311 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1312 int colModulo = wid % daysToShow; 1312 int colModulo = wid % daysToShow;
1313 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1313 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1314 //qDebug("rowmod %d ", rowModulo); 1314 //qDebug("rowmod %d ", rowModulo);
1315 int i; 1315 int i;
1316 int x,y,w,h; 1316 int x,y,w,h;
1317 x= 0; 1317 x= 0;
1318 y= 0; 1318 y= 0;
1319 w = colWid; 1319 w = colWid;
1320 h = dayLabelHei ; 1320 h = dayLabelHei ;
1321 for ( i = 0; i < 7; i++) { 1321 for ( i = 0; i < 7; i++) {
1322 if ( i && !( i % daysToShow) && i < 6) { 1322 if ( i && !( i % daysToShow) && i < 6) {
1323 y += hei/(5-daysToShow); 1323 y += hei/(5-daysToShow);
1324 x = 0; 1324 x = 0;
1325 w = colWid; 1325 w = colWid;
1326 } 1326 }
1327 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1327 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1328 ++w; 1328 ++w;
1329 } 1329 }
1330 if ( i >= 5 ) { 1330 if ( i >= 5 ) {
1331 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1331 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1332 x -= (w/2 ); 1332 x -= (w/2 );
1333 } 1333 }
1334 else 1334 else
1335 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1335 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1336 x += w; 1336 x += w;
1337 } 1337 }
1338 x= 0; 1338 x= 0;
1339 y= dayLabelHei; 1339 y= dayLabelHei;
1340 w = colWid; 1340 w = colWid;
1341 h = cellHei; 1341 h = cellHei;
1342 for ( i = 0; i < mCellsW.count(); ++i) { 1342 for ( i = 0; i < mCellsW.count(); ++i) {
1343 if ( i > 6 ) { 1343 if ( i > 6 ) {
1344 mCellsW[i]->hide(); 1344 mCellsW[i]->hide();
1345 continue; 1345 continue;
1346 } 1346 }
1347 1347
1348 w = colWid; 1348 w = colWid;
1349 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1349 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1350 ++w; 1350 ++w;
1351 } 1351 }
1352 if ( i == (daysToShow-1-rowModulo)*7) 1352 if ( i == (daysToShow-1-rowModulo)*7)
1353 ++h; 1353 ++h;
1354 1354
1355 if ( i >= 5 ) { 1355 if ( i >= 5 ) {
1356 if ( i ==5 ) { 1356 if ( i ==5 ) {
1357 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1357 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1358 x -= w ;y += h/2; 1358 x -= w ;y += h/2;
1359 } else { 1359 } else {
1360 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1360 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1361 ++w; 1361 ++w;
1362 } 1362 }
1363 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1363 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1364 y -= h/2; 1364 y -= h/2;
1365 } 1365 }
1366 } else 1366 } else
1367 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1367 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1368 1368
1369 1369
1370 x += w; 1370 x += w;
1371 if ( x + w/2 > wid ) { 1371 if ( x + w/2 > wid ) {
1372 x = 0; 1372 x = 0;
1373 y += h+dayLabelHei ; 1373 y += h+dayLabelHei ;
1374 } 1374 }
1375 } 1375 }
1376 y= dayLabelHei; 1376 y= dayLabelHei;
1377 h = cellHei ; 1377 h = cellHei ;
1378 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1378 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1379 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1379 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1380 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1380 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1381 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1381 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1382 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; 1382 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
1383 updateDayLabels(); 1383 updateDayLabels();
1384 bool forceUpdate = !updatePossible; 1384 bool forceUpdate = !updatePossible;
1385 updatePossible = true; 1385 updatePossible = true;
1386 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1386 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1387 if ( forceUpdate ) 1387 if ( forceUpdate )
1388 updateView(); 1388 updateView();
1389} 1389}
1390void KOMonthView::computeLayout() 1390void KOMonthView::computeLayout()
1391{ 1391{
1392 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1392 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1393 // note this only changes the text if the requested size crosses the 1393 // note this only changes the text if the requested size crosses the
1394 // threshold between big enough to support the full name and not big 1394 // threshold between big enough to support the full name and not big
1395 // enough. 1395 // enough.
1396 if ( mShowWeekView ){ 1396 if ( mShowWeekView ){
1397 computeLayoutWeek(); 1397 computeLayoutWeek();
1398 return; 1398 return;
1399 } 1399 }
1400 int daysToShow = 7; 1400 int daysToShow = 7;
1401 bool combinedSatSun = false; 1401 bool combinedSatSun = false;
1402 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1402 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1403 daysToShow = 6; 1403 daysToShow = 6;
1404 combinedSatSun = true; 1404 combinedSatSun = true;
1405 } 1405 }
1406 int tWid = topLevelWidget()->size().width(); 1406 int tWid = topLevelWidget()->size().width();
1407 int tHei = topLevelWidget()->size().height(); 1407 int tHei = topLevelWidget()->size().height();
1408 1408
1409 int wid = size().width();//e 1409 int wid = size().width();//e
1410 int hei = size().height()-1; 1410 int hei = size().height()-1;
1411 1411
1412 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1412 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1413 return; 1413 return;
1414 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1414 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1415 QFontMetrics fm ( mWeekLabels[0]->font() ); 1415 QFontMetrics fm ( mWeekLabels[0]->font() );
1416 int weeklabelwid = fm.width( "888" ); 1416 int weeklabelwid = fm.width( "888" );
1417 wid -= weeklabelwid; 1417 wid -= weeklabelwid;
1418 1418
1419 int colWid = wid / daysToShow; 1419 int colWid = wid / daysToShow;
1420 int lastCol = wid - ( colWid*6 ); 1420 int lastCol = wid - ( colWid*6 );
1421 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1421 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1422 int cellHei = (hei - dayLabelHei) /6; 1422 int cellHei = (hei - dayLabelHei) /6;
1423 int colModulo = wid % daysToShow; 1423 int colModulo = wid % daysToShow;
1424 int rowModulo = (hei- dayLabelHei) % 6; 1424 int rowModulo = (hei- dayLabelHei) % 6;
1425 //qDebug("rowmod %d ", rowModulo); 1425 //qDebug("rowmod %d ", rowModulo);
1426 int i; 1426 int i;
1427 int x,y,w,h; 1427 int x,y,w,h;
1428 x= 0; 1428 x= 0;
1429 y= 0; 1429 y= 0;
1430 w = colWid; 1430 w = colWid;
1431 h = dayLabelHei ; 1431 h = dayLabelHei ;
1432 for ( i = 0; i < 7; i++) { 1432 for ( i = 0; i < 7; i++) {
1433 if ( i == daysToShow-colModulo ) 1433 if ( i == daysToShow-colModulo )
1434 ++w; 1434 ++w;
1435 if ( combinedSatSun ) { 1435 if ( combinedSatSun ) {
1436 if ( i >= daysToShow-1 ) { 1436 if ( i >= daysToShow-1 ) {
1437 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1437 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1438 x -= w/2 ; 1438 x -= w/2 ;
1439 } 1439 }
1440 else 1440 else
1441 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1441 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1442 } else 1442 } else
1443 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1443 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1444 x += w; 1444 x += w;
1445 } 1445 }
1446 x= 0; 1446 x= 0;
1447 y= dayLabelHei; 1447 y= dayLabelHei;
1448 w = colWid; 1448 w = colWid;
1449 h = cellHei ; 1449 h = cellHei ;
1450 for ( i = 0; i < mCells.count(); ++i) { 1450 for ( i = 0; i < mCells.count(); ++i) {
1451 w = colWid; 1451 w = colWid;
1452 if ( ((i) % 7) >= 7-colModulo ) { 1452 if ( ((i) % 7) >= 7-colModulo ) {
1453 ++w; 1453 ++w;
1454 } 1454 }
1455 if ( i == (6-rowModulo)*7) 1455 if ( i == (6-rowModulo)*7)
1456 ++h; 1456 ++h;
1457 if ( combinedSatSun ) { 1457 if ( combinedSatSun ) {
1458 if ( (i)%7 >= daysToShow-1 ) { 1458 if ( (i)%7 >= daysToShow-1 ) {
1459 if ( (i)%7 == daysToShow-1 ) { 1459 if ( (i)%7 == daysToShow-1 ) {
1460 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1460 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1461 x -= w ;y += h/2; 1461 x -= w ;y += h/2;
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 6bdee18..78d4027 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -75,394 +75,390 @@ void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 if (isOn()!=state) { 206 if (isOn()!=state) {
207 setOn(state); 207 setOn(state);
208 //qDebug("SETON "); 208 //qDebug("SETON ");
209 return; 209 return;
210 } 210 }
211 if ( mTodo->isCompleted() == state ) { 211 if ( mTodo->isCompleted() == state ) {
212 //qDebug("STATECHANGE:nothing to do "); 212 //qDebug("STATECHANGE:nothing to do ");
213 return; 213 return;
214 } 214 }
215 QString keyd = "=="; 215 QString keyd = "==";
216 QString keyt = "=="; 216 QString keyt = "==";
217 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 217 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
218 mTodo->setCompleted(state); 218 mTodo->setCompleted(state);
219 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 219 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
220 220
221 if (mTodo->hasDueDate()) { 221 if (mTodo->hasDueDate()) {
222 setText(3, mTodo->dtDueDateStr()); 222 setText(3, mTodo->dtDueDateStr());
223 QDate d = mTodo->dtDue().date(); 223 QDate d = mTodo->dtDue().date();
224 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 224 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
225 setSortKey(3,keyd); 225 setSortKey(3,keyd);
226 if (mTodo->doesFloat()) { 226 if (mTodo->doesFloat()) {
227 setText(4,""); 227 setText(4,"");
228 } 228 }
229 else { 229 else {
230 setText(4,mTodo->dtDueTimeStr()); 230 setText(4,mTodo->dtDueTimeStr());
231 QTime t = mTodo->dtDue().time(); 231 QTime t = mTodo->dtDue().time();
232 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 232 keyt.sprintf("%02d%02d",t.hour(),t.minute());
233 setSortKey(4,keyt); 233 setSortKey(4,keyt);
234 } 234 }
235 } 235 }
236 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 236 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
237 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 237 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
238 238
239 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 239 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
240 if (mTodo->percentComplete()<100) { 240 if (mTodo->percentComplete()<100) {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(mTodo->percentComplete())); 242 else setSortKey(2,QString::number(mTodo->percentComplete()));
243 } 243 }
244 else { 244 else {
245 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 245 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
246 else setSortKey(2,QString::number(99)); 246 else setSortKey(2,QString::number(99));
247 } 247 }
248 if ( state ) { 248 if ( state ) {
249 QListViewItem * myChild = firstChild(); 249 QListViewItem * myChild = firstChild();
250 KOTodoViewItem *item; 250 KOTodoViewItem *item;
251 while( myChild ) { 251 while( myChild ) {
252 //qDebug("stateCH "); 252 //qDebug("stateCH ");
253 item = static_cast<KOTodoViewItem*>(myChild); 253 item = static_cast<KOTodoViewItem*>(myChild);
254 item->stateChange(state); 254 item->stateChange(state);
255 myChild = myChild->nextSibling(); 255 myChild = myChild->nextSibling();
256 } 256 }
257 } else { 257 } else {
258 QListViewItem * myChild = parent(); 258 QListViewItem * myChild = parent();
259 if ( myChild ) 259 if ( myChild )
260 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 260 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
261 } 261 }
262 mTodoView->modified(true); 262 mTodoView->modified(true);
263 setMyPixmap(); 263 setMyPixmap();
264 mTodoView->setTodoModified( mTodo ); 264 mTodoView->setTodoModified( mTodo );
265} 265}
266 266
267bool KOTodoViewItem::isAlternate() 267bool KOTodoViewItem::isAlternate()
268{ 268{
269#ifndef KORG_NOLVALTERNATION 269#ifndef KORG_NOLVALTERNATION
270 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 270 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
271 if (lv && lv->alternateBackground().isValid()) 271 if (lv && lv->alternateBackground().isValid())
272 { 272 {
273 KOTodoViewItem *above = 0; 273 KOTodoViewItem *above = 0;
274 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 274 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
275 m_known = above ? above->m_known : true; 275 m_known = above ? above->m_known : true;
276 if (m_known) 276 if (m_known)
277 { 277 {
278 m_odd = above ? !above->m_odd : false; 278 m_odd = above ? !above->m_odd : false;
279 } 279 }
280 else 280 else
281 { 281 {
282 KOTodoViewItem *item; 282 KOTodoViewItem *item;
283 bool previous = true; 283 bool previous = true;
284 if (QListViewItem::parent()) 284 if (QListViewItem::parent())
285 { 285 {
286 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 286 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
287 if (item) 287 if (item)
288 previous = item->m_odd; 288 previous = item->m_odd;
289 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 289 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
290 } 290 }
291 else 291 else
292 { 292 {
293 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 293 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
294 } 294 }
295 295
296 while(item) 296 while(item)
297 { 297 {
298 item->m_odd = previous = !previous; 298 item->m_odd = previous = !previous;
299 item->m_known = true; 299 item->m_known = true;
300 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 300 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
301 } 301 }
302 } 302 }
303 return m_odd; 303 return m_odd;
304 } 304 }
305 return false; 305 return false;
306#else 306#else
307 return false; 307 return false;
308#endif 308#endif
309} 309}
310 310
311void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 311void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
312{ 312{
313 QColorGroup _cg = cg; 313 QColorGroup _cg = cg;
314 QColorGroup::ColorRole role; 314 QColorGroup::ColorRole role;
315 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 315 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
316 role = QColorGroup::Text; 316 role = QColorGroup::Text;
317 else 317 else
318 role = QColorGroup::Base; 318 role = QColorGroup::Base;
319 //#ifndef KORG_NOLVALTERNATION 319 //#ifndef KORG_NOLVALTERNATION
320 // if (isAlternate()) 320 // if (isAlternate())
321 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 321 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
322 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 322 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
323 QColor colorToSet; 323 QColor colorToSet;
324 if ( setColor ) { 324 if ( setColor ) {
325 QStringList categories = mTodo->categories(); 325 QStringList categories = mTodo->categories();
326 QString cat = categories.first(); 326 QString cat = categories.first();
327 if ( !cat.isEmpty()) { 327 if ( !cat.isEmpty()) {
328 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 328 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
329 } else 329 } else
330 setColor = false; 330 setColor = false;
331 } 331 }
332 if (mTodo->hasDueDate()) { 332
333 if (mTodo->dtDue().date()==QDate::currentDate() && 333 int odue = mTodo->hasDueSubTodo( !isOpen());
334 !mTodo->isCompleted()) { 334 if (odue == 2) {
335 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 335 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
336 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 336 setColor = true;
337 setColor = true; 337 } else if ( odue == 1 ) {
338 } 338 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
339 if (mTodo->dtDue().date() < QDate::currentDate() && 339 setColor = true;
340 !mTodo->isCompleted()) { 340 }
341 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 341
342 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
343 setColor = true;
344 }
345 }
346 342
347 if ( setColor ) { 343 if ( setColor ) {
348 _cg.setColor(role,colorToSet ); 344 _cg.setColor(role,colorToSet );
349 if ( role == QColorGroup::Base) { 345 if ( role == QColorGroup::Base) {
350 int rgb = colorToSet.red(); 346 int rgb = colorToSet.red();
351 rgb += colorToSet.blue()/2; 347 rgb += colorToSet.blue()/2;
352 rgb += colorToSet.green(); 348 rgb += colorToSet.green();
353 if ( rgb < 200 ) 349 if ( rgb < 200 )
354 _cg.setColor(QColorGroup::Text,Qt::white ); 350 _cg.setColor(QColorGroup::Text,Qt::white );
355 } 351 }
356 } 352 }
357 //#endif 353 //#endif
358 if ( column > 0 ){ 354 if ( column > 0 ){
359 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 355 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
360 p->save(); 356 p->save();
361 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 357 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
362 358
363 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 359 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
364 // p->setPen(Qt::black ); //border 360 // p->setPen(Qt::black ); //border
365 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 361 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
366 QColor fc = KOPrefs::instance()->mHighlightColor; 362 QColor fc = KOPrefs::instance()->mHighlightColor;
367 if ( mTodo->percentComplete() == 100 ) 363 if ( mTodo->percentComplete() == 100 )
368 fc = darkGreen; 364 fc = darkGreen;
369 p->drawRect( 2, 2, width-4, height()-4); 365 p->drawRect( 2, 2, width-4, height()-4);
370 p->fillRect( 3, 3, progress, height()-6, 366 p->fillRect( 3, 3, progress, height()-6,
371 fc ); 367 fc );
372 p->restore(); 368 p->restore();
373 } else { 369 } else {
374 QCheckListItem::paintCell(p, _cg, column, width, alignment); 370 QCheckListItem::paintCell(p, _cg, column, width, alignment);
375 } 371 }
376 return; 372 return;
377 } 373 }
378 374
379 int align = alignment; 375 int align = alignment;
380 376
381 if ( !p ) 377 if ( !p )
382 return; 378 return;
383 379
384 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 380 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
385 381
386 QListView *lv = listView(); 382 QListView *lv = listView();
387 if ( !lv ) 383 if ( !lv )
388 return; 384 return;
389 int marg = 2;//lv->itemMargin(); 385 int marg = 2;//lv->itemMargin();
390 int r = 0; 386 int r = 0;
391 QCheckListItem::Type myType = QCheckListItem::CheckBox; 387 QCheckListItem::Type myType = QCheckListItem::CheckBox;
392 int BoxSize = 20; 388 int BoxSize = 20;
393 int boxOffset = 2; 389 int boxOffset = 2;
394 int xOffset = 2; 390 int xOffset = 2;
395 if (qApp->desktop()->width() < 300 ) { 391 if (qApp->desktop()->width() < 300 ) {
396 BoxSize = 14; 392 BoxSize = 14;
397 boxOffset = -1; 393 boxOffset = -1;
398 xOffset = 1; 394 xOffset = 1;
399 // marg = 0; 395 // marg = 0;
400 } 396 }
401 if ( height() < BoxSize ) { 397 if ( height() < BoxSize ) {
402 boxOffset = boxOffset - ((BoxSize - height())/2) ; 398 boxOffset = boxOffset - ((BoxSize - height())/2) ;
403 // qDebug("boxOffset %d height %d", boxOffset, height() ); 399 // qDebug("boxOffset %d height %d", boxOffset, height() );
404 BoxSize = height(); 400 BoxSize = height();
405 401
406 } 402 }
407 //bool winStyle = lv->style() == WindowsStyle; 403 //bool winStyle = lv->style() == WindowsStyle;
408 404
409 int lineStart = 5; 405 int lineStart = 5;
410 if ( myType == Controller ) { 406 if ( myType == Controller ) {
411 if ( !pixmap( 0 ) ) 407 if ( !pixmap( 0 ) )
412 r += BoxSize + 4; 408 r += BoxSize + 4;
413 } else { 409 } else {
414 ASSERT( lv ); //### 410 ASSERT( lv ); //###
415 //QFontMetrics fm( lv->font() ); 411 //QFontMetrics fm( lv->font() );
416 //int d = fm.height(); 412 //int d = fm.height();
417 int x = 0; 413 int x = 0;
418 int y = (height() - BoxSize) / 2; 414 int y = (height() - BoxSize) / 2;
419 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 415 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
420 if ( myType == CheckBox ) { 416 if ( myType == CheckBox ) {
421 if ( isEnabled() ) 417 if ( isEnabled() )
422 p->setPen( QPen( _cg.text(), 1 ) ); 418 p->setPen( QPen( _cg.text(), 1 ) );
423 else 419 else
424 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 420 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
425 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 421 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
426 lineStart = x+marg; 422 lineStart = x+marg;
427 ///////////////////// 423 /////////////////////
428 x++; 424 x++;
429 y++; 425 y++;
430 if ( isOn() ) { 426 if ( isOn() ) {
431 QPointArray a( 7*2 ); 427 QPointArray a( 7*2 );
432 int i, xx, yy; 428 int i, xx, yy;
433 xx = x+xOffset+marg+(boxOffset/2); 429 xx = x+xOffset+marg+(boxOffset/2);
434 yy = y+5+boxOffset; 430 yy = y+5+boxOffset;
435 for ( i=0; i<3; i++ ) { 431 for ( i=0; i<3; i++ ) {
436 a.setPoint( 2*i, xx, yy ); 432 a.setPoint( 2*i, xx, yy );
437 a.setPoint( 2*i+1, xx, yy+2 ); 433 a.setPoint( 2*i+1, xx, yy+2 );
438 // qDebug(" "); 434 // qDebug(" ");
439 xx++; yy++; 435 xx++; yy++;
440 } 436 }
441 yy -= 2; 437 yy -= 2;
442 for ( i=3; i<7; i++ ) { 438 for ( i=3; i<7; i++ ) {
443 a.setPoint( 2*i, xx, yy ); 439 a.setPoint( 2*i, xx, yy );
444 a.setPoint( 2*i+1, xx, yy+2 ); 440 a.setPoint( 2*i+1, xx, yy+2 );
445 xx++; yy--; 441 xx++; yy--;
446 } 442 }
447 p->setPen( darkGreen ); 443 p->setPen( darkGreen );
448 p->drawLineSegments( a ); 444 p->drawLineSegments( a );
449 } 445 }
450 //////////////////////// 446 ////////////////////////
451 } 447 }
452 r += BoxSize + 4; 448 r += BoxSize + 4;
453 } 449 }
454 450
455 p->translate( r, 0 ); 451 p->translate( r, 0 );
456 p->setPen( QPen( _cg.text() ) ); 452 p->setPen( QPen( _cg.text() ) );
457 QListViewItem::paintCell( p, _cg, column, width - r, align ); 453 QListViewItem::paintCell( p, _cg, column, width - r, align );
458 if ( mTodo->cancelled () ) { 454 if ( mTodo->cancelled () ) {
459 p->setPen( black ); 455 p->setPen( black );
460 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 456 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
461 int wid = br.width() +lineStart; 457 int wid = br.width() +lineStart;
462 if ( wid > width-3 ) 458 if ( wid > width-3 )
463 wid = width-3; 459 wid = width-3;
464 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 460 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
465 461
466 } 462 }
467 463
468} 464}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index a2c20a8..5bc8c00 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1093,513 +1093,522 @@ void MainWindow::exportToPhone( int mode )
1093 cal->setLocalTime(); 1093 cal->setLocalTime();
1094 Incidence *incidence = delSel.first(); 1094 Incidence *incidence = delSel.first();
1095 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1095 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1096 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1096 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1097 while ( incidence ) { 1097 while ( incidence ) {
1098 if ( incidence->type() != "Journal" ) { 1098 if ( incidence->type() != "Journal" ) {
1099 bool add = true; 1099 bool add = true;
1100 if ( inFuture ) { 1100 if ( inFuture ) {
1101 QDateTime dt; 1101 QDateTime dt;
1102 if ( incidence->type() == "Todo" ) { 1102 if ( incidence->type() == "Todo" ) {
1103 Todo * t = (Todo*)incidence; 1103 Todo * t = (Todo*)incidence;
1104 if ( t->hasDueDate() ) 1104 if ( t->hasDueDate() )
1105 dt = t->dtDue(); 1105 dt = t->dtDue();
1106 else 1106 else
1107 dt = cur.addSecs( 62 ); 1107 dt = cur.addSecs( 62 );
1108 } 1108 }
1109 else { 1109 else {
1110 bool ok; 1110 bool ok;
1111 dt = incidence->getNextOccurence( cur, &ok ); 1111 dt = incidence->getNextOccurence( cur, &ok );
1112 if ( !ok ) 1112 if ( !ok )
1113 dt = cur.addSecs( -62 ); 1113 dt = cur.addSecs( -62 );
1114 } 1114 }
1115 if ( dt < cur || dt > end ) { 1115 if ( dt < cur || dt > end ) {
1116 add = false; 1116 add = false;
1117 } 1117 }
1118 } 1118 }
1119 if ( add ) { 1119 if ( add ) {
1120 Incidence *in = incidence->clone(); 1120 Incidence *in = incidence->clone();
1121 cal->addIncidence( in ); 1121 cal->addIncidence( in );
1122 } 1122 }
1123 } 1123 }
1124 incidence = delSel.next(); 1124 incidence = delSel.next();
1125 } 1125 }
1126 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1126 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1127 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1127 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1128 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1128 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1129 1129
1130 setCaption( i18n("Writing to phone...")); 1130 setCaption( i18n("Writing to phone..."));
1131 if ( PhoneFormat::writeToPhone( cal ) ) 1131 if ( PhoneFormat::writeToPhone( cal ) )
1132 setCaption( i18n("Export to phone successful!")); 1132 setCaption( i18n("Export to phone successful!"));
1133 else 1133 else
1134 setCaption( i18n("Error exporting to phone!")); 1134 setCaption( i18n("Error exporting to phone!"));
1135 delete cal; 1135 delete cal;
1136} 1136}
1137 1137
1138 1138
1139void MainWindow::setDefaultPreferences() 1139void MainWindow::setDefaultPreferences()
1140{ 1140{
1141 KOPrefs *p = KOPrefs::instance(); 1141 KOPrefs *p = KOPrefs::instance();
1142 1142
1143 p->mCompactDialogs = true; 1143 p->mCompactDialogs = true;
1144 p->mConfirm = true; 1144 p->mConfirm = true;
1145 // p->mEnableQuickTodo = false; 1145 // p->mEnableQuickTodo = false;
1146 1146
1147} 1147}
1148 1148
1149QString MainWindow::resourcePath() 1149QString MainWindow::resourcePath()
1150{ 1150{
1151 return KGlobal::iconLoader()->iconPath(); 1151 return KGlobal::iconLoader()->iconPath();
1152} 1152}
1153 1153
1154void MainWindow::displayText( QString text ,QString cap ) 1154void MainWindow::displayText( QString text ,QString cap )
1155{ 1155{
1156 QDialog dia( this, "name", true ); ; 1156 QDialog dia( this, "name", true ); ;
1157 dia.setCaption( cap ); 1157 dia.setCaption( cap );
1158 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1158 QVBoxLayout* lay = new QVBoxLayout( &dia );
1159 lay->setSpacing( 3 ); 1159 lay->setSpacing( 3 );
1160 lay->setMargin( 3 ); 1160 lay->setMargin( 3 );
1161 QTextBrowser tb ( &dia ); 1161 QTextBrowser tb ( &dia );
1162 lay->addWidget( &tb ); 1162 lay->addWidget( &tb );
1163 tb.setText( text ); 1163 tb.setText( text );
1164#ifdef DESKTOP_VERSION 1164#ifdef DESKTOP_VERSION
1165 dia.resize( 640, 480); 1165 dia.resize( 640, 480);
1166#else 1166#else
1167 dia.showMaximized(); 1167 dia.showMaximized();
1168#endif 1168#endif
1169 dia.exec(); 1169 dia.exec();
1170} 1170}
1171 1171
1172void MainWindow::features() 1172void MainWindow::features()
1173{ 1173{
1174 1174
1175 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1175 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1176} 1176}
1177 1177
1178void MainWindow::usertrans() 1178void MainWindow::usertrans()
1179{ 1179{
1180 1180
1181 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1181 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1182} 1182}
1183 1183
1184void MainWindow::kdesynchowto() 1184void MainWindow::kdesynchowto()
1185{ 1185{
1186 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1186 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1187} 1187}
1188void MainWindow::multisynchowto() 1188void MainWindow::multisynchowto()
1189{ 1189{
1190 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1190 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1191} 1191}
1192void MainWindow::synchowto() 1192void MainWindow::synchowto()
1193{ 1193{
1194 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1194 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1195} 1195}
1196void MainWindow::faq() 1196void MainWindow::faq()
1197{ 1197{
1198 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1198 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1199 1199
1200} 1200}
1201void MainWindow::whatsNew() 1201void MainWindow::whatsNew()
1202{ 1202{
1203 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1203 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1204 1204
1205} 1205}
1206void MainWindow::licence() 1206void MainWindow::licence()
1207{ 1207{
1208 KApplication::showLicence(); 1208 KApplication::showLicence();
1209 1209
1210} 1210}
1211void MainWindow::about() 1211void MainWindow::about()
1212{ 1212{
1213 QString version; 1213 QString version;
1214#include <../version> 1214#include <../version>
1215 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1215 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1216 i18n("KOrganizer/Platform-independent\n") + 1216 i18n("KOrganizer/Platform-independent\n") +
1217 "(KO/Pi) " + version + " - " + 1217 "(KO/Pi) " + version + " - " +
1218 1218
1219#ifdef DESKTOP_VERSION 1219#ifdef DESKTOP_VERSION
1220 i18n("Desktop Edition\n") + 1220 i18n("Desktop Edition\n") +
1221#else 1221#else
1222 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1222 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1223#endif 1223#endif
1224 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1224 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1225} 1225}
1226void MainWindow::keyBindings() 1226void MainWindow::keyBindings()
1227{ 1227{
1228 QString cap = i18n("KO/Pi Keys + Colors"); 1228 QString cap = i18n("KO/Pi Keys + Colors");
1229 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1229 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1230 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1230 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1231 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1231 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1232 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1232 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1233 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1233 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1234 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1234 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1235 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1235 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1236 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1236 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1237 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1237 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1238 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1238 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1239 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1239 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1240 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1240 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1241 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1241 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1242 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1242 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1243 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1243 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1244 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1244 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1245 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1245 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1246 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1246 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1247 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1247 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1248 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1248 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1249 i18n("<p><h3>In agenda view:</h3></p>\n") + 1249 i18n("<p><h3>In agenda view:</h3></p>\n") +
1250 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1250 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1251 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1251 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1252 i18n("<p><h3>In todo view:</h3></p>\n") + 1252 i18n("<p><h3>In todo view:</h3></p>\n") +
1253 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1253 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1254 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1254 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1255 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1255 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1256 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1256 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1257 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1257 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1258 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1258 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1259 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1259 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1260 i18n("<p><h3>In list view:</h3></p>\n") + 1260 i18n("<p><h3>In list view:</h3></p>\n") +
1261 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1261 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1262 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1262 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1263 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1263 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1264 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1264 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1265 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1265 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1266 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1266 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1267 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1267 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1268 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1268 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1269 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1269 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1270 i18n("<p><b>E</b>: Edit item</p>\n") + 1270 i18n("<p><b>E</b>: Edit item</p>\n") +
1271 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1271 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1272 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1272 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1273 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1273 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1274 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1274 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1275 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1275 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1276 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1276 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1277 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1277 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1278 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1278 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1279 i18n("<p><b>White</b>: Item readonly</p>\n"); 1279 i18n("<p><b>White</b>: Item readonly</p>\n");
1280 displayText( text, cap); 1280 displayText( text, cap);
1281} 1281}
1282void MainWindow::aboutAutoSaving() 1282void MainWindow::aboutAutoSaving()
1283{ 1283{
1284 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1284 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1285 1285
1286 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1286 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1287 1287
1288} 1288}
1289void MainWindow::aboutKnownBugs() 1289void MainWindow::aboutKnownBugs()
1290{ 1290{
1291 QMessageBox* msg; 1291 QMessageBox* msg;
1292 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1292 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1293 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1293 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1294 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1294 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1295 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1295 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1296 i18n("\nor report them in the bugtracker on\n") + 1296 i18n("\nor report them in the bugtracker on\n") +
1297 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1297 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1298 QMessageBox::NoIcon, 1298 QMessageBox::NoIcon,
1299 QMessageBox::Ok, 1299 QMessageBox::Ok,
1300 QMessageBox::NoButton, 1300 QMessageBox::NoButton,
1301 QMessageBox::NoButton); 1301 QMessageBox::NoButton);
1302 msg->exec(); 1302 msg->exec();
1303 delete msg; 1303 delete msg;
1304 1304
1305} 1305}
1306 1306
1307QString MainWindow::defaultFileName() 1307QString MainWindow::defaultFileName()
1308{ 1308{
1309 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1309 return locateLocal( "data", "korganizer/mycalendar.ics" );
1310} 1310}
1311QString MainWindow::syncFileName() 1311QString MainWindow::syncFileName()
1312{ 1312{
1313#ifdef DESKTOP_VERSION 1313#ifdef DESKTOP_VERSION
1314 return locateLocal( "tmp", "synccalendar.ics" ); 1314 return locateLocal( "tmp", "synccalendar.ics" );
1315#else 1315#else
1316 return QString( "/tmp/synccalendar.ics" ); 1316 return QString( "/tmp/synccalendar.ics" );
1317#endif 1317#endif
1318} 1318}
1319 1319
1320void MainWindow::processIncidenceSelection( Incidence *incidence ) 1320void MainWindow::processIncidenceSelection( Incidence *incidence )
1321{ 1321{
1322 if ( !incidence ) { 1322 if ( !incidence ) {
1323 enableIncidenceActions( false ); 1323 enableIncidenceActions( false );
1324 1324
1325 mNewSubTodoAction->setEnabled( false ); 1325 mNewSubTodoAction->setEnabled( false );
1326 setCaptionToDates(); 1326 setCaptionToDates();
1327 return; 1327 return;
1328 1328
1329 } 1329 }
1330 1330
1331 //KGlobal::locale()->formatDateTime(nextA, true); 1331 //KGlobal::locale()->formatDateTime(nextA, true);
1332 QString startString = ""; 1332 QString startString = "";
1333 if ( incidence->type() != "Todo" ) { 1333 if ( incidence->type() != "Todo" ) {
1334 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1334 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1335 if ( incidence->doesFloat() ) { 1335 if ( incidence->doesFloat() ) {
1336 startString += ": "+incidence->dtStartDateStr( true ); 1336 startString += ": "+incidence->dtStartDateStr( true );
1337 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1337 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1338 1338
1339 } else { 1339 } else {
1340 startString = ": "+incidence->dtStartStr(true); 1340 startString = ": "+incidence->dtStartStr(true);
1341 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1341 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1342 1342
1343 } 1343 }
1344 1344
1345 } else { 1345 } else {
1346 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1346 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1347 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1347 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1348 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1348 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1349 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1349 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1350 bool ok;
1351 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1352 if ( ok ) {
1353 int years = noc.date().year() - incidence->dtStart().date().year();
1354 startString += i18n(" (%1 y.)"). arg( years );
1355 }
1356 }
1357 else
1358 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1350 } 1359 }
1351 1360
1352 } 1361 }
1353 else 1362 else
1354 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1363 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1355 if ( !incidence->location().isEmpty() ) 1364 if ( !incidence->location().isEmpty() )
1356 startString += " (" +incidence->location()+")"; 1365 startString += " (" +incidence->location()+")";
1357 setCaption( incidence->summary()+startString); 1366 setCaption( incidence->summary()+startString);
1358 1367
1359 enableIncidenceActions( true ); 1368 enableIncidenceActions( true );
1360 1369
1361 if ( incidence->type() == "Event" ) { 1370 if ( incidence->type() == "Event" ) {
1362 mShowAction->setText( i18n("Show Event...") ); 1371 mShowAction->setText( i18n("Show Event...") );
1363 mEditAction->setText( i18n("Edit Event...") ); 1372 mEditAction->setText( i18n("Edit Event...") );
1364 mDeleteAction->setText( i18n("Delete Event...") ); 1373 mDeleteAction->setText( i18n("Delete Event...") );
1365 1374
1366 mNewSubTodoAction->setEnabled( false ); 1375 mNewSubTodoAction->setEnabled( false );
1367 } else if ( incidence->type() == "Todo" ) { 1376 } else if ( incidence->type() == "Todo" ) {
1368 mShowAction->setText( i18n("Show Todo...") ); 1377 mShowAction->setText( i18n("Show Todo...") );
1369 mEditAction->setText( i18n("Edit Todo...") ); 1378 mEditAction->setText( i18n("Edit Todo...") );
1370 mDeleteAction->setText( i18n("Delete Todo...") ); 1379 mDeleteAction->setText( i18n("Delete Todo...") );
1371 1380
1372 mNewSubTodoAction->setEnabled( true ); 1381 mNewSubTodoAction->setEnabled( true );
1373 } else { 1382 } else {
1374 mShowAction->setText( i18n("Show...") ); 1383 mShowAction->setText( i18n("Show...") );
1375 mShowAction->setText( i18n("Edit...") ); 1384 mShowAction->setText( i18n("Edit...") );
1376 mShowAction->setText( i18n("Delete...") ); 1385 mShowAction->setText( i18n("Delete...") );
1377 1386
1378 mNewSubTodoAction->setEnabled( false ); 1387 mNewSubTodoAction->setEnabled( false );
1379 } 1388 }
1380} 1389}
1381 1390
1382void MainWindow::enableIncidenceActions( bool enabled ) 1391void MainWindow::enableIncidenceActions( bool enabled )
1383{ 1392{
1384 mShowAction->setEnabled( enabled ); 1393 mShowAction->setEnabled( enabled );
1385 mEditAction->setEnabled( enabled ); 1394 mEditAction->setEnabled( enabled );
1386 mDeleteAction->setEnabled( enabled ); 1395 mDeleteAction->setEnabled( enabled );
1387 1396
1388 mCloneAction->setEnabled( enabled ); 1397 mCloneAction->setEnabled( enabled );
1389 mMoveAction->setEnabled( enabled ); 1398 mMoveAction->setEnabled( enabled );
1390 mBeamAction->setEnabled( enabled ); 1399 mBeamAction->setEnabled( enabled );
1391 mCancelAction->setEnabled( enabled ); 1400 mCancelAction->setEnabled( enabled );
1392} 1401}
1393 1402
1394void MainWindow::importOL() 1403void MainWindow::importOL()
1395{ 1404{
1396#ifdef _OL_IMPORT_ 1405#ifdef _OL_IMPORT_
1397 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1406 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1398 id->exec(); 1407 id->exec();
1399 delete id; 1408 delete id;
1400 mView->updateView(); 1409 mView->updateView();
1401#endif 1410#endif
1402} 1411}
1403void MainWindow::importBday() 1412void MainWindow::importBday()
1404{ 1413{
1405 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1414 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1406 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1415 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1407 i18n("Import!"), i18n("Cancel"), 0, 1416 i18n("Import!"), i18n("Cancel"), 0,
1408 0, 1 ); 1417 0, 1 );
1409 if ( result == 0 ) { 1418 if ( result == 0 ) {
1410 mView->importBday(); 1419 mView->importBday();
1411 1420
1412 } 1421 }
1413 1422
1414 1423
1415} 1424}
1416void MainWindow::importQtopia() 1425void MainWindow::importQtopia()
1417{ 1426{
1418#ifndef DESKTOP_VERSION 1427#ifndef DESKTOP_VERSION
1419 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1428 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1420 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1429 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1421 i18n("Import!"), i18n("Cancel"), 0, 1430 i18n("Import!"), i18n("Cancel"), 0,
1422 0, 1 ); 1431 0, 1 );
1423 if ( result == 0 ) { 1432 if ( result == 0 ) {
1424 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1433 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1425 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1434 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1426 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1435 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1427 mView->importQtopia( categories, datebook, todolist ); 1436 mView->importQtopia( categories, datebook, todolist );
1428 } 1437 }
1429#else 1438#else
1430 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1439 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1431 i18n("Not supported \non desktop!\n"), 1440 i18n("Not supported \non desktop!\n"),
1432 i18n("Ok"), i18n("Cancel"), 0, 1441 i18n("Ok"), i18n("Cancel"), 0,
1433 0, 1 ); 1442 0, 1 );
1434 1443
1435#endif 1444#endif
1436} 1445}
1437 1446
1438void MainWindow::saveOnClose() 1447void MainWindow::saveOnClose()
1439{ 1448{
1440 KOPrefs *p = KOPrefs::instance(); 1449 KOPrefs *p = KOPrefs::instance();
1441 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1450 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1442 p->mToolBarUp = iconToolBar->x() > width()/2 || 1451 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1443 iconToolBar->y() > height()/2; 1452 iconToolBar->y() > height()/2;
1444 mView->writeSettings(); 1453 mView->writeSettings();
1445 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1454 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1446 save(); 1455 save();
1447} 1456}
1448void MainWindow::slotModifiedChanged( bool changed ) 1457void MainWindow::slotModifiedChanged( bool changed )
1449{ 1458{
1450 if ( mBlockAtStartup ) 1459 if ( mBlockAtStartup )
1451 return; 1460 return;
1452 1461
1453 int msec; 1462 int msec;
1454 // we store the changes after 1 minute, 1463 // we store the changes after 1 minute,
1455 // and for safety reasons after 10 minutes again 1464 // and for safety reasons after 10 minutes again
1456 if ( !mSyncManager->blockSave() ) 1465 if ( !mSyncManager->blockSave() )
1457 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1466 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1458 else 1467 else
1459 msec = 1000 * 600; 1468 msec = 1000 * 600;
1460 mSaveTimer.start( msec, true ); // 1 minute 1469 mSaveTimer.start( msec, true ); // 1 minute
1461 qDebug("KO: Saving File in %d secs!", msec/1000); 1470 qDebug("KO: Saving File in %d secs!", msec/1000);
1462 mCalendarModifiedFlag = true; 1471 mCalendarModifiedFlag = true;
1463} 1472}
1464void MainWindow::saveStopTimer() 1473void MainWindow::saveStopTimer()
1465{ 1474{
1466 mSaveTimer.stop(); 1475 mSaveTimer.stop();
1467 if (mSaveTimer.isActive() ) 1476 if (mSaveTimer.isActive() )
1468 qDebug("ti active "); 1477 qDebug("ti active ");
1469 else 1478 else
1470 qDebug("KO: Save timer stopped"); 1479 qDebug("KO: Save timer stopped");
1471} 1480}
1472void MainWindow::save() 1481void MainWindow::save()
1473{ 1482{
1474 if ( !mCalendarModifiedFlag ) { 1483 if ( !mCalendarModifiedFlag ) {
1475 qDebug("KO: Calendar not modified. Nothing saved."); 1484 qDebug("KO: Calendar not modified. Nothing saved.");
1476 return; 1485 return;
1477 } 1486 }
1478 if ( mSyncManager->blockSave() ) 1487 if ( mSyncManager->blockSave() )
1479 return; 1488 return;
1480 mSyncManager->setBlockSave(true); 1489 mSyncManager->setBlockSave(true);
1481 if ( mView->checkFileVersion( defaultFileName()) ) { 1490 if ( mView->checkFileVersion( defaultFileName()) ) {
1482 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1491 QTime neededSaveTime = QDateTime::currentDateTime().time();
1483 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1492 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1484 qDebug("KO: Start saving data to file!"); 1493 qDebug("KO: Start saving data to file!");
1485 mView->saveCalendar( defaultFileName() ); 1494 mView->saveCalendar( defaultFileName() );
1486 mCalendarModifiedFlag = false; 1495 mCalendarModifiedFlag = false;
1487 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1496 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1488 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1497 qDebug("KO: Needed %d ms for saving.",msNeeded );
1489 QString savemes; 1498 QString savemes;
1490 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1499 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1491 setCaption(savemes); 1500 setCaption(savemes);
1492 } else 1501 } else
1493 setCaption(i18n("Saving cancelled!")); 1502 setCaption(i18n("Saving cancelled!"));
1494 mSyncManager->setBlockSave( false ); 1503 mSyncManager->setBlockSave( false );
1495} 1504}
1496 1505
1497void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1506void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1498{ 1507{
1499 if ( !e->isAutoRepeat() ) { 1508 if ( !e->isAutoRepeat() ) {
1500 mFlagKeyPressed = false; 1509 mFlagKeyPressed = false;
1501 } 1510 }
1502} 1511}
1503void MainWindow::keyPressEvent ( QKeyEvent * e ) 1512void MainWindow::keyPressEvent ( QKeyEvent * e )
1504{ 1513{
1505 qApp->processEvents(); 1514 qApp->processEvents();
1506 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1515 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1507 e->ignore(); 1516 e->ignore();
1508 // qDebug(" ignore %d",e->isAutoRepeat() ); 1517 // qDebug(" ignore %d",e->isAutoRepeat() );
1509 return; 1518 return;
1510 } 1519 }
1511 if (! e->isAutoRepeat() ) 1520 if (! e->isAutoRepeat() )
1512 mFlagKeyPressed = true; 1521 mFlagKeyPressed = true;
1513 KOPrefs *p = KOPrefs::instance(); 1522 KOPrefs *p = KOPrefs::instance();
1514 bool showSelectedDates = false; 1523 bool showSelectedDates = false;
1515 int size; 1524 int size;
1516 int pro = 0; 1525 int pro = 0;
1517 //qDebug("MainWindow::keyPressEvent "); 1526 //qDebug("MainWindow::keyPressEvent ");
1518 switch ( e->key() ) { 1527 switch ( e->key() ) {
1519 case Qt::Key_Right: 1528 case Qt::Key_Right:
1520 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1529 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1521 mView->goNextMonth(); 1530 mView->goNextMonth();
1522 else 1531 else
1523 mView->goNext(); 1532 mView->goNext();
1524 showSelectedDates = true; 1533 showSelectedDates = true;
1525 break; 1534 break;
1526 case Qt::Key_Left: 1535 case Qt::Key_Left:
1527 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1536 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1528 mView->goPreviousMonth(); 1537 mView->goPreviousMonth();
1529 else 1538 else
1530 mView->goPrevious(); 1539 mView->goPrevious();
1531 showSelectedDates = true; 1540 showSelectedDates = true;
1532 break; 1541 break;
1533 case Qt::Key_Down: 1542 case Qt::Key_Down:
1534 mView->viewManager()->agendaView()->scrollOneHourDown(); 1543 mView->viewManager()->agendaView()->scrollOneHourDown();
1535 break; 1544 break;
1536 case Qt::Key_Up: 1545 case Qt::Key_Up:
1537 mView->viewManager()->agendaView()->scrollOneHourUp(); 1546 mView->viewManager()->agendaView()->scrollOneHourUp();
1538 break; 1547 break;
1539 case Qt::Key_I: 1548 case Qt::Key_I:
1540 mView->showIncidence(); 1549 mView->showIncidence();
1541 break; 1550 break;
1542 case Qt::Key_Delete: 1551 case Qt::Key_Delete:
1543 case Qt::Key_Backspace: 1552 case Qt::Key_Backspace:
1544 mView->deleteIncidence(); 1553 mView->deleteIncidence();
1545 break; 1554 break;
1546 case Qt::Key_D: 1555 case Qt::Key_D:
1547 mView->viewManager()->showDayView(); 1556 mView->viewManager()->showDayView();
1548 showSelectedDates = true; 1557 showSelectedDates = true;
1549 break; 1558 break;
1550 case Qt::Key_O: 1559 case Qt::Key_O:
1551 mView->toggleFilerEnabled( ); 1560 mView->toggleFilerEnabled( );
1552 break; 1561 break;
1553 case Qt::Key_0: 1562 case Qt::Key_0:
1554 case Qt::Key_1: 1563 case Qt::Key_1:
1555 case Qt::Key_2: 1564 case Qt::Key_2:
1556 case Qt::Key_3: 1565 case Qt::Key_3:
1557 case Qt::Key_4: 1566 case Qt::Key_4:
1558 case Qt::Key_5: 1567 case Qt::Key_5:
1559 case Qt::Key_6: 1568 case Qt::Key_6:
1560 case Qt::Key_7: 1569 case Qt::Key_7:
1561 case Qt::Key_8: 1570 case Qt::Key_8:
1562 case Qt::Key_9: 1571 case Qt::Key_9:
1563 pro = e->key()-48; 1572 pro = e->key()-48;
1564 if ( pro == 0 ) 1573 if ( pro == 0 )
1565 pro = 10; 1574 pro = 10;
1566 if ( e->state() == Qt::ControlButton) 1575 if ( e->state() == Qt::ControlButton)
1567 pro += 10; 1576 pro += 10;
1568 break; 1577 break;
1569 case Qt::Key_M: 1578 case Qt::Key_M:
1570 mView->viewManager()->showMonthView(); 1579 mView->viewManager()->showMonthView();
1571 showSelectedDates = true; 1580 showSelectedDates = true;
1572 break; 1581 break;
1573 case Qt::Key_Insert: 1582 case Qt::Key_Insert:
1574 mView->newEvent(); 1583 mView->newEvent();
1575 break; 1584 break;
1576 case Qt::Key_S : 1585 case Qt::Key_S :
1577 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1586 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1578 mView->newSubTodo(); 1587 mView->newSubTodo();
1579 else 1588 else
1580 mView->dialogManager()->showSearchDialog(); 1589 mView->dialogManager()->showSearchDialog();
1581 break; 1590 break;
1582 case Qt::Key_Y : 1591 case Qt::Key_Y :
1583 case Qt::Key_Z : 1592 case Qt::Key_Z :
1584 mView->viewManager()->showWorkWeekView(); 1593 mView->viewManager()->showWorkWeekView();
1585 showSelectedDates = true; 1594 showSelectedDates = true;
1586 break; 1595 break;
1587 case Qt::Key_U : 1596 case Qt::Key_U :
1588 mView->viewManager()->showWeekView(); 1597 mView->viewManager()->showWeekView();
1589 showSelectedDates = true; 1598 showSelectedDates = true;
1590 break; 1599 break;
1591 case Qt::Key_H : 1600 case Qt::Key_H :
1592 keyBindings(); 1601 keyBindings();
1593 break; 1602 break;
1594 case Qt::Key_W: 1603 case Qt::Key_W:
1595 mView->viewManager()->showWhatsNextView(); 1604 mView->viewManager()->showWhatsNextView();
1596 break; 1605 break;
1597 case Qt::Key_L: 1606 case Qt::Key_L:
1598 mView->viewManager()->showListView(); 1607 mView->viewManager()->showListView();
1599 break; 1608 break;
1600 case Qt::Key_N: 1609 case Qt::Key_N:
1601 mView->viewManager()->showNextXView(); 1610 mView->viewManager()->showNextXView();
1602 showSelectedDates = true; 1611 showSelectedDates = true;
1603 break; 1612 break;
1604 case Qt::Key_V: 1613 case Qt::Key_V:
1605 mView->viewManager()->showTodoView(); 1614 mView->viewManager()->showTodoView();
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 1807bc4..de2a381 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -13,287 +13,287 @@
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef INCIDENCE_H 20#ifndef INCIDENCE_H
21#define INCIDENCE_H 21#define INCIDENCE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include "recurrence.h" 30#include "recurrence.h"
31#include "alarm.h" 31#include "alarm.h"
32#include "attachment.h" 32#include "attachment.h"
33#include "listbase.h" 33#include "listbase.h"
34#include "incidencebase.h" 34#include "incidencebase.h"
35 35
36namespace KCal { 36namespace KCal {
37 37
38class Event; 38class Event;
39class Todo; 39class Todo;
40class Journal; 40class Journal;
41 41
42/** 42/**
43 This class provides the base class common to all calendar components. 43 This class provides the base class common to all calendar components.
44*/ 44*/
45class Incidence : public IncidenceBase 45class Incidence : public IncidenceBase
46{ 46{
47 public: 47 public:
48 /** 48 /**
49 This class provides the interface for a visitor of calendar components. It 49 This class provides the interface for a visitor of calendar components. It
50 serves as base class for concrete visitors, which implement certain actions on 50 serves as base class for concrete visitors, which implement certain actions on
51 calendar components. It allows to add functions, which operate on the concrete 51 calendar components. It allows to add functions, which operate on the concrete
52 types of calendar components, without changing the calendar component classes. 52 types of calendar components, without changing the calendar component classes.
53 */ 53 */
54 class Visitor 54 class Visitor
55 { 55 {
56 public: 56 public:
57 /** Destruct Incidence::Visitor */ 57 /** Destruct Incidence::Visitor */
58 virtual ~Visitor() {} 58 virtual ~Visitor() {}
59 59
60 /** 60 /**
61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
62 on an Event object. 62 on an Event object.
63 */ 63 */
64 virtual bool visit(Event *) { return false; } 64 virtual bool visit(Event *) { return false; }
65 /** 65 /**
66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
67 on an Todo object. 67 on an Todo object.
68 */ 68 */
69 virtual bool visit(Todo *) { return false; } 69 virtual bool visit(Todo *) { return false; }
70 /** 70 /**
71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
72 on an Journal object. 72 on an Journal object.
73 */ 73 */
74 virtual bool visit(Journal *) { return false; } 74 virtual bool visit(Journal *) { return false; }
75 75
76 protected: 76 protected:
77 /** Constructor is protected to prevent direct creation of visitor base class. */ 77 /** Constructor is protected to prevent direct creation of visitor base class. */
78 Visitor() {} 78 Visitor() {}
79 }; 79 };
80 80
81 /** 81 /**
82 This class implements a visitor for adding an Incidence to a resource 82 This class implements a visitor for adding an Incidence to a resource
83 supporting addEvent(), addTodo() and addJournal() calls. 83 supporting addEvent(), addTodo() and addJournal() calls.
84 */ 84 */
85 template<class T> 85 template<class T>
86 class AddVisitor : public Visitor 86 class AddVisitor : public Visitor
87 { 87 {
88 public: 88 public:
89 AddVisitor( T *r ) : mResource( r ) {} 89 AddVisitor( T *r ) : mResource( r ) {}
90 bool visit( Event *e ) { return mResource->addEvent( e ); } 90 bool visit( Event *e ) { return mResource->addEvent( e ); }
91 bool visit( Todo *t ) { return mResource->addTodo( t ); } 91 bool visit( Todo *t ) { return mResource->addTodo( t ); }
92 bool visit( Journal *j ) { return mResource->addJournal( j ); } 92 bool visit( Journal *j ) { return mResource->addJournal( j ); }
93 93
94 private: 94 private:
95 T *mResource; 95 T *mResource;
96 }; 96 };
97 97
98 /** enumeration for describing an event's secrecy. */ 98 /** enumeration for describing an event's secrecy. */
99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; 99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
100 typedef ListBase<Incidence> List; 100 typedef ListBase<Incidence> List;
101 Incidence(); 101 Incidence();
102 Incidence(const Incidence &); 102 Incidence(const Incidence &);
103 ~Incidence(); 103 ~Incidence();
104 104
105 /** 105 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 107 provide this implementation:
108 <pre> 108 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 109 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 110 </pre>
111 */ 111 */
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 115
116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; 116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
117 void setReadOnly( bool ); 117 void setReadOnly( bool );
118 118
119 /** 119 /**
120 Recreate event. The event is made a new unique event, but already stored 120 Recreate event. The event is made a new unique event, but already stored
121 event information is preserved. Sets uniquie id, creation date, last 121 event information is preserved. Sets uniquie id, creation date, last
122 modification date and revision number. 122 modification date and revision number.
123 */ 123 */
124 void recreate(); 124 void recreate();
125 Incidence* recreateCloneException(QDate); 125 Incidence* recreateCloneException(QDate);
126 126
127 /** set creation date */ 127 /** set creation date */
128 void setCreated(QDateTime); 128 void setCreated(QDateTime);
129 /** return time and date of creation. */ 129 /** return time and date of creation. */
130 QDateTime created() const; 130 QDateTime created() const;
131 131
132 /** set the number of revisions this event has seen */ 132 /** set the number of revisions this event has seen */
133 void setRevision(int rev); 133 void setRevision(int rev);
134 /** return the number of revisions this event has seen */ 134 /** return the number of revisions this event has seen */
135 int revision() const; 135 int revision() const;
136 136
137 /** Set starting date/time. */ 137 /** Set starting date/time. */
138 virtual void setDtStart(const QDateTime &dtStart); 138 virtual void setDtStart(const QDateTime &dtStart);
139 /** Return the incidence's ending date/time as a QDateTime. */ 139 /** Return the incidence's ending date/time as a QDateTime. */
140 virtual QDateTime dtEnd() const { return QDateTime(); } 140 virtual QDateTime dtEnd() const { return QDateTime(); }
141 141
142 /** sets the event's lengthy description. */ 142 /** sets the event's lengthy description. */
143 void setDescription(const QString &description); 143 void setDescription(const QString &description);
144 /** returns a reference to the event's description. */ 144 /** returns a reference to the event's description. */
145 QString description() const; 145 QString description() const;
146 146
147 /** sets the event's short summary. */ 147 /** sets the event's short summary. */
148 void setSummary(const QString &summary); 148 void setSummary(const QString &summary);
149 /** returns a reference to the event's summary. */ 149 /** returns a reference to the event's summary. */
150 QString summary() const; 150 QString summary() const;
151 151
152 /** set event's applicable categories */ 152 /** set event's applicable categories */
153 void setCategories(const QStringList &categories); 153 void setCategories(const QStringList &categories);
154 /** set event's categories based on a comma delimited string */ 154 /** set event's categories based on a comma delimited string */
155 void setCategories(const QString &catStr); 155 void setCategories(const QString &catStr);
156 /** return categories in a list */ 156 /** return categories in a list */
157 QStringList categories() const; 157 QStringList categories() const;
158 /** return categories as a comma separated string */ 158 /** return categories as a comma separated string */
159 QString categoriesStr(); 159 QString categoriesStr();
160 160
161 /** point at some other event to which the event relates. This function should 161 /** point at some other event to which the event relates. This function should
162 * only be used when constructing a calendar before the related Event 162 * only be used when constructing a calendar before the related Event
163 * exists. */ 163 * exists. */
164 void setRelatedToUid(const QString &); 164 void setRelatedToUid(const QString &);
165 /** what event does this one relate to? This function should 165 /** what event does this one relate to? This function should
166 * only be used when constructing a calendar before the related Event 166 * only be used when constructing a calendar before the related Event
167 * exists. */ 167 * exists. */
168 QString relatedToUid() const; 168 QString relatedToUid() const;
169 /** point at some other event to which the event relates */ 169 /** point at some other event to which the event relates */
170 void setRelatedTo(Incidence *relatedTo); 170 void setRelatedTo(Incidence *relatedTo);
171 /** what event does this one relate to? */ 171 /** what event does this one relate to? */
172 Incidence *relatedTo() const; 172 Incidence *relatedTo() const;
173 /** All events that are related to this event */ 173 /** All events that are related to this event */
174 QPtrList<Incidence> relations() const; 174 QPtrList<Incidence> relations() const;
175 /** Add an event which is related to this event */ 175 /** Add an event which is related to this event */
176 void addRelation(Incidence *); 176 void addRelation(Incidence *);
177 /** Remove event that is related to this event */ 177 /** Remove event that is related to this event */
178 void removeRelation(Incidence *); 178 void removeRelation(Incidence *);
179 179
180 /** returns the list of dates which are exceptions to the recurrence rule */ 180 /** returns the list of dates which are exceptions to the recurrence rule */
181 DateList exDates() const; 181 DateList exDates() const;
182 /** sets the list of dates which are exceptions to the recurrence rule */ 182 /** sets the list of dates which are exceptions to the recurrence rule */
183 void setExDates(const DateList &_exDates); 183 void setExDates(const DateList &_exDates);
184 void setExDates(const char *dates); 184 void setExDates(const char *dates);
185 /** Add a date to the list of exceptions of the recurrence rule. */ 185 /** Add a date to the list of exceptions of the recurrence rule. */
186 void addExDate(const QDate &date); 186 void addExDate(const QDate &date);
187 187
188 /** returns true if there is an exception for this date in the recurrence 188 /** returns true if there is an exception for this date in the recurrence
189 rule set, or false otherwise. */ 189 rule set, or false otherwise. */
190 bool isException(const QDate &qd) const; 190 bool isException(const QDate &qd) const;
191 191
192 /** add attachment to this event */ 192 /** add attachment to this event */
193 void addAttachment(Attachment *attachment); 193 void addAttachment(Attachment *attachment);
194 /** remove and delete a specific attachment */ 194 /** remove and delete a specific attachment */
195 void deleteAttachment(Attachment *attachment); 195 void deleteAttachment(Attachment *attachment);
196 /** remove and delete all attachments with this mime type */ 196 /** remove and delete all attachments with this mime type */
197 void deleteAttachments(const QString& mime); 197 void deleteAttachments(const QString& mime);
198 /** return list of all associated attachments */ 198 /** return list of all associated attachments */
199 QPtrList<Attachment> attachments() const; 199 QPtrList<Attachment> attachments() const;
200 /** find a list of attachments with this mime type */ 200 /** find a list of attachments with this mime type */
201 QPtrList<Attachment> attachments(const QString& mime) const; 201 QPtrList<Attachment> attachments(const QString& mime) const;
202 202
203 /** sets the event's status the value specified. See the enumeration 203 /** sets the event's status the value specified. See the enumeration
204 * above for possible values. */ 204 * above for possible values. */
205 void setSecrecy(int); 205 void setSecrecy(int);
206 /** return the event's secrecy. */ 206 /** return the event's secrecy. */
207 int secrecy() const; 207 int secrecy() const;
208 /** return the event's secrecy in string format. */ 208 /** return the event's secrecy in string format. */
209 QString secrecyStr() const; 209 QString secrecyStr() const;
210 /** return list of all availbale secrecy classes */ 210 /** return list of all availbale secrecy classes */
211 static QStringList secrecyList(); 211 static QStringList secrecyList();
212 /** return human-readable name of secrecy class */ 212 /** return human-readable name of secrecy class */
213 static QString secrecyName(int); 213 static QString secrecyName(int);
214 214
215 /** returns TRUE if the date specified is one on which the event will 215 /** returns TRUE if the date specified is one on which the event will
216 * recur. */ 216 * recur. */
217 bool recursOn(const QDate &qd) const; 217 bool recursOn(const QDate &qd) const;
218 218
219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
220 220
221 /** set resources used, such as Office, Car, etc. */ 221 /** set resources used, such as Office, Car, etc. */
222 void setResources(const QStringList &resources); 222 void setResources(const QStringList &resources);
223 /** return list of current resources */ 223 /** return list of current resources */
224 QStringList resources() const; 224 QStringList resources() const;
225 225
226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
227 void setPriority(int priority); 227 void setPriority(int priority);
228 /** get the event's priority */ 228 /** get the event's priority */
229 int priority() const; 229 int priority() const;
230 230
231 /** All alarms that are associated with this incidence */ 231 /** All alarms that are associated with this incidence */
232 QPtrList<Alarm> alarms() const; 232 QPtrList<Alarm> alarms() const;
233 /** Create a new alarm which is associated with this incidence */ 233 /** Create a new alarm which is associated with this incidence */
234 Alarm* newAlarm(); 234 Alarm* newAlarm();
235 /** Add an alarm which is associated with this incidence */ 235 /** Add an alarm which is associated with this incidence */
236 void addAlarm(Alarm*); 236 void addAlarm(Alarm*);
237 /** Remove an alarm that is associated with this incidence */ 237 /** Remove an alarm that is associated with this incidence */
238 void removeAlarm(Alarm*); 238 void removeAlarm(Alarm*);
239 /** Remove all alarms that are associated with this incidence */ 239 /** Remove all alarms that are associated with this incidence */
240 void clearAlarms(); 240 void clearAlarms();
241 /** return whether any alarm associated with this incidence is enabled */ 241 /** return whether any alarm associated with this incidence is enabled */
242 bool isAlarmEnabled() const; 242 bool isAlarmEnabled() const;
243 243
244 /** 244 /**
245 Return the recurrence rule associated with this incidence. If there is 245 Return the recurrence rule associated with this incidence. If there is
246 none, returns an appropriate (non-0) object. 246 none, returns an appropriate (non-0) object.
247 */ 247 */
248 Recurrence *recurrence() const; 248 Recurrence *recurrence() const;
249 void setRecurrence(Recurrence * r); 249 void setRecurrence(Recurrence * r);
250 /** 250 /**
251 Forward to Recurrence::doesRecur(). 251 Forward to Recurrence::doesRecur().
252 */ 252 */
253 ushort doesRecur() const; 253 ushort doesRecur() const;
254 254
255 /** set the event's/todo's location. Do _not_ use it with journal */ 255 /** set the event's/todo's location. Do _not_ use it with journal */
256 void setLocation(const QString &location); 256 void setLocation(const QString &location);
257 /** return the event's/todo's location. Do _not_ use it with journal */ 257 /** return the event's/todo's location. Do _not_ use it with journal */
258 QString location() const; 258 QString location() const;
259 /** returns TRUE or FALSE depending on whether the todo has a start date */ 259 /** returns TRUE or FALSE depending on whether the todo has a start date */
260 bool hasStartDate() const; 260 bool hasStartDate() const;
261 /** sets the event's hasStartDate value. */ 261 /** sets the event's hasStartDate value. */
262 void setHasStartDate(bool f); 262 void setHasStartDate(bool f);
263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
264 bool cancelled() const; 264 bool cancelled() const;
265 void setCancelled( bool b ); 265 void setCancelled( bool b );
266 266
267protected: 267protected:
268 QPtrList<Alarm> mAlarms; 268 QPtrList<Alarm> mAlarms;
269 QPtrList<Incidence> mRelations;
269 private: 270 private:
270 int mRevision; 271 int mRevision;
271 bool mCancelled; 272 bool mCancelled;
272 273
273 // base components of jounal, event and todo 274 // base components of jounal, event and todo
274 QDateTime mCreated; 275 QDateTime mCreated;
275 QString mDescription; 276 QString mDescription;
276 QString mSummary; 277 QString mSummary;
277 QStringList mCategories; 278 QStringList mCategories;
278 Incidence *mRelatedTo; 279 Incidence *mRelatedTo;
279 QString mRelatedToUid; 280 QString mRelatedToUid;
280 QPtrList<Incidence> mRelations;
281 DateList mExDates; 281 DateList mExDates;
282 QPtrList<Attachment> mAttachments; 282 QPtrList<Attachment> mAttachments;
283 QStringList mResources; 283 QStringList mResources;
284 bool mHasStartDate; // if todo has associated start date 284 bool mHasStartDate; // if todo has associated start date
285 285
286 int mSecrecy; 286 int mSecrecy;
287 int mPriority; // 1 = highest, 2 = less, etc. 287 int mPriority; // 1 = highest, 2 = less, etc.
288 288
289 //QPtrList<Alarm> mAlarms; 289 //QPtrList<Alarm> mAlarms;
290 Recurrence *mRecurrence; 290 Recurrence *mRecurrence;
291 291
292 QString mLocation; 292 QString mLocation;
293}; 293};
294 294
295bool operator==( const Incidence&, const Incidence& ); 295bool operator==( const Incidence&, const Incidence& );
296 296
297} 297}
298 298
299#endif 299#endif
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7f1de78..d81a68f 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,384 +1,414 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "todo.h" 25#include "todo.h"
26 26
27using namespace KCal; 27using namespace KCal;
28 28
29Todo::Todo(): Incidence() 29Todo::Todo(): Incidence()
30{ 30{
31// mStatus = TENTATIVE; 31// mStatus = TENTATIVE;
32 32
33 mHasDueDate = false; 33 mHasDueDate = false;
34 setHasStartDate( false ); 34 setHasStartDate( false );
35 mCompleted = getEvenTime(QDateTime::currentDateTime()); 35 mCompleted = getEvenTime(QDateTime::currentDateTime());
36 mHasCompletedDate = false; 36 mHasCompletedDate = false;
37 mPercentComplete = 0; 37 mPercentComplete = 0;
38} 38}
39 39
40Todo::Todo(const Todo &t) : Incidence(t) 40Todo::Todo(const Todo &t) : Incidence(t)
41{ 41{
42 mDtDue = t.mDtDue; 42 mDtDue = t.mDtDue;
43 mHasDueDate = t.mHasDueDate; 43 mHasDueDate = t.mHasDueDate;
44 mCompleted = t.mCompleted; 44 mCompleted = t.mCompleted;
45 mHasCompletedDate = t.mHasCompletedDate; 45 mHasCompletedDate = t.mHasCompletedDate;
46 mPercentComplete = t.mPercentComplete; 46 mPercentComplete = t.mPercentComplete;
47} 47}
48 48
49Todo::~Todo() 49Todo::~Todo()
50{ 50{
51 51
52} 52}
53 53
54Incidence *Todo::clone() 54Incidence *Todo::clone()
55{ 55{
56 return new Todo(*this); 56 return new Todo(*this);
57} 57}
58 58
59bool Todo::contains ( Todo* from ) 59bool Todo::contains ( Todo* from )
60{ 60{
61 61
62 if ( !from->summary().isEmpty() ) 62 if ( !from->summary().isEmpty() )
63 if ( !summary().startsWith( from->summary() )) 63 if ( !summary().startsWith( from->summary() ))
64 return false; 64 return false;
65 if ( from->hasStartDate() ) { 65 if ( from->hasStartDate() ) {
66 if ( !hasStartDate() ) 66 if ( !hasStartDate() )
67 return false; 67 return false;
68 if ( from->dtStart() != dtStart()) 68 if ( from->dtStart() != dtStart())
69 return false; 69 return false;
70 } 70 }
71 if ( from->hasDueDate() ){ 71 if ( from->hasDueDate() ){
72 if ( !hasDueDate() ) 72 if ( !hasDueDate() )
73 return false; 73 return false;
74 if ( from->dtDue() != dtDue()) 74 if ( from->dtDue() != dtDue())
75 return false; 75 return false;
76 } 76 }
77 if ( !from->location().isEmpty() ) 77 if ( !from->location().isEmpty() )
78 if ( !location().startsWith( from->location() ) ) 78 if ( !location().startsWith( from->location() ) )
79 return false; 79 return false;
80 if ( !from->description().isEmpty() ) 80 if ( !from->description().isEmpty() )
81 if ( !description().startsWith( from->description() )) 81 if ( !description().startsWith( from->description() ))
82 return false; 82 return false;
83 if ( from->alarms().count() ) { 83 if ( from->alarms().count() ) {
84 Alarm *a = from->alarms().first(); 84 Alarm *a = from->alarms().first();
85 if ( a->enabled() ){ 85 if ( a->enabled() ){
86 if ( !alarms().count() ) 86 if ( !alarms().count() )
87 return false; 87 return false;
88 Alarm *b = alarms().first(); 88 Alarm *b = alarms().first();
89 if( ! b->enabled() ) 89 if( ! b->enabled() )
90 return false; 90 return false;
91 if ( ! (a->offset() == b->offset() )) 91 if ( ! (a->offset() == b->offset() ))
92 return false; 92 return false;
93 } 93 }
94 } 94 }
95 95
96 QStringList cat = categories(); 96 QStringList cat = categories();
97 QStringList catFrom = from->categories(); 97 QStringList catFrom = from->categories();
98 QString nCat; 98 QString nCat;
99 int iii; 99 int iii;
100 for ( iii = 0; iii < catFrom.count();++iii ) { 100 for ( iii = 0; iii < catFrom.count();++iii ) {
101 nCat = catFrom[iii]; 101 nCat = catFrom[iii];
102 if ( !nCat.isEmpty() ) 102 if ( !nCat.isEmpty() )
103 if ( !cat.contains( nCat )) { 103 if ( !cat.contains( nCat )) {
104 return false; 104 return false;
105 } 105 }
106 } 106 }
107 if ( from->isCompleted() ) { 107 if ( from->isCompleted() ) {
108 if ( !isCompleted() ) 108 if ( !isCompleted() )
109 return false; 109 return false;
110 } 110 }
111 if( priority() != from->priority() ) 111 if( priority() != from->priority() )
112 return false; 112 return false;
113 113
114 114
115 return true; 115 return true;
116 116
117} 117}
118bool KCal::operator==( const Todo& t1, const Todo& t2 ) 118bool KCal::operator==( const Todo& t1, const Todo& t2 )
119{ 119{
120 120
121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
122 if ( ! ret ) 122 if ( ! ret )
123 return false; 123 return false;
124 if ( t1.hasDueDate() == t2.hasDueDate() ) { 124 if ( t1.hasDueDate() == t2.hasDueDate() ) {
125 if ( t1.hasDueDate() ) { 125 if ( t1.hasDueDate() ) {
126 if ( t1.doesFloat() == t2.doesFloat() ) { 126 if ( t1.doesFloat() == t2.doesFloat() ) {
127 if ( t1.doesFloat() ) { 127 if ( t1.doesFloat() ) {
128 if ( t1.dtDue().date() != t2.dtDue().date() ) 128 if ( t1.dtDue().date() != t2.dtDue().date() )
129 return false; 129 return false;
130 } else 130 } else
131 if ( t1.dtDue() != t2.dtDue() ) 131 if ( t1.dtDue() != t2.dtDue() )
132 return false; 132 return false;
133 } else 133 } else
134 return false;// float != 134 return false;// float !=
135 } 135 }
136 136
137 } else 137 } else
138 return false; 138 return false;
139 if ( t1.percentComplete() != t2.percentComplete() ) 139 if ( t1.percentComplete() != t2.percentComplete() )
140 return false; 140 return false;
141 if ( t1.isCompleted() ) { 141 if ( t1.isCompleted() ) {
142 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 142 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
143 if ( t1.hasCompletedDate() ) { 143 if ( t1.hasCompletedDate() ) {
144 if ( t1.completed() != t2.completed() ) 144 if ( t1.completed() != t2.completed() )
145 return false; 145 return false;
146 } 146 }
147 147
148 } else 148 } else
149 return false; 149 return false;
150 } 150 }
151 return true; 151 return true;
152 152
153} 153}
154 154
155void Todo::setDtDue(const QDateTime &dtDue) 155void Todo::setDtDue(const QDateTime &dtDue)
156{ 156{
157 //int diffsecs = mDtDue.secsTo(dtDue); 157 //int diffsecs = mDtDue.secsTo(dtDue);
158 158
159 /*if (mReadOnly) return; 159 /*if (mReadOnly) return;
160 const QPtrList<Alarm>& alarms = alarms(); 160 const QPtrList<Alarm>& alarms = alarms();
161 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 161 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
162 if (alarm->enabled()) { 162 if (alarm->enabled()) {
163 alarm->setTime(alarm->time().addSecs(diffsecs)); 163 alarm->setTime(alarm->time().addSecs(diffsecs));
164 } 164 }
165 }*/ 165 }*/
166 mDtDue = getEvenTime(dtDue); 166 mDtDue = getEvenTime(dtDue);
167 167
168 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 168 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
169 169
170 /*const QPtrList<Alarm>& alarms = alarms(); 170 /*const QPtrList<Alarm>& alarms = alarms();
171 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 171 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
172 alarm->setAlarmStart(mDtDue);*/ 172 alarm->setAlarmStart(mDtDue);*/
173 173
174 updated(); 174 updated();
175} 175}
176 176
177QDateTime Todo::dtDue() const 177QDateTime Todo::dtDue() const
178{ 178{
179 return mDtDue; 179 return mDtDue;
180} 180}
181 181
182QString Todo::dtDueTimeStr() const 182QString Todo::dtDueTimeStr() const
183{ 183{
184 return KGlobal::locale()->formatTime(mDtDue.time()); 184 return KGlobal::locale()->formatTime(mDtDue.time());
185} 185}
186 186
187QString Todo::dtDueDateStr(bool shortfmt) const 187QString Todo::dtDueDateStr(bool shortfmt) const
188{ 188{
189 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 189 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
190} 190}
191 191
192QString Todo::dtDueStr(bool shortfmt) const 192QString Todo::dtDueStr(bool shortfmt) const
193{ 193{
194 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 194 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
195} 195}
196 196// retval 0 : no found
197// 1 : due for date found
198// 2 : overdue for date found
199int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
200{
201 int retval = 0;
202 if ( isCompleted() )
203 return 0;
204 if ( hasDueDate() ) {
205 if ( dtDue().date() < date )
206 return 2;
207 // we do not return, because we may find an overdue sub todo
208 if ( dtDue().date() == date )
209 retval = 1;
210 }
211 if ( checkSubtodos ) {
212 Incidence *aTodo;
213 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
214 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
215 if ( ret == 2 )
216 return 2;
217 if ( ret == 1)
218 retval = 1;
219 }
220 }
221 return retval;
222}
223int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
224{
225 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
226}
197bool Todo::hasDueDate() const 227bool Todo::hasDueDate() const
198{ 228{
199 return mHasDueDate; 229 return mHasDueDate;
200} 230}
201 231
202void Todo::setHasDueDate(bool f) 232void Todo::setHasDueDate(bool f)
203{ 233{
204 if (mReadOnly) return; 234 if (mReadOnly) return;
205 mHasDueDate = f; 235 mHasDueDate = f;
206 updated(); 236 updated();
207} 237}
208 238
209 239
210#if 0 240#if 0
211void Todo::setStatus(const QString &statStr) 241void Todo::setStatus(const QString &statStr)
212{ 242{
213 if (mReadOnly) return; 243 if (mReadOnly) return;
214 QString ss(statStr.upper()); 244 QString ss(statStr.upper());
215 245
216 if (ss == "X-ACTION") 246 if (ss == "X-ACTION")
217 mStatus = NEEDS_ACTION; 247 mStatus = NEEDS_ACTION;
218 else if (ss == "NEEDS ACTION") 248 else if (ss == "NEEDS ACTION")
219 mStatus = NEEDS_ACTION; 249 mStatus = NEEDS_ACTION;
220 else if (ss == "ACCEPTED") 250 else if (ss == "ACCEPTED")
221 mStatus = ACCEPTED; 251 mStatus = ACCEPTED;
222 else if (ss == "SENT") 252 else if (ss == "SENT")
223 mStatus = SENT; 253 mStatus = SENT;
224 else if (ss == "TENTATIVE") 254 else if (ss == "TENTATIVE")
225 mStatus = TENTATIVE; 255 mStatus = TENTATIVE;
226 else if (ss == "CONFIRMED") 256 else if (ss == "CONFIRMED")
227 mStatus = CONFIRMED; 257 mStatus = CONFIRMED;
228 else if (ss == "DECLINED") 258 else if (ss == "DECLINED")
229 mStatus = DECLINED; 259 mStatus = DECLINED;
230 else if (ss == "COMPLETED") 260 else if (ss == "COMPLETED")
231 mStatus = COMPLETED; 261 mStatus = COMPLETED;
232 else if (ss == "DELEGATED") 262 else if (ss == "DELEGATED")
233 mStatus = DELEGATED; 263 mStatus = DELEGATED;
234 264
235 updated(); 265 updated();
236} 266}
237 267
238void Todo::setStatus(int status) 268void Todo::setStatus(int status)
239{ 269{
240 if (mReadOnly) return; 270 if (mReadOnly) return;
241 mStatus = status; 271 mStatus = status;
242 updated(); 272 updated();
243} 273}
244 274
245int Todo::status() const 275int Todo::status() const
246{ 276{
247 return mStatus; 277 return mStatus;
248} 278}
249 279
250QString Todo::statusStr() const 280QString Todo::statusStr() const
251{ 281{
252 switch(mStatus) { 282 switch(mStatus) {
253 case NEEDS_ACTION: 283 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 284 return QString("NEEDS ACTION");
255 break; 285 break;
256 case ACCEPTED: 286 case ACCEPTED:
257 return QString("ACCEPTED"); 287 return QString("ACCEPTED");
258 break; 288 break;
259 case SENT: 289 case SENT:
260 return QString("SENT"); 290 return QString("SENT");
261 break; 291 break;
262 case TENTATIVE: 292 case TENTATIVE:
263 return QString("TENTATIVE"); 293 return QString("TENTATIVE");
264 break; 294 break;
265 case CONFIRMED: 295 case CONFIRMED:
266 return QString("CONFIRMED"); 296 return QString("CONFIRMED");
267 break; 297 break;
268 case DECLINED: 298 case DECLINED:
269 return QString("DECLINED"); 299 return QString("DECLINED");
270 break; 300 break;
271 case COMPLETED: 301 case COMPLETED:
272 return QString("COMPLETED"); 302 return QString("COMPLETED");
273 break; 303 break;
274 case DELEGATED: 304 case DELEGATED:
275 return QString("DELEGATED"); 305 return QString("DELEGATED");
276 break; 306 break;
277 } 307 }
278 return QString(""); 308 return QString("");
279} 309}
280#endif 310#endif
281 311
282bool Todo::isCompleted() const 312bool Todo::isCompleted() const
283{ 313{
284 if (mPercentComplete == 100) return true; 314 if (mPercentComplete == 100) return true;
285 else return false; 315 else return false;
286} 316}
287 317
288void Todo::setCompleted(bool completed) 318void Todo::setCompleted(bool completed)
289{ 319{
290 if (completed) mPercentComplete = 100; 320 if (completed) mPercentComplete = 100;
291 else { 321 else {
292 mPercentComplete = 0; 322 mPercentComplete = 0;
293 mHasCompletedDate = false; 323 mHasCompletedDate = false;
294 } 324 }
295 updated(); 325 updated();
296} 326}
297 327
298QDateTime Todo::completed() const 328QDateTime Todo::completed() const
299{ 329{
300 return mCompleted; 330 return mCompleted;
301} 331}
302 332
303QString Todo::completedStr( bool shortF ) const 333QString Todo::completedStr( bool shortF ) const
304{ 334{
305 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 335 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
306} 336}
307 337
308void Todo::setCompleted(const QDateTime &completed) 338void Todo::setCompleted(const QDateTime &completed)
309{ 339{
310 //qDebug("Todo::setCompleted "); 340 //qDebug("Todo::setCompleted ");
311 if ( mHasCompletedDate ) { 341 if ( mHasCompletedDate ) {
312 // qDebug("has completed data - return "); 342 // qDebug("has completed data - return ");
313 return; 343 return;
314 } 344 }
315 mHasCompletedDate = true; 345 mHasCompletedDate = true;
316 mPercentComplete = 100; 346 mPercentComplete = 100;
317 mCompleted = getEvenTime(completed); 347 mCompleted = getEvenTime(completed);
318 updated(); 348 updated();
319} 349}
320 350
321bool Todo::hasCompletedDate() const 351bool Todo::hasCompletedDate() const
322{ 352{
323 return mHasCompletedDate; 353 return mHasCompletedDate;
324} 354}
325 355
326int Todo::percentComplete() const 356int Todo::percentComplete() const
327{ 357{
328 return mPercentComplete; 358 return mPercentComplete;
329} 359}
330 360
331void Todo::setPercentComplete(int v) 361void Todo::setPercentComplete(int v)
332{ 362{
333 mPercentComplete = v; 363 mPercentComplete = v;
334 if ( v != 100 ) 364 if ( v != 100 )
335 mHasCompletedDate = false; 365 mHasCompletedDate = false;
336 updated(); 366 updated();
337} 367}
338QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 368QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
339{ 369{
340 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 370 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
341 *ok = false; 371 *ok = false;
342 return QDateTime (); 372 return QDateTime ();
343 } 373 }
344 QDateTime incidenceStart; 374 QDateTime incidenceStart;
345 incidenceStart = dtDue(); 375 incidenceStart = dtDue();
346 bool enabled = false; 376 bool enabled = false;
347 Alarm* alarm; 377 Alarm* alarm;
348 int off; 378 int off;
349 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 379 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
350 // if ( QDateTime::currentDateTime() > incidenceStart ){ 380 // if ( QDateTime::currentDateTime() > incidenceStart ){
351// *ok = false; 381// *ok = false;
352// return incidenceStart; 382// return incidenceStart;
353// } 383// }
354 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 384 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
355 if (alarm->enabled()) { 385 if (alarm->enabled()) {
356 if ( alarm->hasTime () ) { 386 if ( alarm->hasTime () ) {
357 if ( alarm->time() < alarmStart ) { 387 if ( alarm->time() < alarmStart ) {
358 alarmStart = alarm->time(); 388 alarmStart = alarm->time();
359 enabled = true; 389 enabled = true;
360 off = alarmStart.secsTo( incidenceStart ); 390 off = alarmStart.secsTo( incidenceStart );
361 } 391 }
362 392
363 } else { 393 } else {
364 int secs = alarm->startOffset().asSeconds(); 394 int secs = alarm->startOffset().asSeconds();
365 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 395 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
366 alarmStart = incidenceStart.addSecs( secs ); 396 alarmStart = incidenceStart.addSecs( secs );
367 enabled = true; 397 enabled = true;
368 off = -secs; 398 off = -secs;
369 } 399 }
370 } 400 }
371 } 401 }
372 } 402 }
373 if ( enabled ) { 403 if ( enabled ) {
374 if ( alarmStart > QDateTime::currentDateTime() ) { 404 if ( alarmStart > QDateTime::currentDateTime() ) {
375 *ok = true; 405 *ok = true;
376 * offset = off; 406 * offset = off;
377 return alarmStart; 407 return alarmStart;
378 } 408 }
379 } 409 }
380 *ok = false; 410 *ok = false;
381 return QDateTime (); 411 return QDateTime ();
382 412
383} 413}
384 414
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 41f5841..137b252 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,122 +1,134 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides a Todo in the sense of RFC2445. 31 This class provides a Todo in the sense of RFC2445.
32*/ 32*/
33class Todo : public Incidence 33class Todo : public Incidence
34{ 34{
35 public: 35 public:
36 Todo(); 36 Todo();
37 Todo(const Todo &); 37 Todo(const Todo &);
38 ~Todo(); 38 ~Todo();
39 typedef ListBase<Todo> List; 39 typedef ListBase<Todo> List;
40 QCString type() const { return "Todo"; } 40 QCString type() const { return "Todo"; }
41 41
42 /** Return an exact copy of this todo. */ 42 /** Return an exact copy of this todo. */
43 Incidence *clone(); 43 Incidence *clone();
44 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; 44 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
45 45
46 /** for setting the todo's due date/time with a QDateTime. */ 46 /** for setting the todo's due date/time with a QDateTime. */
47 void setDtDue(const QDateTime &dtDue); 47 void setDtDue(const QDateTime &dtDue);
48 /** returns an event's Due date/time as a QDateTime. */ 48 /** returns an event's Due date/time as a QDateTime. */
49 QDateTime dtDue() const; 49 QDateTime dtDue() const;
50 /** returns an event's due time as a string formatted according to the 50 /** returns an event's due time as a string formatted according to the
51 users locale settings */ 51 users locale settings */
52 QString dtDueTimeStr() const; 52 QString dtDueTimeStr() const;
53 /** returns an event's due date as a string formatted according to the 53 /** returns an event's due date as a string formatted according to the
54 users locale settings */ 54 users locale settings */
55 QString dtDueDateStr(bool shortfmt=true) const; 55 QString dtDueDateStr(bool shortfmt=true) const;
56 /** returns an event's due date and time as a string formatted according 56 /** returns an event's due date and time as a string formatted according
57 to the users locale settings */ 57 to the users locale settings */
58 QString dtDueStr(bool shortfmt=true) const; 58 QString dtDueStr(bool shortfmt=true) const;
59 59
60 /** returns TRUE or FALSE depending on whether the todo has a due date */ 60 /** returns TRUE or FALSE depending on whether the todo has a due date */
61 bool hasDueDate() const; 61 bool hasDueDate() const;
62 /** sets the event's hasDueDate value. */ 62 /** sets the event's hasDueDate value. */
63 void setHasDueDate(bool f); 63 void setHasDueDate(bool f);
64 64
65 /*
66 Looks for a subtodo (including itself ) which is not complete and is
67 - overdue, or
68 - due today.
69 It returns 0 for nothing found,
70 1 for found a todo which is due today and no overdue found
71 2 for found a overdue todo
72 */
73 int hasDueSubTodo( bool checkSubtodos = true );
74 /* same as above, but a specific date can be specified*/
75 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
76
65 77
66 /** sets the event's status to the string specified. The string 78 /** sets the event's status to the string specified. The string
67 * must be a recognized value for the status field, i.e. a string 79 * must be a recognized value for the status field, i.e. a string
68 * equivalent of the possible status enumerations previously described. */ 80 * equivalent of the possible status enumerations previously described. */
69// void setStatus(const QString &statStr); 81// void setStatus(const QString &statStr);
70 /** sets the event's status to the value specified. See the enumeration 82 /** sets the event's status to the value specified. See the enumeration
71 * above for possible values. */ 83 * above for possible values. */
72// void setStatus(int); 84// void setStatus(int);
73 /** return the event's status. */ 85 /** return the event's status. */
74// int status() const; 86// int status() const;
75 /** return the event's status in string format. */ 87 /** return the event's status in string format. */
76// QString statusStr() const; 88// QString statusStr() const;
77 89
78 /** return, if this todo is completed */ 90 /** return, if this todo is completed */
79 bool isCompleted() const; 91 bool isCompleted() const;
80 /** set completed state of this todo */ 92 /** set completed state of this todo */
81 void setCompleted(bool); 93 void setCompleted(bool);
82 94
83 /** 95 /**
84 Return how many percent of the task are completed. Returns a value 96 Return how many percent of the task are completed. Returns a value
85 between 0 and 100. 97 between 0 and 100.
86 */ 98 */
87 int percentComplete() const; 99 int percentComplete() const;
88 /** 100 /**
89 Set how many percent of the task are completed. Valid values are in the 101 Set how many percent of the task are completed. Valid values are in the
90 range from 0 to 100. 102 range from 0 to 100.
91 */ 103 */
92 void setPercentComplete(int); 104 void setPercentComplete(int);
93 105
94 /** return date and time when todo was completed */ 106 /** return date and time when todo was completed */
95 QDateTime completed() const; 107 QDateTime completed() const;
96 QString completedStr(bool shortF = true) const; 108 QString completedStr(bool shortF = true) const;
97 /** set date and time of completion */ 109 /** set date and time of completion */
98 void setCompleted(const QDateTime &completed); 110 void setCompleted(const QDateTime &completed);
99 111
100 /** Return true, if todo has a date associated with completion */ 112 /** Return true, if todo has a date associated with completion */
101 bool hasCompletedDate() const; 113 bool hasCompletedDate() const;
102 bool contains ( Todo*); 114 bool contains ( Todo*);
103 115
104 private: 116 private:
105 bool accept(Visitor &v) { return v.visit(this); } 117 bool accept(Visitor &v) { return v.visit(this); }
106 118
107 QDateTime mDtDue; // due date of todo 119 QDateTime mDtDue; // due date of todo
108 120
109 bool mHasDueDate; // if todo has associated due date 121 bool mHasDueDate; // if todo has associated due date
110 122
111// int mStatus; // confirmed/delegated/tentative/etc 123// int mStatus; // confirmed/delegated/tentative/etc
112 124
113 QDateTime mCompleted; 125 QDateTime mCompleted;
114 bool mHasCompletedDate; 126 bool mHasCompletedDate;
115 127
116 int mPercentComplete; 128 int mPercentComplete;
117}; 129};
118 130
119 bool operator==( const Todo&, const Todo& ); 131 bool operator==( const Todo&, const Todo& );
120} 132}
121 133
122#endif 134#endif