summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt5
-rw-r--r--korganizer/kdatenavigator.cpp2
-rw-r--r--korganizer/komonthview.cpp52
-rw-r--r--korganizer/komonthview.h4
4 files changed, 51 insertions, 12 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 3ba0841..7214035 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,398 +1,403 @@
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.
16Now TAB key jumps to next cell with an event/todo.
17Scroll in cell with coursor keys, scroll in time (next week) with
18Shift/Control + coursorkeys.
19
15********** VERSION 2.0.2 ************ 20********** VERSION 2.0.2 ************
16 21
17KO/Pi: 22KO/Pi:
18Fixed the layout problem of the day label buttons 23Fixed the layout problem of the day label buttons
19of the agenda view introduced in version 2.0.1. 24of the agenda view introduced in version 2.0.1.
20 25
21Added WhatsThis support for the todo view and the list view. 26Added WhatsThis support for the todo view and the list view.
22 27
23Added a quite useful feature to the montview. 28Added a quite useful feature to the montview.
24Just click on the week numbers on the left. 29Just click on the week numbers on the left.
25And in the top right corner of month view/agenda view 30And in the top right corner of month view/agenda view
26there is now a "week number quick selector". 31there is now a "week number quick selector".
27(Click on the black triangle). 32(Click on the black triangle).
28 33
29Made the quite difficult timezone change in KO/Pi easy. 34Made the quite difficult timezone change in KO/Pi easy.
30 35
31OM/Pi: 36OM/Pi:
32Fixed too small icons on desktop. 37Fixed too small icons on desktop.
33Fixed non visible icons in mainwindow on Z with fastload enabled. 38Fixed non visible icons in mainwindow on Z with fastload enabled.
34Added signature file setting to smtp account config. 39Added signature file setting to smtp account config.
35And the signature can be edited and saved in the edit mail dialog. 40And the signature can be edited and saved in the edit mail dialog.
36That does mean: 41That does mean:
37Simply edit the signature for the selected smtp account in the 42Simply edit the signature for the selected smtp account in the
38edit new mail dialog and press the "save signature" button there. 43edit new mail dialog and press the "save signature" button there.
39Then the signature is saved to the file specified in the smtp account settings. 44Then the signature is saved to the file specified in the smtp account settings.
40If there is no file specified, it is saved automatically to the file 45If there is no file specified, it is saved automatically to the file
41kdepim/apps/kopiemail/<accountname>.sig. 46kdepim/apps/kopiemail/<accountname>.sig.
42 47
43 48
44 49
45********** VERSION 2.0.1 ************ 50********** VERSION 2.0.1 ************
46 51
47Oooops ... I forgot to test on the Zaurus 5500 ... 52Oooops ... I forgot to test on the Zaurus 5500 ...
48 53
49Fixed many problems of new (english) strings (and german translations) 54Fixed many problems of new (english) strings (and german translations)
50introduced in the latest versions, where the text was not fitting on the 55introduced in the latest versions, where the text was not fitting on the
51240x320 display of the Zaurus 5500. 56240x320 display of the Zaurus 5500.
52 57
53KO/Pi: 58KO/Pi:
54Added a popup menu ( press pen and hold to get popup ) to the agenda view 59Added a popup menu ( press pen and hold to get popup ) to the agenda view
55with many useful items (add event/todo, show next week, two weeks, month, journal). 60with many useful items (add event/todo, show next week, two weeks, month, journal).
56 61
57Added items to the todolist popup menu for: 62Added items to the todolist popup menu for:
58Display all opened, all closed or all todos flat. 63Display all opened, all closed or all todos flat.
59The "flat" view makes is possible to sort all todos after ,e.g., prio or date. 64The "flat" view makes is possible to sort all todos after ,e.g., prio or date.
60Made the reparenting of todos on the desktop possible via Drag&Drop. 65Made the reparenting of todos on the desktop possible via Drag&Drop.
61Fixed several bugs in setting the completed datetime for todos. 66Fixed several bugs in setting the completed datetime for todos.
62Added info about completed datetime of todos to the todo viewer. 67Added info about completed datetime of todos to the todo viewer.
63Now displaying a completed todo (with completed datetime set) in the agenda view 68Now displaying a completed todo (with completed datetime set) in the agenda view
64at the time of the completion. Such that now it is possible to see in the agenda view 69at the time of the completion. Such that now it is possible to see in the agenda view
65when what todo was completed. 70when what todo was completed.
66Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. 71Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos.
67Now the behaviour is: 72Now the behaviour is:
68Setting a parent to complete sets all (sub)childs to complete. 73Setting a parent to complete sets all (sub)childs to complete.
69Setting a parent to uncomplete does not change the childs. 74Setting a parent to uncomplete does not change the childs.
70Setting a child to uncomplete sets all parent to uncomplete. 75Setting a child to uncomplete sets all parent to uncomplete.
71Setting a child to complete does not change the parents. 76Setting a child to complete does not change the parents.
72 77
73Smart updating and double buffering of the daymatrix. 78Smart updating and double buffering of the daymatrix.
74Showing holidays in the day matrix. 79Showing holidays in the day matrix.
75Many other small performance updates. 80Many other small performance updates.
76 81
77Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode. 82Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode.
78 83
79Now the translation file usertranslation.txt is supposed to be in utf8 format. 84Now the translation file usertranslation.txt is supposed to be in utf8 format.
80If 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. 85If 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.
81 86
82 87
83********** VERSION 2.0.0 ************ 88********** VERSION 2.0.0 ************
84 89
85Stable release 2.0.0! 90Stable release 2.0.0!
86 91
87KO/Pi: 92KO/Pi:
88Fixed problem in edit dialog recreation at startup. 93Fixed problem in edit dialog recreation at startup.
89Made "toggle view*" menu items enabled context sensitive. 94Made "toggle view*" menu items enabled context sensitive.
90Changed agenda size menu to items 1-10. 95Changed agenda size menu to items 1-10.
91Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. 96Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down.
92Usebility enhancements in the KO/Pi menus. 97Usebility enhancements in the KO/Pi menus.
93Birthday import now adds year to summary. 98Birthday import now adds year to summary.
94What's Next view shows age in years for birthday. 99What's Next view shows age in years for birthday.
95 100
96OM/Pi: 101OM/Pi:
97Added three info lines to display subject, from and to of selected mails. 102Added three info lines to display subject, from and to of selected mails.
98 103
99KA/Pi: 104KA/Pi:
100Fixed jump bar behaviour on Zaurus. 105Fixed jump bar behaviour on Zaurus.
101Now KA/Pi search field supports searching for a range of starting characters. 106Now KA/Pi search field supports searching for a range of starting characters.
102E.g. to search for all contact beginning with b to n, type 107E.g. to search for all contact beginning with b to n, type
103b-n 108b-n
104in the search field. 109in the search field.
105 110
106********** VERSION 1.9.20 ************ 111********** VERSION 1.9.20 ************
107 112
108KO/Pi: 113KO/Pi:
109Added for the "dislplay one day" agenda mode 114Added for the "dislplay one day" agenda mode
110info in the caption and in the day lables: 115info in the caption and in the day lables:
111Now it is displayed, if the selected day is from "day before yesterday" 116Now it is displayed, if the selected day is from "day before yesterday"
112to "day after tomorrow". 117to "day after tomorrow".
113Made it possible to delete a Todo, which has sub-todos. 118Made it possible to delete a Todo, which has sub-todos.
114Fixed two small problems in the todo view. 119Fixed two small problems in the todo view.
115Added missing German translation for filter edit and print dialog. 120Added missing German translation for filter edit and print dialog.
116Made search dialog closeable by cancel key. 121Made search dialog closeable by cancel key.
117 122
118Made it possible to select in the date picker the (ligt grey ) 123Made it possible to select in the date picker the (ligt grey )
119dates of the prev./next month with the mouse. 124dates of the prev./next month with the mouse.
120 125
121OM/Pi: 126OM/Pi:
122"Delete mail" icon in main window now deletes all selected mails. 127"Delete mail" icon in main window now deletes all selected mails.
123Fixed the problem, that the state flag of imap mails was ignored. 128Fixed the problem, that the state flag of imap mails was ignored.
124Now mails with "FLAG_SEEN" on the imap server get no icon in the list view 129Now mails with "FLAG_SEEN" on the imap server get no icon in the list view
125to indecate that they are already seen. 130to indecate that they are already seen.
126Fixed the problem that the body of some mails was not displayed in the 131Fixed the problem that the body of some mails was not displayed in the
127mail viewer when fetching them from the imap server directly to read them. 132mail viewer when fetching them from the imap server directly to read them.
128Made it (configurable) possible to show the "To:" field in the list view. 133Made it (configurable) possible to show the "To:" field in the list view.
129Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. 134Added to the mail viewer the option "View Source" to make it possible to see the raw mail data.
130Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the 135Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the
131local storage folder (specified in account settings) of the account of the mail. 136local storage folder (specified in account settings) of the account of the mail.
132Removed some memory leaks in OM/Pi. 137Removed some memory leaks in OM/Pi.
133 138
134 139
135********** VERSION 1.9.19 ************ 140********** VERSION 1.9.19 ************
136 141
137Added a lot of missing translations to KA/Pi, 142Added a lot of missing translations to KA/Pi,
138Added some missing translations to KO/Pi and OM/Pi. 143Added some missing translations to KO/Pi and OM/Pi.
139 144
140Fixed some minor problems in KA/Pi + KO/Pi. 145Fixed some minor problems in KA/Pi + KO/Pi.
141 146
142Fixed a crash when closing PwM/Pi. 147Fixed a crash when closing PwM/Pi.
143Added German translation for PwM/Pi. 148Added German translation for PwM/Pi.
144 149
145Made view change and Month View update faster in KO/Pi. 150Made view change and Month View update faster in KO/Pi.
146 151
147 152
148********** VERSION 1.9.18 ************ 153********** VERSION 1.9.18 ************
149 154
150FYI: The VERSION 1.9.17 was a testing release only. 155FYI: The VERSION 1.9.17 was a testing release only.
151Please read the changelog of VERSION 1.9.17 as well. 156Please read the changelog of VERSION 1.9.17 as well.
152 157
153Cleaned up the syncing config dialog. 158Cleaned up the syncing config dialog.
154Added sync config options for date range for events. 159Added sync config options for date range for events.
155Added sync config options for filters on incoming data. 160Added sync config options for filters on incoming data.
156Added sync config options for filters on outgoing data. 161Added sync config options for filters on outgoing data.
157Please read the updated SyncHowTo about the new filter settings. 162Please read the updated SyncHowTo about the new filter settings.
158These filter settings make it now possible to sync with shared 163These filter settings make it now possible to sync with shared
159calendars without writing back private or confidential data 164calendars without writing back private or confidential data
160(via the outgoing filters). 165(via the outgoing filters).
161To sync only with particular parts of a shared calendar, 166To sync only with particular parts of a shared calendar,
162the incoming filter settings can be used. 167the incoming filter settings can be used.
163An example can be found in the SyncHowTo. 168An example can be found in the SyncHowTo.
164Same for shared addressbooks. 169Same for shared addressbooks.
165 170
166Added a setting for the global kdepim data storage. 171Added a setting for the global kdepim data storage.
167Usually the data is stored in (yourhomedir/kdepim). 172Usually the data is stored in (yourhomedir/kdepim).
168Now you can set in the Global config dialog TAB, subTAB "Data storage path" 173Now you can set in the Global config dialog TAB, subTAB "Data storage path"
169a directory where all the kdepim data is stored. 174a directory where all the kdepim data is stored.
170That makes it easy to save all kdepim data on a SD card on the Z, for example. 175That makes it easy to save all kdepim data on a SD card on the Z, for example.
171 176
172KO/Pi: 177KO/Pi:
173The timeedit input has a pulldown list for times. 178The timeedit input has a pulldown list for times.
174If opened, this pulldown list should now has the right time highlighted. 179If opened, this pulldown list should now has the right time highlighted.
175Added the possibility to exclude events/todos/journals in a filter. 180Added the possibility to exclude events/todos/journals in a filter.
176You should exclude journals, if you do not want them to sync with a public calendar. 181You should exclude journals, if you do not want them to sync with a public calendar.
177 182
178KA/Pi: 183KA/Pi:
179Added the possibility to in/exclude public/private/confidential contacts to a filter. 184Added the possibility to in/exclude public/private/confidential contacts to a filter.
180If 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 ... 185If 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 ...
181Added printing of card view and details view on desktop. 186Added printing of card view and details view on desktop.
182Printing of list view is not working... 187Printing of list view is not working...
183Added button for removing pictures in contact editor. 188Added button for removing pictures in contact editor.
184Parsing data fix of KA/Pi version 1.9.17. 189Parsing data fix of KA/Pi version 1.9.17.
185Fixed the "parse name automatically" problem of KA/Pi version 1.9.17. 190Fixed the "parse name automatically" problem of KA/Pi version 1.9.17.
186Fixed some syncing merging problems. 191Fixed some syncing merging problems.
187 192
188 193
189********** VERSION 1.9.17 ************ 194********** VERSION 1.9.17 ************
190 195
191KO/Pi: 196KO/Pi:
192Fixed that tooltips were not updated after moving an item in agenda view. 197Fixed that tooltips were not updated after moving an item in agenda view.
193Fixed a bug in sorting start date for recurring events in list view. 198Fixed a bug in sorting start date for recurring events in list view.
194Changed the left button in todo viewer from "Agenda" to "Set completed". 199Changed the left button in todo viewer from "Agenda" to "Set completed".
195This 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. 200This 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.
196Added more info in the todo viewer: Startdate, parent/sub todos. 201Added more info in the todo viewer: Startdate, parent/sub todos.
197 202
198 203
199KA/Pi: 204KA/Pi:
200All fields search does now actually search all the (possible) fields, 205All fields search does now actually search all the (possible) fields,
201not only those listed in the contact list. 206not only those listed in the contact list.
202Made is possible to inline a picture in a vcard on the Z. 207Made is possible to inline a picture in a vcard on the Z.
203This was only possible on the desktop, now is it possible on the Z as well. 208This was only possible on the desktop, now is it possible on the Z as well.
204Fixed of missing save settings after filter configuration. 209Fixed of missing save settings after filter configuration.
205Made saving of addressbook much faster. 210Made saving of addressbook much faster.
206Fixed extension widget layout problem. 211Fixed extension widget layout problem.
207Fixed saving of default formatted name settings. 212Fixed saving of default formatted name settings.
208Fixed formatted name handling in edit dialog. 213Fixed formatted name handling in edit dialog.
209Added an option for changing formatted names of many contacts 214Added an option for changing formatted names of many contacts
210(menu: File - Change - Set formatted name). 215(menu: File - Change - Set formatted name).
211 216
212QWhatsThis was not working on the Z ( only black rectangle was shown). 217QWhatsThis was not working on the Z ( only black rectangle was shown).
213This is Fixed. 218This is Fixed.
214 219
215KDE-Sync: 220KDE-Sync:
216Now readonly KDE resources are synced as well. 221Now readonly KDE resources are synced as well.
217(They are not changed in KDE itself, of course). 222(They are not changed in KDE itself, of course).
218 223
219 224
220 225
221********** VERSION 1.9.16 ************ 226********** VERSION 1.9.16 ************
222 227
223KO/Pi: 228KO/Pi:
224Fixed search dialog size on Z 6000 (480x640 display). 229Fixed search dialog size on Z 6000 (480x640 display).
225Added setting to hide/show time in agenda items. 230Added setting to hide/show time in agenda items.
226Added setting to hide not running todos in todo view. 231Added setting to hide not running todos in todo view.
227Added columns for start date/time in todo view. 232Added columns for start date/time in todo view.
228Replaced the solid half-hour lines in agenda view by dot lines. 233Replaced the solid half-hour lines in agenda view by dot lines.
229Added possibility of printing the What's Next View on the desktop 234Added possibility of printing the What's Next View on the desktop
230(i.e. Windows and Linux). 235(i.e. Windows and Linux).
231Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. 236Fixed a crash in KO/Pi when starting KO/Pi with What's Next view.
232Added tooltips in month view.(Tooltips only available on desktop) 237Added tooltips in month view.(Tooltips only available on desktop)
233 238
234Fixed a strange problem in KO/Pi alarm applet. 239Fixed a strange problem in KO/Pi alarm applet.
235Did not find the actual problem, 240Did not find the actual problem,
236such that now Qtopia reboots again if deinstalling the alarm applet. 241such that now Qtopia reboots again if deinstalling the alarm applet.
237But the alarm applet should work again. 242But the alarm applet should work again.
238 243
239KA/Pi: 244KA/Pi:
240Fixed the problem, that internal pictures were not saved. 245Fixed the problem, that internal pictures were not saved.
241 246
242Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. 247Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes.
243 248
244Fixed some minor problems. (Like word wrap in help text windows). 249Fixed some minor problems. (Like word wrap in help text windows).
245 250
246Fixed a compiling problem in microkde/kresources. 251Fixed a compiling problem in microkde/kresources.
247 252
248KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. 253KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM.
249This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) 254This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9)
250such that now syncing KO/Pi with Sharp DTM should work on the 255such that now syncing KO/Pi with Sharp DTM should work on the
251Zaurus C 3000 model. 256Zaurus C 3000 model.
252 257
253********** VERSION 1.9.15 ************ 258********** VERSION 1.9.15 ************
254 259
255Usebilty enhancements in KO/Pi: 260Usebilty enhancements in KO/Pi:
256When clicking on the date in a month view cell, the day view is shown. 261When clicking on the date in a month view cell, the day view is shown.
257Old behaviour was, that the "new event" dialog popped up. 262Old behaviour was, that the "new event" dialog popped up.
258 263
259Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). 264Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu).
260That means, you can restore the latest 265That means, you can restore the latest
261event/todo/journal you have deleted. 266event/todo/journal you have deleted.
262A journal is deleted, if you clear all the text of the journal. 267A journal is deleted, if you clear all the text of the journal.
263 268
264Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. 269Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14.
265 270
266KA/Pi starting in 480x640 resolution: 271KA/Pi starting in 480x640 resolution:
267Hide the filter action in toolbar 272Hide the filter action in toolbar
268and added icons for undo/delete/redo in toolbar. 273and added icons for undo/delete/redo in toolbar.
269 274
270Change in OM/Pi ViewMail dialog: 275Change in OM/Pi ViewMail dialog:
271When clicking on the "delete" icon the mail is deleted after confirmation as usual. 276When clicking on the "delete" icon the mail is deleted after confirmation as usual.
272But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). 277But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any).
273 278
274Fixed a crash when deleting mail-accounts in OM/Pi. 279Fixed a crash when deleting mail-accounts in OM/Pi.
275 280
276 281
277********** VERSION 1.9.14 ************ 282********** VERSION 1.9.14 ************
278 283
279Fixed some problems with the dialog sizes when switching 284Fixed some problems with the dialog sizes when switching
280portrait/landscape mode on 640x480 PDA display. 285portrait/landscape mode on 640x480 PDA display.
281 286
282Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. 287Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi.
283 288
284Fixed an ugly bug in KOpieMail: 289Fixed an ugly bug in KOpieMail:
285KOpieMail was not able to write files (mails) to MSDOS file system, 290KOpieMail was not able to write files (mails) to MSDOS file system,
286like on an usual preformatted SD card. That should work now. 291like on an usual preformatted SD card. That should work now.
287To save your mail data on the Sd card do the following: 292To save your mail data on the Sd card do the following:
288Create a dir on the SD card: 293Create a dir on the SD card:
289mkdir /mnt/card/localmail 294mkdir /mnt/card/localmail
290Go to your home dir: 295Go to your home dir:
291cd 296cd
292Go to kopiemail data storage dir: 297Go to kopiemail data storage dir:
293cd kdepim/apps/kopiemail 298cd kdepim/apps/kopiemail
294Create a symlink to the SD card: 299Create a symlink to the SD card:
295ls -s /mnt/card/localmail 300ls -s /mnt/card/localmail
296Now KOpieMail will store all mails on the SD card. 301Now KOpieMail will store all mails on the SD card.
297 302
298KO/Pi Monthview: 303KO/Pi Monthview:
299Now "Go to Today" selects the current month from day 1-end, 304Now "Go to Today" selects the current month from day 1-end,
300not the current date + some days. 305not the current date + some days.
301I.e. "Go to Today" shows now always 306I.e. "Go to Today" shows now always
302the current month with first day of month in the first row. 307the current month with first day of month in the first row.
303 308
304Added missing German translation. 309Added missing German translation.
305 310
306Fixed icons of executeable on Wintendo. 311Fixed icons of executeable on Wintendo.
307 312
308Added a "Show next Mail" button to the OM/Pi 313Added a "Show next Mail" button to the OM/Pi
309mail viewer such that the mail below the current mail 314mail viewer such that the mail below the current mail
310in the mail list view of the current folder 315in the mail list view of the current folder
311can be read with a single click. 316can be read with a single click.
312 317
313 318
314********** VERSION 1.9.13 ************ 319********** VERSION 1.9.13 ************
315 320
316Fixed nasty PwM/Pi file reading bug, when 321Fixed nasty PwM/Pi file reading bug, when
317the used hash algo of file is different then the global 322the used hash algo of file is different then the global
318hash algo. 323hash algo.
319 324
320Added KA/Pi support for opie mailit mailapplication. 325Added KA/Pi support for opie mailit mailapplication.
321 326
322Fixed some bugs in OM/Pi. 327Fixed some bugs in OM/Pi.
323Now character conversion tables are available for the Zaurus 328Now character conversion tables are available for the Zaurus
324to make OM/Pi working properly. 329to make OM/Pi working properly.
325To get the character conversion in OM/Pi working, please download 330To get the character conversion in OM/Pi working, please download
326at the sourceforge project site the package 331at the sourceforge project site the package
327sr-character-conversion_SharpROM_arm.ipk.zip 332sr-character-conversion_SharpROM_arm.ipk.zip
328(or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) 333(or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms)
329from the section "general files for KDE/Pim" 334from the section "general files for KDE/Pim"
330Instructions how to install this package are in a ReadMe in this file. 335Instructions how to install this package are in a ReadMe in this file.
331 336
332 337
333Fixed the orientation change problem in KA/Pi when switching 338Fixed the orientation change problem in KA/Pi when switching
334portrait/landscape mode. 339portrait/landscape mode.
335 340
336French translation available for KA/Pi and OM/Pi. 341French translation available for KA/Pi and OM/Pi.
337 342
338Fixed some problems with categories in KO/Pi in DTM sync. 343Fixed some problems with categories in KO/Pi in DTM sync.
339 344
340Added selection dialog for export to phone in KA/Pi. 345Added selection dialog for export to phone in KA/Pi.
341 346
342If in KO/Pi is an attendee selected to add to a meeting and this 347If in KO/Pi is an attendee selected to add to a meeting and this
343attendee is already in the list of attendees, this person is not added 348attendee is already in the list of attendees, this person is not added
344again. 349again.
345 350
346Some menu cleanup in KA/Pi. 351Some menu cleanup in KA/Pi.
347 352
348********** VERSION 1.9.12 ************ 353********** VERSION 1.9.12 ************
349 354
350Fix for the bug in KO/Pi What's Next view of version 1.9.11. 355Fix for the bug in KO/Pi What's Next view of version 1.9.11.
351 356
352Bugfix: Licence file is now shown again. 357Bugfix: Licence file is now shown again.
353 358
354OM/Pi now supports Unicode (utf8 charset). 359OM/Pi now supports Unicode (utf8 charset).
355Fixed some bugs in OM/Pi. 360Fixed some bugs in OM/Pi.
356 361
357KA/Pi has more German translation. 362KA/Pi has more German translation.
358 363
359 364
360********** VERSION 1.9.11 ************ 365********** VERSION 1.9.11 ************
361 366
362Fixed several problems in PWM/Pi, like 367Fixed several problems in PWM/Pi, like
363asking the user, if unsaved changed are pending 368asking the user, if unsaved changed are pending
364when closing the app. 369when closing the app.
365And PwM/Pi handles now different texts for the 370And PwM/Pi handles now different texts for the
366fields Description, Username, Password, configurable per category. 371fields Description, Username, Password, configurable per category.
367 372
368Fixed a crash in KO/Pi , when importing/loading vcs files 373Fixed a crash in KO/Pi , when importing/loading vcs files
369which have an entry with an attendee with state: 374which have an entry with an attendee with state:
370NEEDS ACTION 375NEEDS ACTION
371 376
372Fixed some problems in the German translation of OM/Pi, 377Fixed some problems in the German translation of OM/Pi,
373which makes some dialogs not fitting on the screen 378which makes some dialogs not fitting on the screen
374of the Z 5500. 379of the Z 5500.
375 380
376Fixed Qtopia crash, when disabling/deinstalling 381Fixed Qtopia crash, when disabling/deinstalling
377KO/Pi alarm applet. 382KO/Pi alarm applet.
378 383
379Implemented direct KDE<->KA/Pi sync for KA/Pi running 384Implemented direct KDE<->KA/Pi sync for KA/Pi running
380on Linux desktop. 385on Linux desktop.
381 386
382Added feature "remove sync info" to sync menu. 387Added feature "remove sync info" to sync menu.
383 388
384Tweaked the KO/Pi What's next view a bit, added 389Tweaked the KO/Pi What's next view a bit, added
385setting to hide events that are done. 390setting to hide events that are done.
386 391
387Disabled "beam receive enabled" on startup to 392Disabled "beam receive enabled" on startup to
388avoid problems if Fastload is enabled. 393avoid problems if Fastload is enabled.
389Please set "beam receive enabled", 394Please set "beam receive enabled",
390if you want to receive data via IR. 395if you want to receive data via IR.
391 396
392Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running 397Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running
393on Linux desktop. 398on Linux desktop.
394 399
395Made in KA/Pi scrolling possible, if details view is selected. 400Made in KA/Pi scrolling possible, if details view is selected.
396(The keyboard focus is set automatically to the search line) 401(The keyboard focus is set automatically to the search line)
397 402
398Fixed a bug in DMT sync, that a new entry in DTM was added 403Fixed a bug in DMT sync, that a new entry in DTM was added
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index f31e50a..c08f44f 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,367 +1,367 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, 48KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar,
49 bool show_week_nums, const char *name, 49 bool show_week_nums, const char *name,
50 QDate startDate ) 50 QDate startDate )
51 : QFrame(parent, name), 51 : QFrame(parent, name),
52 updateTimer(0L) 52 updateTimer(0L)
53{ 53{
54 mCalendar = calendar; 54 mCalendar = calendar;
55 55
56 setFrameStyle(QFrame::NoFrame); 56 setFrameStyle(QFrame::NoFrame);
57 57
58 QGridLayout *topLayout = new QGridLayout(this,8,8); 58 QGridLayout *topLayout = new QGridLayout(this,8,8);
59 59
60 if (! startDate.isValid()) { 60 if (! startDate.isValid()) {
61 kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; 61 qDebug("KDateNavigator::invalid startdate ");
62 startDate = QDate::currentDate(); 62 startDate = QDate::currentDate();
63 } 63 }
64 64
65 mSelectedDates.append(startDate); 65 mSelectedDates.append(startDate);
66 m_MthYr = startDate; 66 m_MthYr = startDate;
67 m_bShowWeekNums = show_week_nums; 67 m_bShowWeekNums = show_week_nums;
68 68
69 setFont( KOPrefs::instance()->mDateNavigatorFont ); 69 setFont( KOPrefs::instance()->mDateNavigatorFont );
70 mNavigatorBar = new NavigatorBar( startDate, this ); 70 mNavigatorBar = new NavigatorBar( startDate, this );
71 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 71 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
72 //mNavigatorBar->resize( 1,1); 72 //mNavigatorBar->resize( 1,1);
73 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 73 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 74 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
75 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 75 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
76 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 76 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
77 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 77 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
78 78
79 // get the day of the week on the first day 79 // get the day of the week on the first day
80 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 80 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
81 m_fstDayOfWk = dayone.dayOfWeek(); 81 m_fstDayOfWk = dayone.dayOfWeek();
82 82
83 int i; 83 int i;
84 84
85 // Set up the heading fields. 85 // Set up the heading fields.
86 for( i = 0; i < 7; i++ ) { 86 for( i = 0; i < 7; i++ ) {
87 headings[i] = new QLabel("",this); 87 headings[i] = new QLabel("",this);
88 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 88 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
89 headings[i]->setAlignment(AlignCenter); 89 headings[i]->setAlignment(AlignCenter);
90 90
91 topLayout->addWidget(headings[i],1,i+1); 91 topLayout->addWidget(headings[i],1,i+1);
92 } 92 }
93 93
94 // Create the weeknumber labels 94 // Create the weeknumber labels
95 for( i = 0; i < 6; i++ ) { 95 for( i = 0; i < 6; i++ ) {
96 weeknos[i] = new QLabel(this); 96 weeknos[i] = new QLabel(this);
97 weeknos[i]->setAlignment(AlignCenter); 97 weeknos[i]->setAlignment(AlignCenter);
98 //weeknos[i]->setFont(QFont("Arial", 10)); 98 //weeknos[i]->setFont(QFont("Arial", 10));
99 if(!show_week_nums) { 99 if(!show_week_nums) {
100 weeknos[i]->hide(); 100 weeknos[i]->hide();
101 } 101 }
102 weeknos[i]->installEventFilter(this); 102 weeknos[i]->installEventFilter(this);
103 103
104 topLayout->addWidget(weeknos[i],i+2,0); 104 topLayout->addWidget(weeknos[i],i+2,0);
105 } 105 }
106 106
107 daymatrix = new KODayMatrix( this, mCalendar, dayone, 107 daymatrix = new KODayMatrix( this, mCalendar, dayone,
108 "KDateNavigator::DayMatrix"); 108 "KDateNavigator::DayMatrix");
109 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 daymatrix->setLineWidth(1); 110 daymatrix->setLineWidth(1);
111 111
112 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 112 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
113 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 113 SIGNAL( datesSelected( const KCal::DateList & ) ) );
114 114
115 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 115 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
116 SIGNAL( eventDropped( Event * ) ) ); 116 SIGNAL( eventDropped( Event * ) ) );
117 117
118 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 118 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
119 119
120 // read settings from configuration file. 120 // read settings from configuration file.
121 updateConfig(); 121 updateConfig();
122 enableRollover(FollowMonth); 122 enableRollover(FollowMonth);
123 setFixedSize ( sizeHint() ); 123 setFixedSize ( sizeHint() );
124} 124}
125 125
126void KDateNavigator::enableRollover(RolloverType r) 126void KDateNavigator::enableRollover(RolloverType r)
127{ 127{
128 switch(r) 128 switch(r)
129 { 129 {
130 case None : 130 case None :
131 if (updateTimer) 131 if (updateTimer)
132 { 132 {
133 updateTimer->stop(); 133 updateTimer->stop();
134 delete updateTimer; 134 delete updateTimer;
135 updateTimer=0L; 135 updateTimer=0L;
136 } 136 }
137 break; 137 break;
138 case FollowDay : 138 case FollowDay :
139 case FollowMonth : 139 case FollowMonth :
140 if (!updateTimer) 140 if (!updateTimer)
141 { 141 {
142 updateTimer = new QTimer(this); 142 updateTimer = new QTimer(this);
143 QObject::connect(updateTimer,SIGNAL(timeout()), 143 QObject::connect(updateTimer,SIGNAL(timeout()),
144 this,SLOT(possiblyPastMidnight())); 144 this,SLOT(possiblyPastMidnight()));
145 } 145 }
146 updateTimer->start(0,true); 146 updateTimer->start(0,true);
147 lastDayChecked = QDate::currentDate(); 147 lastDayChecked = QDate::currentDate();
148 } 148 }
149 updateRollover=r; 149 updateRollover=r;
150} 150}
151 151
152 152
153KDateNavigator::~KDateNavigator() 153KDateNavigator::~KDateNavigator()
154{ 154{
155} 155}
156 156
157 157
158void KDateNavigator::passedMidnight() 158void KDateNavigator::passedMidnight()
159{ 159{
160 QDate today = QDate::currentDate(); 160 QDate today = QDate::currentDate();
161 bool emitMonth = false; 161 bool emitMonth = false;
162 162
163 if (today.month() != lastDayChecked.month()) 163 if (today.month() != lastDayChecked.month())
164 { 164 {
165 if (updateRollover==FollowMonth && 165 if (updateRollover==FollowMonth &&
166 daymatrix->isEndOfMonth()) { 166 daymatrix->isEndOfMonth()) {
167 goNextMonth(); 167 goNextMonth();
168 emitMonth=true; 168 emitMonth=true;
169 } 169 }
170 } 170 }
171 daymatrix->recalculateToday(); 171 daymatrix->recalculateToday();
172 daymatrix->repaint(); 172 daymatrix->repaint();
173 emit dayPassed(today); 173 emit dayPassed(today);
174 if (emitMonth) { emit monthPassed(today); } 174 if (emitMonth) { emit monthPassed(today); }
175} 175}
176 176
177/* slot */ void KDateNavigator::possiblyPastMidnight() 177/* slot */ void KDateNavigator::possiblyPastMidnight()
178{ 178{
179 if (lastDayChecked!=QDate::currentDate()) 179 if (lastDayChecked!=QDate::currentDate())
180 { 180 {
181 passedMidnight(); 181 passedMidnight();
182 lastDayChecked=QDate::currentDate(); 182 lastDayChecked=QDate::currentDate();
183 } 183 }
184 // Set the timer to go off 1 second after midnight 184 // Set the timer to go off 1 second after midnight
185 // or after 8 minutes, whichever comes first. 185 // or after 8 minutes, whichever comes first.
186 if (updateTimer) 186 if (updateTimer)
187 { 187 {
188 QTime now = QTime::currentTime(); 188 QTime now = QTime::currentTime();
189 QTime midnight = QTime(23,59,59); 189 QTime midnight = QTime(23,59,59);
190 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 190 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
191 191
192 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 192 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
193 //.arg(now.toString()).arg(midnight.toString())); 193 //.arg(now.toString()).arg(midnight.toString()));
194 194
195 updateTimer->stop(); 195 updateTimer->stop();
196 updateTimer->start(msecsWait,true); 196 updateTimer->start(msecsWait,true);
197 } 197 }
198} 198}
199 199
200void KDateNavigator::updateDates() 200void KDateNavigator::updateDates()
201{ 201{
202 // Find the first day of the week of the current month. 202 // Find the first day of the week of the current month.
203 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 203 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
204 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 204 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
205 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 205 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
206 //int di = d1 - d2 + 1; 206 //int di = d1 - d2 + 1;
207 dayone = dayone.addDays( -d2 + 1 ); 207 dayone = dayone.addDays( -d2 + 1 );
208 208
209 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 209 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
210 210
211 // If month begins on Monday and Monday is first day of week, 211 // If month begins on Monday and Monday is first day of week,
212 // month should begin on second line. Sunday doesn't have this problem. 212 // month should begin on second line. Sunday doesn't have this problem.
213 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 213 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
214 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 214 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
215 215
216 // update the matrix dates 216 // update the matrix dates
217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
218 218
219 219
220 daymatrix->updateView(dayone.addDays(index)); 220 daymatrix->updateView(dayone.addDays(index));
221//each updateDates is followed by an updateView -> repaint is issued there ! 221//each updateDates is followed by an updateView -> repaint is issued there !
222// daymatrix->repaint(); 222// daymatrix->repaint();
223} 223}
224 224
225void KDateNavigator::updateDayMatrix() 225void KDateNavigator::updateDayMatrix()
226{ 226{
227 daymatrix->updateView(); 227 daymatrix->updateView();
228 //daymatrix->repaint(); 228 //daymatrix->repaint();
229} 229}
230 230
231 231
232void KDateNavigator::updateView() 232void KDateNavigator::updateView()
233{ 233{
234 234
235 setUpdatesEnabled( false ); 235 setUpdatesEnabled( false );
236 236
237 int i; 237 int i;
238 238
239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
240 daymatrix->updateView(); 240 daymatrix->updateView();
241 241
242 // set the week numbers. 242 // set the week numbers.
243 for(i = 0; i < 6; i++) { 243 for(i = 0; i < 6; i++) {
244 QString weeknum; 244 QString weeknum;
245 // remember, according to ISO 8601, the first week of the year is the 245 // remember, according to ISO 8601, the first week of the year is the
246 // first week that contains a thursday. Thus we must subtract off 4, 246 // first week that contains a thursday. Thus we must subtract off 4,
247 // not just 1. 247 // not just 1.
248 248
249 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 249 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
250 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 250 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
251 251
252 int add = 0; 252 int add = 0;
253 if ( ! KGlobal::locale()->weekStartsMonday() ) 253 if ( ! KGlobal::locale()->weekStartsMonday() )
254 ++add; 254 ++add;
255 if (dayOfYear % 7 != 0) 255 if (dayOfYear % 7 != 0)
256 weeknum.setNum(dayOfYear / 7 + 1+add); 256 weeknum.setNum(dayOfYear / 7 + 1+add);
257 else 257 else
258 weeknum.setNum(dayOfYear / 7 +add); 258 weeknum.setNum(dayOfYear / 7 +add);
259 weeknos[i]->setText(weeknum); 259 weeknos[i]->setText(weeknum);
260 } 260 }
261 261
262 setUpdatesEnabled( true ); 262 setUpdatesEnabled( true );
263// kdDebug() << "updateView() -> repaint()" << endl; 263// kdDebug() << "updateView() -> repaint()" << endl;
264 repaint(); 264 repaint();
265 // daymatrix->repaint(); 265 // daymatrix->repaint();
266} 266}
267 267
268void KDateNavigator::updateConfig() 268void KDateNavigator::updateConfig()
269{ 269{
270 int day; 270 int day;
271 for(int i=0; i<7; i++) { 271 for(int i=0; i<7; i++) {
272 // take the first letter of the day name to be the abbreviation 272 // take the first letter of the day name to be the abbreviation
273 if (KGlobal::locale()->weekStartsMonday()) { 273 if (KGlobal::locale()->weekStartsMonday()) {
274 day = i+1; 274 day = i+1;
275 } else { 275 } else {
276 if (i==0) day = 7; 276 if (i==0) day = 7;
277 else day = i; 277 else day = i;
278 } 278 }
279 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 279 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
280 true ); 280 true );
281 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 281 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
282 headings[i]->setText( dayName ); 282 headings[i]->setText( dayName );
283 } 283 }
284 updateDates(); 284 updateDates();
285 updateView(); 285 updateView();
286} 286}
287 287
288void KDateNavigator::setShowWeekNums(bool enabled) 288void KDateNavigator::setShowWeekNums(bool enabled)
289{ 289{
290 m_bShowWeekNums = enabled; 290 m_bShowWeekNums = enabled;
291 for(int i=0; i<6; i++) { 291 for(int i=0; i<6; i++) {
292 if(enabled) 292 if(enabled)
293 weeknos[i]->show(); 293 weeknos[i]->show();
294 else 294 else
295 weeknos[i]->hide(); 295 weeknos[i]->hide();
296 } 296 }
297 resize(size()); 297 resize(size());
298} 298}
299 299
300void KDateNavigator::selectDates(const DateList& dateList) 300void KDateNavigator::selectDates(const DateList& dateList)
301{ 301{
302 302
303 if (dateList.count() > 0) { 303 if (dateList.count() > 0) {
304 mNavigatorBar->selectDates( dateList ); 304 mNavigatorBar->selectDates( dateList );
305 mSelectedDates = dateList; 305 mSelectedDates = dateList;
306 306
307 // set our record of the month and year that this datetbl is 307 // set our record of the month and year that this datetbl is
308 // displaying. 308 // displaying.
309 m_MthYr = mSelectedDates.first(); 309 m_MthYr = mSelectedDates.first();
310 310
311 311
312 // set our record of the first day of the week of the current 312 // set our record of the first day of the week of the current
313 // month. This needs to be done before calling dayToIndex, since it 313 // month. This needs to be done before calling dayToIndex, since it
314 // relies on this information being up to date. 314 // relies on this information being up to date.
315 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 315 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
316 m_fstDayOfWk = dayone.dayOfWeek(); 316 m_fstDayOfWk = dayone.dayOfWeek();
317 317
318 updateDates(); 318 updateDates();
319 319
320 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 320 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
321 321
322 updateView(); 322 updateView();
323 } 323 }
324} 324}
325 325
326int KDateNavigator::dayNum(int row, int col) 326int KDateNavigator::dayNum(int row, int col)
327{ 327{
328 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 328 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
329} 329}
330 330
331int KDateNavigator::dayToIndex(int dayNum) 331int KDateNavigator::dayToIndex(int dayNum)
332{ 332{
333 int row, col; 333 int row, col;
334 334
335 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 335 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
336 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 336 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
337 row++; 337 row++;
338 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 338 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
339 return row * 7 + col; 339 return row * 7 + col;
340} 340}
341 341
342void KDateNavigator::wheelEvent (QWheelEvent *e) 342void KDateNavigator::wheelEvent (QWheelEvent *e)
343{ 343{
344 if(e->delta()>0) emit goPrevious(); 344 if(e->delta()>0) emit goPrevious();
345 else emit goNext(); 345 else emit goNext();
346 346
347 e->accept(); 347 e->accept();
348} 348}
349 349
350bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 350bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
351{ 351{
352 if (e->type() == QEvent::MouseButtonPress) { 352 if (e->type() == QEvent::MouseButtonPress) {
353 int i; 353 int i;
354 for(i=0;i<6;++i) { 354 for(i=0;i<6;++i) {
355 if (o == weeknos[i]) { 355 if (o == weeknos[i]) {
356 QDate weekstart = daymatrix->getDate(i*7); 356 QDate weekstart = daymatrix->getDate(i*7);
357 emit weekClicked(weekstart); 357 emit weekClicked(weekstart);
358 break; 358 break;
359 } 359 }
360 } 360 }
361 return true; 361 return true;
362 } else { 362 } else {
363 return false; 363 return false;
364 } 364 }
365} 365}
366 366
367//#include "kdatenavigator.moc" 367//#include "kdatenavigator.moc"
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index dfa89e2..df5e060 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1546 +1,1578 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#ifndef DESKTOP_VERSION 31#ifndef DESKTOP_VERSION
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#else 33#else
34#include <qapplication.h> 34#include <qapplication.h>
35#endif 35#endif
36 36
37#include <kdebug.h> 37#include <kdebug.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42 42
43#include <kcalendarsystem.h> 43#include <kcalendarsystem.h>
44 44
45#ifndef KORG_NOPRINTER 45#ifndef KORG_NOPRINTER
46#include "calprinter.h" 46#include "calprinter.h"
47#endif 47#endif
48#include "koprefs.h" 48#include "koprefs.h"
49#ifndef KORG_NOPLUGINS 49#ifndef KORG_NOPLUGINS
50#include "kocore.h" 50#include "kocore.h"
51#endif 51#endif
52#include "koglobals.h" 52#include "koglobals.h"
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54 54
55#include "komonthview.h" 55#include "komonthview.h"
56 56
57#define PIXMAP_SIZE 5 57#define PIXMAP_SIZE 5
58#ifdef DESKTOP_VERSION 58#ifdef DESKTOP_VERSION
59QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 59QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
60#endif 60#endif
61class KNOWhatsThis :public QWhatsThis 61class KNOWhatsThis :public QWhatsThis
62{ 62{
63public: 63public:
64 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 64 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
65 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 65 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
66 66
67protected: 67protected:
68 virtual QString text( const QPoint& p) 68 virtual QString text( const QPoint& p)
69 { 69 {
70 return _wid->getWhatsThisText(p) ; 70 return _wid->getWhatsThisText(p) ;
71 }; 71 };
72private: 72private:
73 KNoScrollListBox* _wid; 73 KNoScrollListBox* _wid;
74 74
75}; 75};
76 76
77 77
78KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 78KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
79 : QListBox(parent, name, WRepaintNoErase) 79 : QListBox(parent, name, WRepaintNoErase)
80{ 80{
81#ifndef DESKTOP_VERSION 81#ifndef DESKTOP_VERSION
82 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 82 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
83#endif 83#endif
84 mWT = new KNOWhatsThis(this); 84 mWT = new KNOWhatsThis(this);
85} 85}
86KNoScrollListBox::~KNoScrollListBox() 86KNoScrollListBox::~KNoScrollListBox()
87{ 87{
88 88
89} 89}
90QString KNoScrollListBox::getWhatsThisText(QPoint p) 90QString KNoScrollListBox::getWhatsThisText(QPoint p)
91{ 91{
92 QListBoxItem* item = itemAt ( p ); 92 QListBoxItem* item = itemAt ( p );
93 if ( ! item ) { 93 if ( ! item ) {
94 return i18n("Click in the cell\nto add an event!"); 94 return i18n("Click in the cell\nto add an event!");
95 } 95 }
96 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 96 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
97} 97}
98void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 98void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
99{ 99{
100 100
101 switch(e->key()) { 101 switch(e->key()) {
102 case Key_Right: 102 case Key_Right:
103 // if ( e->state() == Qt::ControlButton ) 103 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
104 { 104 {
105 e->ignore(); 105 e->ignore();
106 return; 106 return;
107 } 107 }
108 scrollBy(4,0); 108 scrollBy(10,0);
109 break; 109 break;
110 case Key_Left: 110 case Key_Left:
111 // if ( e->state() == Qt::ControlButton ) 111 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
112 { 112 {
113 e->ignore(); 113 e->ignore();
114 return; 114 return;
115 } 115 }
116 scrollBy(-4,0); 116 scrollBy(-10,0);
117 break; 117 break;
118 case Key_Up: 118 case Key_Up:
119 if(count() < 2) { 119 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
120 e->ignore(); 120 e->ignore();
121 break; 121 break;
122 } 122 }
123 setCurrentItem((currentItem()+count()-1)%count()); 123 setCurrentItem((currentItem()+count()-1)%count());
124 if(!itemVisible(currentItem())) { 124 if(!itemVisible(currentItem())) {
125 if((unsigned int) currentItem() == (count()-1)) { 125 if((unsigned int) currentItem() == (count()-1)) {
126 setTopItem(currentItem()-numItemsVisible()+1); 126 setTopItem(currentItem()-numItemsVisible()+1);
127 } else { 127 } else {
128 setTopItem(topItem()-1); 128 setTopItem(topItem()-1);
129 } 129 }
130 } 130 }
131 break; 131 break;
132 case Key_Down: 132 case Key_Down:
133 if(count() < 2) { 133 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
134 e->ignore(); 134 e->ignore();
135 break; 135 break;
136 } 136 }
137 setCurrentItem((currentItem()+1)%count()); 137 setCurrentItem((currentItem()+1)%count());
138 if(!itemVisible(currentItem())) { 138 if(!itemVisible(currentItem())) {
139 if(currentItem() == 0) { 139 if(currentItem() == 0) {
140 setTopItem(0); 140 setTopItem(0);
141 } else { 141 } else {
142 setTopItem(topItem()+1); 142 setTopItem(topItem()+1);
143 } 143 }
144 } 144 }
145 break; 145 break;
146 case Key_I:
147 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
148 e->ignore();
149 break;
146 case Key_Shift: 150 case Key_Shift:
147 emit shiftDown(); 151 emit shiftDown();
148 break; 152 break;
149 default: 153 default:
150 e->ignore(); 154 e->ignore();
151 break; 155 break;
152 } 156 }
153} 157}
154 158
159void KNoScrollListBox::oneDown()
160{
161 setCurrentItem((currentItem()+1)%count());
162 if(!itemVisible(currentItem())) {
163 if(currentItem() == 0) {
164 setTopItem(0);
165 } else {
166 setTopItem(topItem()+1);
167 }
168 }
169}
155void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 170void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
156{ 171{
157 switch(e->key()) { 172 switch(e->key()) {
158 case Key_Shift: 173 case Key_Shift:
159 emit shiftUp(); 174 emit shiftUp();
160 break; 175 break;
161 default: 176 default:
162 break; 177 break;
163 } 178 }
164} 179}
165 180
166void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 181void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
167{ 182{
168 QListBox::mousePressEvent(e); 183 QListBox::mousePressEvent(e);
169 184
170 if(e->button() == RightButton) { 185 if(e->button() == RightButton) {
171 emit rightClick(); 186 emit rightClick();
172 } 187 }
173} 188}
174 189
175MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 190MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
176 : QListBoxItem() 191 : QListBoxItem()
177{ 192{
178 setText( s ); 193 setText( s );
179 194
180 mIncidence = incidence; 195 mIncidence = incidence;
181 mDate = qd; 196 mDate = qd;
182 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 197 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
183 mRecur = false; 198 mRecur = false;
184 mAlarm = false; 199 mAlarm = false;
185 mReply = false; 200 mReply = false;
186 mInfo = false; 201 mInfo = false;
187} 202}
188 203
189void MonthViewItem::paint(QPainter *p) 204void MonthViewItem::paint(QPainter *p)
190{ 205{
191#if QT_VERSION >= 0x030000 206#if QT_VERSION >= 0x030000
192 bool sel = isSelected(); 207 bool sel = isSelected();
193#else 208#else
194 bool sel = selected(); 209 bool sel = selected();
195#endif 210#endif
196 211
197 212
198 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 213 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
199 { 214 {
200 p->setBackgroundColor( palette().color( QPalette::Normal, \ 215 p->setBackgroundColor( palette().color( QPalette::Normal, \
201 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 216 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
202 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 217 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
203 } 218 }
204 int x = 1; 219 int x = 1;
205 int y = 3;//(height() - mRecurPixmap.height()) /2; 220 int y = 3;//(height() - mRecurPixmap.height()) /2;
206 int size = PIXMAP_SIZE; 221 int size = PIXMAP_SIZE;
207 if ( QApplication::desktop()->width() < 300 ) 222 if ( QApplication::desktop()->width() < 300 )
208 size = 3; 223 size = 3;
209 if ( KOPrefs::instance()->mMonthShowIcons ) { 224 if ( KOPrefs::instance()->mMonthShowIcons ) {
210 if ( mInfo ) { 225 if ( mInfo ) {
211 p->fillRect ( x, y,size,size, Qt::darkGreen ); 226 p->fillRect ( x, y,size,size, Qt::darkGreen );
212 x += size + 1; 227 x += size + 1;
213 } 228 }
214 if ( mRecur ) { 229 if ( mRecur ) {
215 p->fillRect ( x, y,size,size, Qt::blue ); 230 p->fillRect ( x, y,size,size, Qt::blue );
216 x += size + 1; 231 x += size + 1;
217 } 232 }
218 if ( mAlarm ) { 233 if ( mAlarm ) {
219 p->fillRect ( x, y,size,size, Qt::red ); 234 p->fillRect ( x, y,size,size, Qt::red );
220 x += size + 1; 235 x += size + 1;
221 } 236 }
222 if ( mReply ) { 237 if ( mReply ) {
223 p->fillRect ( x, y,size,size, Qt::yellow ); 238 p->fillRect ( x, y,size,size, Qt::yellow );
224 x += size + 1; 239 x += size + 1;
225 } 240 }
226 } 241 }
227 QFontMetrics fm = p->fontMetrics(); 242 QFontMetrics fm = p->fontMetrics();
228 int yPos; 243 int yPos;
229 int pmheight = size; 244 int pmheight = size;
230 if( pmheight < fm.height() ) 245 if( pmheight < fm.height() )
231 yPos = fm.ascent() + fm.leading()/2; 246 yPos = fm.ascent() + fm.leading()/2;
232 else 247 else
233 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 248 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
234 p->setPen( palette().color( QPalette::Normal, sel ? \ 249 p->setPen( palette().color( QPalette::Normal, sel ? \
235 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 250 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
236 p->drawText( x, yPos, text() ); 251 p->drawText( x, yPos, text() );
237 if ( mIncidence->cancelled() ) { 252 if ( mIncidence->cancelled() ) {
238 int wid = fm.width( text() ); 253 int wid = fm.width( text() );
239 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 254 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
240 } 255 }
241 256
242} 257}
243 258
244int MonthViewItem::height(const QListBox *lb) const 259int MonthViewItem::height(const QListBox *lb) const
245{ 260{
246 return lb->fontMetrics().lineSpacing()+1; 261 return lb->fontMetrics().lineSpacing()+1;
247} 262}
248 263
249int MonthViewItem::width(const QListBox *lb) const 264int MonthViewItem::width(const QListBox *lb) const
250{ 265{
251 int size = PIXMAP_SIZE; 266 int size = PIXMAP_SIZE;
252 if ( QApplication::desktop()->width() < 300 ) 267 if ( QApplication::desktop()->width() < 300 )
253 size = 3; 268 size = 3;
254 int x = 1; 269 int x = 1;
255 if ( mInfo ) { 270 if ( mInfo ) {
256 x += size + 1; 271 x += size + 1;
257 } 272 }
258 if( mRecur ) { 273 if( mRecur ) {
259 x += size+1; 274 x += size+1;
260 } 275 }
261 if( mAlarm ) { 276 if( mAlarm ) {
262 x += size+1; 277 x += size+1;
263 } 278 }
264 if( mReply ) { 279 if( mReply ) {
265 x += size+1; 280 x += size+1;
266 } 281 }
267 282
268 return( x + lb->fontMetrics().width( text() ) + 1 ); 283 return( x + lb->fontMetrics().width( text() ) + 1 );
269} 284}
270 285
271 286
272MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 287MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
273 : QWidget( par ), 288 : QWidget( par ),
274 mMonthView( parent ) 289 mMonthView( parent )
275{ 290{
276 291
277 QVBoxLayout *topLayout = new QVBoxLayout( this ); 292 QVBoxLayout *topLayout = new QVBoxLayout( this );
278 293
279 // mLabel = new QLabel( this );QPushButton 294 // mLabel = new QLabel( this );QPushButton
280 mLabel = new QPushButton( this ); 295 mLabel = new QPushButton( this );
281 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 296 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
282 //mLabel->setLineWidth( 1 ); 297 //mLabel->setLineWidth( 1 );
283 //mLabel->setAlignment( AlignCenter ); 298 //mLabel->setAlignment( AlignCenter );
284 mLabel->setFlat( true ); 299 mLabel->setFlat( true );
300 mLabel->setFocusPolicy(NoFocus);
285 mItemList = new KNoScrollListBox( this ); 301 mItemList = new KNoScrollListBox( this );
286 mItemList->setMinimumSize( 10, 10 ); 302 mItemList->setMinimumSize( 10, 10 );
287 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 303 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
288 mItemList->setLineWidth( 1 ); 304 mItemList->setLineWidth( 1 );
289 topLayout->addWidget( mItemList ); 305 topLayout->addWidget( mItemList );
290 mLabel->raise(); 306 mLabel->raise();
291 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 307 // QColor( 0,0,255 ) QColor( 160,1600,255 )
292 mStandardPalette = palette(); 308 mStandardPalette = palette();
293 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 309 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
294 310
295 enableScrollBars( false ); 311 enableScrollBars( false );
296 updateConfig(); 312 updateConfig();
297 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 313 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
298 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 314 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
299 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 315 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
300 SLOT( defaultAction( QListBoxItem * ) ) ); 316 SLOT( defaultAction( QListBoxItem * ) ) );
301 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 317 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
302 const QPoint &) ), 318 const QPoint &) ),
303 SLOT( contextMenu( QListBoxItem * ) ) ); 319 SLOT( contextMenu( QListBoxItem * ) ) );
304 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 320 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
305 SLOT( selection( QListBoxItem * ) ) ); 321 SLOT( selection( QListBoxItem * ) ) );
306 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 322 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
307 SLOT( cellClicked( QListBoxItem * ) ) ); 323 SLOT( cellClicked( QListBoxItem * ) ) );
308 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 324 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
309 SLOT( selection( QListBoxItem * ) ) ); 325 SLOT( selection( QListBoxItem * ) ) );
310} 326}
311#ifdef DESKTOP_VERSION 327#ifdef DESKTOP_VERSION
312QToolTipGroup *MonthViewCell::toolTipGroup() 328QToolTipGroup *MonthViewCell::toolTipGroup()
313{ 329{
314 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 330 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
315 return mToolTipGroup; 331 return mToolTipGroup;
316} 332}
317#endif 333#endif
318 334
319void MonthViewCell::setDate( const QDate &date ) 335void MonthViewCell::setDate( const QDate &date )
320{ 336{
321 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 337 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
322 mDate = date; 338 mDate = date;
323 339
324 340
325 341
326 //resizeEvent( 0 ); 342 //resizeEvent( 0 );
327} 343}
328 344
329QDate MonthViewCell::date() const 345QDate MonthViewCell::date() const
330{ 346{
331 return mDate; 347 return mDate;
332} 348}
333 349
334void MonthViewCell::setPrimary( bool primary ) 350void MonthViewCell::setPrimary( bool primary )
335{ 351{
336 mPrimary = primary; 352 mPrimary = primary;
337 //setMyPalette(); 353 //setMyPalette();
338} 354}
339void MonthViewCell::setMyPalette() 355void MonthViewCell::setMyPalette()
340{ 356{
341 357
342 if ( mHoliday) { 358 if ( mHoliday) {
343 setPalette( mHolidayPalette ); 359 setPalette( mHolidayPalette );
344 } else { 360 } else {
345 if ( mPrimary ) { 361 if ( mPrimary ) {
346 setPalette( mPrimaryPalette ); 362 setPalette( mPrimaryPalette );
347 } else { 363 } else {
348 setPalette( mNonPrimaryPalette ); 364 setPalette( mNonPrimaryPalette );
349 } 365 }
350 } 366 }
351 QPalette pal = palette(); 367 QPalette pal = palette();
352 368
353 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 369 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
354} 370}
355QPalette MonthViewCell::getPalette () 371QPalette MonthViewCell::getPalette ()
356{ 372{
357 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 373 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
358 return mStandardPalette; 374 return mStandardPalette;
359 if ( mHoliday) { 375 if ( mHoliday) {
360 return mHolidayPalette ; 376 return mHolidayPalette ;
361 } else { 377 } else {
362 if ( mPrimary ) { 378 if ( mPrimary ) {
363 return mPrimaryPalette ; 379 return mPrimaryPalette ;
364 } 380 }
365 } 381 }
366 return mNonPrimaryPalette; 382 return mNonPrimaryPalette;
367} 383}
368bool MonthViewCell::isPrimary() const 384bool MonthViewCell::isPrimary() const
369{ 385{
370 return mPrimary; 386 return mPrimary;
371} 387}
372 388
373void MonthViewCell::setHoliday( bool holiday ) 389void MonthViewCell::setHoliday( bool holiday )
374{ 390{
375 mHoliday = holiday; 391 mHoliday = holiday;
376 //setMyPalette(); 392 //setMyPalette();
377} 393}
378 394
379void MonthViewCell::setHoliday( const QString &holiday ) 395void MonthViewCell::setHoliday( const QString &holiday )
380{ 396{
381 mHolidayString = holiday; 397 mHolidayString = holiday;
382 398
383 if ( !holiday.isEmpty() ) { 399 if ( !holiday.isEmpty() ) {
384 setHoliday( true ); 400 setHoliday( true );
385 } 401 }
386} 402}
387void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 403void MonthViewCell::keyPressEvent ( QKeyEvent * e )
388{ 404{
389 405
390 e->ignore(); 406 e->ignore();
391 407
392} 408}
393void MonthViewCell::clear() 409void MonthViewCell::clear()
394{ 410{
395 mItemList->clear(); 411 mItemList->clear();
396 QApplication::removePostedEvents ( mItemList ); 412 QApplication::removePostedEvents ( mItemList );
397 QApplication::removePostedEvents ( mLabel ); 413 QApplication::removePostedEvents ( mLabel );
398 QApplication::removePostedEvents ( this ); 414 QApplication::removePostedEvents ( this );
399} 415}
400 416
401void MonthViewCell::startUpdateCell() 417void MonthViewCell::startUpdateCell()
402{ 418{
403 419
420 mItemList->setFocusPolicy(NoFocus);
404 if ( !mMonthView->isUpdatePossible() ) 421 if ( !mMonthView->isUpdatePossible() )
405 return; 422 return;
423
406 /* 424 /*
407 if ( !isVisible() ){ 425 if ( !isVisible() ){
408 return; 426 return;
409 } 427 }
410 */ 428 */
411 // qDebug("MonthViewCell::updateCell() "); 429 // qDebug("MonthViewCell::updateCell() ");
412 setPrimary( mDate.month()%2 ); 430 setPrimary( mDate.month()%2 );
413 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 431 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
414 if ( mDate == QDate::currentDate() ) { 432 if ( mDate == QDate::currentDate() ) {
415 mItemList->setLineWidth( 3 ); 433 mItemList->setLineWidth( 3 );
416 } else { 434 } else {
417 mItemList->setLineWidth( 1 ); 435 mItemList->setLineWidth( 1 );
418 } 436 }
419 mItemList->clear(); 437 mItemList->clear();
420 438
421#ifdef DESKTOP_VERSION 439#ifdef DESKTOP_VERSION
422 QToolTip::remove(this); 440 QToolTip::remove(this);
423#endif 441#endif
424 mToolTip = ""; 442 mToolTip = "";
425 //qApp->processEvents(); 443 //qApp->processEvents();
426 if ( !mHolidayString.isEmpty() ) { 444 if ( !mHolidayString.isEmpty() ) {
427 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 445 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
428 item->setPalette( mHolidayPalette ); 446 item->setPalette( mHolidayPalette );
429 mItemList->insertItem( item ); 447 mItemList->insertItem( item );
430 mToolTip += mHolidayString+"\n"; 448 mToolTip += mHolidayString+"\n";
431 } 449 }
432} 450}
433 451
434void MonthViewCell::insertEvent(Event *event) 452void MonthViewCell::insertEvent(Event *event)
435{ 453{
454
455 mItemList->setFocusPolicy(WheelFocus);
436 if ( !(event->doesRecur() == Recurrence::rNone) ) { 456 if ( !(event->doesRecur() == Recurrence::rNone) ) {
437 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 457 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
438 return; 458 return;
439 else 459 else
440 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 460 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
441 return; 461 return;
442 } 462 }
443 463
444 if ( event->categories().contains("Holiday") || 464 if ( event->categories().contains("Holiday") ||
445 event->categories().contains(i18n("Holiday"))) { 465 event->categories().contains(i18n("Holiday"))) {
446 setHoliday( true ); 466 setHoliday( true );
447 if ( mDate.dayOfWeek() == 7 ) 467 if ( mDate.dayOfWeek() == 7 )
448 mItemList->setLineWidth( 3 ); 468 mItemList->setLineWidth( 3 );
449 } 469 }
450 QString text; 470 QString text;
451 if (event->isMultiDay()) { 471 if (event->isMultiDay()) {
452 QString prefix = "<->"; 472 QString prefix = "<->";
453 if ( event->doesRecur() ) { 473 if ( event->doesRecur() ) {
454 if ( event->recursOn( mDate) ) 474 if ( event->recursOn( mDate) )
455 prefix ="->" ; 475 prefix ="->" ;
456 else { 476 else {
457 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 477 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
458 if ( event->recursOn( mDate.addDays( -days)) ) 478 if ( event->recursOn( mDate.addDays( -days)) )
459 prefix ="<-" ; 479 prefix ="<-" ;
460 } 480 }
461 481
462 } else { 482 } else {
463 if (mDate == event->dtStart().date()) { 483 if (mDate == event->dtStart().date()) {
464 prefix ="->" ; 484 prefix ="->" ;
465 } else if (mDate == event->dtEnd().date()) { 485 } else if (mDate == event->dtEnd().date()) {
466 prefix ="<-" ; 486 prefix ="<-" ;
467 } 487 }
468 } 488 }
469 if ( !event->doesFloat() ) { 489 if ( !event->doesFloat() ) {
470 if ( mDate == event->dtStart().date () ) 490 if ( mDate == event->dtStart().date () )
471 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 491 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
472 else if ( mDate == event->dtEnd().date () ) 492 else if ( mDate == event->dtEnd().date () )
473 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 493 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
474 494
475 } 495 }
476 text = prefix + event->summary(); 496 text = prefix + event->summary();
477 mToolTip += text; 497 mToolTip += text;
478 } else { 498 } else {
479 if (event->doesFloat()) { 499 if (event->doesFloat()) {
480 text = event->summary(); 500 text = event->summary();
481 mToolTip += text; 501 mToolTip += text;
482 } 502 }
483 else { 503 else {
484 text = KGlobal::locale()->formatTime(event->dtStart().time()); 504 text = KGlobal::locale()->formatTime(event->dtStart().time());
485 text += " " + event->summary(); 505 text += " " + event->summary();
486 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 506 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
487 } 507 }
488 } 508 }
489 509
490 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 510 MonthViewItem *item = new MonthViewItem( event, mDate, text );
491 QPalette pal; 511 QPalette pal;
492 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 512 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
493 QStringList categories = event->categories(); 513 QStringList categories = event->categories();
494 QString cat = categories.first(); 514 QString cat = categories.first();
495 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 515 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
496 pal = getPalette(); 516 pal = getPalette();
497 if (cat.isEmpty()) { 517 if (cat.isEmpty()) {
498 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 518 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
499 } else { 519 } else {
500 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 520 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
501 } 521 }
502 522
503 } else { 523 } else {
504 if (cat.isEmpty()) { 524 if (cat.isEmpty()) {
505 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 525 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
506 } else { 526 } else {
507 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 527 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
508 } 528 }
509 } 529 }
510 530
511 } else { 531 } else {
512 pal = mStandardPalette ; 532 pal = mStandardPalette ;
513 } 533 }
514 item->setPalette( pal ); 534 item->setPalette( pal );
515 item->setRecur( event->recurrence()->doesRecur() ); 535 item->setRecur( event->recurrence()->doesRecur() );
516 item->setAlarm( event->isAlarmEnabled() ); 536 item->setAlarm( event->isAlarmEnabled() );
517 item->setMoreInfo( event->description().length() > 0 ); 537 item->setMoreInfo( event->description().length() > 0 );
518#ifdef DESKTOP_VERSION 538#ifdef DESKTOP_VERSION
519 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 539 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
520 KOPrefs::instance()->email()); 540 KOPrefs::instance()->email());
521 if ( me != 0 ) { 541 if ( me != 0 ) {
522 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 542 if ( me->status() == Attendee::NeedsAction && me->RSVP())
523 item->setReply(true); 543 item->setReply(true);
524 else 544 else
525 item->setReply(false); 545 item->setReply(false);
526 } else 546 } else
527 item->setReply(false); 547 item->setReply(false);
528#endif 548#endif
529 mItemList->insertItem( item ); 549 mItemList->insertItem( item );
530 mToolTip += "\n"; 550 mToolTip += "\n";
531} 551}
532void MonthViewCell::insertTodo(Todo *todo) 552void MonthViewCell::insertTodo(Todo *todo)
533{ 553{
534 QString text; 554 QString text;
535 if (todo->hasDueDate()) { 555 if (todo->hasDueDate()) {
536 if (!todo->doesFloat()) { 556 if (!todo->doesFloat()) {
537 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 557 text += KGlobal::locale()->formatTime(todo->dtDue().time());
538 text += " "; 558 text += " ";
539 } 559 }
540 } 560 }
541 text += i18n("To-Do: %1").arg(todo->summary()); 561 text += i18n("Td: %1").arg(todo->summary());
542 562
543 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 563 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
544 //item->setPalette( mStandardPalette ); 564 //item->setPalette( mStandardPalette );
545 QPalette pal; 565 QPalette pal;
546 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 566 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
547 QStringList categories = todo->categories(); 567 QStringList categories = todo->categories();
548 QString cat = categories.first(); 568 QString cat = categories.first();
549 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 569 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
550 pal = getPalette(); 570 pal = getPalette();
551 if (cat.isEmpty()) { 571 if (cat.isEmpty()) {
552 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 572 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
553 } else { 573 } else {
554 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 574 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
555 } 575 }
556 576
557 } else { 577 } else {
558 if (cat.isEmpty()) { 578 if (cat.isEmpty()) {
559 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 579 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
560 } else { 580 } else {
561 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 581 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
562 } 582 }
563 } 583 }
564 584
565 } else { 585 } else {
566 pal = mStandardPalette ; 586 pal = mStandardPalette ;
567 } 587 }
568 item->setPalette( pal ); 588 item->setPalette( pal );
569 mItemList->insertItem( item ); 589 mItemList->insertItem( item );
570 mToolTip += text+"\n"; 590 mToolTip += text+"\n";
571} 591}
572void MonthViewCell::finishUpdateCell() 592void MonthViewCell::finishUpdateCell()
573{ 593{
574#ifdef DESKTOP_VERSION 594#ifdef DESKTOP_VERSION
575 if (mToolTip != "") 595 if (mToolTip != "")
576 QToolTip::add(this,mToolTip,toolTipGroup(),""); 596 QToolTip::add(this,mToolTip,toolTipGroup(),"");
577#endif 597#endif
578 mItemList->sort(); 598 mItemList->sort();
579 //setMyPalette(); 599 //setMyPalette();
580 setMyPalette(); 600 setMyPalette();
581 QString text; 601 QString text;
582 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 602 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
583 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 603 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
584 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 604 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
585 mLabel->resize( mLabelBigSize ); 605 mLabel->resize( mLabelBigSize );
586 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 606 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
587 } else { 607 } else {
588 mLabel->resize( mLabelSize ); 608 mLabel->resize( mLabelSize );
589 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 609 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
590 } 610 }
591 611
592 mLabel->setText( text ); 612 mLabel->setText( text );
593 resizeEvent( 0 ); 613 resizeEvent( 0 );
594} 614}
595void MonthViewCell::updateCell() 615void MonthViewCell::updateCell()
596{ 616{
597 if ( !mMonthView->isUpdatePossible() ) 617 if ( !mMonthView->isUpdatePossible() )
598 return; 618 return;
599 startUpdateCell(); 619 startUpdateCell();
600 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 620 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
601 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 621 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
602 Event *event; 622 Event *event;
603 for( event = events.first(); event; event = events.next() ) { // for event 623 for( event = events.first(); event; event = events.next() ) { // for event
604 insertEvent(event); 624 insertEvent(event);
605 } 625 }
606 // insert due todos 626 // insert due todos
607 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 627 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
608 Todo *todo; 628 Todo *todo;
609 for(todo = todos.first(); todo; todo = todos.next()) { 629 for(todo = todos.first(); todo; todo = todos.next()) {
610 insertTodo( todo ); 630 insertTodo( todo );
611 } 631 }
612 finishUpdateCell(); 632 finishUpdateCell();
613 // if ( isVisible()) 633 // if ( isVisible())
614 //qApp->processEvents(); 634 //qApp->processEvents();
615} 635}
616 636
617void MonthViewCell::updateConfig( bool bigFont ) // = false 637void MonthViewCell::updateConfig( bool bigFont ) // = false
618{ 638{
619 639
620 if ( bigFont ) { 640 if ( bigFont ) {
621 QFont fo = KOPrefs::instance()->mMonthViewFont; 641 QFont fo = KOPrefs::instance()->mMonthViewFont;
622 int ps = fo.pointSize() + 2; 642 int ps = fo.pointSize() + 2;
623 if ( ps < 18 ) 643 if ( ps < 18 )
624 ps += 2; 644 ps += 2;
625 fo.setPointSize( ps ); 645 fo.setPointSize( ps );
626 setFont( fo ); 646 setFont( fo );
627 } else 647 } else
628 setFont( KOPrefs::instance()->mMonthViewFont ); 648 setFont( KOPrefs::instance()->mMonthViewFont );
629 649
630 QFontMetrics fm( font() ); 650 QFontMetrics fm( font() );
631 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 651 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
632 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 652 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
633 mHolidayPalette = mStandardPalette; 653 mHolidayPalette = mStandardPalette;
634 mPrimaryPalette = mStandardPalette; 654 mPrimaryPalette = mStandardPalette;
635 mNonPrimaryPalette = mStandardPalette; 655 mNonPrimaryPalette = mStandardPalette;
636 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 656 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
637 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 657 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
638 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 658 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
639 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 659 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
640 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 660 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
641 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 661 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
642 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 662 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
643 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 663 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
644 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 664 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
645 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 665 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
646 } 666 }
647 //updateCell(); 667 //updateCell();
648} 668}
649 669
650void MonthViewCell::enableScrollBars( bool enabled ) 670void MonthViewCell::enableScrollBars( bool enabled )
651{ 671{
652 if ( enabled ) { 672 if ( enabled ) {
653 mItemList->setVScrollBarMode(QScrollView::Auto); 673 mItemList->setVScrollBarMode(QScrollView::Auto);
654 mItemList->setHScrollBarMode(QScrollView::Auto); 674 mItemList->setHScrollBarMode(QScrollView::Auto);
655 } else { 675 } else {
656 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 676 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
657 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 677 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
658 } 678 }
659} 679}
660 680
661Incidence *MonthViewCell::selectedIncidence() 681Incidence *MonthViewCell::selectedIncidence()
662{ 682{
663 int index = mItemList->currentItem(); 683 int index = mItemList->currentItem();
664 if ( index < 0 ) return 0; 684 if ( index < 0 ) return 0;
665 685
666 MonthViewItem *item = 686 MonthViewItem *item =
667 static_cast<MonthViewItem *>( mItemList->item( index ) ); 687 static_cast<MonthViewItem *>( mItemList->item( index ) );
668 688
669 if ( !item ) return 0; 689 if ( !item ) return 0;
670 690
671 return item->incidence(); 691 return item->incidence();
672} 692}
673 693
674QDate MonthViewCell::selectedIncidenceDate() 694QDate MonthViewCell::selectedIncidenceDate()
675{ 695{
676 QDate qd; 696 QDate qd;
677 int index = mItemList->currentItem(); 697 int index = mItemList->currentItem();
678 if ( index < 0 ) return qd; 698 if ( index < 0 ) return qd;
679 699
680 MonthViewItem *item = 700 MonthViewItem *item =
681 static_cast<MonthViewItem *>( mItemList->item( index ) ); 701 static_cast<MonthViewItem *>( mItemList->item( index ) );
682 702
683 if ( !item ) return qd; 703 if ( !item ) return qd;
684 704
685 return item->incidenceDate(); 705 return item->incidenceDate();
686} 706}
687 707
688void MonthViewCell::deselect() 708void MonthViewCell::deselect()
689{ 709{
690 mItemList->clearSelection(); 710 mItemList->clearSelection();
691 enableScrollBars( false ); 711 enableScrollBars( false );
692 // updateCell(); 712 // updateCell();
693} 713}
694void MonthViewCell::select() 714void MonthViewCell::select()
695{ 715{
696 ;// updateCell(); 716 ;// updateCell();
697} 717}
698 718
699void MonthViewCell::resizeEvent ( QResizeEvent * ) 719void MonthViewCell::resizeEvent ( QResizeEvent * )
700{ 720{
701 if ( !mMonthView->isUpdatePossible() ) 721 if ( !mMonthView->isUpdatePossible() )
702 return; 722 return;
703 723
704 int size = height() - mLabel->height() - 2; 724 int size = height() - mLabel->height() - 2;
705 if ( size > 0 ) 725 if ( size > 0 )
706 mItemList->verticalScrollBar()->setMaximumHeight( size ); 726 mItemList->verticalScrollBar()->setMaximumHeight( size );
707 size = width() - mLabel->width() -2; 727 size = width() - mLabel->width() -2;
708 if ( size > 0 ) 728 if ( size > 0 )
709 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 729 mItemList->horizontalScrollBar()->setMaximumWidth( size );
710 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 730 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
711 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 731 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
712} 732}
713 733
714void MonthViewCell::defaultAction( QListBoxItem *item ) 734void MonthViewCell::defaultAction( QListBoxItem *item )
715{ 735{
716 if ( !item ) return; 736 if ( !item ) return;
717 737
718 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 738 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
719 Incidence *incidence = eventItem->incidence(); 739 Incidence *incidence = eventItem->incidence();
720 if ( incidence ) mMonthView->defaultAction( incidence ); 740 if ( incidence ) mMonthView->defaultAction( incidence );
721} 741}
722void MonthViewCell::showDay() 742void MonthViewCell::showDay()
723{ 743{
724 emit showDaySignal( date() ); 744 emit showDaySignal( date() );
725} 745}
726void MonthViewCell::newEvent() 746void MonthViewCell::newEvent()
727{ 747{
728 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 748 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
729 emit newEventSignal( dt ); 749 emit newEventSignal( dt );
730} 750}
731void MonthViewCell::cellClicked( QListBoxItem *item ) 751void MonthViewCell::cellClicked( QListBoxItem *item )
732{ 752{
733 static QListBoxItem * lastClicked = 0; 753 static QListBoxItem * lastClicked = 0;
734 if ( item == 0 ) { 754 if ( item == 0 ) {
735 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 755 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
736 emit newEventSignal( dt ); 756 emit newEventSignal( dt );
737 return; 757 return;
738 } 758 }
739 /* 759 /*
740 if ( lastClicked ) 760 if ( lastClicked )
741 if ( ! item ) { 761 if ( ! item ) {
742 if ( lastClicked->listBox() != item->listBox() ) 762 if ( lastClicked->listBox() != item->listBox() )
743 lastClicked->listBox()->clearSelection(); 763 lastClicked->listBox()->clearSelection();
744 } 764 }
745 */ 765 */
746 766
747 mMonthView->setSelectedCell( this ); 767 mMonthView->setSelectedCell( this );
748 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 768 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
749 select(); 769 select();
750} 770}
751 771
752void MonthViewCell::contextMenu( QListBoxItem *item ) 772void MonthViewCell::contextMenu( QListBoxItem *item )
753{ 773{
754 if ( !item ) return; 774 if ( !item ) return;
755 775
756 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 776 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
757 Incidence *incidence = eventItem->incidence(); 777 Incidence *incidence = eventItem->incidence();
758 if ( incidence ) mMonthView->showContextMenu( incidence ); 778 if ( incidence ) mMonthView->showContextMenu( incidence );
759} 779}
760 780
761void MonthViewCell::selection( QListBoxItem *item ) 781void MonthViewCell::selection( QListBoxItem *item )
762{ 782{
763 if ( !item ) return; 783 if ( !item ) return;
764 784
765 mMonthView->setSelectedCell( this ); 785 mMonthView->setSelectedCell( this );
766} 786}
767 787
768 788
769// ******************************************************************************* 789// *******************************************************************************
770// ******************************************************************************* 790// *******************************************************************************
771// ******************************************************************************* 791// *******************************************************************************
772 792
773 793
774KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 794KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
775 : KOEventView( calendar, parent, name ), 795 : KOEventView( calendar, parent, name ),
776 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 796 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
777 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 797 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
778{ 798{
779 799
780 clPending = true; 800 clPending = true;
781 mWidStack = new QWidgetStack( this ); 801 mWidStack = new QWidgetStack( this );
782 QHBoxLayout* hb = new QHBoxLayout( this ); 802 QHBoxLayout* hb = new QHBoxLayout( this );
783 mMonthView = new QWidget( mWidStack ); 803 mMonthView = new QWidget( mWidStack );
784 mWeekView = new QWidget( mWidStack ); 804 mWeekView = new QWidget( mWidStack );
785#if QT_VERSION >= 0x030000 805#if QT_VERSION >= 0x030000
786 mWidStack->addWidget(mMonthView ); 806 mWidStack->addWidget(mMonthView );
787 mWidStack->addWidget(mWeekView ); 807 mWidStack->addWidget(mWeekView );
788#else 808#else
789 mWidStack->addWidget( mMonthView, 1 ); 809 mWidStack->addWidget( mMonthView, 1 );
790 mWidStack->addWidget( mWeekView , 1 ); 810 mWidStack->addWidget( mWeekView , 1 );
791#endif 811#endif
792 hb->addWidget( mWidStack ); 812 hb->addWidget( mWidStack );
793 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 813 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
794 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 814 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
795 if ( mShowWeekView ) 815 if ( mShowWeekView )
796 mWeekStartsMonday = true; 816 mWeekStartsMonday = true;
797 updatePossible = false; 817 updatePossible = false;
798 mCells.setAutoDelete( true ); 818 mCells.setAutoDelete( true );
799 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 819 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
800 mDayLabels.resize( mDaysPerWeek ); 820 mDayLabels.resize( mDaysPerWeek );
801 mDayLabelsW.resize( mDaysPerWeek ); 821 mDayLabelsW.resize( mDaysPerWeek );
802 QFont bfont = font(); 822 QFont bfont = font();
803 if ( QApplication::desktop()->width() < 650 ) { 823 if ( QApplication::desktop()->width() < 650 ) {
804 bfont.setPointSize( bfont.pointSize() - 2 ); 824 bfont.setPointSize( bfont.pointSize() - 2 );
805 } 825 }
806 bfont.setBold( true ); 826 bfont.setBold( true );
807 int i; 827 int i;
808 828
809 for( i = 0; i < mDaysPerWeek; i++ ) { 829 for( i = 0; i < mDaysPerWeek; i++ ) {
810 QLabel *label = new QLabel( mMonthView ); 830 QLabel *label = new QLabel( mMonthView );
811 label->setFont(bfont); 831 label->setFont(bfont);
812 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 832 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
813 label->setLineWidth(1); 833 label->setLineWidth(1);
814 label->setAlignment(AlignCenter); 834 label->setAlignment(AlignCenter);
815 mDayLabels.insert( i, label ); 835 mDayLabels.insert( i, label );
816 label = new QLabel( mWeekView ); 836 label = new QLabel( mWeekView );
817 label->setFont(bfont); 837 label->setFont(bfont);
818 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 838 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
819 label->setLineWidth(1); 839 label->setLineWidth(1);
820 label->setAlignment(AlignCenter); 840 label->setAlignment(AlignCenter);
821 mDayLabelsW.insert( i, label ); 841 mDayLabelsW.insert( i, label );
822 } 842 }
823 843
824 bfont.setBold( false ); 844 bfont.setBold( false );
825 mWeekLabels.resize( mNumWeeks+1 ); 845 mWeekLabels.resize( mNumWeeks+1 );
826 mWeekLabelsW.resize( 2 ); 846 mWeekLabelsW.resize( 2 );
827 for( i = 0; i < mNumWeeks+1; i++ ) { 847 for( i = 0; i < mNumWeeks+1; i++ ) {
828 KOWeekButton *label = new KOWeekButton( mMonthView ); 848 KOWeekButton *label = new KOWeekButton( mMonthView );
849 label->setFocusPolicy(NoFocus);
829 label->setFont(bfont); 850 label->setFont(bfont);
830 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 851 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
831 label->setFlat(true); 852 label->setFlat(true);
832 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 853 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
833 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 854 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
834 //label->setLineWidth(1); 855 //label->setLineWidth(1);
835 //label->setAlignment(AlignCenter); 856 //label->setAlignment(AlignCenter);
836 mWeekLabels.insert( i, label ); 857 mWeekLabels.insert( i, label );
837 } 858 }
838 mWeekLabels[mNumWeeks]->setText( i18n("W")); 859 mWeekLabels[mNumWeeks]->setText( i18n("W"));
839 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 860 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
840 861
841 for( i = 0; i < 1+1; i++ ) { 862 for( i = 0; i < 1+1; i++ ) {
842 KOWeekButton *label = new KOWeekButton( mWeekView ); 863 KOWeekButton *label = new KOWeekButton( mWeekView );
864 label->setFocusPolicy(NoFocus);
843 label->setFont(bfont); 865 label->setFont(bfont);
844 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 866 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
845 label->setFlat(true); 867 label->setFlat(true);
846 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 868 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
847 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 869 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
848 //label->setLineWidth(1); 870 //label->setLineWidth(1);
849 //label->setAlignment(AlignCenter); 871 //label->setAlignment(AlignCenter);
850 mWeekLabelsW.insert( i, label ); 872 mWeekLabelsW.insert( i, label );
851 } 873 }
852 mWeekLabelsW[1]->setText( i18n("W")); 874 mWeekLabelsW[1]->setText( i18n("W"));
853 875
854 876
855 int row, col; 877 int row, col;
856 mCells.resize( mNumCells ); 878 mCells.resize( mNumCells );
857 for( row = 0; row < mNumWeeks; ++row ) { 879 for( row = 0; row < mNumWeeks; ++row ) {
858 for( col = 0; col < mDaysPerWeek; ++col ) { 880 for( col = 0; col < mDaysPerWeek; ++col ) {
859 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 881 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
860 mCells.insert( row * mDaysPerWeek + col, cell ); 882 mCells.insert( row * mDaysPerWeek + col, cell );
861 883
862 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 884 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
863 SLOT( defaultAction( Incidence * ) ) ); 885 SLOT( defaultAction( Incidence * ) ) );
864 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 886 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
865 SIGNAL( newEventSignal( QDateTime ) ) ); 887 SIGNAL( newEventSignal( QDateTime ) ) );
866 connect( cell, SIGNAL( showDaySignal( QDate ) ), 888 connect( cell, SIGNAL( showDaySignal( QDate ) ),
867 SIGNAL( showDaySignal( QDate ) ) ); 889 SIGNAL( showDaySignal( QDate ) ) );
868 } 890 }
869 } 891 }
870 mCellsW.resize( mDaysPerWeek ); 892 mCellsW.resize( mDaysPerWeek );
871 for( col = 0; col < mDaysPerWeek; ++col ) { 893 for( col = 0; col < mDaysPerWeek; ++col ) {
872 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 894 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
873 mCellsW.insert( col, cell ); 895 mCellsW.insert( col, cell );
874 896
875 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 897 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
876 SLOT( defaultAction( Incidence * ) ) ); 898 SLOT( defaultAction( Incidence * ) ) );
877 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 899 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
878 SIGNAL( newEventSignal( QDateTime ) ) ); 900 SIGNAL( newEventSignal( QDateTime ) ) );
879 connect( cell, SIGNAL( showDaySignal( QDate ) ), 901 connect( cell, SIGNAL( showDaySignal( QDate ) ),
880 SIGNAL( showDaySignal( QDate ) ) ); 902 SIGNAL( showDaySignal( QDate ) ) );
881 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 903 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
882 } 904 }
883 905
884 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 906 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
885 mContextMenu = eventPopup(); 907 mContextMenu = eventPopup();
886 // updateConfig(); //useless here 908 // updateConfig(); //useless here
887 909
888 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 910 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
889#if 0 911#if 0
890 mWidStack = new QWidgetStack( this ); 912 mWidStack = new QWidgetStack( this );
891 mMonthView = new QWidget( mWidStack ); 913 mMonthView = new QWidget( mWidStack );
892 mWeekView = new QWidget( mWidStack ); 914 mWeekView = new QWidget( mWidStack );
893#endif 915#endif
894 if ( mShowWeekView ) 916 if ( mShowWeekView )
895 mWidStack->raiseWidget( mWeekView ); 917 mWidStack->raiseWidget( mWeekView );
896 else 918 else
897 mWidStack->raiseWidget( mMonthView ); 919 mWidStack->raiseWidget( mMonthView );
898 920
899 emit incidenceSelected( 0 ); 921 emit incidenceSelected( 0 );
900} 922}
901 923
902KOMonthView::~KOMonthView() 924KOMonthView::~KOMonthView()
903{ 925{
904 delete mContextMenu; 926 delete mContextMenu;
905} 927}
906void KOMonthView::selectDateWeekNum ( int )
907{
908 928
909}
910void KOMonthView::selectInternalWeekNum ( int n ) 929void KOMonthView::selectInternalWeekNum ( int n )
911{ 930{
912 switchView(); 931 switchView();
913 emit selectWeekNum ( n ); 932 emit selectWeekNum ( n );
914} 933}
915 934
935int KOMonthView::currentWeek()
936{
937 if ( mShowWeekView )
938 return mWeekLabelsW[0]->getWeekNum();
939 return mWeekLabels[0]->getWeekNum();
940}
916void KOMonthView::switchView() 941void KOMonthView::switchView()
917{ 942{
918 943
919 if ( selectedCell( ) ) 944 if ( selectedCell( ) )
920 selectedCell()->deselect(); 945 selectedCell()->deselect();
921 mShowWeekView = !mShowWeekView; 946 mShowWeekView = !mShowWeekView;
922 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 947 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
923 //emit showNavigator( !mShowWeekView ); 948 //emit showNavigator( !mShowWeekView );
924 if ( clPending ) { 949 if ( clPending ) {
925 computeLayout(); 950 computeLayout();
926 updateConfig(); 951 updateConfig();
927 } 952 }
928 if ( mShowWeekView ) 953 if ( mShowWeekView )
929 mWidStack->raiseWidget( mWeekView ); 954 mWidStack->raiseWidget( mWeekView );
930 else 955 else
931 mWidStack->raiseWidget( mMonthView ); 956 mWidStack->raiseWidget( mMonthView );
932 clPending = false; 957 clPending = false;
933} 958}
934 959
935int KOMonthView::maxDatesHint() 960int KOMonthView::maxDatesHint()
936{ 961{
937 return mNumCells; 962 return mNumCells;
938} 963}
939 964
940int KOMonthView::currentDateCount() 965int KOMonthView::currentDateCount()
941{ 966{
942 return mNumCells; 967 return mNumCells;
943} 968}
944 969
945QPtrList<Incidence> KOMonthView::selectedIncidences() 970QPtrList<Incidence> KOMonthView::selectedIncidences()
946{ 971{
947 QPtrList<Incidence> selected; 972 QPtrList<Incidence> selected;
948 973
949 if ( mSelectedCell ) { 974 if ( mSelectedCell ) {
950 Incidence *incidence = mSelectedCell->selectedIncidence(); 975 Incidence *incidence = mSelectedCell->selectedIncidence();
951 if ( incidence ) selected.append( incidence ); 976 if ( incidence ) selected.append( incidence );
952 } 977 }
953 978
954 return selected; 979 return selected;
955} 980}
956 981
957DateList KOMonthView::selectedDates() 982DateList KOMonthView::selectedDates()
958{ 983{
959 DateList selected; 984 DateList selected;
960 985
961 if ( mSelectedCell ) { 986 if ( mSelectedCell ) {
962 QDate qd = mSelectedCell->selectedIncidenceDate(); 987 QDate qd = mSelectedCell->selectedIncidenceDate();
963 if ( qd.isValid() ) selected.append( qd ); 988 if ( qd.isValid() ) selected.append( qd );
964 } 989 }
965 990
966 return selected; 991 return selected;
967} 992}
968 993
969void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 994void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
970 const QDate &td) 995 const QDate &td)
971{ 996{
972#ifndef KORG_NOPRINTER 997#ifndef KORG_NOPRINTER
973 calPrinter->preview(CalPrinter::Month, fd, td); 998 calPrinter->preview(CalPrinter::Month, fd, td);
974#endif 999#endif
975} 1000}
976 1001
977void KOMonthView::updateConfig() 1002void KOMonthView::updateConfig()
978{ 1003{
979 1004
980 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1005 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
981 1006
982 if ( mShowWeekView ) { 1007 if ( mShowWeekView ) {
983 mWeekStartsMonday = true; 1008 mWeekStartsMonday = true;
984 } 1009 }
985 QFontMetrics fontmetric(mDayLabels[0]->font()); 1010 QFontMetrics fontmetric(mDayLabels[0]->font());
986 mWidthLongDayLabel = 0; 1011 mWidthLongDayLabel = 0;
987 1012
988 for (int i = 0; i < 7; i++) { 1013 for (int i = 0; i < 7; i++) {
989 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1014 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
990 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1015 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
991 } 1016 }
992 bool temp = mShowSatSunComp ; 1017 bool temp = mShowSatSunComp ;
993 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1018 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
994 if ( ! mShowWeekView ) { 1019 if ( ! mShowWeekView ) {
995 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1020 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
996 computeLayout(); 1021 computeLayout();
997 } 1022 }
998 updateDayLabels(); 1023 updateDayLabels();
999 //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);
1000 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1025 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1001 //resizeEvent( 0 ); 1026 //resizeEvent( 0 );
1002 for (uint i = 0; i < mCells.count(); ++i) { 1027 for (uint i = 0; i < mCells.count(); ++i) {
1003 mCells[i]->updateConfig(); 1028 mCells[i]->updateConfig();
1004 } 1029 }
1005 1030
1006 for (uint i = 0; i < mCellsW.count(); ++i) { 1031 for (uint i = 0; i < mCellsW.count(); ++i) {
1007 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1032 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1008 } 1033 }
1009#ifdef DESKTOP_VERSION 1034#ifdef DESKTOP_VERSION
1010 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1035 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1011#endif 1036#endif
1012 updateView(); 1037 updateView();
1013} 1038}
1014 1039
1015void KOMonthView::updateDayLabels() 1040void KOMonthView::updateDayLabels()
1016{ 1041{
1017 1042
1018 QPtrVector<QLabel> *mDayLabelsT; 1043 QPtrVector<QLabel> *mDayLabelsT;
1019#if 0 1044#if 0
1020 if (mShowWeekView ) 1045 if (mShowWeekView )
1021 mDayLabelsT = &mDayLabelsW; 1046 mDayLabelsT = &mDayLabelsW;
1022 else 1047 else
1023 mDayLabelsT = &mDayLabels; 1048 mDayLabelsT = &mDayLabels;
1024#endif 1049#endif
1025 1050
1026 mDayLabelsT = &mDayLabelsW; 1051 mDayLabelsT = &mDayLabelsW;
1027 for (int i = 0; i < 7; i++) { 1052 for (int i = 0; i < 7; i++) {
1028 if (mWeekStartsMonday) { 1053 if (mWeekStartsMonday) {
1029 bool show = mShortDayLabels; 1054 bool show = mShortDayLabels;
1030 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1055 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1031 show = true; 1056 show = true;
1032 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1057 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1033 } else { 1058 } else {
1034 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));
1035 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1060 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1036 1061
1037 } 1062 }
1038 } 1063 }
1039 mDayLabelsT = &mDayLabels; 1064 mDayLabelsT = &mDayLabels;
1040 for (int i = 0; i < 7; i++) { 1065 for (int i = 0; i < 7; i++) {
1041 if (mWeekStartsMonday) { 1066 if (mWeekStartsMonday) {
1042 bool show = mShortDayLabels; 1067 bool show = mShortDayLabels;
1043 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1068 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1044 show = true; 1069 show = true;
1045 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1070 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1046 } else { 1071 } else {
1047 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));
1048 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1073 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1049 1074
1050 } 1075 }
1051 } 1076 }
1052 1077
1053} 1078}
1054 1079
1055void KOMonthView::showDates(const QDate &start, const QDate &) 1080void KOMonthView::showDates(const QDate &start, const QDate &)
1056{ 1081{
1057 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1082 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1058 1083
1059 QPtrVector<MonthViewCell> *cells; 1084 QPtrVector<MonthViewCell> *cells;
1060 QPtrVector<QLabel> *dayLabels; 1085 QPtrVector<QLabel> *dayLabels;
1061 QPtrVector<KOWeekButton> *weekLabels; 1086 QPtrVector<KOWeekButton> *weekLabels;
1062 int weekNum = 6; 1087 int weekNum = 6;
1063 if ( mShowWeekView ) { 1088 if ( mShowWeekView ) {
1064 weekNum = 1; 1089 weekNum = 1;
1065 cells = &mCellsW; 1090 cells = &mCellsW;
1066 dayLabels = &mDayLabelsW; 1091 dayLabels = &mDayLabelsW;
1067 weekLabels = &mWeekLabelsW; 1092 weekLabels = &mWeekLabelsW;
1068 } else { 1093 } else {
1069 cells = &mCells; 1094 cells = &mCells;
1070 dayLabels = &mDayLabels; 1095 dayLabels = &mDayLabels;
1071 weekLabels = &mWeekLabels; 1096 weekLabels = &mWeekLabels;
1072 } 1097 }
1073 1098
1074 mStartDate = start; 1099 mStartDate = start;
1075 1100
1076 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1101 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1077 1102
1078 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1103 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1079 mStartDate = mStartDate.addDays( -1 ); 1104 mStartDate = mStartDate.addDays( -1 );
1080 } 1105 }
1081 1106
1082 bool primary = false; 1107 bool primary = false;
1083 uint i; 1108 uint i;
1084 for( i = 0; i < (*cells).size(); ++i ) { 1109 for( i = 0; i < (*cells).size(); ++i ) {
1085 QDate date = mStartDate.addDays( i ); 1110 QDate date = mStartDate.addDays( i );
1086 (*cells)[i]->setDate( date ); 1111 (*cells)[i]->setDate( date );
1087 1112
1088#ifndef KORG_NOPLUGINS 1113#ifndef KORG_NOPLUGINS
1089 // add holiday, if present 1114 // add holiday, if present
1090 QString hstring(KOCore::self()->holiday(date)); 1115 QString hstring(KOCore::self()->holiday(date));
1091 (*cells)[i]->setHoliday( hstring ); 1116 (*cells)[i]->setHoliday( hstring );
1092#endif 1117#endif
1093 1118
1094 } 1119 }
1095 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1120 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1096 for( i = 0; i < weekNum; ++i ) { 1121 for( i = 0; i < weekNum; ++i ) {
1097 int wno; 1122 int wno;
1098 // 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
1099 // 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,
1100 // not just 1. 1125 // not just 1.
1101 int dayOfYear = date.dayOfYear(); 1126 int dayOfYear = date.dayOfYear();
1102 if (dayOfYear % 7 != 0) 1127 if (dayOfYear % 7 != 0)
1103 wno = dayOfYear / 7 + 1; 1128 wno = dayOfYear / 7 + 1;
1104 else 1129 else
1105 wno =dayOfYear / 7; 1130 wno =dayOfYear / 7;
1106 (*weekLabels)[i]->setWeekNum( wno ); 1131 (*weekLabels)[i]->setWeekNum( wno );
1107 date = date.addDays( 7 ); 1132 date = date.addDays( 7 );
1108 } 1133 }
1109 updateView(); 1134 updateView();
1110} 1135}
1111 1136
1112void KOMonthView::showEvents(QPtrList<Event>) 1137void KOMonthView::showEvents(QPtrList<Event>)
1113{ 1138{
1114 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1139 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1115} 1140}
1116 1141
1117void KOMonthView::changeEventDisplay(Event *, int) 1142void KOMonthView::changeEventDisplay(Event *, int)
1118{ 1143{
1119 // 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
1120 // quick-and-dirty-hack gets the job done for right now. 1145 // quick-and-dirty-hack gets the job done for right now.
1121 updateView(); 1146 updateView();
1122} 1147}
1123 1148
1124void KOMonthView::updateView() 1149void KOMonthView::updateView()
1125{ 1150{
1126 1151
1127 if ( !updatePossible ) 1152 if ( !updatePossible )
1128 return; 1153 return;
1129 //QTime ti; 1154 //QTime ti;
1130 //ti.start(); 1155 //ti.start();
1131 QPtrVector<MonthViewCell> *cells; 1156 QPtrVector<MonthViewCell> *cells;
1132 if ( mShowWeekView ) { 1157 if ( mShowWeekView ) {
1133 cells = &mCellsW; 1158 cells = &mCellsW;
1134 } else { 1159 } else {
1135 cells = &mCells; 1160 cells = &mCells;
1136 } 1161 }
1137#if 1 1162#if 1
1138 int i; 1163 int i;
1139 int timeSpan = (*cells).size()-1; 1164 int timeSpan = (*cells).size()-1;
1140 if ( KOPrefs::instance()->mMonthViewWeek ) 1165 if ( KOPrefs::instance()->mMonthViewWeek )
1141 timeSpan = 6; 1166 timeSpan = 6;
1142 for( i = 0; i < timeSpan + 1; ++i ) { 1167 for( i = 0; i < timeSpan + 1; ++i ) {
1143 (*cells)[i]->startUpdateCell(); 1168 (*cells)[i]->startUpdateCell();
1144 } 1169 }
1145 1170
1146 QPtrList<Event> events = calendar()->events(); 1171 QPtrList<Event> events = calendar()->events();
1147 Event *event; 1172 Event *event;
1148 QDateTime dt; 1173 QDateTime dt;
1149 bool ok; 1174 bool ok;
1150 QDate endDate = mStartDate.addDays( timeSpan ); 1175 QDate endDate = mStartDate.addDays( timeSpan );
1151 for( event = events.first(); event; event = events.next() ) { // for event 1176 for( event = events.first(); event; event = events.next() ) { // for event
1152 if ( event->doesRecur() ) { 1177 if ( event->doesRecur() ) {
1153 bool last; 1178 bool last;
1154 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1179 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1155 QDateTime incidenceEnd; 1180 QDateTime incidenceEnd;
1156 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1181 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1157 bool invalid = false; 1182 bool invalid = false;
1158 while( true ) { 1183 while( true ) {
1159 if ( incidenceStart.isValid() ) { 1184 if ( incidenceStart.isValid() ) {
1160 incidenceEnd = incidenceStart.addDays( eventlen ); 1185 incidenceEnd = incidenceStart.addDays( eventlen );
1161 int st = incidenceStart.date().daysTo( endDate ); 1186 int st = incidenceStart.date().daysTo( endDate );
1162 if ( st >= 0 ) { // start before timeend 1187 if ( st >= 0 ) { // start before timeend
1163 int end = mStartDate.daysTo( incidenceEnd.date() ); 1188 int end = mStartDate.daysTo( incidenceEnd.date() );
1164 if ( end >= 0 ) { // end after timestart --- got one! 1189 if ( end >= 0 ) { // end after timestart --- got one!
1165 //normalize 1190 //normalize
1166 st = timeSpan - st; 1191 st = timeSpan - st;
1167 if ( st < 0 ) st = 0; 1192 if ( st < 0 ) st = 0;
1168 if ( end > timeSpan ) end = timeSpan; 1193 if ( end > timeSpan ) end = timeSpan;
1169 int iii; 1194 int iii;
1170 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1195 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1171 for ( iii = st;iii<= end;++iii) 1196 for ( iii = st;iii<= end;++iii)
1172 (*cells)[iii]->insertEvent( event ); 1197 (*cells)[iii]->insertEvent( event );
1173 } 1198 }
1174 } 1199 }
1175 } else { 1200 } else {
1176 if ( invalid ) 1201 if ( invalid )
1177 break; 1202 break;
1178 invalid = true; 1203 invalid = true;
1179 //qDebug("invalid %s", event->summary().latin1()); 1204 //qDebug("invalid %s", event->summary().latin1());
1180 incidenceStart = QDateTime( mStartDate ); 1205 incidenceStart = QDateTime( mStartDate );
1181 } 1206 }
1182 if ( last ) 1207 if ( last )
1183 break; 1208 break;
1184 bool ok; 1209 bool ok;
1185 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1210 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1186 if ( ! ok ) 1211 if ( ! ok )
1187 break; 1212 break;
1188 if ( incidenceStart.date() > endDate ) 1213 if ( incidenceStart.date() > endDate )
1189 break; 1214 break;
1190 } 1215 }
1191 } else { // no recur 1216 } else { // no recur
1192 int st = event->dtStart().date().daysTo( endDate ); 1217 int st = event->dtStart().date().daysTo( endDate );
1193 if ( st >= 0 ) { // start before timeend 1218 if ( st >= 0 ) { // start before timeend
1194 int end = mStartDate.daysTo( event->dtEnd().date() ); 1219 int end = mStartDate.daysTo( event->dtEnd().date() );
1195 if ( end >= 0 ) { // end after timestart --- got one! 1220 if ( end >= 0 ) { // end after timestart --- got one!
1196 //normalize 1221 //normalize
1197 st = timeSpan - st; 1222 st = timeSpan - st;
1198 if ( st < 0 ) st = 0; 1223 if ( st < 0 ) st = 0;
1199 if ( end > timeSpan ) end = timeSpan; 1224 if ( end > timeSpan ) end = timeSpan;
1200 int iii; 1225 int iii;
1201 for ( iii = st;iii<= end;++iii) 1226 for ( iii = st;iii<= end;++iii)
1202 (*cells)[iii]->insertEvent( event ); 1227 (*cells)[iii]->insertEvent( event );
1203 } 1228 }
1204 } 1229 }
1205 } 1230 }
1206 } 1231 }
1207 // insert due todos 1232 // insert due todos
1208 QPtrList<Todo> todos = calendar()->todos( ); 1233 QPtrList<Todo> todos = calendar()->todos( );
1209 Todo *todo; 1234 Todo *todo;
1210 for(todo = todos.first(); todo; todo = todos.next()) { 1235 for(todo = todos.first(); todo; todo = todos.next()) {
1211 //insertTodo( todo ); 1236 //insertTodo( todo );
1212 if ( todo->hasDueDate() ) { 1237 if ( todo->hasDueDate() ) {
1213 int day = mStartDate.daysTo( todo->dtDue().date() ); 1238 int day = mStartDate.daysTo( todo->dtDue().date() );
1214 if ( day >= 0 && day < timeSpan + 1) { 1239 if ( day >= 0 && day < timeSpan + 1) {
1215 (*cells)[day]->insertTodo( todo ); 1240 (*cells)[day]->insertTodo( todo );
1216 } 1241 }
1217 } 1242 }
1218 } 1243 }
1219 1244
1220 for( i = 0; i < timeSpan+1; ++i ) { 1245 for( i = 0; i < timeSpan+1; ++i ) {
1221 (*cells)[i]->finishUpdateCell(); 1246 (*cells)[i]->finishUpdateCell();
1222 } 1247 }
1223 processSelectionChange(); 1248 processSelectionChange();
1224 (*cells)[0]->setFocus(); 1249 (*cells)[0]->setFocus();
1225 1250
1226 1251
1227#else 1252#else
1228 // old code 1253 // old code
1229 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1254 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1230 int i; 1255 int i;
1231 for( i = 0; i < (*cells).count(); ++i ) { 1256 for( i = 0; i < (*cells).count(); ++i ) {
1232 (*cells)[i]->updateCell(); 1257 (*cells)[i]->updateCell();
1233 } 1258 }
1234 1259
1235 //qDebug("KOMonthView::updateView() "); 1260 //qDebug("KOMonthView::updateView() ");
1236 processSelectionChange(); 1261 processSelectionChange();
1237 // qDebug("---------------------------------------------------------------------+ "); 1262 // qDebug("---------------------------------------------------------------------+ ");
1238 (*cells)[0]->setFocus(); 1263 (*cells)[0]->setFocus();
1239#endif 1264#endif
1240 1265
1241 //qDebug("update time %d ", ti.elapsed()); 1266 //qDebug("update time %d ", ti.elapsed());
1242} 1267}
1243 1268
1244void KOMonthView::resizeEvent(QResizeEvent * e) 1269void KOMonthView::resizeEvent(QResizeEvent * e)
1245{ 1270{
1246 computeLayout(); 1271 computeLayout();
1247 clPending = true; 1272 clPending = true;
1248 if ( mShowWeekView ) 1273 if ( mShowWeekView )
1249 mCellsW[0]->setFocus(); 1274 mCellsW[0]->setFocus();
1250 else 1275 else
1251 mCells[0]->setFocus(); 1276 mCells[0]->setFocus();
1252} 1277}
1253void KOMonthView::computeLayoutWeek() 1278void KOMonthView::computeLayoutWeek()
1254{ 1279{
1255 1280
1256 int daysToShow; 1281 int daysToShow;
1257 bool combinedSatSun = false; 1282 bool combinedSatSun = false;
1258 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1283 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1259 daysToShow = 6; 1284 daysToShow = 6;
1260 combinedSatSun = true; 1285 combinedSatSun = true;
1261 } 1286 }
1262 int tWid = topLevelWidget()->size().width(); 1287 int tWid = topLevelWidget()->size().width();
1263 int tHei = topLevelWidget()->size().height(); 1288 int tHei = topLevelWidget()->size().height();
1264 1289
1265 int wid = size().width();//e 1290 int wid = size().width();//e
1266 int hei = size().height()-1; 1291 int hei = size().height()-1;
1267 1292
1268 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1293 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1269 return; 1294 return;
1270 1295
1271 if ( wid < hei ) 1296 if ( wid < hei )
1272 daysToShow = 2; 1297 daysToShow = 2;
1273 else 1298 else
1274 daysToShow = 3; 1299 daysToShow = 3;
1275 mShowSatSunComp = true; 1300 mShowSatSunComp = true;
1276 combinedSatSun = true; 1301 combinedSatSun = true;
1277 1302
1278 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1303 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1279 QFontMetrics fm ( mWeekLabels[0]->font() ); 1304 QFontMetrics fm ( mWeekLabels[0]->font() );
1280 int weeklabelwid = fm.width( "888" ); 1305 int weeklabelwid = fm.width( "888" );
1281 wid -= weeklabelwid; 1306 wid -= weeklabelwid;
1282 1307
1283 int colWid = wid / daysToShow; 1308 int colWid = wid / daysToShow;
1284 int lastCol = wid - ( colWid*6 ); 1309 int lastCol = wid - ( colWid*6 );
1285 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1310 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1286 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1311 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1287 int colModulo = wid % daysToShow; 1312 int colModulo = wid % daysToShow;
1288 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1313 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1289 //qDebug("rowmod %d ", rowModulo); 1314 //qDebug("rowmod %d ", rowModulo);
1290 int i; 1315 int i;
1291 int x,y,w,h; 1316 int x,y,w,h;
1292 x= 0; 1317 x= 0;
1293 y= 0; 1318 y= 0;
1294 w = colWid; 1319 w = colWid;
1295 h = dayLabelHei ; 1320 h = dayLabelHei ;
1296 for ( i = 0; i < 7; i++) { 1321 for ( i = 0; i < 7; i++) {
1297 if ( i && !( i % daysToShow) && i < 6) { 1322 if ( i && !( i % daysToShow) && i < 6) {
1298 y += hei/(5-daysToShow); 1323 y += hei/(5-daysToShow);
1299 x = 0; 1324 x = 0;
1300 w = colWid; 1325 w = colWid;
1301 } 1326 }
1302 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1327 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1303 ++w; 1328 ++w;
1304 } 1329 }
1305 if ( i >= 5 ) { 1330 if ( i >= 5 ) {
1306 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1331 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1307 x -= (w/2 ); 1332 x -= (w/2 );
1308 } 1333 }
1309 else 1334 else
1310 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1335 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1311 x += w; 1336 x += w;
1312 } 1337 }
1313 x= 0; 1338 x= 0;
1314 y= dayLabelHei; 1339 y= dayLabelHei;
1315 w = colWid; 1340 w = colWid;
1316 h = cellHei; 1341 h = cellHei;
1317 for ( i = 0; i < mCellsW.count(); ++i) { 1342 for ( i = 0; i < mCellsW.count(); ++i) {
1318 if ( i > 6 ) { 1343 if ( i > 6 ) {
1319 mCellsW[i]->hide(); 1344 mCellsW[i]->hide();
1320 continue; 1345 continue;
1321 } 1346 }
1322 1347
1323 w = colWid; 1348 w = colWid;
1324 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1349 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1325 ++w; 1350 ++w;
1326 } 1351 }
1327 if ( i == (daysToShow-1-rowModulo)*7) 1352 if ( i == (daysToShow-1-rowModulo)*7)
1328 ++h; 1353 ++h;
1329 1354
1330 if ( i >= 5 ) { 1355 if ( i >= 5 ) {
1331 if ( i ==5 ) { 1356 if ( i ==5 ) {
1332 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1357 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1333 x -= w ;y += h/2; 1358 x -= w ;y += h/2;
1334 } else { 1359 } else {
1335 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1360 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1336 ++w; 1361 ++w;
1337 } 1362 }
1338 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1363 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1339 y -= h/2; 1364 y -= h/2;
1340 } 1365 }
1341 } else 1366 } else
1342 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1367 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1343 1368
1344 1369
1345 x += w; 1370 x += w;
1346 if ( x + w/2 > wid ) { 1371 if ( x + w/2 > wid ) {
1347 x = 0; 1372 x = 0;
1348 y += h+dayLabelHei ; 1373 y += h+dayLabelHei ;
1349 } 1374 }
1350 } 1375 }
1351 y= dayLabelHei; 1376 y= dayLabelHei;
1352 h = cellHei ; 1377 h = cellHei ;
1353 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1378 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1354 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1379 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1355 // 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());
1356 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1381 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1357 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; 1382 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
1358 updateDayLabels(); 1383 updateDayLabels();
1359 bool forceUpdate = !updatePossible; 1384 bool forceUpdate = !updatePossible;
1360 updatePossible = true; 1385 updatePossible = true;
1361 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1386 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1362 if ( forceUpdate ) 1387 if ( forceUpdate )
1363 updateView(); 1388 updateView();
1364} 1389}
1365void KOMonthView::computeLayout() 1390void KOMonthView::computeLayout()
1366{ 1391{
1367 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1392 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1368 // 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
1369 // 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
1370 // enough. 1395 // enough.
1371 if ( mShowWeekView ){ 1396 if ( mShowWeekView ){
1372 computeLayoutWeek(); 1397 computeLayoutWeek();
1373 return; 1398 return;
1374 } 1399 }
1375 int daysToShow = 7; 1400 int daysToShow = 7;
1376 bool combinedSatSun = false; 1401 bool combinedSatSun = false;
1377 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1402 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1378 daysToShow = 6; 1403 daysToShow = 6;
1379 combinedSatSun = true; 1404 combinedSatSun = true;
1380 } 1405 }
1381 int tWid = topLevelWidget()->size().width(); 1406 int tWid = topLevelWidget()->size().width();
1382 int tHei = topLevelWidget()->size().height(); 1407 int tHei = topLevelWidget()->size().height();
1383 1408
1384 int wid = size().width();//e 1409 int wid = size().width();//e
1385 int hei = size().height()-1; 1410 int hei = size().height()-1;
1386 1411
1387 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1412 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1388 return; 1413 return;
1389 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1414 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1390 QFontMetrics fm ( mWeekLabels[0]->font() ); 1415 QFontMetrics fm ( mWeekLabels[0]->font() );
1391 int weeklabelwid = fm.width( "888" ); 1416 int weeklabelwid = fm.width( "888" );
1392 wid -= weeklabelwid; 1417 wid -= weeklabelwid;
1393 1418
1394 int colWid = wid / daysToShow; 1419 int colWid = wid / daysToShow;
1395 int lastCol = wid - ( colWid*6 ); 1420 int lastCol = wid - ( colWid*6 );
1396 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1421 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1397 int cellHei = (hei - dayLabelHei) /6; 1422 int cellHei = (hei - dayLabelHei) /6;
1398 int colModulo = wid % daysToShow; 1423 int colModulo = wid % daysToShow;
1399 int rowModulo = (hei- dayLabelHei) % 6; 1424 int rowModulo = (hei- dayLabelHei) % 6;
1400 //qDebug("rowmod %d ", rowModulo); 1425 //qDebug("rowmod %d ", rowModulo);
1401 int i; 1426 int i;
1402 int x,y,w,h; 1427 int x,y,w,h;
1403 x= 0; 1428 x= 0;
1404 y= 0; 1429 y= 0;
1405 w = colWid; 1430 w = colWid;
1406 h = dayLabelHei ; 1431 h = dayLabelHei ;
1407 for ( i = 0; i < 7; i++) { 1432 for ( i = 0; i < 7; i++) {
1408 if ( i == daysToShow-colModulo ) 1433 if ( i == daysToShow-colModulo )
1409 ++w; 1434 ++w;
1410 if ( combinedSatSun ) { 1435 if ( combinedSatSun ) {
1411 if ( i >= daysToShow-1 ) { 1436 if ( i >= daysToShow-1 ) {
1412 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1437 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1413 x -= w/2 ; 1438 x -= w/2 ;
1414 } 1439 }
1415 else 1440 else
1416 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1441 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1417 } else 1442 } else
1418 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1443 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1419 x += w; 1444 x += w;
1420 } 1445 }
1421 x= 0; 1446 x= 0;
1422 y= dayLabelHei; 1447 y= dayLabelHei;
1423 w = colWid; 1448 w = colWid;
1424 h = cellHei ; 1449 h = cellHei ;
1425 for ( i = 0; i < mCells.count(); ++i) { 1450 for ( i = 0; i < mCells.count(); ++i) {
1426 w = colWid; 1451 w = colWid;
1427 if ( ((i) % 7) >= 7-colModulo ) { 1452 if ( ((i) % 7) >= 7-colModulo ) {
1428 ++w; 1453 ++w;
1429 } 1454 }
1430 if ( i == (6-rowModulo)*7) 1455 if ( i == (6-rowModulo)*7)
1431 ++h; 1456 ++h;
1432 if ( combinedSatSun ) { 1457 if ( combinedSatSun ) {
1433 if ( (i)%7 >= daysToShow-1 ) { 1458 if ( (i)%7 >= daysToShow-1 ) {
1434 if ( (i)%7 == daysToShow-1 ) { 1459 if ( (i)%7 == daysToShow-1 ) {
1435 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1460 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1436 x -= w ;y += h/2; 1461 x -= w ;y += h/2;
1437 } else { 1462 } else {
1438 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1463 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1439 y -= h/2; 1464 y -= h/2;
1440 } 1465 }
1441 } else 1466 } else
1442 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1467 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1443 1468
1444 } 1469 }
1445 else 1470 else
1446 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1471 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1447 x += w; 1472 x += w;
1448 if ( x + w/2 > wid ) { 1473 if ( x + w/2 > wid ) {
1449 x = 0; 1474 x = 0;
1450 y += h; 1475 y += h;
1451 } 1476 }
1452 } 1477 }
1453 y= dayLabelHei; 1478 y= dayLabelHei;
1454 h = cellHei ; 1479 h = cellHei ;
1455 for ( i = 0; i < 6; i++) { 1480 for ( i = 0; i < 6; i++) {
1456 if ( i == (6-rowModulo)) 1481 if ( i == (6-rowModulo))
1457 ++h; 1482 ++h;
1458 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1483 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1459 y += h; 1484 y += h;
1460 } 1485 }
1461 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1486 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1462 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1487 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1463 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1488 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1464 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1489 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1465 updateDayLabels(); 1490 updateDayLabels();
1466 bool forceUpdate = !updatePossible; 1491 bool forceUpdate = !updatePossible;
1467 updatePossible = true; 1492 updatePossible = true;
1468 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1493 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1469 if ( forceUpdate ) 1494 if ( forceUpdate )
1470 updateView(); 1495 updateView();
1471} 1496}
1472 1497
1473void KOMonthView::showContextMenu( Incidence *incidence ) 1498void KOMonthView::showContextMenu( Incidence *incidence )
1474{ 1499{
1475 mContextMenu->showIncidencePopup(incidence); 1500 mContextMenu->showIncidencePopup(incidence);
1476 /* 1501 /*
1477 if( incidence && incidence->type() == "Event" ) { 1502 if( incidence && incidence->type() == "Event" ) {
1478 Event *event = static_cast<Event *>(incidence); 1503 Event *event = static_cast<Event *>(incidence);
1479 mContextMenu->showEventPopup(event); 1504 mContextMenu->showEventPopup(event);
1480 } else { 1505 } else {
1481 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1506 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1482 } 1507 }
1483 */ 1508 */
1484} 1509}
1485MonthViewCell * KOMonthView::selectedCell( ) 1510MonthViewCell * KOMonthView::selectedCell( )
1486{ 1511{
1487 return mSelectedCell; 1512 return mSelectedCell;
1488} 1513}
1489void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1514void KOMonthView::setSelectedCell( MonthViewCell *cell )
1490{ 1515{
1491 // qDebug("KOMonthView::setSelectedCell "); 1516 // qDebug("KOMonthView::setSelectedCell ");
1492 if ( mSelectedCell && mSelectedCell != cell ) { 1517 if ( mSelectedCell && mSelectedCell != cell ) {
1493 MonthViewCell * mvc = mSelectedCell; 1518 MonthViewCell * mvc = mSelectedCell;
1494 mSelectedCell = cell; 1519 mSelectedCell = cell;
1495 mvc->deselect(); 1520 mvc->deselect();
1496 } else 1521 } else
1497 mSelectedCell = cell; 1522 mSelectedCell = cell;
1498 // if ( mSelectedCell ) 1523 // if ( mSelectedCell )
1499 // mSelectedCell->select(); 1524 // mSelectedCell->select();
1500 if ( !mSelectedCell ) 1525 if ( !mSelectedCell )
1501 emit incidenceSelected( 0 ); 1526 emit incidenceSelected( 0 );
1502 else 1527 else
1503 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1528 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1504} 1529}
1505 1530
1506void KOMonthView::processSelectionChange() 1531void KOMonthView::processSelectionChange()
1507{ 1532{
1508 QPtrList<Incidence> incidences = selectedIncidences(); 1533 QPtrList<Incidence> incidences = selectedIncidences();
1509 if (incidences.count() > 0) { 1534 if (incidences.count() > 0) {
1510 emit incidenceSelected( incidences.first() ); 1535 emit incidenceSelected( incidences.first() );
1511 } else { 1536 } else {
1512 emit incidenceSelected( 0 ); 1537 emit incidenceSelected( 0 );
1513 } 1538 }
1514} 1539}
1515 1540
1516void KOMonthView::clearSelection() 1541void KOMonthView::clearSelection()
1517{ 1542{
1518 if ( mSelectedCell ) { 1543 if ( mSelectedCell ) {
1519 mSelectedCell->deselect(); 1544 mSelectedCell->deselect();
1520 mSelectedCell = 0; 1545 mSelectedCell = 0;
1521 } 1546 }
1522} 1547}
1523void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1548void KOMonthView::keyPressEvent ( QKeyEvent * e )
1524{ 1549{
1525 //qDebug("KOMonthView::keyPressEvent "); 1550 //qDebug("KOMonthView::keyPressEvent ");
1526 switch(e->key()) { 1551 switch(e->key()) {
1527 case Key_Up: 1552 case Key_Up:
1528 { 1553 {
1529 emit prevMonth(); 1554 emit prevMonth();
1530 mCells[0]->setFocus(); 1555 mCells[0]->setFocus();
1531 } 1556 }
1532 e->accept(); 1557 e->accept();
1533 break; 1558 break;
1534 case Key_Down: 1559 case Key_Down:
1535 { 1560 {
1536 emit nextMonth(); 1561 emit nextMonth();
1537 mCells[0]->setFocus(); 1562 mCells[0]->setFocus();
1538 1563
1539 } 1564 }
1540 e->accept(); 1565 e->accept();
1541 break; 1566 break;
1567 case Key_Return:
1568 case Key_Enter:
1569 {
1570 selectInternalWeekNum ( currentWeek() );
1571 }
1572 e->accept();
1573 break;
1542 default: 1574 default:
1543 e->ignore(); 1575 e->ignore();
1544 break; 1576 break;
1545 } 1577 }
1546} 1578}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 700f098..51eb9e6 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,293 +1,295 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qintdict.h> 30#include <qintdict.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvaluelist.h> 32#include <qvaluelist.h>
33#include <qptrvector.h> 33#include <qptrvector.h>
34 34
35#include <libkcal/calendar.h> 35#include <libkcal/calendar.h>
36#include <libkcal/event.h> 36#include <libkcal/event.h>
37 37
38#include "koeventview.h" 38#include "koeventview.h"
39 39
40#ifdef DESKTOP_VERSION 40#ifdef DESKTOP_VERSION
41class QToolTipGroup; 41class QToolTipGroup;
42#endif 42#endif
43 43
44class KNOWhatsThis; 44class KNOWhatsThis;
45class KOWeekButton : public QPushButton 45class KOWeekButton : public QPushButton
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 49 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
50 QPushButton( parent, name) 50 QPushButton( parent, name)
51 { 51 {
52 connect( this, SIGNAL( clicked() ), 52 connect( this, SIGNAL( clicked() ),
53 SLOT( bottonClicked() )); 53 SLOT( bottonClicked() ));
54 mNumber = -1; 54 mNumber = -1;
55 } 55 }
56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
57 int getWeekNum() { return mNumber;}
57 signals: 58 signals:
58 void selectWeekNum ( int ); 59 void selectWeekNum ( int );
59private: 60private:
60 int mNumber; 61 int mNumber;
61private slots : 62private slots :
62 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 63 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
63}; 64};
64 65
65class KNoScrollListBox: public QListBox 66class KNoScrollListBox: public QListBox
66{ 67{
67 Q_OBJECT 68 Q_OBJECT
68 public: 69 public:
69 KNoScrollListBox(QWidget *parent=0, const char *name=0); 70 KNoScrollListBox(QWidget *parent=0, const char *name=0);
70 ~KNoScrollListBox(); 71 ~KNoScrollListBox();
71 QString getWhatsThisText(QPoint p) ; 72 QString getWhatsThisText(QPoint p) ;
72 73
73 signals: 74 signals:
74 void shiftDown(); 75 void shiftDown();
75 void shiftUp(); 76 void shiftUp();
76 void rightClick(); 77 void rightClick();
77 78
78 protected slots: 79 protected slots:
80 void oneDown();
79 void keyPressEvent(QKeyEvent *); 81 void keyPressEvent(QKeyEvent *);
80 void keyReleaseEvent(QKeyEvent *); 82 void keyReleaseEvent(QKeyEvent *);
81 void mousePressEvent(QMouseEvent *); 83 void mousePressEvent(QMouseEvent *);
82 84
83 private: 85 private:
84 KNOWhatsThis * mWT; 86 KNOWhatsThis * mWT;
85}; 87};
86 88
87 89
88class MonthViewItem: public QListBoxItem 90class MonthViewItem: public QListBoxItem
89{ 91{
90 public: 92 public:
91 MonthViewItem( Incidence *, QDate qd, const QString & title ); 93 MonthViewItem( Incidence *, QDate qd, const QString & title );
92 94
93 void setRecur(bool on) { mRecur = on; } 95 void setRecur(bool on) { mRecur = on; }
94 void setAlarm(bool on) { mAlarm = on; } 96 void setAlarm(bool on) { mAlarm = on; }
95 void setReply(bool on) { mReply = on; } 97 void setReply(bool on) { mReply = on; }
96 void setMoreInfo(bool on) { mInfo = on; } 98 void setMoreInfo(bool on) { mInfo = on; }
97 99
98 100
99 void setPalette(const QPalette &p) { mPalette = p; } 101 void setPalette(const QPalette &p) { mPalette = p; }
100 QPalette palette() const { return mPalette; } 102 QPalette palette() const { return mPalette; }
101 103
102 Incidence *incidence() const { return mIncidence; } 104 Incidence *incidence() const { return mIncidence; }
103 QDate incidenceDate() { return mDate; } 105 QDate incidenceDate() { return mDate; }
104 106
105 protected: 107 protected:
106 virtual void paint(QPainter *); 108 virtual void paint(QPainter *);
107 virtual int height(const QListBox *) const; 109 virtual int height(const QListBox *) const;
108 virtual int width(const QListBox *) const; 110 virtual int width(const QListBox *) const;
109 111
110 private: 112 private:
111 bool mRecur; 113 bool mRecur;
112 bool mAlarm; 114 bool mAlarm;
113 bool mReply; 115 bool mReply;
114 bool mInfo; 116 bool mInfo;
115 117
116 QPalette mPalette; 118 QPalette mPalette;
117 QDate mDate; 119 QDate mDate;
118 120
119 Incidence *mIncidence; 121 Incidence *mIncidence;
120}; 122};
121 123
122 124
123class KOMonthView; 125class KOMonthView;
124 126
125class MonthViewCell : public QWidget 127class MonthViewCell : public QWidget
126{ 128{
127 Q_OBJECT 129 Q_OBJECT
128 public: 130 public:
129 MonthViewCell(KOMonthView *,QWidget* ); 131 MonthViewCell(KOMonthView *,QWidget* );
130 132
131 void setDate( const QDate & ); 133 void setDate( const QDate & );
132 QDate date() const; 134 QDate date() const;
133 135
134 void setPrimary( bool ); 136 void setPrimary( bool );
135 bool isPrimary() const; 137 bool isPrimary() const;
136 138
137 void setHoliday( bool ); 139 void setHoliday( bool );
138 void setHoliday( const QString & ); 140 void setHoliday( const QString & );
139 141
140 void updateCell(); 142 void updateCell();
141 void startUpdateCell(); 143 void startUpdateCell();
142 void finishUpdateCell(); 144 void finishUpdateCell();
143 void insertEvent(Event *); 145 void insertEvent(Event *);
144 void insertTodo(Todo *); 146 void insertTodo(Todo *);
145 147
146 void updateConfig( bool bigFont = false ); 148 void updateConfig( bool bigFont = false );
147 149
148 void enableScrollBars( bool ); 150 void enableScrollBars( bool );
149 151
150 Incidence *selectedIncidence(); 152 Incidence *selectedIncidence();
151 QDate selectedIncidenceDate(); 153 QDate selectedIncidenceDate();
152 154
153 void deselect(); 155 void deselect();
154 void select(); 156 void select();
155 void clear(); 157 void clear();
156 158
157#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
158 static QToolTipGroup *toolTipGroup(); 160 static QToolTipGroup *toolTipGroup();
159#endif 161#endif
160 signals: 162 signals:
161 void defaultAction( Incidence * ); 163 void defaultAction( Incidence * );
162 void newEventSignal( QDateTime ); 164 void newEventSignal( QDateTime );
163 void showDaySignal( QDate ); 165 void showDaySignal( QDate );
164 166
165 protected: 167 protected:
166 QString mToolTip; 168 QString mToolTip;
167 void resizeEvent( QResizeEvent * ); 169 void resizeEvent( QResizeEvent * );
168 170
169 protected slots: 171 protected slots:
170 void defaultAction( QListBoxItem * ); 172 void defaultAction( QListBoxItem * );
171 void contextMenu( QListBoxItem * ); 173 void contextMenu( QListBoxItem * );
172 void selection( QListBoxItem * ); 174 void selection( QListBoxItem * );
173 void cellClicked( QListBoxItem * ); 175 void cellClicked( QListBoxItem * );
174 void newEvent(); 176 void newEvent();
175 void showDay(); 177 void showDay();
176 178
177 private: 179 private:
178 KOMonthView *mMonthView; 180 KOMonthView *mMonthView;
179 181
180 QDate mDate; 182 QDate mDate;
181 bool mPrimary; 183 bool mPrimary;
182 bool mHoliday; 184 bool mHoliday;
183 QString mHolidayString; 185 QString mHolidayString;
184 186
185 //QLabel *mLabel; 187 //QLabel *mLabel;
186 QPushButton *mLabel; 188 QPushButton *mLabel;
187 QListBox *mItemList; 189 QListBox *mItemList;
188#ifdef DESKTOP_VERSION 190#ifdef DESKTOP_VERSION
189 static QToolTipGroup *mToolTipGroup; 191 static QToolTipGroup *mToolTipGroup;
190#endif 192#endif
191 QSize mLabelSize; 193 QSize mLabelSize;
192 QSize mLabelBigSize; 194 QSize mLabelBigSize;
193 QPalette mHolidayPalette; 195 QPalette mHolidayPalette;
194 QPalette mStandardPalette; 196 QPalette mStandardPalette;
195 QPalette mPrimaryPalette; 197 QPalette mPrimaryPalette;
196 QPalette mNonPrimaryPalette; 198 QPalette mNonPrimaryPalette;
197 void setMyPalette(); 199 void setMyPalette();
198 QPalette getPalette (); 200 QPalette getPalette ();
199 void keyPressEvent ( QKeyEvent * ) ; 201 void keyPressEvent ( QKeyEvent * ) ;
200 202
201}; 203};
202 204
203 205
204class KOMonthView: public KOEventView 206class KOMonthView: public KOEventView
205{ 207{
206 Q_OBJECT 208 Q_OBJECT
207 public: 209 public:
208 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 210 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
209 ~KOMonthView(); 211 ~KOMonthView();
210 212
211 /** Returns maximum number of days supported by the komonthview */ 213 /** Returns maximum number of days supported by the komonthview */
212 virtual int maxDatesHint(); 214 virtual int maxDatesHint();
213 215
214 /** Returns number of currently shown dates. */ 216 /** Returns number of currently shown dates. */
215 virtual int currentDateCount(); 217 virtual int currentDateCount();
216 218
217 /** returns the currently selected events */ 219 /** returns the currently selected events */
218 virtual QPtrList<Incidence> selectedIncidences(); 220 virtual QPtrList<Incidence> selectedIncidences();
219 221
220 /** returns dates of the currently selected events */ 222 /** returns dates of the currently selected events */
221 virtual DateList selectedDates(); 223 virtual DateList selectedDates();
222 224
223 virtual void printPreview(CalPrinter *calPrinter, 225 virtual void printPreview(CalPrinter *calPrinter,
224 const QDate &, const QDate &); 226 const QDate &, const QDate &);
225 bool isMonthView() { return true; } 227 bool isMonthView() { return true; }
226 bool isUpdatePossible() { return updatePossible; } 228 bool isUpdatePossible() { return updatePossible; }
227 229
228 MonthViewCell * selectedCell(); 230 MonthViewCell * selectedCell();
229 public slots: 231 public slots:
230 virtual void updateView(); 232 virtual void updateView();
231 virtual void updateConfig(); 233 virtual void updateConfig();
232 virtual void showDates(const QDate &start, const QDate &end); 234 virtual void showDates(const QDate &start, const QDate &end);
233 virtual void showEvents(QPtrList<Event> eventList); 235 virtual void showEvents(QPtrList<Event> eventList);
234 236
235 void changeEventDisplay(Event *, int); 237 void changeEventDisplay(Event *, int);
236 238
237 void clearSelection(); 239 void clearSelection();
238 240
239 void showContextMenu( Incidence * ); 241 void showContextMenu( Incidence * );
240 242
241 void setSelectedCell( MonthViewCell * ); 243 void setSelectedCell( MonthViewCell * );
242 244
243 protected slots: 245 protected slots:
244 void selectDateWeekNum ( int );
245 void selectInternalWeekNum ( int ); 246 void selectInternalWeekNum ( int );
246 void switchView(); 247 void switchView();
247 void processSelectionChange(); 248 void processSelectionChange();
248 signals: 249 signals:
249 void nextMonth(); 250 void nextMonth();
250 void prevMonth(); 251 void prevMonth();
251 void showNavigator( bool ); 252 void showNavigator( bool );
252 void selectWeekNum ( int ); 253 void selectWeekNum ( int );
253 void showDaySignal( QDate ); 254 void showDaySignal( QDate );
254 protected: 255 protected:
255 void resizeEvent(QResizeEvent *); 256 void resizeEvent(QResizeEvent *);
256 void viewChanged(); 257 void viewChanged();
257 void updateDayLabels(); 258 void updateDayLabels();
258 259
259 private: 260 private:
261 int currentWeek();
260 bool clPending; 262 bool clPending;
261 QWidgetStack * mWidStack; 263 QWidgetStack * mWidStack;
262 QWidget* mMonthView; 264 QWidget* mMonthView;
263 QWidget* mWeekView; 265 QWidget* mWeekView;
264 bool mShowWeekView; 266 bool mShowWeekView;
265 bool updatePossible; 267 bool updatePossible;
266 int mDaysPerWeek; 268 int mDaysPerWeek;
267 int mNumWeeks; 269 int mNumWeeks;
268 int mNumCells; 270 int mNumCells;
269 bool mWeekStartsMonday; 271 bool mWeekStartsMonday;
270 bool mShowSatSunComp; 272 bool mShowSatSunComp;
271 void computeLayout(); 273 void computeLayout();
272 void computeLayoutWeek(); 274 void computeLayoutWeek();
273 275
274 QPtrVector<MonthViewCell> mCells; 276 QPtrVector<MonthViewCell> mCells;
275 QPtrVector<QLabel> mDayLabels; 277 QPtrVector<QLabel> mDayLabels;
276 QPtrVector<KOWeekButton> mWeekLabels; 278 QPtrVector<KOWeekButton> mWeekLabels;
277 QPtrVector<MonthViewCell> mCellsW; 279 QPtrVector<MonthViewCell> mCellsW;
278 QPtrVector<QLabel> mDayLabelsW; 280 QPtrVector<QLabel> mDayLabelsW;
279 QPtrVector<KOWeekButton> mWeekLabelsW; 281 QPtrVector<KOWeekButton> mWeekLabelsW;
280 282
281 bool mShortDayLabels; 283 bool mShortDayLabels;
282 int mWidthLongDayLabel; 284 int mWidthLongDayLabel;
283 285
284 QDate mStartDate; 286 QDate mStartDate;
285 287
286 MonthViewCell *mSelectedCell; 288 MonthViewCell *mSelectedCell;
287 289
288 KOEventPopupMenu *mContextMenu; 290 KOEventPopupMenu *mContextMenu;
289 void keyPressEvent ( QKeyEvent * ) ; 291 void keyPressEvent ( QKeyEvent * ) ;
290 292
291}; 293};
292 294
293#endif 295#endif