author | zautrix <zautrix> | 2005-07-07 22:22:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 22:22:20 (UTC) |
commit | 876816e6582299d527610e847d259d2be6de403c (patch) (unidiff) | |
tree | 6683baf2835672d0d9b28b3cbbf90e84c398b835 | |
parent | 3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc (diff) | |
download | kdepimpi-876816e6582299d527610e847d259d2be6de403c.zip kdepimpi-876816e6582299d527610e847d259d2be6de403c.tar.gz kdepimpi-876816e6582299d527610e847d259d2be6de403c.tar.bz2 |
fixxx
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 64 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 5 |
5 files changed, 17 insertions, 61 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 814c541..aa4a89a 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,244 +1,244 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.14 ************ | 3 | ********** VERSION 2.1.14 ************ |
4 | 4 | ||
5 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. | 5 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. |
6 | Added a button to add a subtodo quickly. | 6 | Added a button to add a subtodo quickly. |
7 | 7 | ||
8 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q" ). | 8 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). |
9 | 9 | Added an option to change the layout of the list week to column mode. | |
10 | 10 | ||
11 | ********** VERSION 2.1.13 ************ | 11 | ********** VERSION 2.1.13 ************ |
12 | 12 | ||
13 | Fixed a problem in KA/Pi search. | 13 | Fixed a problem in KA/Pi search. |
14 | Fixed some minor problems in KO/Pi. | 14 | Fixed some minor problems in KO/Pi. |
15 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. | 15 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. |
16 | 16 | ||
17 | Fixed memory usage problems in KA/Pi: | 17 | Fixed memory usage problems in KA/Pi: |
18 | When loading data KA/Pi did load the file data twice. | 18 | When loading data KA/Pi did load the file data twice. |
19 | Example: | 19 | Example: |
20 | A 600k file did consume 1200k memory during loading process. | 20 | A 600k file did consume 1200k memory during loading process. |
21 | This is fixed, it does now consume only 600k during loading process. | 21 | This is fixed, it does now consume only 600k during loading process. |
22 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. | 22 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. |
23 | This is fixed. | 23 | This is fixed. |
24 | Example: | 24 | Example: |
25 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. | 25 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. |
26 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. | 26 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. |
27 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. | 27 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. |
28 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. | 28 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. |
29 | The saving of data may be a bit slower now. | 29 | The saving of data may be a bit slower now. |
30 | 30 | ||
31 | Fixed memory usage problems in KO/Pi: | 31 | Fixed memory usage problems in KO/Pi: |
32 | When KO/Pi did save the data to file, it did not release the used buffers after saving. | 32 | When KO/Pi did save the data to file, it did not release the used buffers after saving. |
33 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. | 33 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. |
34 | This is fixed. | 34 | This is fixed. |
35 | Example: | 35 | Example: |
36 | When saving a 400k file KO/Pi do now use 400k less memory now. | 36 | When saving a 400k file KO/Pi do now use 400k less memory now. |
37 | 37 | ||
38 | Optimized memory usage in KO/Pi Agenda view: | 38 | Optimized memory usage in KO/Pi Agenda view: |
39 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. | 39 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. |
40 | These buffers were not made smaller (i.e. downsized) because of performance reasons. | 40 | These buffers were not made smaller (i.e. downsized) because of performance reasons. |
41 | The handling of these buffers are now much smarter: | 41 | The handling of these buffers are now much smarter: |
42 | Two (of six) buffers are removed completely. | 42 | Two (of six) buffers are removed completely. |
43 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. | 43 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. |
44 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. | 44 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. |
45 | 45 | ||
46 | Worst case example ( for a maximum size agenda content): | 46 | Worst case example ( for a maximum size agenda content): |
47 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. | 47 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. |
48 | 48 | ||
49 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. | 49 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. |
50 | 50 | ||
51 | Summary: | 51 | Summary: |
52 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. | 52 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. |
53 | 53 | ||
54 | ********** VERSION 2.1.12 ************ | 54 | ********** VERSION 2.1.12 ************ |
55 | 55 | ||
56 | KO/Pi: | 56 | KO/Pi: |
57 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. | 57 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. |
58 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. | 58 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. |
59 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). | 59 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). |
60 | Fixed some other small problems. | 60 | Fixed some other small problems. |
61 | 61 | ||
62 | ********** VERSION 2.1.11 ************ | 62 | ********** VERSION 2.1.11 ************ |
63 | 63 | ||
64 | KO/Pi: | 64 | KO/Pi: |
65 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. | 65 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. |
66 | Added features to handle (and add ) more than one journal entry per day. | 66 | Added features to handle (and add ) more than one journal entry per day. |
67 | Added option for a journal title. | 67 | Added option for a journal title. |
68 | 68 | ||
69 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. | 69 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. |
70 | Fixed a problem of the alarm of completed recurring todos. | 70 | Fixed a problem of the alarm of completed recurring todos. |
71 | Added to the event/todo editor to set quickly the category of an item. | 71 | Added to the event/todo editor to set quickly the category of an item. |
72 | 72 | ||
73 | 73 | ||
74 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. | 74 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. |
75 | 75 | ||
76 | Added KA/Pi multi sync to the multi sync called from the alarm applet. | 76 | Added KA/Pi multi sync to the multi sync called from the alarm applet. |
77 | 77 | ||
78 | ********** VERSION 2.1.10 ************ | 78 | ********** VERSION 2.1.10 ************ |
79 | 79 | ||
80 | KO/Pi: | 80 | KO/Pi: |
81 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. | 81 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. |
82 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. | 82 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. |
83 | Fixed a bug in searching for a small timerange, i.e. one day. | 83 | Fixed a bug in searching for a small timerange, i.e. one day. |
84 | 84 | ||
85 | KA/Pi: | 85 | KA/Pi: |
86 | Fixed two problems in csv export. | 86 | Fixed two problems in csv export. |
87 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. | 87 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. |
88 | 88 | ||
89 | ********** VERSION 2.1.9 ************ | 89 | ********** VERSION 2.1.9 ************ |
90 | 90 | ||
91 | KO/Pi: | 91 | KO/Pi: |
92 | Fixed some problems of the new search options in the search dialog. | 92 | Fixed some problems of the new search options in the search dialog. |
93 | Fixed some problems in the new resource config options. | 93 | Fixed some problems in the new resource config options. |
94 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. | 94 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. |
95 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: | 95 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: |
96 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. | 96 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. |
97 | 97 | ||
98 | Fixed a problem in recurrence range in syncing with DTM. | 98 | Fixed a problem in recurrence range in syncing with DTM. |
99 | 99 | ||
100 | KA/Pi: | 100 | KA/Pi: |
101 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) | 101 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) |
102 | 102 | ||
103 | PwM/Pi: | 103 | PwM/Pi: |
104 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 104 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
105 | 105 | ||
106 | ********** VERSION 2.1.8 ************ | 106 | ********** VERSION 2.1.8 ************ |
107 | 107 | ||
108 | KO/Pi: | 108 | KO/Pi: |
109 | Added info about the completion state of a todo in the ListView/Searchdialog. | 109 | Added info about the completion state of a todo in the ListView/Searchdialog. |
110 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 110 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
111 | Fixed some updating problems when changing the filter. | 111 | Fixed some updating problems when changing the filter. |
112 | 112 | ||
113 | KA/Pi: | 113 | KA/Pi: |
114 | In the addressee selection dialog now the formatted name is shown, if not empty. | 114 | In the addressee selection dialog now the formatted name is shown, if not empty. |
115 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 115 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
116 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 116 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
117 | 117 | ||
118 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 118 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
119 | Fixed the sorting for size in the file selector on the Z. | 119 | Fixed the sorting for size in the file selector on the Z. |
120 | 120 | ||
121 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 121 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
122 | 122 | ||
123 | ********** VERSION 2.1.7 ************ | 123 | ********** VERSION 2.1.7 ************ |
124 | 124 | ||
125 | KO/Pi: | 125 | KO/Pi: |
126 | Fixed several problems in the new Resource handling. | 126 | Fixed several problems in the new Resource handling. |
127 | Added more options to the search dialog. | 127 | Added more options to the search dialog. |
128 | Fixed a problem in the Month view. | 128 | Fixed a problem in the Month view. |
129 | Added more options to the dialog when setting a todo to stopped. | 129 | Added more options to the dialog when setting a todo to stopped. |
130 | 130 | ||
131 | Fixed two small problems in KO/Pi Alarm applet. | 131 | Fixed two small problems in KO/Pi Alarm applet. |
132 | 132 | ||
133 | ********** VERSION 2.1.6 ************ | 133 | ********** VERSION 2.1.6 ************ |
134 | 134 | ||
135 | This release is for testing only. | 135 | This release is for testing only. |
136 | 136 | ||
137 | KO/Pi: | 137 | KO/Pi: |
138 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 138 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
139 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 139 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
140 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 140 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
141 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 141 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
142 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 142 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
143 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 143 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
144 | 144 | ||
145 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 145 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
146 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. | 146 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. |
147 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 147 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
148 | 148 | ||
149 | A calendar is enabled in the resource view if the "eye" column is checked. | 149 | A calendar is enabled in the resource view if the "eye" column is checked. |
150 | You can set a calendar to be the default for new items( "+" column ). | 150 | You can set a calendar to be the default for new items( "+" column ). |
151 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 151 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
152 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 152 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
153 | 153 | ||
154 | 154 | ||
155 | ********** VERSION 2.1.5 ************ | 155 | ********** VERSION 2.1.5 ************ |
156 | 156 | ||
157 | This is the new stable version. | 157 | This is the new stable version. |
158 | Bugfix: | 158 | Bugfix: |
159 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 159 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
160 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 160 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
161 | Added config option to not display completed todos in agenda view. | 161 | Added config option to not display completed todos in agenda view. |
162 | Addressee view is now using the formatted name, if defined. | 162 | Addressee view is now using the formatted name, if defined. |
163 | That makes it possible to display "lastname, firstname" in that view now. | 163 | That makes it possible to display "lastname, firstname" in that view now. |
164 | To set the formatted name for all contacts, please use menu: | 164 | To set the formatted name for all contacts, please use menu: |
165 | Edit->Change->Set formatted name. | 165 | Edit->Change->Set formatted name. |
166 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 166 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
167 | 167 | ||
168 | ********** VERSION 2.1.4 ************ | 168 | ********** VERSION 2.1.4 ************ |
169 | 169 | ||
170 | Fixed two more bugs in the KA/Pi CSV import dialog: | 170 | Fixed two more bugs in the KA/Pi CSV import dialog: |
171 | Made it possible to read multi-line fields and import it to the "Note" field. | 171 | Made it possible to read multi-line fields and import it to the "Note" field. |
172 | Fixed a problem in mapping custom fields, whatever a custem field is... | 172 | Fixed a problem in mapping custom fields, whatever a custem field is... |
173 | 173 | ||
174 | ********** VERSION 2.1.3 ************ | 174 | ********** VERSION 2.1.3 ************ |
175 | 175 | ||
176 | Changed the menu structure of the alarm applet: | 176 | Changed the menu structure of the alarm applet: |
177 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 177 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
178 | 178 | ||
179 | Fixed several problems in the KA/Pi CSV import dialog: | 179 | Fixed several problems in the KA/Pi CSV import dialog: |
180 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 180 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
181 | 181 | ||
182 | 182 | ||
183 | ********** VERSION 2.1.2 ************ | 183 | ********** VERSION 2.1.2 ************ |
184 | 184 | ||
185 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 185 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
186 | 186 | ||
187 | Fixed a problem when importing data from Outlook with mutiple categories set. | 187 | Fixed a problem when importing data from Outlook with mutiple categories set. |
188 | 188 | ||
189 | Changed display of days in datenavigator: | 189 | Changed display of days in datenavigator: |
190 | Birthdays are now blue, not dark green. | 190 | Birthdays are now blue, not dark green. |
191 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 191 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
192 | When journal view is shown, only holidays are shown and days with journals are blue. | 192 | When journal view is shown, only holidays are shown and days with journals are blue. |
193 | 193 | ||
194 | Added Backup options to global config: | 194 | Added Backup options to global config: |
195 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). | 195 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). |
196 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. | 196 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. |
197 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. | 197 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. |
198 | 198 | ||
199 | ********** VERSION 2.1.1 ************ | 199 | ********** VERSION 2.1.1 ************ |
200 | 200 | ||
201 | Stable release 2.1.1! | 201 | Stable release 2.1.1! |
202 | 202 | ||
203 | KO/Pi: | 203 | KO/Pi: |
204 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 204 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
205 | 205 | ||
206 | ********** VERSION 2.1.0 ************ | 206 | ********** VERSION 2.1.0 ************ |
207 | 207 | ||
208 | Stable release 2.1.0! | 208 | Stable release 2.1.0! |
209 | 209 | ||
210 | Summary of changes/fixes compared to version 2.0.6: | 210 | Summary of changes/fixes compared to version 2.0.6: |
211 | 211 | ||
212 | Many bugs of version 2.0.6 fixed. | 212 | Many bugs of version 2.0.6 fixed. |
213 | Most of them were small bugs, but some of them were important. | 213 | Most of them were small bugs, but some of them were important. |
214 | It is recommended to use version 2.1.0 and not version 2.0.6. | 214 | It is recommended to use version 2.1.0 and not version 2.0.6. |
215 | 215 | ||
216 | Important changes: | 216 | Important changes: |
217 | 217 | ||
218 | Added recurring todos to KO/Pi. | 218 | Added recurring todos to KO/Pi. |
219 | 219 | ||
220 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 220 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
221 | 221 | ||
222 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 222 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
223 | 223 | ||
224 | Datenavigator can now display many months. Very useful on the desktop. | 224 | Datenavigator can now display many months. Very useful on the desktop. |
225 | 225 | ||
226 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 226 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
227 | 227 | ||
228 | Made alarm sound working on Linux desktop. | 228 | Made alarm sound working on Linux desktop. |
229 | 229 | ||
230 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 230 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
231 | 231 | ||
232 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 232 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
233 | 233 | ||
234 | Many other usebility enhancements. | 234 | Many other usebility enhancements. |
235 | Special thanks to Ben for his suggestions! | 235 | Special thanks to Ben for his suggestions! |
236 | 236 | ||
237 | You can find the complete changelog | 237 | You can find the complete changelog |
238 | from version 1.7.7 to 2.1.0 | 238 | from version 1.7.7 to 2.1.0 |
239 | in the source package or on | 239 | in the source package or on |
240 | 240 | ||
241 | http://www.pi-sync.net/html/changelog.html | 241 | http://www.pi-sync.net/html/changelog.html |
242 | 242 | ||
243 | 243 | ||
244 | 244 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 426e8f9..2582931 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3851 +1,3799 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | ||
107 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 116 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
119 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
120 | 121 | ||
121 | #include "calendarview.h" | 122 | #include "calendarview.h" |
122 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
123 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
124 | #endif | 125 | #endif |
125 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
126 | #include <stdlib.h> | 127 | #include <stdlib.h> |
127 | #include <stdio.h> | 128 | #include <stdio.h> |
128 | #include <unistd.h> | 129 | #include <unistd.h> |
129 | #else | 130 | #else |
130 | #include <qprocess.h> | 131 | #include <qprocess.h> |
131 | #endif | 132 | #endif |
132 | 133 | ||
133 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
134 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
135 | #endif | 136 | #endif |
136 | using namespace KOrg; | 137 | using namespace KOrg; |
137 | using namespace KCal; | 138 | using namespace KCal; |
138 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
139 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
140 | 141 | ||
141 | 142 | ||
142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
143 | 144 | ||
144 | { | 145 | { |
145 | mAlarms = alarms; | 146 | mAlarms = alarms; |
146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
147 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
149 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
151 | #else | 152 | #else |
152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
153 | #endif | 154 | #endif |
154 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
155 | // mText += ipath; | 156 | // mText += ipath; |
156 | // mText += "\">"; | 157 | // mText += "\">"; |
157 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
158 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
160 | #else | 161 | #else |
161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
162 | #endif | 163 | #endif |
163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
164 | 165 | ||
165 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
166 | int time = 0; | 167 | int time = 0; |
167 | //mText += "<table>"; | 168 | //mText += "<table>"; |
168 | while ( inc ) { | 169 | while ( inc ) { |
169 | QDateTime dt ; | 170 | QDateTime dt ; |
170 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
171 | bool ok; | 172 | bool ok; |
172 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
173 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
174 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
175 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
176 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
177 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
178 | } | 179 | } |
179 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
180 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
181 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
182 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
183 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
184 | else | 185 | else |
185 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
186 | QString timestr; | 187 | QString timestr; |
187 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
189 | else | 190 | else |
190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
193 | mText += "<table>"; | 194 | mText += "<table>"; |
194 | time = 1; | 195 | time = 1; |
195 | } | 196 | } |
196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
197 | if ( time > 0 ) | 198 | if ( time > 0 ) |
198 | mText +="</table>"; | 199 | mText +="</table>"; |
199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
200 | mText += "<table>"; | 201 | mText += "<table>"; |
201 | time = 2; | 202 | time = 2; |
202 | 203 | ||
203 | } | 204 | } |
204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
205 | if ( time > 0 ) | 206 | if ( time > 0 ) |
206 | mText +="</table>"; | 207 | mText +="</table>"; |
207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
208 | mText += "<table>"; | 209 | mText += "<table>"; |
209 | time = 3; | 210 | time = 3; |
210 | } | 211 | } |
211 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
212 | mText += timestr; | 213 | mText += timestr; |
213 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
214 | mText += tempText; | 215 | mText += tempText; |
215 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
216 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
217 | } | 218 | } |
218 | mText +="</table>"; | 219 | mText +="</table>"; |
219 | setText( mText ); | 220 | setText( mText ); |
220 | } | 221 | } |
221 | 222 | ||
222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
223 | { | 224 | { |
224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
225 | } | 226 | } |
226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
227 | { | 228 | { |
228 | QDateTime dt ; | 229 | QDateTime dt ; |
229 | Incidence * retInc; | 230 | Incidence * retInc; |
230 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
231 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
232 | return 0; | 233 | return 0; |
233 | bool ok; | 234 | bool ok; |
234 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
235 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
236 | QDateTime dtn ; | 237 | QDateTime dtn ; |
237 | retInc = inc; | 238 | retInc = inc; |
238 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
239 | while ( inc ) { | 240 | while ( inc ) { |
240 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
241 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
242 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
243 | dt = dtn; | 244 | dt = dtn; |
244 | retInc = inc; | 245 | retInc = inc; |
245 | } | 246 | } |
246 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
247 | } | 248 | } |
248 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
249 | return retInc; | 250 | return retInc; |
250 | 251 | ||
251 | } | 252 | } |
252 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
253 | { | 254 | { |
254 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
255 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
256 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
257 | #else | 258 | #else |
258 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
259 | #endif | 260 | #endif |
260 | return; | 261 | return; |
261 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
262 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
263 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
264 | #else | 265 | #else |
265 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
266 | #endif | 267 | #endif |
267 | return; | 268 | return; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | 271 | ||
271 | 272 | ||
272 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
273 | { | 274 | { |
274 | public: | 275 | public: |
275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
276 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
277 | { | 278 | { |
278 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
279 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
280 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
281 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
283 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
284 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
286 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
287 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
288 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
289 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
290 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
291 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
292 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
294 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
296 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
299 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
300 | } | 301 | } |
301 | 302 | ||
302 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
303 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
304 | private: | 305 | private: |
305 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
306 | }; | 307 | }; |
307 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
308 | { | 309 | { |
309 | public: | 310 | public: |
310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
311 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
312 | { | 313 | { |
313 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
314 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
315 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
316 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
317 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
318 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
320 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
321 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
324 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
326 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
328 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
331 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
332 | } | 333 | } |
333 | 334 | ||
334 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
335 | private: | 336 | private: |
336 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
337 | }; | 338 | }; |
338 | 339 | ||
339 | 340 | ||
340 | 341 | ||
341 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
342 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
343 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
344 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
345 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
346 | { | 347 | { |
347 | 348 | ||
348 | mEventEditor = 0; | 349 | mEventEditor = 0; |
349 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
350 | 351 | ||
351 | init(); | 352 | init(); |
352 | } | 353 | } |
353 | 354 | ||
354 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
355 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
356 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
357 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
358 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
359 | { | 360 | { |
360 | 361 | ||
361 | mEventEditor = 0; | 362 | mEventEditor = 0; |
362 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
363 | init(); | 364 | init(); |
364 | } | 365 | } |
365 | 366 | ||
366 | void CalendarView::init() | 367 | void CalendarView::init() |
367 | { | 368 | { |
368 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
369 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
370 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
371 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
372 | 373 | ||
373 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
374 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
375 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
378 | mModified = false; | 379 | mModified = false; |
379 | mReadOnly = false; | 380 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
383 | 384 | ||
384 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 387 | ||
387 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 390 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 393 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
395 | 396 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 400 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
402 | 403 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 408 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 410 | mResourceView = 0; |
410 | #else | 411 | #else |
411 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
416 | } else { | 417 | } else { |
417 | mResourceView = 0; | 418 | mResourceView = 0; |
418 | } | 419 | } |
419 | #endif | 420 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 423 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 426 | ||
426 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
427 | #else | 428 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 439 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 446 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
449 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
451 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
453 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
454 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
455 | #endif | 456 | #endif |
456 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
458 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
459 | #if 0 | 460 | #if 0 |
460 | // FIXME | 461 | // FIXME |
461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
462 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
463 | #endif | 464 | #endif |
464 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
465 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
479 | 480 | ||
480 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
481 | #if 0 | 482 | #if 0 |
482 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
483 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
484 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
485 | 486 | ||
486 | } else { | 487 | } else { |
487 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
488 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
489 | } | 490 | } |
490 | #endif | 491 | #endif |
491 | mFilterView->hide(); | 492 | mFilterView->hide(); |
492 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
493 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
494 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
496 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
497 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
498 | 499 | ||
499 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
500 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | } else { | 506 | } else { |
506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | } | 510 | } |
510 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
511 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
512 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
513 | #endif | 514 | #endif |
514 | 515 | ||
515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
516 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
517 | 518 | ||
518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | 521 | ||
521 | 522 | ||
522 | 523 | ||
523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
525 | 526 | ||
526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
528 | 529 | ||
529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
530 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
531 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
532 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
534 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
536 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
537 | 538 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
539 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
541 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
544 | 545 | ||
545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
547 | #if 0 | 548 | #if 0 |
548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
549 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
550 | #endif | 551 | #endif |
551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
552 | 553 | ||
553 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
554 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
555 | 556 | ||
556 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
557 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
559 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
561 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
563 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
565 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
568 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 572 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 577 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 582 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 585 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 592 | ||
592 | 593 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 598 | ||
598 | 599 | ||
599 | 600 | ||
600 | 601 | ||
601 | 602 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 608 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 610 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 618 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 620 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 623 | ||
623 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
624 | 625 | ||
625 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 636 | ||
636 | 637 | ||
637 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 642 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
646 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
647 | { | 648 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 651 | delete mDialogManager; |
651 | delete mViewManager; | 652 | delete mViewManager; |
652 | delete mStorage; | 653 | delete mStorage; |
653 | delete mDateFrame ; | 654 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 657 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
658 | { | 659 | { |
659 | 660 | ||
660 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
661 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
662 | while ( test ) { | 663 | while ( test ) { |
663 | test->setTagged( false ); | 664 | test->setTagged( false ); |
664 | test = testlist.next(); | 665 | test = testlist.next(); |
665 | } | 666 | } |
666 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | ||
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | ||
670 | //qDebug("time %s ", st.toString().latin1()); | ||
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | ||
667 | QDateTime conflict; | 672 | QDateTime conflict; |
668 | QDateTime retVal; | 673 | QDateTime retVal; |
669 | bool found = false; | 674 | bool found = false; |
670 | Event * cE = 0; | 675 | Event * cE = 0; |
671 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
672 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
673 | test = testlist.first(); | 678 | test = testlist.first(); |
674 | bool skip = false; | 679 | bool skip = false; |
675 | while ( test ) { | 680 | while ( test ) { |
676 | skip = false; | 681 | skip = false; |
677 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
678 | if ( !skip ) { | 683 | if ( !skip ) { |
679 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
680 | while ( test2 ) { | 685 | while ( test2 ) { |
681 | skip = false; | 686 | skip = false; |
682 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
683 | if ( !skip ) { | 688 | if ( !skip ) { |
684 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
685 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
686 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
687 | if ( ! found ) { | 692 | if ( ! found ) { |
688 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
689 | conflict = retVal; | 694 | conflict = retVal; |
690 | cE = test; | 695 | cE = test; |
691 | cE2 = test2; | 696 | cE2 = test2; |
692 | found = true; | 697 | found = true; |
693 | } | 698 | } |
694 | } else { | 699 | } else { |
695 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
696 | conflict = retVal; | 701 | conflict = retVal; |
697 | cE = test; | 702 | cE = test; |
698 | cE2 = test2; | 703 | cE2 = test2; |
699 | } | 704 | } |
700 | } | 705 | } |
701 | } | 706 | } |
702 | } | 707 | } |
703 | } | 708 | } |
704 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
705 | } | 710 | } |
706 | } | 711 | } |
707 | test->setTagged( true ); | 712 | test->setTagged( true ); |
708 | test = testlist.next(); | 713 | test = testlist.next(); |
709 | } | 714 | } |
710 | if ( found ) { | 715 | if ( found ) { |
711 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
712 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
713 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
714 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
715 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
716 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
717 | return; | 722 | return; |
718 | } | 723 | } |
719 | 724 | ||
720 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
721 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
722 | return; | 727 | return; |
723 | |||
724 | |||
725 | |||
726 | |||
727 | |||
728 | #if 0 | ||
729 | |||
730 | |||
731 | QDate end = start.addDays( 365*2); | ||
732 | while ( start < end ) { | ||
733 | QPtrList<Event> eventList = calendar()->events( start ); | ||
734 | Event * ev = eventList.first(); | ||
735 | QPtrList<Event> test = eventList; | ||
736 | while ( ev ) { | ||
737 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
738 | Event * t_ev = test.first(); | ||
739 | QDateTime es = ev->dtStart(); | ||
740 | QDateTime ee = ev->dtEnd(); | ||
741 | if ( ev->doesFloat() ) | ||
742 | ee = ee.addDays( 1 ); | ||
743 | if ( ! all ) { | ||
744 | if ( ev->doesFloat() != allday ) | ||
745 | t_ev = 0; | ||
746 | } | ||
747 | while ( t_ev ) { | ||
748 | bool skip = false; | ||
749 | if ( ! all ) { | ||
750 | if ( t_ev->doesFloat() != allday ) | ||
751 | skip = true; | ||
752 | } | ||
753 | if ( !skip && ev != t_ev ) { | ||
754 | QDateTime ets = t_ev->dtStart(); | ||
755 | QDateTime ete = t_ev->dtEnd(); | ||
756 | if ( t_ev->doesFloat() ) | ||
757 | ete = ete.addDays( 1 ); | ||
758 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
759 | if ( es < ete && ets < ee ) { | ||
760 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
761 | mViewManager->showDayView(); | ||
762 | mNavigator->slotDaySelect( start ); | ||
763 | int hour = es.time().hour(); | ||
764 | if ( ets > es ) | ||
765 | hour = ets.time().hour(); | ||
766 | mViewManager->agendaView()->setStartHour( hour ); | ||
767 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
768 | return; | ||
769 | } | ||
770 | } | ||
771 | t_ev = test.next(); | ||
772 | } | ||
773 | ev = eventList.next(); | ||
774 | } | ||
775 | start = start.addDays( 1 ); | ||
776 | } | ||
777 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | ||
778 | qDebug("No conflict found "); | ||
779 | #endif | ||
780 | } | 728 | } |
781 | 729 | ||
782 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
783 | { | 731 | { |
784 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
785 | } | 733 | } |
786 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
787 | { | 735 | { |
788 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
789 | } | 737 | } |
790 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
791 | { | 739 | { |
792 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
793 | } | 741 | } |
794 | 742 | ||
795 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
796 | { | 744 | { |
797 | if ( readO ) { | 745 | if ( readO ) { |
798 | emit save(); | 746 | emit save(); |
799 | } | 747 | } |
800 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
801 | } | 749 | } |
802 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
803 | { | 751 | { |
804 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
805 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
806 | #endif | 754 | #endif |
807 | } | 755 | } |
808 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
809 | { | 757 | { |
810 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
811 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
812 | static bool block = false; | 760 | static bool block = false; |
813 | if ( block ) return; | 761 | if ( block ) return; |
814 | block = true; | 762 | block = true; |
815 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
816 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
817 | int stepdays = val; | 765 | int stepdays = val; |
818 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
819 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
820 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
821 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
822 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
823 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
824 | } | 772 | } |
825 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
826 | block = false; | 774 | block = false; |
827 | return; | 775 | return; |
828 | } | 776 | } |
829 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
830 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
831 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
832 | block = false; | 780 | block = false; |
833 | #endif | 781 | #endif |
834 | 782 | ||
835 | } | 783 | } |
836 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
837 | { | 785 | { |
838 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
839 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
840 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
841 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
842 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
843 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
844 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
845 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
846 | } | 794 | } |
847 | } | 795 | } |
848 | #endif | 796 | #endif |
849 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
850 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
851 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
852 | } | 800 | } |
853 | 801 | ||
854 | 802 | ||
855 | 803 | ||
856 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
857 | { | 805 | { |
858 | QString message; | 806 | QString message; |
859 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
860 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
861 | while ( cal ) { | 809 | while ( cal ) { |
862 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
863 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
864 | } | 812 | } |
865 | cal = calendars.next(); | 813 | cal = calendars.next(); |
866 | } | 814 | } |
867 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
868 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
869 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
870 | } | 818 | } |
871 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
872 | } | 820 | } |
873 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
874 | { | 822 | { |
875 | 823 | ||
876 | 824 | ||
877 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
878 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
879 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
880 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
881 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
882 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
883 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
884 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
885 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
886 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
887 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
888 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
889 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
890 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
891 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
892 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
893 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
894 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
895 | while ( inL ) { | 843 | while ( inL ) { |
896 | bool ok = false; | 844 | bool ok = false; |
897 | int offset = 0; | 845 | int offset = 0; |
898 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
899 | if ( ok ) { | 847 | if ( ok ) { |
900 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
901 | if ( next < cur ) { | 849 | if ( next < cur ) { |
902 | al.append( inL ); | 850 | al.append( inL ); |
903 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
904 | } | 852 | } |
905 | } | 853 | } |
906 | inL = el.next(); | 854 | inL = el.next(); |
907 | } | 855 | } |
908 | if ( al.count() ) { | 856 | if ( al.count() ) { |
909 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
910 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
911 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
912 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
913 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
914 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
915 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
916 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
917 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
918 | int wid = 210; | 866 | int wid = 210; |
919 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
920 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
921 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
922 | } else { | 870 | } else { |
923 | int si = 220; | 871 | int si = 220; |
924 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
925 | si = 400; | 873 | si = 400; |
926 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
927 | } | 875 | } |
928 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
929 | dia->show(); | 877 | dia->show(); |
930 | 878 | ||
931 | } | 879 | } |
932 | } | 880 | } |
933 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
934 | { | 882 | { |
935 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
936 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
937 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
938 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
939 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
940 | } | 888 | } |
941 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
942 | { | 890 | { |
943 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
944 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
945 | } | 893 | } |
946 | 894 | ||
947 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
948 | { | 896 | { |
949 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
950 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
951 | 899 | ||
952 | } | 900 | } |
953 | 901 | ||
954 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
955 | { | 903 | { |
956 | 904 | ||
957 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
958 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
959 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
960 | 908 | ||
961 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
962 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
963 | 911 | ||
964 | } | 912 | } |
965 | 913 | ||
966 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
967 | { | 915 | { |
968 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
969 | } | 917 | } |
970 | 918 | ||
971 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
972 | { | 920 | { |
973 | 921 | ||
974 | QString mess = msg; | 922 | QString mess = msg; |
975 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
976 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
977 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
978 | QString tempfilename; | 926 | QString tempfilename; |
979 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
980 | bool error = false; | 928 | bool error = false; |
981 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
982 | if ( len < 2 ) | 930 | if ( len < 2 ) |
983 | error = true; | 931 | error = true; |
984 | else { | 932 | else { |
985 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
986 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
987 | error = true; | 935 | error = true; |
988 | } | 936 | } |
989 | if ( ! error ) { | 937 | if ( ! error ) { |
990 | filename = tempfilename; | 938 | filename = tempfilename; |
991 | } | 939 | } |
992 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
993 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
994 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
995 | return; | 943 | return; |
996 | } | 944 | } |
997 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
998 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
999 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
1000 | return; | 948 | return; |
1001 | } | 949 | } |
1002 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
1003 | bool error = false; | 951 | bool error = false; |
1004 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
1005 | if ( len < 2 ) | 953 | if ( len < 2 ) |
1006 | error = true; | 954 | error = true; |
1007 | else { | 955 | else { |
1008 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
1009 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
1010 | error = true; | 958 | error = true; |
1011 | } | 959 | } |
1012 | if ( error ) { | 960 | if ( error ) { |
1013 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1014 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1015 | } else { | 963 | } else { |
1016 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1017 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1018 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
1019 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
1020 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
1021 | return; | 969 | return; |
1022 | } | 970 | } |
1023 | #else | 971 | #else |
1024 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
1025 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
1026 | p->start(); | 974 | p->start(); |
1027 | return; | 975 | return; |
1028 | #endif | 976 | #endif |
1029 | 977 | ||
1030 | return; | 978 | return; |
1031 | } | 979 | } |
1032 | 980 | ||
1033 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1034 | } | 982 | } |
1035 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
1036 | bool error = false; | 984 | bool error = false; |
1037 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
1038 | if ( len < 2 ) | 986 | if ( len < 2 ) |
1039 | error = true; | 987 | error = true; |
1040 | else { | 988 | else { |
1041 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
1042 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
1043 | error = true; | 991 | error = true; |
1044 | } | 992 | } |
1045 | if ( ! error ) { | 993 | if ( ! error ) { |
1046 | filename = tempfilename; | 994 | filename = tempfilename; |
1047 | } | 995 | } |
1048 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1049 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1050 | } | 998 | } |
1051 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1052 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1053 | } | 1001 | } |
1054 | 1002 | ||
1055 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1056 | 1004 | ||
1057 | 1005 | ||
1058 | } | 1006 | } |
1059 | 1007 | ||
1060 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1061 | { | 1009 | { |
1062 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1063 | 1011 | ||
1064 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1065 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1066 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1067 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1068 | 1016 | ||
1069 | } | 1017 | } |
1070 | 1018 | ||
1071 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1072 | { | 1020 | { |
1073 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1074 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1075 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1076 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1077 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1078 | #endif | 1026 | #endif |
1079 | return; | 1027 | return; |
1080 | } | 1028 | } |
1081 | int maxSec; | 1029 | int maxSec; |
1082 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1083 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1084 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1085 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1086 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1087 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1088 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1089 | return; | 1037 | return; |
1090 | } else { | 1038 | } else { |
1091 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1092 | } | 1040 | } |
1093 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1094 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1095 | 1043 | ||
1096 | } | 1044 | } |
1097 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1098 | // we need this, because a QTimer has only a max range of 25 days | 1046 | // we need this, because a QTimer has only a max range of 25 days |
1099 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1100 | { | 1048 | { |
1101 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1102 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1103 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1104 | } | 1052 | } |
1105 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1106 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1107 | #else | 1055 | #else |
1108 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1109 | #endif | 1057 | #endif |
1110 | { | 1058 | { |
1111 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1112 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1113 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1114 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1115 | #endif | 1063 | #endif |
1116 | return; | 1064 | return; |
1117 | } | 1065 | } |
1118 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1119 | } | 1067 | } |
1120 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1121 | { | 1069 | { |
1122 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1123 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1124 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1125 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1126 | } | 1074 | } |
1127 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1128 | { | 1076 | { |
1129 | return mViewManager; | 1077 | return mViewManager; |
1130 | } | 1078 | } |
1131 | 1079 | ||
1132 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1133 | { | 1081 | { |
1134 | return mDialogManager; | 1082 | return mDialogManager; |
1135 | } | 1083 | } |
1136 | 1084 | ||
1137 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1138 | { | 1086 | { |
1139 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1140 | 1088 | ||
1141 | return dates.first(); | 1089 | return dates.first(); |
1142 | } | 1090 | } |
1143 | 1091 | ||
1144 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1145 | { | 1093 | { |
1146 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1147 | 1095 | ||
1148 | return dates.last(); | 1096 | return dates.last(); |
1149 | } | 1097 | } |
1150 | 1098 | ||
1151 | 1099 | ||
1152 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1153 | { | 1101 | { |
1154 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1155 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1156 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1157 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1158 | } | 1106 | } |
1159 | #endif | 1107 | #endif |
1160 | } | 1108 | } |
1161 | 1109 | ||
1162 | 1110 | ||
1163 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1164 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1165 | 1113 | ||
1166 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1167 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1168 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1169 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1170 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1171 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1172 | 1120 | ||
1173 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1174 | { | 1122 | { |
1175 | 1123 | ||
1176 | // 0 equal | 1124 | // 0 equal |
1177 | // 1 take local | 1125 | // 1 take local |
1178 | // 2 take remote | 1126 | // 2 take remote |
1179 | // 3 cancel | 1127 | // 3 cancel |
1180 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1181 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1182 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1183 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1184 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1185 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1186 | //if ( remCh ) | 1134 | //if ( remCh ) |
1187 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1188 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1189 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1190 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1191 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1192 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1193 | return 0; | 1141 | return 0; |
1194 | } else { | 1142 | } else { |
1195 | if ( locCh ) { | 1143 | if ( locCh ) { |
1196 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1197 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1198 | if ( !remCh ) | 1146 | if ( !remCh ) |
1199 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1200 | } else { | 1148 | } else { |
1201 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1202 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1203 | if ( remCh ) | 1151 | if ( remCh ) |
1204 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1205 | 1153 | ||
1206 | } | 1154 | } |
1207 | } | 1155 | } |
1208 | full = true; | 1156 | full = true; |
1209 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1210 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1211 | } else { | 1159 | } else { |
1212 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1213 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1214 | return 0; | 1162 | return 0; |
1215 | 1163 | ||
1216 | } | 1164 | } |
1217 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1218 | 1166 | ||
1219 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1220 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1221 | //full = true; //debug only | 1169 | //full = true; //debug only |
1222 | if ( full ) { | 1170 | if ( full ) { |
1223 | bool equ = false; | 1171 | bool equ = false; |
1224 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1225 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1226 | } | 1174 | } |
1227 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1228 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1229 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1230 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1231 | if ( equ ) { | 1179 | if ( equ ) { |
1232 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1233 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1234 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1235 | } | 1183 | } |
1236 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1237 | return 0; | 1185 | return 0; |
1238 | 1186 | ||
1239 | }//else //debug only | 1187 | }//else //debug only |
1240 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1241 | } | 1189 | } |
1242 | int result; | 1190 | int result; |
1243 | bool localIsNew; | 1191 | bool localIsNew; |
1244 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1192 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1245 | 1193 | ||
1246 | 1194 | ||
1247 | // ************************************************ | 1195 | // ************************************************ |
1248 | // ************************************************ | 1196 | // ************************************************ |
1249 | // ************************************************ | 1197 | // ************************************************ |
1250 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1251 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1252 | 1200 | ||
1253 | 1201 | ||
1254 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1255 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1256 | 1204 | ||
1257 | switch( mode ) { | 1205 | switch( mode ) { |
1258 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1259 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1260 | return 1; | 1208 | return 1; |
1261 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1262 | return 2; | 1210 | return 2; |
1263 | return 1; | 1211 | return 1; |
1264 | break; | 1212 | break; |
1265 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1266 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1267 | return 2; | 1215 | return 2; |
1268 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1269 | return 1; | 1217 | return 1; |
1270 | return 2; | 1218 | return 2; |
1271 | break; | 1219 | break; |
1272 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1273 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1274 | return 1; | 1222 | return 1; |
1275 | else | 1223 | else |
1276 | return 2; | 1224 | return 2; |
1277 | break; | 1225 | break; |
1278 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1279 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1280 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1281 | return 0; | 1229 | return 0; |
1282 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1283 | return 1; | 1231 | return 1; |
1284 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1285 | return 2; | 1233 | return 2; |
1286 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1287 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1288 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1289 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1290 | else | 1238 | else |
1291 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1292 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1293 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1294 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1295 | else | 1243 | else |
1296 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1297 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1298 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1299 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1300 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1301 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1302 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1303 | return result; | 1251 | return result; |
1304 | 1252 | ||
1305 | break; | 1253 | break; |
1306 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1307 | return 1; | 1255 | return 1; |
1308 | break; | 1256 | break; |
1309 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1310 | return 2; | 1258 | return 2; |
1311 | break; | 1259 | break; |
1312 | 1260 | ||
1313 | default: | 1261 | default: |
1314 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1315 | break; | 1263 | break; |
1316 | } | 1264 | } |
1317 | return 0; | 1265 | return 0; |
1318 | } | 1266 | } |
1319 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1320 | { | 1268 | { |
1321 | Event* lse; | 1269 | Event* lse; |
1322 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1323 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1324 | if (!lse) { | 1272 | if (!lse) { |
1325 | lse = new Event(); | 1273 | lse = new Event(); |
1326 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1327 | QString sum = ""; | 1275 | QString sum = ""; |
1328 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1329 | sum = "E: "; | 1277 | sum = "E: "; |
1330 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1331 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1332 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1333 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1334 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1335 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1336 | } | 1284 | } |
1337 | 1285 | ||
1338 | return lse; | 1286 | return lse; |
1339 | 1287 | ||
1340 | } | 1288 | } |
1341 | 1289 | ||
1342 | // we check, if the to delete event has a id for a profile | 1290 | // we check, if the to delete event has a id for a profile |
1343 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1344 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1345 | { | 1293 | { |
1346 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1347 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1348 | return; | 1296 | return; |
1349 | } | 1297 | } |
1350 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1351 | return; | 1299 | return; |
1352 | 1300 | ||
1353 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1354 | 1302 | ||
1355 | while ( eve ) { | 1303 | while ( eve ) { |
1356 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1357 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1358 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1359 | QString pref = "e"; | 1307 | QString pref = "e"; |
1360 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1361 | pref = "t"; | 1309 | pref = "t"; |
1362 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1363 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1364 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1365 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1366 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1367 | } | 1315 | } |
1368 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1369 | } | 1317 | } |
1370 | 1318 | ||
1371 | } | 1319 | } |
1372 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1373 | { | 1321 | { |
1374 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1375 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1376 | 1324 | ||
1377 | } | 1325 | } |
1378 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1379 | { | 1327 | { |
1380 | bool syncOK = true; | 1328 | bool syncOK = true; |
1381 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1382 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1383 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1384 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1385 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1386 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1387 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1388 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1389 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1390 | Event* eventR; | 1338 | Event* eventR; |
1391 | QString uid; | 1339 | QString uid; |
1392 | int take; | 1340 | int take; |
1393 | Event* eventRSync; | 1341 | Event* eventRSync; |
1394 | Event* eventLSync; | 1342 | Event* eventLSync; |
1395 | clearAllViews(); | 1343 | clearAllViews(); |
1396 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1397 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1398 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1399 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1400 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1401 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1402 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1403 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1404 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1405 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1406 | } else { | 1354 | } else { |
1407 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1408 | } | 1356 | } |
1409 | } | 1357 | } |
1410 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1411 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1412 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1413 | if ( eventR ) { | 1361 | if ( eventR ) { |
1414 | eventRSync = (Event*) eventR->clone(); | 1362 | eventRSync = (Event*) eventR->clone(); |
1415 | remote->deleteEvent(eventR ); | 1363 | remote->deleteEvent(eventR ); |
1416 | 1364 | ||
1417 | } else { | 1365 | } else { |
1418 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1419 | eventRSync = (Event*)eventLSync->clone(); | 1367 | eventRSync = (Event*)eventLSync->clone(); |
1420 | } else { | 1368 | } else { |
1421 | fullDateRange = true; | 1369 | fullDateRange = true; |
1422 | eventRSync = new Event(); | 1370 | eventRSync = new Event(); |
1423 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1424 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1425 | eventRSync->setDtStart( mLastCalendarSync ); | 1373 | eventRSync->setDtStart( mLastCalendarSync ); |
1426 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1427 | eventRSync->setCategories( i18n("SyncEvent") ); | 1375 | eventRSync->setCategories( i18n("SyncEvent") ); |
1428 | } | 1376 | } |
1429 | } | 1377 | } |
1430 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1431 | fullDateRange = true; | 1379 | fullDateRange = true; |
1432 | 1380 | ||
1433 | if ( ! fullDateRange ) { | 1381 | if ( ! fullDateRange ) { |
1434 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1435 | 1383 | ||
1436 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1437 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1438 | fullDateRange = true; | 1386 | fullDateRange = true; |
1439 | } | 1387 | } |
1440 | } | 1388 | } |
1441 | if ( mSyncManager->syncWithDesktop() ) { | 1389 | if ( mSyncManager->syncWithDesktop() ) { |
1442 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1443 | } | 1391 | } |
1444 | if ( fullDateRange ) | 1392 | if ( fullDateRange ) |
1445 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1446 | else | 1394 | else |
1447 | mLastCalendarSync = eventLSync->dtStart(); | 1395 | mLastCalendarSync = eventLSync->dtStart(); |
1448 | // for resyncing if own file has changed | 1396 | // for resyncing if own file has changed |
1449 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1450 | mLastCalendarSync = loadedFileVersion; | 1398 | mLastCalendarSync = loadedFileVersion; |
1451 | //qDebug("setting mLastCalendarSync "); | 1399 | //qDebug("setting mLastCalendarSync "); |
1452 | } | 1400 | } |
1453 | //qDebug("*************************** "); | 1401 | //qDebug("*************************** "); |
1454 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1455 | QPtrList<Incidence> er = remote->rawIncidences(); | 1403 | QPtrList<Incidence> er = remote->rawIncidences(); |
1456 | Incidence* inR = er.first(); | 1404 | Incidence* inR = er.first(); |
1457 | Incidence* inL; | 1405 | Incidence* inL; |
1458 | QProgressBar bar( er.count(),0 ); | 1406 | QProgressBar bar( er.count(),0 ); |
1459 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1407 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1460 | 1408 | ||
1461 | // ************** setting up filter ************* | 1409 | // ************** setting up filter ************* |
1462 | CalFilter *filterIN = 0; | 1410 | CalFilter *filterIN = 0; |
1463 | CalFilter *filterOUT = 0; | 1411 | CalFilter *filterOUT = 0; |
1464 | CalFilter *filter = mFilters.first(); | 1412 | CalFilter *filter = mFilters.first(); |
1465 | while(filter) { | 1413 | while(filter) { |
1466 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1414 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1467 | filterIN = filter; | 1415 | filterIN = filter; |
1468 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1469 | filterOUT = filter; | 1417 | filterOUT = filter; |
1470 | filter = mFilters.next(); | 1418 | filter = mFilters.next(); |
1471 | } | 1419 | } |
1472 | int w = 300; | 1420 | int w = 300; |
1473 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1474 | w = 220; | 1422 | w = 220; |
1475 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1476 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1477 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1478 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1479 | bar.show(); | 1427 | bar.show(); |
1480 | int modulo = (er.count()/10)+1; | 1428 | int modulo = (er.count()/10)+1; |
1481 | int incCounter = 0; | 1429 | int incCounter = 0; |
1482 | while ( inR ) { | 1430 | while ( inR ) { |
1483 | if ( ! bar.isVisible() ) | 1431 | if ( ! bar.isVisible() ) |
1484 | return false; | 1432 | return false; |
1485 | if ( incCounter % modulo == 0 ) | 1433 | if ( incCounter % modulo == 0 ) |
1486 | bar.setProgress( incCounter ); | 1434 | bar.setProgress( incCounter ); |
1487 | ++incCounter; | 1435 | ++incCounter; |
1488 | uid = inR->uid(); | 1436 | uid = inR->uid(); |
1489 | bool skipIncidence = false; | 1437 | bool skipIncidence = false; |
1490 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1438 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1491 | skipIncidence = true; | 1439 | skipIncidence = true; |
1492 | QString idS; | 1440 | QString idS; |
1493 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1494 | if ( !skipIncidence ) { | 1442 | if ( !skipIncidence ) { |
1495 | inL = local->incidence( uid ); | 1443 | inL = local->incidence( uid ); |
1496 | if ( inL ) { // maybe conflict - same uid in both calendars | 1444 | if ( inL ) { // maybe conflict - same uid in both calendars |
1497 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1498 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1499 | if ( take == 3 ) | 1447 | if ( take == 3 ) |
1500 | return false; | 1448 | return false; |
1501 | if ( take == 1 ) {// take local ********************** | 1449 | if ( take == 1 ) {// take local ********************** |
1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1504 | else | 1452 | else |
1505 | idS = inR->IDStr(); | 1453 | idS = inR->IDStr(); |
1506 | remote->deleteIncidence( inR ); | 1454 | remote->deleteIncidence( inR ); |
1507 | inR = inL->clone(); | 1455 | inR = inL->clone(); |
1508 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1509 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1510 | inR->setIDStr( idS ); | 1458 | inR->setIDStr( idS ); |
1511 | remote->addIncidence( inR ); | 1459 | remote->addIncidence( inR ); |
1512 | if ( mSyncManager->syncWithDesktop() ) | 1460 | if ( mSyncManager->syncWithDesktop() ) |
1513 | inR->setPilotId( 2 ); | 1461 | inR->setPilotId( 2 ); |
1514 | ++changedRemote; | 1462 | ++changedRemote; |
1515 | } else {// take remote ********************** | 1463 | } else {// take remote ********************** |
1516 | idS = inL->IDStr(); | 1464 | idS = inL->IDStr(); |
1517 | int pid = inL->pilotId(); | 1465 | int pid = inL->pilotId(); |
1518 | local->deleteIncidence( inL ); | 1466 | local->deleteIncidence( inL ); |
1519 | inL = inR->clone(); | 1467 | inL = inR->clone(); |
1520 | if ( mSyncManager->syncWithDesktop() ) | 1468 | if ( mSyncManager->syncWithDesktop() ) |
1521 | inL->setPilotId( pid ); | 1469 | inL->setPilotId( pid ); |
1522 | inL->setIDStr( idS ); | 1470 | inL->setIDStr( idS ); |
1523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1524 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1525 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1526 | } | 1474 | } |
1527 | local->addIncidence( inL ); | 1475 | local->addIncidence( inL ); |
1528 | ++changedLocal; | 1476 | ++changedLocal; |
1529 | } | 1477 | } |
1530 | } | 1478 | } |
1531 | } else { // no conflict ********** add or delete remote | 1479 | } else { // no conflict ********** add or delete remote |
1532 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1534 | QString des = eventLSync->description(); | 1482 | QString des = eventLSync->description(); |
1535 | QString pref = "e"; | 1483 | QString pref = "e"; |
1536 | if ( inR->typeID() == todoID ) | 1484 | if ( inR->typeID() == todoID ) |
1537 | pref = "t"; | 1485 | pref = "t"; |
1538 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1539 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1540 | //remote->deleteIncidence( inR ); | 1488 | //remote->deleteIncidence( inR ); |
1541 | ++deletedEventR; | 1489 | ++deletedEventR; |
1542 | } else { | 1490 | } else { |
1543 | inR->setLastModified( modifiedCalendar ); | 1491 | inR->setLastModified( modifiedCalendar ); |
1544 | inL = inR->clone(); | 1492 | inL = inR->clone(); |
1545 | inL->setIDStr( ":" ); | 1493 | inL->setIDStr( ":" ); |
1546 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1547 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1548 | local->addIncidence( inL ); | 1496 | local->addIncidence( inL ); |
1549 | ++addedEvent; | 1497 | ++addedEvent; |
1550 | 1498 | ||
1551 | } | 1499 | } |
1552 | } else { | 1500 | } else { |
1553 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1554 | inR->setLastModified( modifiedCalendar ); | 1502 | inR->setLastModified( modifiedCalendar ); |
1555 | inL = inR->clone(); | 1503 | inL = inR->clone(); |
1556 | inL->setIDStr( ":" ); | 1504 | inL->setIDStr( ":" ); |
1557 | local->addIncidence( inL ); | 1505 | local->addIncidence( inL ); |
1558 | ++addedEvent; | 1506 | ++addedEvent; |
1559 | 1507 | ||
1560 | } else { | 1508 | } else { |
1561 | checkExternSyncEvent(eventRSyncSharp, inR); | 1509 | checkExternSyncEvent(eventRSyncSharp, inR); |
1562 | remote->deleteIncidence( inR ); | 1510 | remote->deleteIncidence( inR ); |
1563 | ++deletedEventR; | 1511 | ++deletedEventR; |
1564 | } | 1512 | } |
1565 | } | 1513 | } |
1566 | } else { | 1514 | } else { |
1567 | ++filteredIN; | 1515 | ++filteredIN; |
1568 | } | 1516 | } |
1569 | } | 1517 | } |
1570 | } | 1518 | } |
1571 | inR = er.next(); | 1519 | inR = er.next(); |
1572 | } | 1520 | } |
1573 | QPtrList<Incidence> el = local->rawIncidences(); | 1521 | QPtrList<Incidence> el = local->rawIncidences(); |
1574 | inL = el.first(); | 1522 | inL = el.first(); |
1575 | modulo = (el.count()/10)+1; | 1523 | modulo = (el.count()/10)+1; |
1576 | bar.setCaption (i18n("Add / remove events") ); | 1524 | bar.setCaption (i18n("Add / remove events") ); |
1577 | bar.setTotalSteps ( el.count() ) ; | 1525 | bar.setTotalSteps ( el.count() ) ; |
1578 | bar.show(); | 1526 | bar.show(); |
1579 | incCounter = 0; | 1527 | incCounter = 0; |
1580 | 1528 | ||
1581 | while ( inL ) { | 1529 | while ( inL ) { |
1582 | 1530 | ||
1583 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1584 | if ( ! bar.isVisible() ) | 1532 | if ( ! bar.isVisible() ) |
1585 | return false; | 1533 | return false; |
1586 | if ( incCounter % modulo == 0 ) | 1534 | if ( incCounter % modulo == 0 ) |
1587 | bar.setProgress( incCounter ); | 1535 | bar.setProgress( incCounter ); |
1588 | ++incCounter; | 1536 | ++incCounter; |
1589 | uid = inL->uid(); | 1537 | uid = inL->uid(); |
1590 | bool skipIncidence = false; | 1538 | bool skipIncidence = false; |
1591 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1539 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1592 | skipIncidence = true; | 1540 | skipIncidence = true; |
1593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1594 | skipIncidence = true; | 1542 | skipIncidence = true; |
1595 | if ( !skipIncidence ) { | 1543 | if ( !skipIncidence ) { |
1596 | inR = remote->incidence( uid ); | 1544 | inR = remote->incidence( uid ); |
1597 | if ( ! inR ) { | 1545 | if ( ! inR ) { |
1598 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1599 | // no conflict ********** add or delete local | 1547 | // no conflict ********** add or delete local |
1600 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1601 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1602 | checkExternSyncEvent(eventLSyncSharp, inL); | 1550 | checkExternSyncEvent(eventLSyncSharp, inL); |
1603 | local->deleteIncidence( inL ); | 1551 | local->deleteIncidence( inL ); |
1604 | ++deletedEventL; | 1552 | ++deletedEventL; |
1605 | } else { | 1553 | } else { |
1606 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1607 | inL->removeID(mCurrentSyncDevice ); | 1555 | inL->removeID(mCurrentSyncDevice ); |
1608 | ++addedEventR; | 1556 | ++addedEventR; |
1609 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1610 | inL->setLastModified( modifiedCalendar ); | 1558 | inL->setLastModified( modifiedCalendar ); |
1611 | inR = inL->clone(); | 1559 | inR = inL->clone(); |
1612 | inR->setIDStr( ":" ); | 1560 | inR->setIDStr( ":" ); |
1613 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1614 | remote->addIncidence( inR ); | 1562 | remote->addIncidence( inR ); |
1615 | } | 1563 | } |
1616 | } | 1564 | } |
1617 | } else { | 1565 | } else { |
1618 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1619 | checkExternSyncEvent(eventLSyncSharp, inL); | 1567 | checkExternSyncEvent(eventLSyncSharp, inL); |
1620 | local->deleteIncidence( inL ); | 1568 | local->deleteIncidence( inL ); |
1621 | ++deletedEventL; | 1569 | ++deletedEventL; |
1622 | } else { | 1570 | } else { |
1623 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1624 | ++addedEventR; | 1572 | ++addedEventR; |
1625 | inL->setLastModified( modifiedCalendar ); | 1573 | inL->setLastModified( modifiedCalendar ); |
1626 | inR = inL->clone(); | 1574 | inR = inL->clone(); |
1627 | inR->setIDStr( ":" ); | 1575 | inR->setIDStr( ":" ); |
1628 | remote->addIncidence( inR ); | 1576 | remote->addIncidence( inR ); |
1629 | } | 1577 | } |
1630 | } | 1578 | } |
1631 | } | 1579 | } |
1632 | } else { | 1580 | } else { |
1633 | ++filteredOUT; | 1581 | ++filteredOUT; |
1634 | } | 1582 | } |
1635 | } | 1583 | } |
1636 | } | 1584 | } |
1637 | inL = el.next(); | 1585 | inL = el.next(); |
1638 | } | 1586 | } |
1639 | int delFut = 0; | 1587 | int delFut = 0; |
1640 | int remRem = 0; | 1588 | int remRem = 0; |
1641 | if ( mSyncManager->mWriteBackInFuture ) { | 1589 | if ( mSyncManager->mWriteBackInFuture ) { |
1642 | er = remote->rawIncidences(); | 1590 | er = remote->rawIncidences(); |
1643 | remRem = er.count(); | 1591 | remRem = er.count(); |
1644 | inR = er.first(); | 1592 | inR = er.first(); |
1645 | QDateTime dt; | 1593 | QDateTime dt; |
1646 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1647 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1648 | while ( inR ) { | 1596 | while ( inR ) { |
1649 | if ( inR->typeID() == todoID ) { | 1597 | if ( inR->typeID() == todoID ) { |
1650 | Todo * t = (Todo*)inR; | 1598 | Todo * t = (Todo*)inR; |
1651 | if ( t->hasDueDate() ) | 1599 | if ( t->hasDueDate() ) |
1652 | dt = t->dtDue(); | 1600 | dt = t->dtDue(); |
1653 | else | 1601 | else |
1654 | dt = cur.addSecs( 62 ); | 1602 | dt = cur.addSecs( 62 ); |
1655 | } | 1603 | } |
1656 | else if (inR->typeID() == eventID ) { | 1604 | else if (inR->typeID() == eventID ) { |
1657 | bool ok; | 1605 | bool ok; |
1658 | dt = inR->getNextOccurence( cur, &ok ); | 1606 | dt = inR->getNextOccurence( cur, &ok ); |
1659 | if ( !ok ) | 1607 | if ( !ok ) |
1660 | dt = cur.addSecs( -62 ); | 1608 | dt = cur.addSecs( -62 ); |
1661 | } | 1609 | } |
1662 | else | 1610 | else |
1663 | dt = inR->dtStart(); | 1611 | dt = inR->dtStart(); |
1664 | if ( dt < cur || dt > end ) { | 1612 | if ( dt < cur || dt > end ) { |
1665 | remote->deleteIncidence( inR ); | 1613 | remote->deleteIncidence( inR ); |
1666 | ++delFut; | 1614 | ++delFut; |
1667 | } | 1615 | } |
1668 | inR = er.next(); | 1616 | inR = er.next(); |
1669 | } | 1617 | } |
1670 | } | 1618 | } |
1671 | bar.hide(); | 1619 | bar.hide(); |
1672 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1673 | eventLSync->setReadOnly( false ); | 1621 | eventLSync->setReadOnly( false ); |
1674 | eventLSync->setDtStart( mLastCalendarSync ); | 1622 | eventLSync->setDtStart( mLastCalendarSync ); |
1675 | eventRSync->setDtStart( mLastCalendarSync ); | 1623 | eventRSync->setDtStart( mLastCalendarSync ); |
1676 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1677 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1678 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1679 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1680 | eventLSync->setReadOnly( true ); | 1628 | eventLSync->setReadOnly( true ); |
1681 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1682 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1683 | remote->addEvent( eventRSync ); | 1631 | remote->addEvent( eventRSync ); |
1684 | else | 1632 | else |
1685 | delete eventRSync; | 1633 | delete eventRSync; |
1686 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1687 | QString mes; | 1635 | QString mes; |
1688 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1636 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1689 | QString delmess; | 1637 | QString delmess; |
1690 | if ( delFut ) { | 1638 | if ( delFut ) { |
1691 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1639 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1692 | mes += delmess; | 1640 | mes += delmess; |
1693 | } | 1641 | } |
1694 | mes = i18n("Local calendar changed!\n") +mes; | 1642 | mes = i18n("Local calendar changed!\n") +mes; |
1695 | mCalendar->checkAlarmForIncidence( 0, true ); | 1643 | mCalendar->checkAlarmForIncidence( 0, true ); |
1696 | qDebug( mes ); | 1644 | qDebug( mes ); |
1697 | if ( mSyncManager->mShowSyncSummary ) { | 1645 | if ( mSyncManager->mShowSyncSummary ) { |
1698 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1699 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1700 | qDebug("KO: WB cancelled "); | 1648 | qDebug("KO: WB cancelled "); |
1701 | mSyncManager->mWriteBackFile = false; | 1649 | mSyncManager->mWriteBackFile = false; |
1702 | return syncOK; | 1650 | return syncOK; |
1703 | } | 1651 | } |
1704 | } | 1652 | } |
1705 | return syncOK; | 1653 | return syncOK; |
1706 | } | 1654 | } |
1707 | 1655 | ||
1708 | void CalendarView::setSyncDevice( QString s ) | 1656 | void CalendarView::setSyncDevice( QString s ) |
1709 | { | 1657 | { |
1710 | mCurrentSyncDevice= s; | 1658 | mCurrentSyncDevice= s; |
1711 | } | 1659 | } |
1712 | void CalendarView::setSyncName( QString s ) | 1660 | void CalendarView::setSyncName( QString s ) |
1713 | { | 1661 | { |
1714 | mCurrentSyncName= s; | 1662 | mCurrentSyncName= s; |
1715 | } | 1663 | } |
1716 | bool CalendarView::syncCalendar(QString filename, int mode) | 1664 | bool CalendarView::syncCalendar(QString filename, int mode) |
1717 | { | 1665 | { |
1718 | //qDebug("syncCalendar %s ", filename.latin1()); | 1666 | //qDebug("syncCalendar %s ", filename.latin1()); |
1719 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1720 | CalendarLocal* calendar = new CalendarLocal(); | 1668 | CalendarLocal* calendar = new CalendarLocal(); |
1721 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1722 | FileStorage* storage = new FileStorage( calendar ); | 1670 | FileStorage* storage = new FileStorage( calendar ); |
1723 | bool syncOK = false; | 1671 | bool syncOK = false; |
1724 | storage->setFileName( filename ); | 1672 | storage->setFileName( filename ); |
1725 | // qDebug("loading ... "); | 1673 | // qDebug("loading ... "); |
1726 | if ( storage->load() ) { | 1674 | if ( storage->load() ) { |
1727 | getEventViewerDialog()->setSyncMode( true ); | 1675 | getEventViewerDialog()->setSyncMode( true ); |
1728 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1729 | getEventViewerDialog()->setSyncMode( false ); | 1677 | getEventViewerDialog()->setSyncMode( false ); |
1730 | if ( syncOK ) { | 1678 | if ( syncOK ) { |
1731 | if ( mSyncManager->mWriteBackFile ) | 1679 | if ( mSyncManager->mWriteBackFile ) |
1732 | { | 1680 | { |
1733 | storage->setSaveFormat( new ICalFormat() ); | 1681 | storage->setSaveFormat( new ICalFormat() ); |
1734 | storage->save(); | 1682 | storage->save(); |
1735 | } | 1683 | } |
1736 | } | 1684 | } |
1737 | setModified( true ); | 1685 | setModified( true ); |
1738 | } | 1686 | } |
1739 | delete storage; | 1687 | delete storage; |
1740 | delete calendar; | 1688 | delete calendar; |
1741 | if ( syncOK ) | 1689 | if ( syncOK ) |
1742 | updateView(); | 1690 | updateView(); |
1743 | return syncOK; | 1691 | return syncOK; |
1744 | } | 1692 | } |
1745 | 1693 | ||
1746 | void CalendarView::syncExternal( int mode ) | 1694 | void CalendarView::syncExternal( int mode ) |
1747 | { | 1695 | { |
1748 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1749 | 1697 | ||
1750 | qApp->processEvents(); | 1698 | qApp->processEvents(); |
1751 | CalendarLocal* calendar = new CalendarLocal(); | 1699 | CalendarLocal* calendar = new CalendarLocal(); |
1752 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1753 | bool syncOK = false; | 1701 | bool syncOK = false; |
1754 | bool loadSuccess = false; | 1702 | bool loadSuccess = false; |
1755 | PhoneFormat* phoneFormat = 0; | 1703 | PhoneFormat* phoneFormat = 0; |
1756 | emit tempDisableBR(true); | 1704 | emit tempDisableBR(true); |
1757 | #ifndef DESKTOP_VERSION | 1705 | #ifndef DESKTOP_VERSION |
1758 | SharpFormat* sharpFormat = 0; | 1706 | SharpFormat* sharpFormat = 0; |
1759 | if ( mode == 0 ) { // sharp | 1707 | if ( mode == 0 ) { // sharp |
1760 | sharpFormat = new SharpFormat () ; | 1708 | sharpFormat = new SharpFormat () ; |
1761 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1762 | 1710 | ||
1763 | } else | 1711 | } else |
1764 | #endif | 1712 | #endif |
1765 | if ( mode == 1 ) { // phone | 1713 | if ( mode == 1 ) { // phone |
1766 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1767 | mSyncManager->mPhoneDevice, | 1715 | mSyncManager->mPhoneDevice, |
1768 | mSyncManager->mPhoneConnection, | 1716 | mSyncManager->mPhoneConnection, |
1769 | mSyncManager->mPhoneModel); | 1717 | mSyncManager->mPhoneModel); |
1770 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1771 | 1719 | ||
1772 | } else { | 1720 | } else { |
1773 | emit tempDisableBR(false); | 1721 | emit tempDisableBR(false); |
1774 | return; | 1722 | return; |
1775 | } | 1723 | } |
1776 | if ( loadSuccess ) { | 1724 | if ( loadSuccess ) { |
1777 | getEventViewerDialog()->setSyncMode( true ); | 1725 | getEventViewerDialog()->setSyncMode( true ); |
1778 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1779 | getEventViewerDialog()->setSyncMode( false ); | 1727 | getEventViewerDialog()->setSyncMode( false ); |
1780 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1781 | if ( syncOK ) { | 1729 | if ( syncOK ) { |
1782 | if ( mSyncManager->mWriteBackFile ) | 1730 | if ( mSyncManager->mWriteBackFile ) |
1783 | { | 1731 | { |
1784 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1785 | Incidence* inc = iL.first(); | 1733 | Incidence* inc = iL.first(); |
1786 | if ( phoneFormat ) { | 1734 | if ( phoneFormat ) { |
1787 | while ( inc ) { | 1735 | while ( inc ) { |
1788 | inc->removeID(mCurrentSyncDevice); | 1736 | inc->removeID(mCurrentSyncDevice); |
1789 | inc = iL.next(); | 1737 | inc = iL.next(); |
1790 | } | 1738 | } |
1791 | } | 1739 | } |
1792 | #ifndef DESKTOP_VERSION | 1740 | #ifndef DESKTOP_VERSION |
1793 | if ( sharpFormat ) | 1741 | if ( sharpFormat ) |
1794 | sharpFormat->save(calendar); | 1742 | sharpFormat->save(calendar); |
1795 | #endif | 1743 | #endif |
1796 | if ( phoneFormat ) | 1744 | if ( phoneFormat ) |
1797 | phoneFormat->save(calendar); | 1745 | phoneFormat->save(calendar); |
1798 | iL = calendar->rawIncidences(); | 1746 | iL = calendar->rawIncidences(); |
1799 | inc = iL.first(); | 1747 | inc = iL.first(); |
1800 | Incidence* loc; | 1748 | Incidence* loc; |
1801 | while ( inc ) { | 1749 | while ( inc ) { |
1802 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1803 | loc = mCalendar->incidence(inc->uid() ); | 1751 | loc = mCalendar->incidence(inc->uid() ); |
1804 | if ( loc ) { | 1752 | if ( loc ) { |
1805 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1806 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1807 | } | 1755 | } |
1808 | } | 1756 | } |
1809 | inc = iL.next(); | 1757 | inc = iL.next(); |
1810 | } | 1758 | } |
1811 | Incidence* lse = getLastSyncEvent(); | 1759 | Incidence* lse = getLastSyncEvent(); |
1812 | if ( lse ) { | 1760 | if ( lse ) { |
1813 | lse->setReadOnly( false ); | 1761 | lse->setReadOnly( false ); |
1814 | lse->setDescription( "" ); | 1762 | lse->setDescription( "" ); |
1815 | lse->setReadOnly( true ); | 1763 | lse->setReadOnly( true ); |
1816 | } | 1764 | } |
1817 | } | 1765 | } |
1818 | } else { | 1766 | } else { |
1819 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1820 | } | 1768 | } |
1821 | setModified( true ); | 1769 | setModified( true ); |
1822 | } else { | 1770 | } else { |
1823 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1824 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1825 | question, i18n("Ok")) ; | 1773 | question, i18n("Ok")) ; |
1826 | 1774 | ||
1827 | } | 1775 | } |
1828 | delete calendar; | 1776 | delete calendar; |
1829 | updateView(); | 1777 | updateView(); |
1830 | emit tempDisableBR(false); | 1778 | emit tempDisableBR(false); |
1831 | return ;//syncOK; | 1779 | return ;//syncOK; |
1832 | 1780 | ||
1833 | } | 1781 | } |
1834 | 1782 | ||
1835 | bool CalendarView::importBday() | 1783 | bool CalendarView::importBday() |
1836 | { | 1784 | { |
1837 | #ifndef KORG_NOKABC | 1785 | #ifndef KORG_NOKABC |
1838 | 1786 | ||
1839 | #ifdef DESKTOP_VERSION | 1787 | #ifdef DESKTOP_VERSION |
1840 | int curCal = mCalendar->defaultCalendar(); | 1788 | int curCal = mCalendar->defaultCalendar(); |
1841 | int bd = mCalEditView->getBirtdayID(); | 1789 | int bd = mCalEditView->getBirtdayID(); |
1842 | if ( bd == 0 ) | 1790 | if ( bd == 0 ) |
1843 | return false; | 1791 | return false; |
1844 | mCalendar->setDefaultCalendar( bd ); | 1792 | mCalendar->setDefaultCalendar( bd ); |
1845 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1846 | KABC::AddressBook::Iterator it; | 1794 | KABC::AddressBook::Iterator it; |
1847 | int count = 0; | 1795 | int count = 0; |
1848 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1849 | ++count; | 1797 | ++count; |
1850 | } | 1798 | } |
1851 | QProgressBar bar(count,0 ); | 1799 | QProgressBar bar(count,0 ); |
1852 | int w = 300; | 1800 | int w = 300; |
1853 | if ( QApplication::desktop()->width() < 320 ) | 1801 | if ( QApplication::desktop()->width() < 320 ) |
1854 | w = 220; | 1802 | w = 220; |
1855 | int h = bar.sizeHint().height() ; | 1803 | int h = bar.sizeHint().height() ; |
1856 | int dw = QApplication::desktop()->width(); | 1804 | int dw = QApplication::desktop()->width(); |
1857 | int dh = QApplication::desktop()->height(); | 1805 | int dh = QApplication::desktop()->height(); |
1858 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1859 | bar.show(); | 1807 | bar.show(); |
1860 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1861 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1862 | count = 0; | 1810 | count = 0; |
1863 | int addCount = 0; | 1811 | int addCount = 0; |
1864 | KCal::Attendee* a = 0; | 1812 | KCal::Attendee* a = 0; |
1865 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1866 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1867 | return false; | 1815 | return false; |
1868 | bar.setProgress( count++ ); | 1816 | bar.setProgress( count++ ); |
1869 | qApp->processEvents(); | 1817 | qApp->processEvents(); |
1870 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1871 | if ( (*it).birthday().date().isValid() ){ | 1819 | if ( (*it).birthday().date().isValid() ){ |
1872 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1873 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1874 | ++addCount; | 1822 | ++addCount; |
1875 | } | 1823 | } |
1876 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1877 | if ( anni.isValid() ){ | 1825 | if ( anni.isValid() ){ |
1878 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1879 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1880 | ++addCount; | 1828 | ++addCount; |
1881 | } | 1829 | } |
1882 | } | 1830 | } |
1883 | mCalendar->setDefaultCalendar( curCal ); | 1831 | mCalendar->setDefaultCalendar( curCal ); |
1884 | updateView(); | 1832 | updateView(); |
1885 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1886 | #else //DESKTOP_VERSION | 1834 | #else //DESKTOP_VERSION |
1887 | 1835 | ||
1888 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1889 | // the result should now arrive through method insertBirthdays | 1837 | // the result should now arrive through method insertBirthdays |
1890 | 1838 | ||
1891 | #endif //DESKTOP_VERSION | 1839 | #endif //DESKTOP_VERSION |
1892 | 1840 | ||
1893 | #endif //KORG_NOKABC | 1841 | #endif //KORG_NOKABC |
1894 | 1842 | ||
1895 | 1843 | ||
1896 | return true; | 1844 | return true; |
1897 | } | 1845 | } |
1898 | 1846 | ||
1899 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1900 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1901 | const QStringList& anniversaryList, const QStringList& realNameList, | 1849 | const QStringList& anniversaryList, const QStringList& realNameList, |
1902 | const QStringList& emailList, const QStringList& assembledNameList, | 1850 | const QStringList& emailList, const QStringList& assembledNameList, |
1903 | const QStringList& uidList) | 1851 | const QStringList& uidList) |
1904 | { | 1852 | { |
1905 | 1853 | ||
1906 | //qDebug("KO::CalendarView::insertBirthdays"); | 1854 | //qDebug("KO::CalendarView::insertBirthdays"); |
1907 | if (uid == this->name()) | 1855 | if (uid == this->name()) |
1908 | { | 1856 | { |
1909 | int curCal = mCalendar->defaultCalendar(); | 1857 | int curCal = mCalendar->defaultCalendar(); |
1910 | int bd = mCalEditView->getBirtdayID(); | 1858 | int bd = mCalEditView->getBirtdayID(); |
1911 | if ( bd == 0 ) | 1859 | if ( bd == 0 ) |
1912 | return; | 1860 | return; |
1913 | mCalendar->setDefaultCalendar( bd ); | 1861 | mCalendar->setDefaultCalendar( bd ); |
1914 | 1862 | ||
1915 | 1863 | ||
1916 | int count = birthdayList.count(); | 1864 | int count = birthdayList.count(); |
1917 | int addCount = 0; | 1865 | int addCount = 0; |
1918 | KCal::Attendee* a = 0; | 1866 | KCal::Attendee* a = 0; |
1919 | 1867 | ||
1920 | //qDebug("CalView 1 %i", count); | 1868 | //qDebug("CalView 1 %i", count); |
1921 | 1869 | ||
1922 | QProgressBar bar(count,0 ); | 1870 | QProgressBar bar(count,0 ); |
1923 | int w = 300; | 1871 | int w = 300; |
1924 | if ( QApplication::desktop()->width() < 320 ) | 1872 | if ( QApplication::desktop()->width() < 320 ) |
1925 | w = 220; | 1873 | w = 220; |
1926 | int h = bar.sizeHint().height() ; | 1874 | int h = bar.sizeHint().height() ; |
1927 | int dw = QApplication::desktop()->width(); | 1875 | int dw = QApplication::desktop()->width(); |
1928 | int dh = QApplication::desktop()->height(); | 1876 | int dh = QApplication::desktop()->height(); |
1929 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1930 | bar.show(); | 1878 | bar.show(); |
1931 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1932 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1933 | 1881 | ||
1934 | QDate birthday; | 1882 | QDate birthday; |
1935 | QDate anniversary; | 1883 | QDate anniversary; |
1936 | QString realName; | 1884 | QString realName; |
1937 | QString email; | 1885 | QString email; |
1938 | QString assembledName; | 1886 | QString assembledName; |
1939 | QString uid; | 1887 | QString uid; |
1940 | bool ok = true; | 1888 | bool ok = true; |
1941 | for ( int i = 0; i < count; i++) | 1889 | for ( int i = 0; i < count; i++) |
1942 | { | 1890 | { |
1943 | if ( ! bar.isVisible() ) | 1891 | if ( ! bar.isVisible() ) |
1944 | return; | 1892 | return; |
1945 | bar.setProgress( i ); | 1893 | bar.setProgress( i ); |
1946 | qApp->processEvents(); | 1894 | qApp->processEvents(); |
1947 | 1895 | ||
1948 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1949 | if (!ok) { | 1897 | if (!ok) { |
1950 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1951 | } | 1899 | } |
1952 | 1900 | ||
1953 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1954 | if (!ok) { | 1902 | if (!ok) { |
1955 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1956 | } | 1904 | } |
1957 | realName = realNameList[i]; | 1905 | realName = realNameList[i]; |
1958 | email = emailList[i]; | 1906 | email = emailList[i]; |
1959 | assembledName = assembledNameList[i]; | 1907 | assembledName = assembledNameList[i]; |
1960 | uid = uidList[i]; | 1908 | uid = uidList[i]; |
1961 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1909 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1962 | 1910 | ||
1963 | if ( birthday.isValid() ){ | 1911 | if ( birthday.isValid() ){ |
1964 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1965 | KCal::Attendee::ReqParticipant,uid) ; | 1913 | KCal::Attendee::ReqParticipant,uid) ; |
1966 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1967 | ++addCount; | 1915 | ++addCount; |
1968 | } | 1916 | } |
1969 | 1917 | ||
1970 | if ( anniversary.isValid() ){ | 1918 | if ( anniversary.isValid() ){ |
1971 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1972 | KCal::Attendee::ReqParticipant,uid) ; | 1920 | KCal::Attendee::ReqParticipant,uid) ; |
1973 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1974 | ++addCount; | 1922 | ++addCount; |
1975 | } | 1923 | } |
1976 | } | 1924 | } |
1977 | 1925 | ||
1978 | mCalendar->setDefaultCalendar( curCal ); | 1926 | mCalendar->setDefaultCalendar( curCal ); |
1979 | updateView(); | 1927 | updateView(); |
1980 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1981 | 1929 | ||
1982 | } | 1930 | } |
1983 | 1931 | ||
1984 | } | 1932 | } |
1985 | 1933 | ||
1986 | 1934 | ||
1987 | 1935 | ||
1988 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1989 | { | 1937 | { |
1990 | //qDebug("addAnni "); | 1938 | //qDebug("addAnni "); |
1991 | Event * ev = new Event(); | 1939 | Event * ev = new Event(); |
1992 | ev->setOrganizer(KOPrefs::instance()->email()); | 1940 | ev->setOrganizer(KOPrefs::instance()->email()); |
1993 | if ( a ) { | 1941 | if ( a ) { |
1994 | ev->addAttendee( a ); | 1942 | ev->addAttendee( a ); |
1995 | } | 1943 | } |
1996 | QString kind; | 1944 | QString kind; |
1997 | if ( birthday ) { | 1945 | if ( birthday ) { |
1998 | kind = i18n( "Birthday" ); | 1946 | kind = i18n( "Birthday" ); |
1999 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2000 | } | 1948 | } |
2001 | else { | 1949 | else { |
2002 | kind = i18n( "Anniversary" ); | 1950 | kind = i18n( "Anniversary" ); |
2003 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2004 | } | 1952 | } |
2005 | ev->setCategories( kind ); | 1953 | ev->setCategories( kind ); |
2006 | ev->setDtStart( QDateTime(date) ); | 1954 | ev->setDtStart( QDateTime(date) ); |
2007 | ev->setDtEnd( QDateTime(date) ); | 1955 | ev->setDtEnd( QDateTime(date) ); |
2008 | ev->setFloats( true ); | 1956 | ev->setFloats( true ); |
2009 | Recurrence * rec = ev->recurrence(); | 1957 | Recurrence * rec = ev->recurrence(); |
2010 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2011 | rec->addYearlyNum( date.month() ); | 1959 | rec->addYearlyNum( date.month() ); |
2012 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2013 | delete ev; | 1961 | delete ev; |
2014 | return false; | 1962 | return false; |
2015 | } | 1963 | } |
2016 | return true; | 1964 | return true; |
2017 | 1965 | ||
2018 | } | 1966 | } |
2019 | bool CalendarView::importQtopia( const QString &categories, | 1967 | bool CalendarView::importQtopia( const QString &categories, |
2020 | const QString &datebook, | 1968 | const QString &datebook, |
2021 | const QString &todolist ) | 1969 | const QString &todolist ) |
2022 | { | 1970 | { |
2023 | 1971 | ||
2024 | QtopiaFormat qtopiaFormat; | 1972 | QtopiaFormat qtopiaFormat; |
2025 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2026 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2027 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2028 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2029 | 1977 | ||
2030 | updateView(); | 1978 | updateView(); |
2031 | return true; | 1979 | return true; |
2032 | 1980 | ||
2033 | #if 0 | 1981 | #if 0 |
2034 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2035 | mCurrentSyncDevice = "qtopia-XML"; | 1983 | mCurrentSyncDevice = "qtopia-XML"; |
2036 | if ( mSyncManager->mAskForPreferences ) | 1984 | if ( mSyncManager->mAskForPreferences ) |
2037 | edit_sync_options(); | 1985 | edit_sync_options(); |
2038 | qApp->processEvents(); | 1986 | qApp->processEvents(); |
2039 | CalendarLocal* calendar = new CalendarLocal(); | 1987 | CalendarLocal* calendar = new CalendarLocal(); |
2040 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1988 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2041 | bool syncOK = false; | 1989 | bool syncOK = false; |
2042 | QtopiaFormat qtopiaFormat; | 1990 | QtopiaFormat qtopiaFormat; |
2043 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1991 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2044 | bool loadOk = true; | 1992 | bool loadOk = true; |
2045 | if ( !categories.isEmpty() ) | 1993 | if ( !categories.isEmpty() ) |
2046 | loadOk = qtopiaFormat.load( calendar, categories ); | 1994 | loadOk = qtopiaFormat.load( calendar, categories ); |
2047 | if ( loadOk && !datebook.isEmpty() ) | 1995 | if ( loadOk && !datebook.isEmpty() ) |
2048 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1996 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2049 | if ( loadOk && !todolist.isEmpty() ) | 1997 | if ( loadOk && !todolist.isEmpty() ) |
2050 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1998 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2051 | 1999 | ||
2052 | if ( loadOk ) { | 2000 | if ( loadOk ) { |
2053 | getEventViewerDialog()->setSyncMode( true ); | 2001 | getEventViewerDialog()->setSyncMode( true ); |
2054 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2002 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2055 | getEventViewerDialog()->setSyncMode( false ); | 2003 | getEventViewerDialog()->setSyncMode( false ); |
2056 | qApp->processEvents(); | 2004 | qApp->processEvents(); |
2057 | if ( syncOK ) { | 2005 | if ( syncOK ) { |
2058 | if ( mSyncManager->mWriteBackFile ) | 2006 | if ( mSyncManager->mWriteBackFile ) |
2059 | { | 2007 | { |
2060 | // write back XML file | 2008 | // write back XML file |
2061 | 2009 | ||
2062 | } | 2010 | } |
2063 | setModified( true ); | 2011 | setModified( true ); |
2064 | } | 2012 | } |
2065 | } else { | 2013 | } else { |
2066 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2014 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2067 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2015 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2068 | question, i18n("Ok")) ; | 2016 | question, i18n("Ok")) ; |
2069 | } | 2017 | } |
2070 | delete calendar; | 2018 | delete calendar; |
2071 | updateView(); | 2019 | updateView(); |
2072 | return syncOK; | 2020 | return syncOK; |
2073 | 2021 | ||
2074 | 2022 | ||
2075 | #endif | 2023 | #endif |
2076 | 2024 | ||
2077 | } | 2025 | } |
2078 | 2026 | ||
2079 | void CalendarView::setSyncEventsReadOnly() | 2027 | void CalendarView::setSyncEventsReadOnly() |
2080 | { | 2028 | { |
2081 | mCalendar->setSyncEventsReadOnly(); | 2029 | mCalendar->setSyncEventsReadOnly(); |
2082 | } | 2030 | } |
2083 | 2031 | ||
2084 | bool CalendarView::loadCalendars() | 2032 | bool CalendarView::loadCalendars() |
2085 | { | 2033 | { |
2086 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2034 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2087 | KopiCalendarFile * cal = calendars.first(); | 2035 | KopiCalendarFile * cal = calendars.first(); |
2088 | mCalendar->setDefaultCalendar( 1 ); | 2036 | mCalendar->setDefaultCalendar( 1 ); |
2089 | openCalendar( MainWindow::defaultFileName(), false ); | 2037 | openCalendar( MainWindow::defaultFileName(), false ); |
2090 | cal = calendars.next(); | 2038 | cal = calendars.next(); |
2091 | while ( cal ) { | 2039 | while ( cal ) { |
2092 | addCalendar( cal ); | 2040 | addCalendar( cal ); |
2093 | cal = calendars.next(); | 2041 | cal = calendars.next(); |
2094 | } | 2042 | } |
2095 | restoreCalendarSettings(); | 2043 | restoreCalendarSettings(); |
2096 | return true; | 2044 | return true; |
2097 | } | 2045 | } |
2098 | bool CalendarView::restoreCalendarSettings() | 2046 | bool CalendarView::restoreCalendarSettings() |
2099 | { | 2047 | { |
2100 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2101 | KopiCalendarFile * cal = calendars.first(); | 2049 | KopiCalendarFile * cal = calendars.first(); |
2102 | while ( cal ) { | 2050 | while ( cal ) { |
2103 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2051 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2104 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2052 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2105 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2053 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2106 | if ( cal->isStandard ) | 2054 | if ( cal->isStandard ) |
2107 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2055 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2108 | cal = calendars.next(); | 2056 | cal = calendars.next(); |
2109 | } | 2057 | } |
2110 | setSyncEventsReadOnly(); | 2058 | setSyncEventsReadOnly(); |
2111 | mCalendar->reInitAlarmSettings(); | 2059 | mCalendar->reInitAlarmSettings(); |
2112 | updateUnmanagedViews(); | 2060 | updateUnmanagedViews(); |
2113 | updateView(); | 2061 | updateView(); |
2114 | return true; | 2062 | return true; |
2115 | } | 2063 | } |
2116 | void CalendarView::addCalendarId( int id ) | 2064 | void CalendarView::addCalendarId( int id ) |
2117 | { | 2065 | { |
2118 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2066 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2119 | if ( cal ) | 2067 | if ( cal ) |
2120 | addCalendar( cal ); | 2068 | addCalendar( cal ); |
2121 | } | 2069 | } |
2122 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2070 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2123 | { | 2071 | { |
2124 | cal->mErrorOnLoad = false; | 2072 | cal->mErrorOnLoad = false; |
2125 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2073 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2126 | cal->mLoadDt = QDateTime::currentDateTime(); | 2074 | cal->mLoadDt = QDateTime::currentDateTime(); |
2127 | return true; | 2075 | return true; |
2128 | } | 2076 | } |
2129 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2077 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2130 | cal->mErrorOnLoad = true; | 2078 | cal->mErrorOnLoad = true; |
2131 | return false; | 2079 | return false; |
2132 | } | 2080 | } |
2133 | bool CalendarView::openCalendar(QString filename, bool merge) | 2081 | bool CalendarView::openCalendar(QString filename, bool merge) |
2134 | { | 2082 | { |
2135 | 2083 | ||
2136 | if (filename.isEmpty()) { | 2084 | if (filename.isEmpty()) { |
2137 | return false; | 2085 | return false; |
2138 | } | 2086 | } |
2139 | 2087 | ||
2140 | if (!QFile::exists(filename)) { | 2088 | if (!QFile::exists(filename)) { |
2141 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2089 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2142 | return false; | 2090 | return false; |
2143 | } | 2091 | } |
2144 | 2092 | ||
2145 | globalFlagBlockAgenda = 1; | 2093 | globalFlagBlockAgenda = 1; |
2146 | clearAllViews(); | 2094 | clearAllViews(); |
2147 | if (!merge) { | 2095 | if (!merge) { |
2148 | mViewManager->setDocumentId( filename ); | 2096 | mViewManager->setDocumentId( filename ); |
2149 | mCalendar->close(); | 2097 | mCalendar->close(); |
2150 | } | 2098 | } |
2151 | mStorage->setFileName( filename ); | 2099 | mStorage->setFileName( filename ); |
2152 | 2100 | ||
2153 | if ( mStorage->load() ) { | 2101 | if ( mStorage->load() ) { |
2154 | if ( merge ) ;//setModified( true ); | 2102 | if ( merge ) ;//setModified( true ); |
2155 | else { | 2103 | else { |
2156 | //setModified( true ); | 2104 | //setModified( true ); |
2157 | mViewManager->setDocumentId( filename ); | 2105 | mViewManager->setDocumentId( filename ); |
2158 | mDialogManager->setDocumentId( filename ); | 2106 | mDialogManager->setDocumentId( filename ); |
2159 | mTodoList->setDocumentId( filename ); | 2107 | mTodoList->setDocumentId( filename ); |
2160 | } | 2108 | } |
2161 | globalFlagBlockAgenda = 2; | 2109 | globalFlagBlockAgenda = 2; |
2162 | // if ( getLastSyncEvent() ) | 2110 | // if ( getLastSyncEvent() ) |
2163 | // getLastSyncEvent()->setReadOnly( true ); | 2111 | // getLastSyncEvent()->setReadOnly( true ); |
2164 | mCalendar->reInitAlarmSettings(); | 2112 | mCalendar->reInitAlarmSettings(); |
2165 | setSyncEventsReadOnly(); | 2113 | setSyncEventsReadOnly(); |
2166 | updateUnmanagedViews(); | 2114 | updateUnmanagedViews(); |
2167 | updateView(); | 2115 | updateView(); |
2168 | if ( filename != MainWindow::defaultFileName() ) { | 2116 | if ( filename != MainWindow::defaultFileName() ) { |
2169 | saveCalendar( MainWindow::defaultFileName() ); | 2117 | saveCalendar( MainWindow::defaultFileName() ); |
2170 | } else { | 2118 | } else { |
2171 | QFileInfo finf ( MainWindow::defaultFileName()); | 2119 | QFileInfo finf ( MainWindow::defaultFileName()); |
2172 | if ( finf.exists() ) { | 2120 | if ( finf.exists() ) { |
2173 | setLoadedFileVersion( finf.lastModified () ); | 2121 | setLoadedFileVersion( finf.lastModified () ); |
2174 | } | 2122 | } |
2175 | } | 2123 | } |
2176 | return true; | 2124 | return true; |
2177 | } else { | 2125 | } else { |
2178 | // while failing to load, the calendar object could | 2126 | // while failing to load, the calendar object could |
2179 | // have become partially populated. Clear it out. | 2127 | // have become partially populated. Clear it out. |
2180 | if ( !merge ) { | 2128 | if ( !merge ) { |
2181 | mCalendar->close(); | 2129 | mCalendar->close(); |
2182 | mViewManager->setDocumentId( filename ); | 2130 | mViewManager->setDocumentId( filename ); |
2183 | mDialogManager->setDocumentId( filename ); | 2131 | mDialogManager->setDocumentId( filename ); |
2184 | mTodoList->setDocumentId( filename ); | 2132 | mTodoList->setDocumentId( filename ); |
2185 | } | 2133 | } |
2186 | 2134 | ||
2187 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2135 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2188 | 2136 | ||
2189 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2137 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2190 | globalFlagBlockAgenda = 2; | 2138 | globalFlagBlockAgenda = 2; |
2191 | mCalendar->reInitAlarmSettings(); | 2139 | mCalendar->reInitAlarmSettings(); |
2192 | setSyncEventsReadOnly(); | 2140 | setSyncEventsReadOnly(); |
2193 | updateUnmanagedViews(); | 2141 | updateUnmanagedViews(); |
2194 | updateView(); | 2142 | updateView(); |
2195 | } | 2143 | } |
2196 | return false; | 2144 | return false; |
2197 | } | 2145 | } |
2198 | void CalendarView::showOpenError() | 2146 | void CalendarView::showOpenError() |
2199 | { | 2147 | { |
2200 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2148 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2201 | } | 2149 | } |
2202 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2150 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2203 | { | 2151 | { |
2204 | loadedFileVersion = dt; | 2152 | loadedFileVersion = dt; |
2205 | } | 2153 | } |
2206 | bool CalendarView::checkFileChanged(QString fn) | 2154 | bool CalendarView::checkFileChanged(QString fn) |
2207 | { | 2155 | { |
2208 | QFileInfo finf ( fn ); | 2156 | QFileInfo finf ( fn ); |
2209 | if ( !finf.exists() ) | 2157 | if ( !finf.exists() ) |
2210 | return true; | 2158 | return true; |
2211 | QDateTime dt = finf.lastModified (); | 2159 | QDateTime dt = finf.lastModified (); |
2212 | if ( dt <= loadedFileVersion ) | 2160 | if ( dt <= loadedFileVersion ) |
2213 | return false; | 2161 | return false; |
2214 | return true; | 2162 | return true; |
2215 | 2163 | ||
2216 | } | 2164 | } |
2217 | void CalendarView::watchSavedFile() | 2165 | void CalendarView::watchSavedFile() |
2218 | { | 2166 | { |
2219 | QFileInfo finf ( MainWindow::defaultFileName()); | 2167 | QFileInfo finf ( MainWindow::defaultFileName()); |
2220 | if ( !finf.exists() ) | 2168 | if ( !finf.exists() ) |
2221 | return; | 2169 | return; |
2222 | QDateTime dt = finf.lastModified (); | 2170 | QDateTime dt = finf.lastModified (); |
2223 | if ( dt < loadedFileVersion ) { | 2171 | if ( dt < loadedFileVersion ) { |
2224 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2172 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2225 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2173 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2226 | return; | 2174 | return; |
2227 | } | 2175 | } |
2228 | loadedFileVersion = dt; | 2176 | loadedFileVersion = dt; |
2229 | } | 2177 | } |
2230 | bool CalendarView::checkAllFileVersions() | 2178 | bool CalendarView::checkAllFileVersions() |
2231 | { | 2179 | { |
2232 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2180 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2233 | KopiCalendarFile * cal = calendars.first(); | 2181 | KopiCalendarFile * cal = calendars.first(); |
2234 | mCalendar->setDefaultCalendar( 1 ); | 2182 | mCalendar->setDefaultCalendar( 1 ); |
2235 | mCalendar->setDefaultCalendarEnabledOnly(); | 2183 | mCalendar->setDefaultCalendarEnabledOnly(); |
2236 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2184 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2237 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2185 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2238 | restoreCalendarSettings(); | 2186 | restoreCalendarSettings(); |
2239 | return false; | 2187 | return false; |
2240 | } | 2188 | } |
2241 | } | 2189 | } |
2242 | cal = calendars.next(); | 2190 | cal = calendars.next(); |
2243 | QDateTime storeTemp = loadedFileVersion; | 2191 | QDateTime storeTemp = loadedFileVersion; |
2244 | while ( cal ) { | 2192 | while ( cal ) { |
2245 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2193 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2246 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2194 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2247 | mCalendar->setDefaultCalendarEnabledOnly(); | 2195 | mCalendar->setDefaultCalendarEnabledOnly(); |
2248 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2196 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2249 | if ( !checkFileVersion(cal->mFileName )) { | 2197 | if ( !checkFileVersion(cal->mFileName )) { |
2250 | loadedFileVersion = storeTemp; | 2198 | loadedFileVersion = storeTemp; |
2251 | restoreCalendarSettings(); | 2199 | restoreCalendarSettings(); |
2252 | return false; | 2200 | return false; |
2253 | } | 2201 | } |
2254 | } | 2202 | } |
2255 | cal = calendars.next(); | 2203 | cal = calendars.next(); |
2256 | } | 2204 | } |
2257 | loadedFileVersion = storeTemp; | 2205 | loadedFileVersion = storeTemp; |
2258 | return true; | 2206 | return true; |
2259 | } | 2207 | } |
2260 | bool CalendarView::checkFileVersion(QString fn) | 2208 | bool CalendarView::checkFileVersion(QString fn) |
2261 | { | 2209 | { |
2262 | QFileInfo finf ( fn ); | 2210 | QFileInfo finf ( fn ); |
2263 | if ( !finf.exists() ) | 2211 | if ( !finf.exists() ) |
2264 | return true; | 2212 | return true; |
2265 | QDateTime dt = finf.lastModified (); | 2213 | QDateTime dt = finf.lastModified (); |
2266 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2214 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2267 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2215 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2268 | if ( dt <= loadedFileVersion ) | 2216 | if ( dt <= loadedFileVersion ) |
2269 | return true; | 2217 | return true; |
2270 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2218 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2271 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2219 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2272 | i18n("Sync+save")); | 2220 | i18n("Sync+save")); |
2273 | 2221 | ||
2274 | if ( km == KMessageBox::Cancel ) | 2222 | if ( km == KMessageBox::Cancel ) |
2275 | return false; | 2223 | return false; |
2276 | if ( km == KMessageBox::Yes ) | 2224 | if ( km == KMessageBox::Yes ) |
2277 | return true; | 2225 | return true; |
2278 | 2226 | ||
2279 | setSyncDevice("deleteaftersync" ); | 2227 | setSyncDevice("deleteaftersync" ); |
2280 | mSyncManager->mAskForPreferences = true; | 2228 | mSyncManager->mAskForPreferences = true; |
2281 | mSyncManager->mSyncAlgoPrefs = 3; | 2229 | mSyncManager->mSyncAlgoPrefs = 3; |
2282 | mSyncManager->mWriteBackFile = false; | 2230 | mSyncManager->mWriteBackFile = false; |
2283 | mSyncManager->mWriteBackExistingOnly = false; | 2231 | mSyncManager->mWriteBackExistingOnly = false; |
2284 | mSyncManager->mShowSyncSummary = false; | 2232 | mSyncManager->mShowSyncSummary = false; |
2285 | syncCalendar( fn, 3 ); | 2233 | syncCalendar( fn, 3 ); |
2286 | Event * e = getLastSyncEvent(); | 2234 | Event * e = getLastSyncEvent(); |
2287 | if ( e ) | 2235 | if ( e ) |
2288 | mCalendar->deleteEvent( e ); | 2236 | mCalendar->deleteEvent( e ); |
2289 | return true; | 2237 | return true; |
2290 | } | 2238 | } |
2291 | bool CalendarView::saveCalendars() | 2239 | bool CalendarView::saveCalendars() |
2292 | { | 2240 | { |
2293 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2241 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2294 | KopiCalendarFile * cal = calendars.first(); | 2242 | KopiCalendarFile * cal = calendars.first(); |
2295 | mCalendar->setDefaultCalendar( 1 ); | 2243 | mCalendar->setDefaultCalendar( 1 ); |
2296 | mCalendar->setDefaultCalendarEnabledOnly(); | 2244 | mCalendar->setDefaultCalendarEnabledOnly(); |
2297 | saveCalendar( MainWindow::defaultFileName() ); | 2245 | saveCalendar( MainWindow::defaultFileName() ); |
2298 | cal = calendars.next(); | 2246 | cal = calendars.next(); |
2299 | while ( cal ) { | 2247 | while ( cal ) { |
2300 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2248 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2301 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2249 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2302 | mCalendar->setDefaultCalendarEnabledOnly(); | 2250 | mCalendar->setDefaultCalendarEnabledOnly(); |
2303 | if ( saveCalendar( cal->mFileName ) ) | 2251 | if ( saveCalendar( cal->mFileName ) ) |
2304 | cal->mLoadDt = QDateTime::currentDateTime(); | 2252 | cal->mLoadDt = QDateTime::currentDateTime(); |
2305 | } | 2253 | } |
2306 | cal = calendars.next(); | 2254 | cal = calendars.next(); |
2307 | } | 2255 | } |
2308 | restoreCalendarSettings(); | 2256 | restoreCalendarSettings(); |
2309 | return true; | 2257 | return true; |
2310 | } | 2258 | } |
2311 | bool CalendarView::saveCalendar( QString filename ) | 2259 | bool CalendarView::saveCalendar( QString filename ) |
2312 | { | 2260 | { |
2313 | 2261 | ||
2314 | // Store back all unsaved data into calendar object | 2262 | // Store back all unsaved data into calendar object |
2315 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2263 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2316 | if ( mViewManager->currentView() ) | 2264 | if ( mViewManager->currentView() ) |
2317 | mViewManager->currentView()->flushView(); | 2265 | mViewManager->currentView()->flushView(); |
2318 | 2266 | ||
2319 | 2267 | ||
2320 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2268 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2321 | mStorage->setSaveFormat( new ICalFormat() ); | 2269 | mStorage->setSaveFormat( new ICalFormat() ); |
2322 | mStorage->setFileName( filename ); | 2270 | mStorage->setFileName( filename ); |
2323 | bool success; | 2271 | bool success; |
2324 | success = mStorage->save(); | 2272 | success = mStorage->save(); |
2325 | if ( !success ) { | 2273 | if ( !success ) { |
2326 | return false; | 2274 | return false; |
2327 | } | 2275 | } |
2328 | if ( filename == MainWindow::defaultFileName() ) { | 2276 | if ( filename == MainWindow::defaultFileName() ) { |
2329 | setLoadedFileVersion( lfv ); | 2277 | setLoadedFileVersion( lfv ); |
2330 | watchSavedFile(); | 2278 | watchSavedFile(); |
2331 | } | 2279 | } |
2332 | return true; | 2280 | return true; |
2333 | } | 2281 | } |
2334 | 2282 | ||
2335 | void CalendarView::closeCalendar() | 2283 | void CalendarView::closeCalendar() |
2336 | { | 2284 | { |
2337 | 2285 | ||
2338 | // child windows no longer valid | 2286 | // child windows no longer valid |
2339 | clearAllViews(); | 2287 | clearAllViews(); |
2340 | emit closingDown(); | 2288 | emit closingDown(); |
2341 | 2289 | ||
2342 | mCalendar->close(); | 2290 | mCalendar->close(); |
2343 | setModified(false); | 2291 | setModified(false); |
2344 | updateView(); | 2292 | updateView(); |
2345 | } | 2293 | } |
2346 | 2294 | ||
2347 | void CalendarView::archiveCalendar() | 2295 | void CalendarView::archiveCalendar() |
2348 | { | 2296 | { |
2349 | mDialogManager->showArchiveDialog(); | 2297 | mDialogManager->showArchiveDialog(); |
2350 | } | 2298 | } |
2351 | 2299 | ||
2352 | 2300 | ||
2353 | void CalendarView::readSettings() | 2301 | void CalendarView::readSettings() |
2354 | { | 2302 | { |
2355 | 2303 | ||
2356 | 2304 | ||
2357 | // mViewManager->showAgendaView(); | 2305 | // mViewManager->showAgendaView(); |
2358 | QString str; | 2306 | QString str; |
2359 | //qDebug("CalendarView::readSettings() "); | 2307 | //qDebug("CalendarView::readSettings() "); |
2360 | // read settings from the KConfig, supplying reasonable | 2308 | // read settings from the KConfig, supplying reasonable |
2361 | // defaults where none are to be found | 2309 | // defaults where none are to be found |
2362 | KConfig *config = KOGlobals::config(); | 2310 | KConfig *config = KOGlobals::config(); |
2363 | #ifndef KORG_NOSPLITTER | 2311 | #ifndef KORG_NOSPLITTER |
2364 | config->setGroup("KOrganizer Geometry"); | 2312 | config->setGroup("KOrganizer Geometry"); |
2365 | 2313 | ||
2366 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2314 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2367 | if (sizes.count() != 2) { | 2315 | if (sizes.count() != 2) { |
2368 | sizes << mDateNavigator->minimumSizeHint().width(); | 2316 | sizes << mDateNavigator->minimumSizeHint().width(); |
2369 | sizes << 300; | 2317 | sizes << 300; |
2370 | } | 2318 | } |
2371 | mPanner->setSizes(sizes); | 2319 | mPanner->setSizes(sizes); |
2372 | 2320 | ||
2373 | sizes = config->readIntListEntry("Separator2"); | 2321 | sizes = config->readIntListEntry("Separator2"); |
2374 | if ( ( mResourceView && sizes.count() == 4 ) || | 2322 | if ( ( mResourceView && sizes.count() == 4 ) || |
2375 | ( !mResourceView && sizes.count() == 3 ) ) { | 2323 | ( !mResourceView && sizes.count() == 3 ) ) { |
2376 | mLeftSplitter->setSizes(sizes); | 2324 | mLeftSplitter->setSizes(sizes); |
2377 | } | 2325 | } |
2378 | #endif | 2326 | #endif |
2379 | globalFlagBlockAgenda = 1; | 2327 | globalFlagBlockAgenda = 1; |
2380 | mViewManager->showAgendaView(); | 2328 | mViewManager->showAgendaView(); |
2381 | //mViewManager->readSettings( config ); | 2329 | //mViewManager->readSettings( config ); |
2382 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2330 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2383 | readFilterSettings(config); | 2331 | readFilterSettings(config); |
2384 | 2332 | ||
2385 | #ifdef DESKTOP_VERSION | 2333 | #ifdef DESKTOP_VERSION |
2386 | config->setGroup("WidgetLayout"); | 2334 | config->setGroup("WidgetLayout"); |
2387 | QStringList list; | 2335 | QStringList list; |
2388 | list = config->readListEntry("MainLayout"); | 2336 | list = config->readListEntry("MainLayout"); |
2389 | int x,y,w,h; | 2337 | int x,y,w,h; |
2390 | if ( ! list.isEmpty() ) { | 2338 | if ( ! list.isEmpty() ) { |
2391 | x = list[0].toInt(); | 2339 | x = list[0].toInt(); |
2392 | y = list[1].toInt(); | 2340 | y = list[1].toInt(); |
2393 | w = list[2].toInt(); | 2341 | w = list[2].toInt(); |
2394 | h = list[3].toInt(); | 2342 | h = list[3].toInt(); |
2395 | KApplication::testCoords( &x,&y,&w,&h ); | 2343 | KApplication::testCoords( &x,&y,&w,&h ); |
2396 | topLevelWidget()->setGeometry(x,y,w,h); | 2344 | topLevelWidget()->setGeometry(x,y,w,h); |
2397 | 2345 | ||
2398 | } else { | 2346 | } else { |
2399 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2347 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2400 | } | 2348 | } |
2401 | list = config->readListEntry("EditEventLayout"); | 2349 | list = config->readListEntry("EditEventLayout"); |
2402 | if ( ! list.isEmpty() ) { | 2350 | if ( ! list.isEmpty() ) { |
2403 | x = list[0].toInt(); | 2351 | x = list[0].toInt(); |
2404 | y = list[1].toInt(); | 2352 | y = list[1].toInt(); |
2405 | w = list[2].toInt(); | 2353 | w = list[2].toInt(); |
2406 | h = list[3].toInt(); | 2354 | h = list[3].toInt(); |
2407 | KApplication::testCoords( &x,&y,&w,&h ); | 2355 | KApplication::testCoords( &x,&y,&w,&h ); |
2408 | mEventEditor->setGeometry(x,y,w,h); | 2356 | mEventEditor->setGeometry(x,y,w,h); |
2409 | 2357 | ||
2410 | } | 2358 | } |
2411 | list = config->readListEntry("EditTodoLayout"); | 2359 | list = config->readListEntry("EditTodoLayout"); |
2412 | if ( ! list.isEmpty() ) { | 2360 | if ( ! list.isEmpty() ) { |
2413 | x = list[0].toInt(); | 2361 | x = list[0].toInt(); |
2414 | y = list[1].toInt(); | 2362 | y = list[1].toInt(); |
2415 | w = list[2].toInt(); | 2363 | w = list[2].toInt(); |
2416 | h = list[3].toInt(); | 2364 | h = list[3].toInt(); |
2417 | KApplication::testCoords( &x,&y,&w,&h ); | 2365 | KApplication::testCoords( &x,&y,&w,&h ); |
2418 | mTodoEditor->setGeometry(x,y,w,h); | 2366 | mTodoEditor->setGeometry(x,y,w,h); |
2419 | 2367 | ||
2420 | } | 2368 | } |
2421 | list = config->readListEntry("ViewerLayout"); | 2369 | list = config->readListEntry("ViewerLayout"); |
2422 | if ( ! list.isEmpty() ) { | 2370 | if ( ! list.isEmpty() ) { |
2423 | x = list[0].toInt(); | 2371 | x = list[0].toInt(); |
2424 | y = list[1].toInt(); | 2372 | y = list[1].toInt(); |
2425 | w = list[2].toInt(); | 2373 | w = list[2].toInt(); |
2426 | h = list[3].toInt(); | 2374 | h = list[3].toInt(); |
2427 | KApplication::testCoords( &x,&y,&w,&h ); | 2375 | KApplication::testCoords( &x,&y,&w,&h ); |
2428 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2376 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2429 | } | 2377 | } |
2430 | #endif | 2378 | #endif |
2431 | config->setGroup( "Views" ); | 2379 | config->setGroup( "Views" ); |
2432 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2380 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2433 | 2381 | ||
2434 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2382 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2435 | 2383 | ||
2436 | int resetval = 0; | 2384 | int resetval = 0; |
2437 | int maxVal = 0; | 2385 | int maxVal = 0; |
2438 | if (sizes.count() != 3) { | 2386 | if (sizes.count() != 3) { |
2439 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2387 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2440 | resetval = mDateNavigator->sizeHint().width()+2; | 2388 | resetval = mDateNavigator->sizeHint().width()+2; |
2441 | } else { | 2389 | } else { |
2442 | resetval = mDateNavigator->sizeHint().height()+2; | 2390 | resetval = mDateNavigator->sizeHint().height()+2; |
2443 | } | 2391 | } |
2444 | } | 2392 | } |
2445 | if ( resetval ) { | 2393 | if ( resetval ) { |
2446 | sizes.clear(); | 2394 | sizes.clear(); |
2447 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2395 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2448 | maxVal = QApplication::desktop()->width() -10; | 2396 | maxVal = QApplication::desktop()->width() -10; |
2449 | } else { | 2397 | } else { |
2450 | maxVal = QApplication::desktop()->height()-10; | 2398 | maxVal = QApplication::desktop()->height()-10; |
2451 | } | 2399 | } |
2452 | sizes << resetval; | 2400 | sizes << resetval; |
2453 | if ( maxVal < resetval + resetval) | 2401 | if ( maxVal < resetval + resetval) |
2454 | resetval = maxVal - resetval; | 2402 | resetval = maxVal - resetval; |
2455 | sizes << resetval; | 2403 | sizes << resetval; |
2456 | sizes << 100; | 2404 | sizes << 100; |
2457 | } | 2405 | } |
2458 | mLeftFrame->setSizes(sizes); | 2406 | mLeftFrame->setSizes(sizes); |
2459 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2407 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2460 | resetval = 0; | 2408 | resetval = 0; |
2461 | maxVal = 0; | 2409 | maxVal = 0; |
2462 | if (sizes.count() != 2) { | 2410 | if (sizes.count() != 2) { |
2463 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2411 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2464 | resetval = mDateNavigator->sizeHint().width()+2; | 2412 | resetval = mDateNavigator->sizeHint().width()+2; |
2465 | } else { | 2413 | } else { |
2466 | resetval = mDateNavigator->sizeHint().height()+2; | 2414 | resetval = mDateNavigator->sizeHint().height()+2; |
2467 | } | 2415 | } |
2468 | } | 2416 | } |
2469 | if ( resetval ) { | 2417 | if ( resetval ) { |
2470 | sizes.clear(); | 2418 | sizes.clear(); |
2471 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2419 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2472 | maxVal = QApplication::desktop()->width() -10; | 2420 | maxVal = QApplication::desktop()->width() -10; |
2473 | } else { | 2421 | } else { |
2474 | maxVal = QApplication::desktop()->height()-10; | 2422 | maxVal = QApplication::desktop()->height()-10; |
2475 | } | 2423 | } |
2476 | sizes << resetval; | 2424 | sizes << resetval; |
2477 | if ( maxVal < resetval + resetval) | 2425 | if ( maxVal < resetval + resetval) |
2478 | resetval = maxVal - resetval; | 2426 | resetval = maxVal - resetval; |
2479 | sizes << resetval; | 2427 | sizes << resetval; |
2480 | } | 2428 | } |
2481 | mMainFrame->setSizes(sizes); | 2429 | mMainFrame->setSizes(sizes); |
2482 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2430 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2483 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2431 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2484 | else mNavigator->selectDates( dateCount ); | 2432 | else mNavigator->selectDates( dateCount ); |
2485 | // mViewManager->readSettings( config ); | 2433 | // mViewManager->readSettings( config ); |
2486 | updateConfig(); | 2434 | updateConfig(); |
2487 | globalFlagBlockAgenda = 2; | 2435 | globalFlagBlockAgenda = 2; |
2488 | mViewManager->readSettings( config ); | 2436 | mViewManager->readSettings( config ); |
2489 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2437 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2490 | } | 2438 | } |
2491 | 2439 | ||
2492 | void CalendarView::checkSuspendAlarm() | 2440 | void CalendarView::checkSuspendAlarm() |
2493 | { | 2441 | { |
2494 | if ( mSuspendTimer->isActive() ) { | 2442 | if ( mSuspendTimer->isActive() ) { |
2495 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2443 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2496 | } | 2444 | } |
2497 | } | 2445 | } |
2498 | void CalendarView::writeSettings() | 2446 | void CalendarView::writeSettings() |
2499 | { | 2447 | { |
2500 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2448 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2501 | 2449 | ||
2502 | KConfig *config = KOGlobals::config(); | 2450 | KConfig *config = KOGlobals::config(); |
2503 | 2451 | ||
2504 | mViewManager->writeSettings( config ); | 2452 | mViewManager->writeSettings( config ); |
2505 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2453 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2506 | mDialogManager->writeSettings( config ); | 2454 | mDialogManager->writeSettings( config ); |
2507 | //KOPrefs::instance()->usrWriteConfig(); | 2455 | //KOPrefs::instance()->usrWriteConfig(); |
2508 | KOPrefs::instance()->writeConfig(); | 2456 | KOPrefs::instance()->writeConfig(); |
2509 | 2457 | ||
2510 | writeFilterSettings(config); | 2458 | writeFilterSettings(config); |
2511 | config->setGroup( "AppRun" ); | 2459 | config->setGroup( "AppRun" ); |
2512 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2460 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2513 | int days = dt.daysTo( QDate::currentDate() ); | 2461 | int days = dt.daysTo( QDate::currentDate() ); |
2514 | dt = dt.addDays( days ); | 2462 | dt = dt.addDays( days ); |
2515 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2463 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2516 | config->writeEntry( "LatestProgramStopDays", days ); | 2464 | config->writeEntry( "LatestProgramStopDays", days ); |
2517 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2465 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2518 | //qDebug("KO: Writing stop time: %d ", secs); | 2466 | //qDebug("KO: Writing stop time: %d ", secs); |
2519 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2467 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2520 | //QDateTime latest = dt.addSecs ( secs ); | 2468 | //QDateTime latest = dt.addSecs ( secs ); |
2521 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2469 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2522 | config->setGroup( "Views" ); | 2470 | config->setGroup( "Views" ); |
2523 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2471 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2524 | 2472 | ||
2525 | #if 0 | 2473 | #if 0 |
2526 | qDebug("********************* "); | 2474 | qDebug("********************* "); |
2527 | qDebug("Testcode secsto "); | 2475 | qDebug("Testcode secsto "); |
2528 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2476 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2529 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2477 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2530 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2478 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2531 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2479 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2532 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2480 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2533 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2481 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2534 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2482 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2535 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2483 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2536 | qDebug("********************* testcode end"); | 2484 | qDebug("********************* testcode end"); |
2537 | 2485 | ||
2538 | #endif | 2486 | #endif |
2539 | 2487 | ||
2540 | QValueList<int> listINT = mLeftFrame->sizes(); | 2488 | QValueList<int> listINT = mLeftFrame->sizes(); |
2541 | config->writeEntry("Left Splitter Frame",listINT); | 2489 | config->writeEntry("Left Splitter Frame",listINT); |
2542 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2490 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2543 | config->writeEntry("Main Splitter Frame",listINT2); | 2491 | config->writeEntry("Main Splitter Frame",listINT2); |
2544 | #ifdef DESKTOP_VERSION | 2492 | #ifdef DESKTOP_VERSION |
2545 | config->setGroup("WidgetLayout"); | 2493 | config->setGroup("WidgetLayout"); |
2546 | QStringList list ;//= config->readListEntry("MainLayout"); | 2494 | QStringList list ;//= config->readListEntry("MainLayout"); |
2547 | int x,y,w,h; | 2495 | int x,y,w,h; |
2548 | QWidget* wid; | 2496 | QWidget* wid; |
2549 | wid = topLevelWidget(); | 2497 | wid = topLevelWidget(); |
2550 | x = wid->geometry().x(); | 2498 | x = wid->geometry().x(); |
2551 | y = wid->geometry().y(); | 2499 | y = wid->geometry().y(); |
2552 | w = wid->width(); | 2500 | w = wid->width(); |
2553 | h = wid->height(); | 2501 | h = wid->height(); |
2554 | list.clear(); | 2502 | list.clear(); |
2555 | list << QString::number( x ); | 2503 | list << QString::number( x ); |
2556 | list << QString::number( y ); | 2504 | list << QString::number( y ); |
2557 | list << QString::number( w ); | 2505 | list << QString::number( w ); |
2558 | list << QString::number( h ); | 2506 | list << QString::number( h ); |
2559 | config->writeEntry("MainLayout",list ); | 2507 | config->writeEntry("MainLayout",list ); |
2560 | 2508 | ||
2561 | wid = mEventEditor; | 2509 | wid = mEventEditor; |
2562 | x = wid->geometry().x(); | 2510 | x = wid->geometry().x(); |
2563 | y = wid->geometry().y(); | 2511 | y = wid->geometry().y(); |
2564 | w = wid->width(); | 2512 | w = wid->width(); |
2565 | h = wid->height(); | 2513 | h = wid->height(); |
2566 | list.clear(); | 2514 | list.clear(); |
2567 | list << QString::number( x ); | 2515 | list << QString::number( x ); |
2568 | list << QString::number( y ); | 2516 | list << QString::number( y ); |
2569 | list << QString::number( w ); | 2517 | list << QString::number( w ); |
2570 | list << QString::number( h ); | 2518 | list << QString::number( h ); |
2571 | config->writeEntry("EditEventLayout",list ); | 2519 | config->writeEntry("EditEventLayout",list ); |
2572 | 2520 | ||
2573 | wid = mTodoEditor; | 2521 | wid = mTodoEditor; |
2574 | x = wid->geometry().x(); | 2522 | x = wid->geometry().x(); |
2575 | y = wid->geometry().y(); | 2523 | y = wid->geometry().y(); |
2576 | w = wid->width(); | 2524 | w = wid->width(); |
2577 | h = wid->height(); | 2525 | h = wid->height(); |
2578 | list.clear(); | 2526 | list.clear(); |
2579 | list << QString::number( x ); | 2527 | list << QString::number( x ); |
2580 | list << QString::number( y ); | 2528 | list << QString::number( y ); |
2581 | list << QString::number( w ); | 2529 | list << QString::number( w ); |
2582 | list << QString::number( h ); | 2530 | list << QString::number( h ); |
2583 | config->writeEntry("EditTodoLayout",list ); | 2531 | config->writeEntry("EditTodoLayout",list ); |
2584 | wid = getEventViewerDialog(); | 2532 | wid = getEventViewerDialog(); |
2585 | x = wid->geometry().x(); | 2533 | x = wid->geometry().x(); |
2586 | y = wid->geometry().y(); | 2534 | y = wid->geometry().y(); |
2587 | w = wid->width(); | 2535 | w = wid->width(); |
2588 | h = wid->height(); | 2536 | h = wid->height(); |
2589 | list.clear(); | 2537 | list.clear(); |
2590 | list << QString::number( x ); | 2538 | list << QString::number( x ); |
2591 | list << QString::number( y ); | 2539 | list << QString::number( y ); |
2592 | list << QString::number( w ); | 2540 | list << QString::number( w ); |
2593 | list << QString::number( h ); | 2541 | list << QString::number( h ); |
2594 | config->writeEntry("ViewerLayout",list ); | 2542 | config->writeEntry("ViewerLayout",list ); |
2595 | wid = mDialogManager->getSearchDialog(); | 2543 | wid = mDialogManager->getSearchDialog(); |
2596 | if ( wid ) { | 2544 | if ( wid ) { |
2597 | x = wid->geometry().x(); | 2545 | x = wid->geometry().x(); |
2598 | y = wid->geometry().y(); | 2546 | y = wid->geometry().y(); |
2599 | w = wid->width(); | 2547 | w = wid->width(); |
2600 | h = wid->height(); | 2548 | h = wid->height(); |
2601 | list.clear(); | 2549 | list.clear(); |
2602 | list << QString::number( x ); | 2550 | list << QString::number( x ); |
2603 | list << QString::number( y ); | 2551 | list << QString::number( y ); |
2604 | list << QString::number( w ); | 2552 | list << QString::number( w ); |
2605 | list << QString::number( h ); | 2553 | list << QString::number( h ); |
2606 | config->writeEntry("SearchLayout",list ); | 2554 | config->writeEntry("SearchLayout",list ); |
2607 | } | 2555 | } |
2608 | #endif | 2556 | #endif |
2609 | 2557 | ||
2610 | 2558 | ||
2611 | config->sync(); | 2559 | config->sync(); |
2612 | } | 2560 | } |
2613 | 2561 | ||
2614 | void CalendarView::readFilterSettings(KConfig *config) | 2562 | void CalendarView::readFilterSettings(KConfig *config) |
2615 | { | 2563 | { |
2616 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2564 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2617 | 2565 | ||
2618 | mFilters.clear(); | 2566 | mFilters.clear(); |
2619 | 2567 | ||
2620 | config->setGroup("General"); | 2568 | config->setGroup("General"); |
2621 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2569 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2622 | 2570 | ||
2623 | QStringList::ConstIterator it = filterList.begin(); | 2571 | QStringList::ConstIterator it = filterList.begin(); |
2624 | QStringList::ConstIterator end = filterList.end(); | 2572 | QStringList::ConstIterator end = filterList.end(); |
2625 | while(it != end) { | 2573 | while(it != end) { |
2626 | // kdDebug() << " filter: " << (*it) << endl; | 2574 | // kdDebug() << " filter: " << (*it) << endl; |
2627 | 2575 | ||
2628 | CalFilter *filter; | 2576 | CalFilter *filter; |
2629 | filter = new CalFilter(*it); | 2577 | filter = new CalFilter(*it); |
2630 | config->setGroup("Filter_" + (*it).utf8()); | 2578 | config->setGroup("Filter_" + (*it).utf8()); |
2631 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2579 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2632 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2580 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2633 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2581 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2634 | mFilters.append(filter); | 2582 | mFilters.append(filter); |
2635 | 2583 | ||
2636 | ++it; | 2584 | ++it; |
2637 | } | 2585 | } |
2638 | 2586 | ||
2639 | if (mFilters.count() == 0) { | 2587 | if (mFilters.count() == 0) { |
2640 | CalFilter *filter = new CalFilter(i18n("Default")); | 2588 | CalFilter *filter = new CalFilter(i18n("Default")); |
2641 | mFilters.append(filter); | 2589 | mFilters.append(filter); |
2642 | } | 2590 | } |
2643 | mFilterView->updateFilters(); | 2591 | mFilterView->updateFilters(); |
2644 | config->setGroup("FilterView"); | 2592 | config->setGroup("FilterView"); |
2645 | 2593 | ||
2646 | mFilterView->blockSignals(true); | 2594 | mFilterView->blockSignals(true); |
2647 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2595 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2648 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2596 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2649 | mFilterView->blockSignals(false); | 2597 | mFilterView->blockSignals(false); |
2650 | // We do it manually to avoid it being done twice by the above calls | 2598 | // We do it manually to avoid it being done twice by the above calls |
2651 | updateFilter(); | 2599 | updateFilter(); |
2652 | } | 2600 | } |
2653 | 2601 | ||
2654 | void CalendarView::writeFilterSettings(KConfig *config) | 2602 | void CalendarView::writeFilterSettings(KConfig *config) |
2655 | { | 2603 | { |
2656 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2604 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2657 | 2605 | ||
2658 | QStringList filterList; | 2606 | QStringList filterList; |
2659 | 2607 | ||
2660 | CalFilter *filter = mFilters.first(); | 2608 | CalFilter *filter = mFilters.first(); |
2661 | while(filter) { | 2609 | while(filter) { |
2662 | // kdDebug() << " fn: " << filter->name() << endl; | 2610 | // kdDebug() << " fn: " << filter->name() << endl; |
2663 | filterList << filter->name(); | 2611 | filterList << filter->name(); |
2664 | config->setGroup("Filter_" + filter->name().utf8()); | 2612 | config->setGroup("Filter_" + filter->name().utf8()); |
2665 | config->writeEntry("Criteria",filter->criteria()); | 2613 | config->writeEntry("Criteria",filter->criteria()); |
2666 | config->writeEntry("CategoryList",filter->categoryList()); | 2614 | config->writeEntry("CategoryList",filter->categoryList()); |
2667 | filter = mFilters.next(); | 2615 | filter = mFilters.next(); |
2668 | } | 2616 | } |
2669 | config->setGroup("General"); | 2617 | config->setGroup("General"); |
2670 | config->writeEntry("CalendarFilters",filterList); | 2618 | config->writeEntry("CalendarFilters",filterList); |
2671 | 2619 | ||
2672 | config->setGroup("FilterView"); | 2620 | config->setGroup("FilterView"); |
2673 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2621 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2674 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2622 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2675 | } | 2623 | } |
2676 | 2624 | ||
2677 | 2625 | ||
2678 | void CalendarView::goToday() | 2626 | void CalendarView::goToday() |
2679 | { | 2627 | { |
2680 | if ( mViewManager->currentView()->isMonthView() ) | 2628 | if ( mViewManager->currentView()->isMonthView() ) |
2681 | mNavigator->selectTodayMonth(); | 2629 | mNavigator->selectTodayMonth(); |
2682 | else | 2630 | else |
2683 | mNavigator->selectToday(); | 2631 | mNavigator->selectToday(); |
2684 | } | 2632 | } |
2685 | 2633 | ||
2686 | void CalendarView::goNext() | 2634 | void CalendarView::goNext() |
2687 | { | 2635 | { |
2688 | mNavigator->selectNext(); | 2636 | mNavigator->selectNext(); |
2689 | } | 2637 | } |
2690 | 2638 | ||
2691 | void CalendarView::goPrevious() | 2639 | void CalendarView::goPrevious() |
2692 | { | 2640 | { |
2693 | mNavigator->selectPrevious(); | 2641 | mNavigator->selectPrevious(); |
2694 | } | 2642 | } |
2695 | void CalendarView::goNextMonth() | 2643 | void CalendarView::goNextMonth() |
2696 | { | 2644 | { |
2697 | mNavigator->selectNextMonth(); | 2645 | mNavigator->selectNextMonth(); |
2698 | } | 2646 | } |
2699 | 2647 | ||
2700 | void CalendarView::goPreviousMonth() | 2648 | void CalendarView::goPreviousMonth() |
2701 | { | 2649 | { |
2702 | mNavigator->selectPreviousMonth(); | 2650 | mNavigator->selectPreviousMonth(); |
2703 | } | 2651 | } |
2704 | 2652 | ||
2705 | void CalendarView::updateConfig() | 2653 | void CalendarView::updateConfig() |
2706 | { | 2654 | { |
2707 | if ( KOPrefs::instance()->mUseAppColors ) | 2655 | if ( KOPrefs::instance()->mUseAppColors ) |
2708 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2656 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2709 | emit configChanged(); | 2657 | emit configChanged(); |
2710 | mTodoList->updateConfig(); | 2658 | mTodoList->updateConfig(); |
2711 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2659 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2712 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2660 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2713 | // To make the "fill window" configurations work | 2661 | // To make the "fill window" configurations work |
2714 | //mViewManager->raiseCurrentView(); | 2662 | //mViewManager->raiseCurrentView(); |
2715 | } | 2663 | } |
2716 | 2664 | ||
2717 | 2665 | ||
2718 | void CalendarView::eventChanged(Event *event) | 2666 | void CalendarView::eventChanged(Event *event) |
2719 | { | 2667 | { |
2720 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2668 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2721 | //updateUnmanagedViews(); | 2669 | //updateUnmanagedViews(); |
2722 | } | 2670 | } |
2723 | 2671 | ||
2724 | void CalendarView::eventAdded(Event *event) | 2672 | void CalendarView::eventAdded(Event *event) |
2725 | { | 2673 | { |
2726 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2674 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2727 | } | 2675 | } |
2728 | 2676 | ||
2729 | void CalendarView::eventToBeDeleted(Event *) | 2677 | void CalendarView::eventToBeDeleted(Event *) |
2730 | { | 2678 | { |
2731 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2679 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2732 | } | 2680 | } |
2733 | 2681 | ||
2734 | void CalendarView::eventDeleted() | 2682 | void CalendarView::eventDeleted() |
2735 | { | 2683 | { |
2736 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2684 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2737 | } | 2685 | } |
2738 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2686 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2739 | { | 2687 | { |
2740 | changeIncidenceDisplay((Incidence *)which, action); | 2688 | changeIncidenceDisplay((Incidence *)which, action); |
2741 | mDateNavigator->updateView(); //LR | 2689 | mDateNavigator->updateView(); //LR |
2742 | //mDialogManager->updateSearchDialog(); | 2690 | //mDialogManager->updateSearchDialog(); |
2743 | 2691 | ||
2744 | if (which) { | 2692 | if (which) { |
2745 | mViewManager->updateWNview(); | 2693 | mViewManager->updateWNview(); |
2746 | //mTodoList->updateView(); | 2694 | //mTodoList->updateView(); |
2747 | } | 2695 | } |
2748 | 2696 | ||
2749 | } | 2697 | } |
2750 | 2698 | ||
2751 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2699 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2752 | { | 2700 | { |
2753 | updateUnmanagedViews(); | 2701 | updateUnmanagedViews(); |
2754 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2702 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2755 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2703 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2756 | mCalendar->checkAlarmForIncidence( 0, true ); | 2704 | mCalendar->checkAlarmForIncidence( 0, true ); |
2757 | if ( mEventViewerDialog ) | 2705 | if ( mEventViewerDialog ) |
2758 | mEventViewerDialog->hide(); | 2706 | mEventViewerDialog->hide(); |
2759 | } | 2707 | } |
2760 | else | 2708 | else |
2761 | mCalendar->checkAlarmForIncidence( which , false ); | 2709 | mCalendar->checkAlarmForIncidence( which , false ); |
2762 | } | 2710 | } |
2763 | 2711 | ||
2764 | // most of the changeEventDisplays() right now just call the view's | 2712 | // most of the changeEventDisplays() right now just call the view's |
2765 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2713 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2766 | void CalendarView::changeEventDisplay(Event *which, int action) | 2714 | void CalendarView::changeEventDisplay(Event *which, int action) |
2767 | { | 2715 | { |
2768 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2716 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2769 | changeIncidenceDisplay((Incidence *)which, action); | 2717 | changeIncidenceDisplay((Incidence *)which, action); |
2770 | static bool clearallviews = false; | 2718 | static bool clearallviews = false; |
2771 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2719 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2772 | if ( clearallviews ) { | 2720 | if ( clearallviews ) { |
2773 | clearAllViews(); | 2721 | clearAllViews(); |
2774 | clearallviews = false; | 2722 | clearallviews = false; |
2775 | } | 2723 | } |
2776 | return; | 2724 | return; |
2777 | } | 2725 | } |
2778 | clearallviews = true; | 2726 | clearallviews = true; |
2779 | mDateNavigator->updateView(); | 2727 | mDateNavigator->updateView(); |
2780 | //mDialogManager->updateSearchDialog(); | 2728 | //mDialogManager->updateSearchDialog(); |
2781 | if (which) { | 2729 | if (which) { |
2782 | // If there is an event view visible update the display | 2730 | // If there is an event view visible update the display |
2783 | mViewManager->currentView()->changeEventDisplay(which,action); | 2731 | mViewManager->currentView()->changeEventDisplay(which,action); |
2784 | // TODO: check, if update needed | 2732 | // TODO: check, if update needed |
2785 | // if (which->getTodoStatus()) { | 2733 | // if (which->getTodoStatus()) { |
2786 | mTodoList->updateView(); | 2734 | mTodoList->updateView(); |
2787 | if ( action != KOGlobals::EVENTDELETED ) { | 2735 | if ( action != KOGlobals::EVENTDELETED ) { |
2788 | mConflictingEvent = which ; | 2736 | mConflictingEvent = which ; |
2789 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2737 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2790 | } | 2738 | } |
2791 | // } | 2739 | // } |
2792 | } else { | 2740 | } else { |
2793 | mViewManager->currentView()->updateView(); | 2741 | mViewManager->currentView()->updateView(); |
2794 | } | 2742 | } |
2795 | } | 2743 | } |
2796 | void CalendarView::checkConflictForEvent() | 2744 | void CalendarView::checkConflictForEvent() |
2797 | { | 2745 | { |
2798 | 2746 | ||
2799 | if (!KOPrefs::instance()->mConfirm) | 2747 | if (!KOPrefs::instance()->mConfirm) |
2800 | return; | 2748 | return; |
2801 | if ( ! mConflictingEvent ) return; | 2749 | if ( ! mConflictingEvent ) return; |
2802 | if ( mConflictingEvent->doesFloat() ) { | 2750 | if ( mConflictingEvent->doesFloat() ) { |
2803 | mConflictingEvent = 0; | 2751 | mConflictingEvent = 0; |
2804 | return; | 2752 | return; |
2805 | } | 2753 | } |
2806 | QPtrList<Event> testlist = mCalendar->events(); | 2754 | QPtrList<Event> testlist = mCalendar->events(); |
2807 | Event * test = testlist.first(); | 2755 | Event * test = testlist.first(); |
2808 | QDateTime conflict; | 2756 | QDateTime conflict; |
2809 | QDateTime retVal; | 2757 | QDateTime retVal; |
2810 | bool found = false; | 2758 | bool found = false; |
2811 | Event * cE = 0; | 2759 | Event * cE = 0; |
2812 | QDateTime current = QDateTime::currentDateTime(); | 2760 | QDateTime current = QDateTime::currentDateTime(); |
2813 | while ( test ) { | 2761 | while ( test ) { |
2814 | if ( !test->doesFloat() ) { | 2762 | if ( !test->doesFloat() ) { |
2815 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2763 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2816 | if ( ! found ) { | 2764 | if ( ! found ) { |
2817 | conflict = retVal; | 2765 | conflict = retVal; |
2818 | cE = test; | 2766 | cE = test; |
2819 | } else { | 2767 | } else { |
2820 | if ( retVal < conflict ) { | 2768 | if ( retVal < conflict ) { |
2821 | conflict = retVal; | 2769 | conflict = retVal; |
2822 | cE = test; | 2770 | cE = test; |
2823 | } | 2771 | } |
2824 | } | 2772 | } |
2825 | found = true; | 2773 | found = true; |
2826 | } | 2774 | } |
2827 | } | 2775 | } |
2828 | test = testlist.next(); | 2776 | test = testlist.next(); |
2829 | } | 2777 | } |
2830 | if ( found ) { | 2778 | if ( found ) { |
2831 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2779 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2832 | qApp->processEvents(); | 2780 | qApp->processEvents(); |
2833 | int km = KMessageBox::warningContinueCancel(this,mess, | 2781 | int km = KMessageBox::warningContinueCancel(this,mess, |
2834 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2782 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2835 | if ( km != KMessageBox::Continue ) | 2783 | if ( km != KMessageBox::Continue ) |
2836 | return; | 2784 | return; |
2837 | 2785 | ||
2838 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2786 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2839 | mViewManager->showDayView(); | 2787 | mViewManager->showDayView(); |
2840 | mNavigator->slotDaySelect( conflict.date() ); | 2788 | mNavigator->slotDaySelect( conflict.date() ); |
2841 | int hour = conflict.time().hour(); | 2789 | int hour = conflict.time().hour(); |
2842 | mViewManager->agendaView()->setStartHour( hour ); | 2790 | mViewManager->agendaView()->setStartHour( hour ); |
2843 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2791 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2844 | return; | 2792 | return; |
2845 | } | 2793 | } |
2846 | 2794 | ||
2847 | return; | 2795 | return; |
2848 | 2796 | ||
2849 | } | 2797 | } |
2850 | 2798 | ||
2851 | void CalendarView::updateTodoViews() | 2799 | void CalendarView::updateTodoViews() |
2852 | { | 2800 | { |
2853 | mTodoList->updateView(); | 2801 | mTodoList->updateView(); |
2854 | mViewManager->currentView()->updateView(); | 2802 | mViewManager->currentView()->updateView(); |
2855 | 2803 | ||
2856 | } | 2804 | } |
2857 | 2805 | ||
2858 | 2806 | ||
2859 | 2807 | ||
2860 | void CalendarView::clearAllViews() | 2808 | void CalendarView::clearAllViews() |
2861 | { | 2809 | { |
2862 | mTodoList->clearList(); | 2810 | mTodoList->clearList(); |
2863 | mViewManager->clearAllViews(); | 2811 | mViewManager->clearAllViews(); |
2864 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2812 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2865 | if ( sd ) { | 2813 | if ( sd ) { |
2866 | KOListView* kol = sd->listview(); | 2814 | KOListView* kol = sd->listview(); |
2867 | if ( kol ) | 2815 | if ( kol ) |
2868 | kol->clearList(); | 2816 | kol->clearList(); |
2869 | } | 2817 | } |
2870 | } | 2818 | } |
2871 | void CalendarView::updateView() | 2819 | void CalendarView::updateView() |
2872 | { | 2820 | { |
2873 | static bool clearallviews = false; | 2821 | static bool clearallviews = false; |
2874 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2822 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2875 | if ( clearallviews ) { | 2823 | if ( clearallviews ) { |
2876 | clearAllViews(); | 2824 | clearAllViews(); |
2877 | clearallviews = false; | 2825 | clearallviews = false; |
2878 | } | 2826 | } |
2879 | return; | 2827 | return; |
2880 | } | 2828 | } |
2881 | clearallviews = true; | 2829 | clearallviews = true; |
2882 | DateList tmpList = mNavigator->selectedDates(); | 2830 | DateList tmpList = mNavigator->selectedDates(); |
2883 | 2831 | ||
2884 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2832 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2885 | mTodoList->updateView(); | 2833 | mTodoList->updateView(); |
2886 | // We assume that the navigator only selects consecutive days. | 2834 | // We assume that the navigator only selects consecutive days. |
2887 | updateView( tmpList.first(), tmpList.last() ); | 2835 | updateView( tmpList.first(), tmpList.last() ); |
2888 | } | 2836 | } |
2889 | 2837 | ||
2890 | void CalendarView::updateUnmanagedViews() | 2838 | void CalendarView::updateUnmanagedViews() |
2891 | { | 2839 | { |
2892 | mDateNavigator->updateDayMatrix(); | 2840 | mDateNavigator->updateDayMatrix(); |
2893 | } | 2841 | } |
2894 | 2842 | ||
2895 | int CalendarView::msgItemDelete(const QString name) | 2843 | int CalendarView::msgItemDelete(const QString name) |
2896 | { | 2844 | { |
2897 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2845 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2898 | i18n("This item will be\npermanently deleted."), | 2846 | i18n("This item will be\npermanently deleted."), |
2899 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2847 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2900 | } | 2848 | } |
2901 | 2849 | ||
2902 | 2850 | ||
2903 | void CalendarView::edit_cut() | 2851 | void CalendarView::edit_cut() |
2904 | { | 2852 | { |
2905 | Event *anEvent=0; | 2853 | Event *anEvent=0; |
2906 | 2854 | ||
2907 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2855 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2908 | 2856 | ||
2909 | if (mViewManager->currentView()->isEventView()) { | 2857 | if (mViewManager->currentView()->isEventView()) { |
2910 | if ( incidence && incidence->typeID() == eventID ) { | 2858 | if ( incidence && incidence->typeID() == eventID ) { |
2911 | anEvent = static_cast<Event *>(incidence); | 2859 | anEvent = static_cast<Event *>(incidence); |
2912 | } | 2860 | } |
2913 | } | 2861 | } |
2914 | 2862 | ||
2915 | if (!anEvent) { | 2863 | if (!anEvent) { |
2916 | KNotifyClient::beep(); | 2864 | KNotifyClient::beep(); |
2917 | return; | 2865 | return; |
2918 | } | 2866 | } |
2919 | DndFactory factory( mCalendar ); | 2867 | DndFactory factory( mCalendar ); |
2920 | factory.cutIncidence(anEvent); | 2868 | factory.cutIncidence(anEvent); |
2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2869 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2922 | } | 2870 | } |
2923 | 2871 | ||
2924 | void CalendarView::edit_copy() | 2872 | void CalendarView::edit_copy() |
2925 | { | 2873 | { |
2926 | Event *anEvent=0; | 2874 | Event *anEvent=0; |
2927 | 2875 | ||
2928 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2876 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2929 | 2877 | ||
2930 | if (mViewManager->currentView()->isEventView()) { | 2878 | if (mViewManager->currentView()->isEventView()) { |
2931 | if ( incidence && incidence->typeID() == eventID ) { | 2879 | if ( incidence && incidence->typeID() == eventID ) { |
2932 | anEvent = static_cast<Event *>(incidence); | 2880 | anEvent = static_cast<Event *>(incidence); |
2933 | } | 2881 | } |
2934 | } | 2882 | } |
2935 | 2883 | ||
2936 | if (!anEvent) { | 2884 | if (!anEvent) { |
2937 | KNotifyClient::beep(); | 2885 | KNotifyClient::beep(); |
2938 | return; | 2886 | return; |
2939 | } | 2887 | } |
2940 | DndFactory factory( mCalendar ); | 2888 | DndFactory factory( mCalendar ); |
2941 | factory.copyIncidence(anEvent); | 2889 | factory.copyIncidence(anEvent); |
2942 | } | 2890 | } |
2943 | 2891 | ||
2944 | void CalendarView::edit_paste() | 2892 | void CalendarView::edit_paste() |
2945 | { | 2893 | { |
2946 | QDate date = mNavigator->selectedDates().first(); | 2894 | QDate date = mNavigator->selectedDates().first(); |
2947 | 2895 | ||
2948 | DndFactory factory( mCalendar ); | 2896 | DndFactory factory( mCalendar ); |
2949 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2897 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2950 | 2898 | ||
2951 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2899 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2952 | } | 2900 | } |
2953 | void CalendarView::edit_global_options() | 2901 | void CalendarView::edit_global_options() |
2954 | { | 2902 | { |
2955 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2903 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2956 | emit save(); | 2904 | emit save(); |
2957 | emit saveStopTimer(); | 2905 | emit saveStopTimer(); |
2958 | mDialogManager->showGlobalOptionsDialog(); | 2906 | mDialogManager->showGlobalOptionsDialog(); |
2959 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2907 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2960 | emit saveStopTimer(); | 2908 | emit saveStopTimer(); |
2961 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2909 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2962 | i18n("Timezone settings"),i18n("Reload"))) { | 2910 | i18n("Timezone settings"),i18n("Reload"))) { |
2963 | qDebug("KO: TZ reload cancelled "); | 2911 | qDebug("KO: TZ reload cancelled "); |
2964 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2912 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2965 | return; | 2913 | return; |
2966 | } | 2914 | } |
2967 | qDebug("KO: Timezone change "); | 2915 | qDebug("KO: Timezone change "); |
2968 | loadCalendars(); | 2916 | loadCalendars(); |
2969 | setModified(true); | 2917 | setModified(true); |
2970 | } | 2918 | } |
2971 | else | 2919 | else |
2972 | qDebug("KO: No tz change "); | 2920 | qDebug("KO: No tz change "); |
2973 | } | 2921 | } |
2974 | void CalendarView::edit_options() | 2922 | void CalendarView::edit_options() |
2975 | { | 2923 | { |
2976 | mDialogManager->showOptionsDialog(); | 2924 | mDialogManager->showOptionsDialog(); |
2977 | } | 2925 | } |
2978 | 2926 | ||
2979 | 2927 | ||
2980 | void CalendarView::slotSelectPickerDate( QDate d) | 2928 | void CalendarView::slotSelectPickerDate( QDate d) |
2981 | { | 2929 | { |
2982 | mDateFrame->hide(); | 2930 | mDateFrame->hide(); |
2983 | if ( mDatePickerMode == 1 ) { | 2931 | if ( mDatePickerMode == 1 ) { |
2984 | mNavigator->slotDaySelect( d ); | 2932 | mNavigator->slotDaySelect( d ); |
2985 | } else if ( mDatePickerMode == 2 ) { | 2933 | } else if ( mDatePickerMode == 2 ) { |
2986 | if ( mMoveIncidence->typeID() == todoID ) { | 2934 | if ( mMoveIncidence->typeID() == todoID ) { |
2987 | Todo * to = (Todo *) mMoveIncidence; | 2935 | Todo * to = (Todo *) mMoveIncidence; |
2988 | QTime tim; | 2936 | QTime tim; |
2989 | int len = 0; | 2937 | int len = 0; |
2990 | if ( to->hasStartDate() && to->hasDueDate() ) | 2938 | if ( to->hasStartDate() && to->hasDueDate() ) |
2991 | len = to->dtStart().secsTo( to->dtDue()); | 2939 | len = to->dtStart().secsTo( to->dtDue()); |
2992 | if ( to->hasDueDate() ) | 2940 | if ( to->hasDueDate() ) |
2993 | tim = to->dtDue().time(); | 2941 | tim = to->dtDue().time(); |
2994 | else { | 2942 | else { |
2995 | tim = QTime ( 0,0,0 ); | 2943 | tim = QTime ( 0,0,0 ); |
2996 | to->setFloats( true ); | 2944 | to->setFloats( true ); |
2997 | to->setHasDueDate( true ); | 2945 | to->setHasDueDate( true ); |
2998 | } | 2946 | } |
2999 | QDateTime dt ( d,tim ); | 2947 | QDateTime dt ( d,tim ); |
3000 | to->setDtDue( dt ); | 2948 | to->setDtDue( dt ); |
3001 | 2949 | ||
3002 | if ( to->hasStartDate() ) { | 2950 | if ( to->hasStartDate() ) { |
3003 | if ( len>0 ) | 2951 | if ( len>0 ) |
3004 | to->setDtStart(to->dtDue().addSecs( -len )); | 2952 | to->setDtStart(to->dtDue().addSecs( -len )); |
3005 | else | 2953 | else |
3006 | if (to->dtStart() > to->dtDue() ) | 2954 | if (to->dtStart() > to->dtDue() ) |
3007 | to->setDtStart(to->dtDue().addDays( -3 )); | 2955 | to->setDtStart(to->dtDue().addDays( -3 )); |
3008 | } | 2956 | } |
3009 | 2957 | ||
3010 | todoChanged( to ); | 2958 | todoChanged( to ); |
3011 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2959 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3012 | if ( mMoveIncidence->doesRecur() ) { | 2960 | if ( mMoveIncidence->doesRecur() ) { |
3013 | #if 0 | 2961 | #if 0 |
3014 | // PENDING implement this | 2962 | // PENDING implement this |
3015 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2963 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3016 | mCalendar()->addIncidence( newInc ); | 2964 | mCalendar()->addIncidence( newInc ); |
3017 | if ( mMoveIncidence->typeID() == todoID ) | 2965 | if ( mMoveIncidence->typeID() == todoID ) |
3018 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2966 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3019 | else | 2967 | else |
3020 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2968 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3021 | mMoveIncidence = newInc; | 2969 | mMoveIncidence = newInc; |
3022 | 2970 | ||
3023 | #endif | 2971 | #endif |
3024 | } | 2972 | } |
3025 | QTime tim = mMoveIncidence->dtStart().time(); | 2973 | QTime tim = mMoveIncidence->dtStart().time(); |
3026 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2974 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3027 | QDateTime dt ( d,tim ); | 2975 | QDateTime dt ( d,tim ); |
3028 | mMoveIncidence->setDtStart( dt ); | 2976 | mMoveIncidence->setDtStart( dt ); |
3029 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2977 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3030 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2978 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3031 | } else if ( mMoveIncidence->typeID() == journalID ) { | 2979 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3032 | QTime tim = mMoveIncidence->dtStart().time(); | 2980 | QTime tim = mMoveIncidence->dtStart().time(); |
3033 | QDateTime dt ( d,tim ); | 2981 | QDateTime dt ( d,tim ); |
3034 | mMoveIncidence->setDtStart( dt ); | 2982 | mMoveIncidence->setDtStart( dt ); |
3035 | updateView(); | 2983 | updateView(); |
3036 | } | 2984 | } |
3037 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2985 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3038 | } | 2986 | } |
3039 | } | 2987 | } |
3040 | 2988 | ||
3041 | void CalendarView::removeCategories() | 2989 | void CalendarView::removeCategories() |
3042 | { | 2990 | { |
3043 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2991 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3044 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2992 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3045 | QStringList catIncList; | 2993 | QStringList catIncList; |
3046 | QStringList newCatList; | 2994 | QStringList newCatList; |
3047 | Incidence* inc = incList.first(); | 2995 | Incidence* inc = incList.first(); |
3048 | uint i; | 2996 | uint i; |
3049 | while ( inc ) { | 2997 | while ( inc ) { |
3050 | newCatList.clear(); | 2998 | newCatList.clear(); |
3051 | catIncList = inc->categories() ; | 2999 | catIncList = inc->categories() ; |
3052 | for( i = 0; i< catIncList.count(); ++i ) { | 3000 | for( i = 0; i< catIncList.count(); ++i ) { |
3053 | if ( catList.contains (catIncList[i])) | 3001 | if ( catList.contains (catIncList[i])) |
3054 | newCatList.append( catIncList[i] ); | 3002 | newCatList.append( catIncList[i] ); |
3055 | } | 3003 | } |
3056 | newCatList.sort(); | 3004 | newCatList.sort(); |
3057 | inc->setCategories( newCatList.join(",") ); | 3005 | inc->setCategories( newCatList.join(",") ); |
3058 | inc = incList.next(); | 3006 | inc = incList.next(); |
3059 | } | 3007 | } |
3060 | } | 3008 | } |
3061 | 3009 | ||
3062 | int CalendarView::addCategories() | 3010 | int CalendarView::addCategories() |
3063 | { | 3011 | { |
3064 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3012 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3065 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3013 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3066 | QStringList catIncList; | 3014 | QStringList catIncList; |
3067 | Incidence* inc = incList.first(); | 3015 | Incidence* inc = incList.first(); |
3068 | uint i; | 3016 | uint i; |
3069 | int count = 0; | 3017 | int count = 0; |
3070 | while ( inc ) { | 3018 | while ( inc ) { |
3071 | catIncList = inc->categories() ; | 3019 | catIncList = inc->categories() ; |
3072 | for( i = 0; i< catIncList.count(); ++i ) { | 3020 | for( i = 0; i< catIncList.count(); ++i ) { |
3073 | if ( !catList.contains (catIncList[i])) { | 3021 | if ( !catList.contains (catIncList[i])) { |
3074 | catList.append( catIncList[i] ); | 3022 | catList.append( catIncList[i] ); |
3075 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3023 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3076 | ++count; | 3024 | ++count; |
3077 | } | 3025 | } |
3078 | } | 3026 | } |
3079 | inc = incList.next(); | 3027 | inc = incList.next(); |
3080 | } | 3028 | } |
3081 | catList.sort(); | 3029 | catList.sort(); |
3082 | KOPrefs::instance()->mCustomCategories = catList; | 3030 | KOPrefs::instance()->mCustomCategories = catList; |
3083 | return count; | 3031 | return count; |
3084 | } | 3032 | } |
3085 | 3033 | ||
3086 | void CalendarView::editCategories() | 3034 | void CalendarView::editCategories() |
3087 | { | 3035 | { |
3088 | qDebug("CalendarView::editCategories() "); | 3036 | qDebug("CalendarView::editCategories() "); |
3089 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3037 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3090 | ced.exec(); | 3038 | ced.exec(); |
3091 | } | 3039 | } |
3092 | void CalendarView::manageCategories() | 3040 | void CalendarView::manageCategories() |
3093 | { | 3041 | { |
3094 | KOCatPrefs* cp = new KOCatPrefs(); | 3042 | KOCatPrefs* cp = new KOCatPrefs(); |
3095 | cp->show(); | 3043 | cp->show(); |
3096 | int w =cp->sizeHint().width() ; | 3044 | int w =cp->sizeHint().width() ; |
3097 | int h = cp->sizeHint().height() ; | 3045 | int h = cp->sizeHint().height() ; |
3098 | int dw = QApplication::desktop()->width(); | 3046 | int dw = QApplication::desktop()->width(); |
3099 | int dh = QApplication::desktop()->height(); | 3047 | int dh = QApplication::desktop()->height(); |
3100 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3048 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3101 | if ( !cp->exec() ) { | 3049 | if ( !cp->exec() ) { |
3102 | delete cp; | 3050 | delete cp; |
3103 | return; | 3051 | return; |
3104 | } | 3052 | } |
3105 | int count = 0; | 3053 | int count = 0; |
3106 | if ( cp->addCat() ) { | 3054 | if ( cp->addCat() ) { |
3107 | count = addCategories(); | 3055 | count = addCategories(); |
3108 | if ( count ) { | 3056 | if ( count ) { |
3109 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3057 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3110 | writeSettings(); | 3058 | writeSettings(); |
3111 | } else | 3059 | } else |
3112 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3060 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3113 | } else { | 3061 | } else { |
3114 | removeCategories(); | 3062 | removeCategories(); |
3115 | updateView(); | 3063 | updateView(); |
3116 | } | 3064 | } |
3117 | delete cp; | 3065 | delete cp; |
3118 | } | 3066 | } |
3119 | 3067 | ||
3120 | void CalendarView::beamIncidence(Incidence * Inc) | 3068 | void CalendarView::beamIncidence(Incidence * Inc) |
3121 | { | 3069 | { |
3122 | QPtrList<Incidence> delSel ; | 3070 | QPtrList<Incidence> delSel ; |
3123 | delSel.append(Inc); | 3071 | delSel.append(Inc); |
3124 | beamIncidenceList( delSel ); | 3072 | beamIncidenceList( delSel ); |
3125 | } | 3073 | } |
3126 | void CalendarView::beamCalendar() | 3074 | void CalendarView::beamCalendar() |
3127 | { | 3075 | { |
3128 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3076 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3129 | //qDebug("beamCalendar() "); | 3077 | //qDebug("beamCalendar() "); |
3130 | beamIncidenceList( delSel ); | 3078 | beamIncidenceList( delSel ); |
3131 | } | 3079 | } |
3132 | void CalendarView::beamFilteredCalendar() | 3080 | void CalendarView::beamFilteredCalendar() |
3133 | { | 3081 | { |
3134 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3082 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3135 | //qDebug("beamFilteredCalendar() "); | 3083 | //qDebug("beamFilteredCalendar() "); |
3136 | beamIncidenceList( delSel ); | 3084 | beamIncidenceList( delSel ); |
3137 | } | 3085 | } |
3138 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3086 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3139 | { | 3087 | { |
3140 | 3088 | ||
3141 | KOBeamPrefs beamDialog; | 3089 | KOBeamPrefs beamDialog; |
3142 | if ( beamDialog.exec () == QDialog::Rejected ) | 3090 | if ( beamDialog.exec () == QDialog::Rejected ) |
3143 | return; | 3091 | return; |
3144 | #ifdef DESKTOP_VERSION | 3092 | #ifdef DESKTOP_VERSION |
3145 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3093 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3146 | #else | 3094 | #else |
3147 | QString fn = "/tmp/kopibeamfile"; | 3095 | QString fn = "/tmp/kopibeamfile"; |
3148 | #endif | 3096 | #endif |
3149 | QString mes; | 3097 | QString mes; |
3150 | bool createbup = true; | 3098 | bool createbup = true; |
3151 | if ( createbup ) { | 3099 | if ( createbup ) { |
3152 | QString description = "\n"; | 3100 | QString description = "\n"; |
3153 | CalendarLocal* cal = new CalendarLocal(); | 3101 | CalendarLocal* cal = new CalendarLocal(); |
3154 | if ( beamDialog.beamLocal() ) | 3102 | if ( beamDialog.beamLocal() ) |
3155 | cal->setLocalTime(); | 3103 | cal->setLocalTime(); |
3156 | else | 3104 | else |
3157 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3105 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3158 | Incidence *incidence = delSel.first(); | 3106 | Incidence *incidence = delSel.first(); |
3159 | bool addText = false; | 3107 | bool addText = false; |
3160 | if ( delSel.count() < 10 ) | 3108 | if ( delSel.count() < 10 ) |
3161 | addText = true; | 3109 | addText = true; |
3162 | else { | 3110 | else { |
3163 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3111 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3164 | } | 3112 | } |
3165 | while ( incidence ) { | 3113 | while ( incidence ) { |
3166 | Incidence *in = incidence->clone(); | 3114 | Incidence *in = incidence->clone(); |
3167 | if ( ! in->summary().isEmpty() ) { | 3115 | if ( ! in->summary().isEmpty() ) { |
3168 | in->setDescription(""); | 3116 | in->setDescription(""); |
3169 | } else { | 3117 | } else { |
3170 | in->setSummary( in->description().left(20)); | 3118 | in->setSummary( in->description().left(20)); |
3171 | in->setDescription(""); | 3119 | in->setDescription(""); |
3172 | } | 3120 | } |
3173 | if ( addText ) | 3121 | if ( addText ) |
3174 | description += in->summary() + "\n"; | 3122 | description += in->summary() + "\n"; |
3175 | cal->addIncidence( in ); | 3123 | cal->addIncidence( in ); |
3176 | incidence = delSel.next(); | 3124 | incidence = delSel.next(); |
3177 | } | 3125 | } |
3178 | if ( beamDialog.beamVcal() ) { | 3126 | if ( beamDialog.beamVcal() ) { |
3179 | fn += ".vcs"; | 3127 | fn += ".vcs"; |
3180 | FileStorage storage( cal, fn, new VCalFormat ); | 3128 | FileStorage storage( cal, fn, new VCalFormat ); |
3181 | storage.save(); | 3129 | storage.save(); |
3182 | } else { | 3130 | } else { |
3183 | fn += ".ics"; | 3131 | fn += ".ics"; |
3184 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3132 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3185 | storage.save(); | 3133 | storage.save(); |
3186 | } | 3134 | } |
3187 | delete cal; | 3135 | delete cal; |
3188 | mes = i18n("KO/Pi: Ready for beaming"); | 3136 | mes = i18n("KO/Pi: Ready for beaming"); |
3189 | topLevelWidget()->setCaption(mes); | 3137 | topLevelWidget()->setCaption(mes); |
3190 | KApplication::convert2latin1( fn ); | 3138 | KApplication::convert2latin1( fn ); |
3191 | #ifndef DESKTOP_VERSION | 3139 | #ifndef DESKTOP_VERSION |
3192 | Ir *ir = new Ir( this ); | 3140 | Ir *ir = new Ir( this ); |
3193 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3141 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3194 | ir->send( fn, description, "text/x-vCalendar" ); | 3142 | ir->send( fn, description, "text/x-vCalendar" ); |
3195 | #endif | 3143 | #endif |
3196 | } | 3144 | } |
3197 | } | 3145 | } |
3198 | 3146 | ||
3199 | #ifndef DESKTOP_VERSION | 3147 | #ifndef DESKTOP_VERSION |
3200 | void CalendarView::beamDone( Ir *ir ) | 3148 | void CalendarView::beamDone( Ir *ir ) |
3201 | { | 3149 | { |
3202 | delete ir; | 3150 | delete ir; |
3203 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3151 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3204 | topLevelWidget()->raise(); | 3152 | topLevelWidget()->raise(); |
3205 | } | 3153 | } |
3206 | #else | 3154 | #else |
3207 | void CalendarView::beamDone( Ir *){;} | 3155 | void CalendarView::beamDone( Ir *){;} |
3208 | #endif | 3156 | #endif |
3209 | void CalendarView::moveIncidence(Incidence * inc ) | 3157 | void CalendarView::moveIncidence(Incidence * inc ) |
3210 | { | 3158 | { |
3211 | if ( !inc ) return; | 3159 | if ( !inc ) return; |
3212 | showDatePickerPopup(); | 3160 | showDatePickerPopup(); |
3213 | mDatePickerMode = 2; | 3161 | mDatePickerMode = 2; |
3214 | mMoveIncidence = inc ; | 3162 | mMoveIncidence = inc ; |
3215 | QDate da; | 3163 | QDate da; |
3216 | if ( mMoveIncidence->typeID() == todoID ) { | 3164 | if ( mMoveIncidence->typeID() == todoID ) { |
3217 | Todo * to = (Todo *) mMoveIncidence; | 3165 | Todo * to = (Todo *) mMoveIncidence; |
3218 | if ( to->hasDueDate() ) | 3166 | if ( to->hasDueDate() ) |
3219 | da = to->dtDue().date(); | 3167 | da = to->dtDue().date(); |
3220 | else | 3168 | else |
3221 | da = QDate::currentDate(); | 3169 | da = QDate::currentDate(); |
3222 | } else { | 3170 | } else { |
3223 | da = mMoveIncidence->dtStart().date(); | 3171 | da = mMoveIncidence->dtStart().date(); |
3224 | } | 3172 | } |
3225 | //PENDING set date for recurring incidence to date of recurrence | 3173 | //PENDING set date for recurring incidence to date of recurrence |
3226 | //mMoveIncidenceOldDate; | 3174 | //mMoveIncidenceOldDate; |
3227 | mDatePicker->setDate( da ); | 3175 | mDatePicker->setDate( da ); |
3228 | } | 3176 | } |
3229 | void CalendarView::showDatePickerPopup() | 3177 | void CalendarView::showDatePickerPopup() |
3230 | { | 3178 | { |
3231 | if ( mDateFrame->isVisible() ) | 3179 | if ( mDateFrame->isVisible() ) |
3232 | mDateFrame->hide(); | 3180 | mDateFrame->hide(); |
3233 | else { | 3181 | else { |
3234 | int offX = 0, offY = 0; | 3182 | int offX = 0, offY = 0; |
3235 | #ifdef DESKTOP_VERSION | 3183 | #ifdef DESKTOP_VERSION |
3236 | int w =mDatePicker->sizeHint().width() ; | 3184 | int w =mDatePicker->sizeHint().width() ; |
3237 | int h = mDatePicker->sizeHint().height() ; | 3185 | int h = mDatePicker->sizeHint().height() ; |
3238 | int dw = topLevelWidget()->width(); | 3186 | int dw = topLevelWidget()->width(); |
3239 | int dh = topLevelWidget()->height(); | 3187 | int dh = topLevelWidget()->height(); |
3240 | offX = topLevelWidget()->x(); | 3188 | offX = topLevelWidget()->x(); |
3241 | offY = topLevelWidget()->y(); | 3189 | offY = topLevelWidget()->y(); |
3242 | #else | 3190 | #else |
3243 | int w =mDatePicker->sizeHint().width() ; | 3191 | int w =mDatePicker->sizeHint().width() ; |
3244 | int h = mDatePicker->sizeHint().height() ; | 3192 | int h = mDatePicker->sizeHint().height() ; |
3245 | int dw = QApplication::desktop()->width(); | 3193 | int dw = QApplication::desktop()->width(); |
3246 | int dh = QApplication::desktop()->height(); | 3194 | int dh = QApplication::desktop()->height(); |
3247 | #endif | 3195 | #endif |
3248 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3196 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3249 | mDateFrame->show(); | 3197 | mDateFrame->show(); |
3250 | } | 3198 | } |
3251 | } | 3199 | } |
3252 | void CalendarView::showDatePicker( ) | 3200 | void CalendarView::showDatePicker( ) |
3253 | { | 3201 | { |
3254 | showDatePickerPopup(); | 3202 | showDatePickerPopup(); |
3255 | mDatePickerMode = 1; | 3203 | mDatePickerMode = 1; |
3256 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3204 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3257 | } | 3205 | } |
3258 | 3206 | ||
3259 | void CalendarView::showEventEditor() | 3207 | void CalendarView::showEventEditor() |
3260 | { | 3208 | { |
3261 | #ifdef DESKTOP_VERSION | 3209 | #ifdef DESKTOP_VERSION |
3262 | int x,y,w,h; | 3210 | int x,y,w,h; |
3263 | x = mEventEditor->geometry().x(); | 3211 | x = mEventEditor->geometry().x(); |
3264 | y = mEventEditor->geometry().y(); | 3212 | y = mEventEditor->geometry().y(); |
3265 | w = mEventEditor->width(); | 3213 | w = mEventEditor->width(); |
3266 | h = mEventEditor->height(); | 3214 | h = mEventEditor->height(); |
3267 | mEventEditor->show(); | 3215 | mEventEditor->show(); |
3268 | mEventEditor->setGeometry(x,y,w,h); | 3216 | mEventEditor->setGeometry(x,y,w,h); |
3269 | #else | 3217 | #else |
3270 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3218 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3271 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3219 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3272 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3220 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3273 | qApp->processEvents(); | 3221 | qApp->processEvents(); |
3274 | delete mEventEditor; | 3222 | delete mEventEditor; |
3275 | mEventEditor = mDialogManager->getEventEditor(); | 3223 | mEventEditor = mDialogManager->getEventEditor(); |
3276 | topLevelWidget()->setCaption( i18n("") ); | 3224 | topLevelWidget()->setCaption( i18n("") ); |
3277 | } | 3225 | } |
3278 | mEventEditor->showMaximized(); | 3226 | mEventEditor->showMaximized(); |
3279 | #endif | 3227 | #endif |
3280 | } | 3228 | } |
3281 | void CalendarView::showTodoEditor() | 3229 | void CalendarView::showTodoEditor() |
3282 | { | 3230 | { |
3283 | #ifdef DESKTOP_VERSION | 3231 | #ifdef DESKTOP_VERSION |
3284 | int x,y,w,h; | 3232 | int x,y,w,h; |
3285 | x = mTodoEditor->geometry().x(); | 3233 | x = mTodoEditor->geometry().x(); |
3286 | y = mTodoEditor->geometry().y(); | 3234 | y = mTodoEditor->geometry().y(); |
3287 | w = mTodoEditor->width(); | 3235 | w = mTodoEditor->width(); |
3288 | h = mTodoEditor->height(); | 3236 | h = mTodoEditor->height(); |
3289 | mTodoEditor->show(); | 3237 | mTodoEditor->show(); |
3290 | mTodoEditor->setGeometry(x,y,w,h); | 3238 | mTodoEditor->setGeometry(x,y,w,h); |
3291 | #else | 3239 | #else |
3292 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3240 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3293 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3241 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3294 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3242 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3295 | qApp->processEvents(); | 3243 | qApp->processEvents(); |
3296 | delete mTodoEditor; | 3244 | delete mTodoEditor; |
3297 | mTodoEditor = mDialogManager->getTodoEditor(); | 3245 | mTodoEditor = mDialogManager->getTodoEditor(); |
3298 | topLevelWidget()->setCaption( i18n("") ); | 3246 | topLevelWidget()->setCaption( i18n("") ); |
3299 | } | 3247 | } |
3300 | mTodoEditor->showMaximized(); | 3248 | mTodoEditor->showMaximized(); |
3301 | #endif | 3249 | #endif |
3302 | } | 3250 | } |
3303 | 3251 | ||
3304 | void CalendarView::cloneIncidence() | 3252 | void CalendarView::cloneIncidence() |
3305 | { | 3253 | { |
3306 | Incidence *incidence = currentSelection(); | 3254 | Incidence *incidence = currentSelection(); |
3307 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3255 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3308 | if ( incidence ) { | 3256 | if ( incidence ) { |
3309 | cloneIncidence(incidence); | 3257 | cloneIncidence(incidence); |
3310 | } | 3258 | } |
3311 | } | 3259 | } |
3312 | void CalendarView::moveIncidence() | 3260 | void CalendarView::moveIncidence() |
3313 | { | 3261 | { |
3314 | Incidence *incidence = currentSelection(); | 3262 | Incidence *incidence = currentSelection(); |
3315 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3263 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3316 | if ( incidence ) { | 3264 | if ( incidence ) { |
3317 | moveIncidence(incidence); | 3265 | moveIncidence(incidence); |
3318 | } | 3266 | } |
3319 | } | 3267 | } |
3320 | void CalendarView::beamIncidence() | 3268 | void CalendarView::beamIncidence() |
3321 | { | 3269 | { |
3322 | Incidence *incidence = currentSelection(); | 3270 | Incidence *incidence = currentSelection(); |
3323 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3271 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3324 | if ( incidence ) { | 3272 | if ( incidence ) { |
3325 | beamIncidence(incidence); | 3273 | beamIncidence(incidence); |
3326 | } | 3274 | } |
3327 | } | 3275 | } |
3328 | void CalendarView::toggleCancelIncidence() | 3276 | void CalendarView::toggleCancelIncidence() |
3329 | { | 3277 | { |
3330 | Incidence *incidence = currentSelection(); | 3278 | Incidence *incidence = currentSelection(); |
3331 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3279 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3332 | if ( incidence ) { | 3280 | if ( incidence ) { |
3333 | cancelIncidence(incidence); | 3281 | cancelIncidence(incidence); |
3334 | } | 3282 | } |
3335 | } | 3283 | } |
3336 | 3284 | ||
3337 | 3285 | ||
3338 | void CalendarView::cancelIncidence(Incidence * inc ) | 3286 | void CalendarView::cancelIncidence(Incidence * inc ) |
3339 | { | 3287 | { |
3340 | inc->setCancelled( ! inc->cancelled() ); | 3288 | inc->setCancelled( ! inc->cancelled() ); |
3341 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3289 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3342 | updateView(); | 3290 | updateView(); |
3343 | } | 3291 | } |
3344 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3292 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3345 | { | 3293 | { |
3346 | Incidence * newInc = orgInc->clone(); | 3294 | Incidence * newInc = orgInc->clone(); |
3347 | newInc->recreate(); | 3295 | newInc->recreate(); |
3348 | 3296 | ||
3349 | if ( newInc->typeID() == todoID ) { | 3297 | if ( newInc->typeID() == todoID ) { |
3350 | Todo* t = (Todo*) newInc; | 3298 | Todo* t = (Todo*) newInc; |
3351 | bool cloneSub = false; | 3299 | bool cloneSub = false; |
3352 | if ( orgInc->relations().count() ) { | 3300 | if ( orgInc->relations().count() ) { |
3353 | int result = KMessageBox::warningYesNoCancel(this, | 3301 | int result = KMessageBox::warningYesNoCancel(this, |
3354 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3302 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3355 | i18n("Todo has subtodos"), | 3303 | i18n("Todo has subtodos"), |
3356 | i18n("Yes"), | 3304 | i18n("Yes"), |
3357 | i18n("No")); | 3305 | i18n("No")); |
3358 | 3306 | ||
3359 | if ( result == KMessageBox::Cancel ) { | 3307 | if ( result == KMessageBox::Cancel ) { |
3360 | delete t; | 3308 | delete t; |
3361 | return; | 3309 | return; |
3362 | } | 3310 | } |
3363 | if (result == KMessageBox::Yes) cloneSub = true; | 3311 | if (result == KMessageBox::Yes) cloneSub = true; |
3364 | } | 3312 | } |
3365 | showTodoEditor(); | 3313 | showTodoEditor(); |
3366 | mTodoEditor->editTodo( t ); | 3314 | mTodoEditor->editTodo( t ); |
3367 | if ( mTodoEditor->exec() ) { | 3315 | if ( mTodoEditor->exec() ) { |
3368 | if ( cloneSub ) { | 3316 | if ( cloneSub ) { |
3369 | orgInc->cloneRelations( t ); | 3317 | orgInc->cloneRelations( t ); |
3370 | mCalendar->addIncidenceBranch( t ); | 3318 | mCalendar->addIncidenceBranch( t ); |
3371 | updateView(); | 3319 | updateView(); |
3372 | 3320 | ||
3373 | } else { | 3321 | } else { |
3374 | mCalendar->addTodo( t ); | 3322 | mCalendar->addTodo( t ); |
3375 | updateView(); | 3323 | updateView(); |
3376 | } | 3324 | } |
3377 | } else { | 3325 | } else { |
3378 | delete t; | 3326 | delete t; |
3379 | } | 3327 | } |
3380 | } | 3328 | } |
3381 | else if ( newInc->typeID() == eventID ) { | 3329 | else if ( newInc->typeID() == eventID ) { |
3382 | Event* e = (Event*) newInc; | 3330 | Event* e = (Event*) newInc; |
3383 | showEventEditor(); | 3331 | showEventEditor(); |
3384 | mEventEditor->editEvent( e ); | 3332 | mEventEditor->editEvent( e ); |
3385 | if ( mEventEditor->exec() ) { | 3333 | if ( mEventEditor->exec() ) { |
3386 | mCalendar->addEvent( e ); | 3334 | mCalendar->addEvent( e ); |
3387 | updateView(); | 3335 | updateView(); |
3388 | } else { | 3336 | } else { |
3389 | delete e; | 3337 | delete e; |
3390 | } | 3338 | } |
3391 | } if ( newInc->typeID() == journalID ) { | 3339 | } if ( newInc->typeID() == journalID ) { |
3392 | mCalendar->addJournal( (Journal*) newInc ); | 3340 | mCalendar->addJournal( (Journal*) newInc ); |
3393 | editJournal( (Journal*) newInc ); | 3341 | editJournal( (Journal*) newInc ); |
3394 | } | 3342 | } |
3395 | setActiveWindow(); | 3343 | setActiveWindow(); |
3396 | } | 3344 | } |
3397 | 3345 | ||
3398 | void CalendarView::newEvent() | 3346 | void CalendarView::newEvent() |
3399 | { | 3347 | { |
3400 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3348 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3401 | KOAgendaView *aView = mViewManager->agendaView(); | 3349 | KOAgendaView *aView = mViewManager->agendaView(); |
3402 | if (aView) { | 3350 | if (aView) { |
3403 | if (aView->selectionStart().isValid()) { | 3351 | if (aView->selectionStart().isValid()) { |
3404 | if (aView->selectedIsAllDay()) { | 3352 | if (aView->selectedIsAllDay()) { |
3405 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3353 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3406 | } else { | 3354 | } else { |
3407 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3355 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3408 | } | 3356 | } |
3409 | return; | 3357 | return; |
3410 | } | 3358 | } |
3411 | } | 3359 | } |
3412 | 3360 | ||
3413 | QDate date = mNavigator->selectedDates().first(); | 3361 | QDate date = mNavigator->selectedDates().first(); |
3414 | QDateTime current = QDateTime::currentDateTime(); | 3362 | QDateTime current = QDateTime::currentDateTime(); |
3415 | if ( date <= current.date() ) { | 3363 | if ( date <= current.date() ) { |
3416 | int hour = current.time().hour() +1; | 3364 | int hour = current.time().hour() +1; |
3417 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3365 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3418 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3366 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3419 | } else | 3367 | } else |
3420 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3368 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3421 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3369 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3422 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3370 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3423 | } | 3371 | } |
3424 | 3372 | ||
3425 | void CalendarView::newEvent(QDateTime fh) | 3373 | void CalendarView::newEvent(QDateTime fh) |
3426 | { | 3374 | { |
3427 | newEvent(fh, | 3375 | newEvent(fh, |
3428 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3376 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3429 | } | 3377 | } |
3430 | 3378 | ||
3431 | void CalendarView::newEvent(QDate dt) | 3379 | void CalendarView::newEvent(QDate dt) |
3432 | { | 3380 | { |
3433 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3381 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3434 | QDateTime(dt, QTime(0,0,0)), true); | 3382 | QDateTime(dt, QTime(0,0,0)), true); |
3435 | } | 3383 | } |
3436 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3384 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3437 | { | 3385 | { |
3438 | newEvent(fromHint, toHint, false); | 3386 | newEvent(fromHint, toHint, false); |
3439 | } | 3387 | } |
3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3388 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3441 | { | 3389 | { |
3442 | 3390 | ||
3443 | showEventEditor(); | 3391 | showEventEditor(); |
3444 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3392 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3445 | if ( mFilterView->filtersEnabled() ) { | 3393 | if ( mFilterView->filtersEnabled() ) { |
3446 | CalFilter *filter = mFilterView->selectedFilter(); | 3394 | CalFilter *filter = mFilterView->selectedFilter(); |
3447 | if (filter && filter->showCategories()) { | 3395 | if (filter && filter->showCategories()) { |
3448 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3396 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3449 | } | 3397 | } |
3450 | if ( filter ) | 3398 | if ( filter ) |
3451 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3399 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3452 | } | 3400 | } |
3453 | mEventEditor->exec(); | 3401 | mEventEditor->exec(); |
3454 | setActiveWindow(); | 3402 | setActiveWindow(); |
3455 | } | 3403 | } |
3456 | void CalendarView::todoAdded(Todo * t) | 3404 | void CalendarView::todoAdded(Todo * t) |
3457 | { | 3405 | { |
3458 | 3406 | ||
3459 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3407 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3460 | updateTodoViews(); | 3408 | updateTodoViews(); |
3461 | } | 3409 | } |
3462 | void CalendarView::todoChanged(Todo * t) | 3410 | void CalendarView::todoChanged(Todo * t) |
3463 | { | 3411 | { |
3464 | emit todoModified( t, 4 ); | 3412 | emit todoModified( t, 4 ); |
3465 | // updateTodoViews(); | 3413 | // updateTodoViews(); |
3466 | } | 3414 | } |
3467 | void CalendarView::todoToBeDeleted(Todo *) | 3415 | void CalendarView::todoToBeDeleted(Todo *) |
3468 | { | 3416 | { |
3469 | //qDebug("todoToBeDeleted(Todo *) "); | 3417 | //qDebug("todoToBeDeleted(Todo *) "); |
3470 | updateTodoViews(); | 3418 | updateTodoViews(); |
3471 | } | 3419 | } |
3472 | void CalendarView::todoDeleted() | 3420 | void CalendarView::todoDeleted() |
3473 | { | 3421 | { |
3474 | //qDebug(" todoDeleted()"); | 3422 | //qDebug(" todoDeleted()"); |
3475 | updateTodoViews(); | 3423 | updateTodoViews(); |
3476 | } | 3424 | } |
3477 | 3425 | ||
3478 | 3426 | ||
3479 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3427 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3480 | { | 3428 | { |
3481 | showTodoEditor(); | 3429 | showTodoEditor(); |
3482 | mTodoEditor->newTodo(dt,0,allday); | 3430 | mTodoEditor->newTodo(dt,0,allday); |
3483 | if ( mFilterView->filtersEnabled() ) { | 3431 | if ( mFilterView->filtersEnabled() ) { |
3484 | CalFilter *filter = mFilterView->selectedFilter(); | 3432 | CalFilter *filter = mFilterView->selectedFilter(); |
3485 | if (filter && filter->showCategories()) { | 3433 | if (filter && filter->showCategories()) { |
3486 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3434 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3487 | } | 3435 | } |
3488 | if ( filter ) | 3436 | if ( filter ) |
3489 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3437 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3490 | } | 3438 | } |
3491 | mTodoEditor->exec(); | 3439 | mTodoEditor->exec(); |
3492 | setActiveWindow(); | 3440 | setActiveWindow(); |
3493 | } | 3441 | } |
3494 | 3442 | ||
3495 | void CalendarView::newTodo() | 3443 | void CalendarView::newTodo() |
3496 | { | 3444 | { |
3497 | newTodoDateTime( QDateTime(),true ); | 3445 | newTodoDateTime( QDateTime(),true ); |
3498 | } | 3446 | } |
3499 | 3447 | ||
3500 | void CalendarView::newSubTodo() | 3448 | void CalendarView::newSubTodo() |
3501 | { | 3449 | { |
3502 | Todo *todo = selectedTodo(); | 3450 | Todo *todo = selectedTodo(); |
3503 | if ( todo ) newSubTodo( todo ); | 3451 | if ( todo ) newSubTodo( todo ); |
3504 | } | 3452 | } |
3505 | 3453 | ||
3506 | void CalendarView::newSubTodo(Todo *parentEvent) | 3454 | void CalendarView::newSubTodo(Todo *parentEvent) |
3507 | { | 3455 | { |
3508 | 3456 | ||
3509 | showTodoEditor(); | 3457 | showTodoEditor(); |
3510 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3458 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3511 | mTodoEditor->exec(); | 3459 | mTodoEditor->exec(); |
3512 | setActiveWindow(); | 3460 | setActiveWindow(); |
3513 | } | 3461 | } |
3514 | 3462 | ||
3515 | void CalendarView::newFloatingEvent() | 3463 | void CalendarView::newFloatingEvent() |
3516 | { | 3464 | { |
3517 | DateList tmpList = mNavigator->selectedDates(); | 3465 | DateList tmpList = mNavigator->selectedDates(); |
3518 | QDate date = tmpList.first(); | 3466 | QDate date = tmpList.first(); |
3519 | 3467 | ||
3520 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3468 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3521 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3469 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3522 | } | 3470 | } |
3523 | 3471 | ||
3524 | 3472 | ||
3525 | void CalendarView::editEvent( Event *event ) | 3473 | void CalendarView::editEvent( Event *event ) |
3526 | { | 3474 | { |
3527 | 3475 | ||
3528 | if ( !event ) return; | 3476 | if ( !event ) return; |
3529 | if ( event->isReadOnly() ) { | 3477 | if ( event->isReadOnly() ) { |
3530 | showEvent( event ); | 3478 | showEvent( event ); |
3531 | return; | 3479 | return; |
3532 | } | 3480 | } |
3533 | showEventEditor(); | 3481 | showEventEditor(); |
3534 | mEventEditor->editEvent( event , mFlagEditDescription); | 3482 | mEventEditor->editEvent( event , mFlagEditDescription); |
3535 | mEventEditor->exec(); | 3483 | mEventEditor->exec(); |
3536 | setActiveWindow(); | 3484 | setActiveWindow(); |
3537 | 3485 | ||
3538 | } | 3486 | } |
3539 | void CalendarView::editJournal( Journal *jour ) | 3487 | void CalendarView::editJournal( Journal *jour ) |
3540 | { | 3488 | { |
3541 | if ( !jour ) return; | 3489 | if ( !jour ) return; |
3542 | mDialogManager->hideSearchDialog(); | 3490 | mDialogManager->hideSearchDialog(); |
3543 | mViewManager->showJournalView(); | 3491 | mViewManager->showJournalView(); |
3544 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3492 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3545 | } | 3493 | } |
3546 | void CalendarView::editTodo( Todo *todo ) | 3494 | void CalendarView::editTodo( Todo *todo ) |
3547 | { | 3495 | { |
3548 | if ( !todo ) return; | 3496 | if ( !todo ) return; |
3549 | 3497 | ||
3550 | if ( todo->isReadOnly() ) { | 3498 | if ( todo->isReadOnly() ) { |
3551 | showTodo( todo ); | 3499 | showTodo( todo ); |
3552 | return; | 3500 | return; |
3553 | } | 3501 | } |
3554 | showTodoEditor(); | 3502 | showTodoEditor(); |
3555 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3503 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3556 | mTodoEditor->exec(); | 3504 | mTodoEditor->exec(); |
3557 | setActiveWindow(); | 3505 | setActiveWindow(); |
3558 | 3506 | ||
3559 | } | 3507 | } |
3560 | 3508 | ||
3561 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3509 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3562 | { | 3510 | { |
3563 | if ( !mEventViewerDialog ) { | 3511 | if ( !mEventViewerDialog ) { |
3564 | mEventViewerDialog = new KOEventViewerDialog(0); | 3512 | mEventViewerDialog = new KOEventViewerDialog(0); |
3565 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3513 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3566 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3514 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3567 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3515 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3568 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3516 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3569 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3517 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3570 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3518 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3571 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3519 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3572 | this, SLOT( slotViewerClosed() ) ); | 3520 | this, SLOT( slotViewerClosed() ) ); |
3573 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3521 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3574 | this, SLOT( todoChanged(Todo *) ) ); | 3522 | this, SLOT( todoChanged(Todo *) ) ); |
3575 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3523 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3576 | mEventViewerDialog->resize( 640, 480 ); | 3524 | mEventViewerDialog->resize( 640, 480 ); |
3577 | 3525 | ||
3578 | } | 3526 | } |
3579 | return mEventViewerDialog; | 3527 | return mEventViewerDialog; |
3580 | } | 3528 | } |
3581 | void CalendarView::showEvent(Event *event) | 3529 | void CalendarView::showEvent(Event *event) |
3582 | { | 3530 | { |
3583 | getEventViewerDialog()->setEvent(event); | 3531 | getEventViewerDialog()->setEvent(event); |
3584 | getEventViewerDialog()->showMe(); | 3532 | getEventViewerDialog()->showMe(); |
3585 | } | 3533 | } |
3586 | 3534 | ||
3587 | void CalendarView::showTodo(Todo *event) | 3535 | void CalendarView::showTodo(Todo *event) |
3588 | { | 3536 | { |
3589 | getEventViewerDialog()->setTodo(event); | 3537 | getEventViewerDialog()->setTodo(event); |
3590 | getEventViewerDialog()->showMe(); | 3538 | getEventViewerDialog()->showMe(); |
3591 | } | 3539 | } |
3592 | void CalendarView::showJournal( Journal *jour ) | 3540 | void CalendarView::showJournal( Journal *jour ) |
3593 | { | 3541 | { |
3594 | getEventViewerDialog()->setJournal(jour); | 3542 | getEventViewerDialog()->setJournal(jour); |
3595 | getEventViewerDialog()->showMe(); | 3543 | getEventViewerDialog()->showMe(); |
3596 | 3544 | ||
3597 | } | 3545 | } |
3598 | // void CalendarView::todoModified (Todo *event, int changed) | 3546 | // void CalendarView::todoModified (Todo *event, int changed) |
3599 | // { | 3547 | // { |
3600 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3548 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3601 | // // kdDebug() << "Todo modified and open" << endl; | 3549 | // // kdDebug() << "Todo modified and open" << endl; |
3602 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3550 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3603 | // // temp->modified (changed); | 3551 | // // temp->modified (changed); |
3604 | 3552 | ||
3605 | // // } | 3553 | // // } |
3606 | 3554 | ||
3607 | // mViewManager->updateView(); | 3555 | // mViewManager->updateView(); |
3608 | // } | 3556 | // } |
3609 | 3557 | ||
3610 | void CalendarView::appointment_show() | 3558 | void CalendarView::appointment_show() |
3611 | { | 3559 | { |
3612 | Event *anEvent = 0; | 3560 | Event *anEvent = 0; |
3613 | 3561 | ||
3614 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3562 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3615 | 3563 | ||
3616 | if (mViewManager->currentView()->isEventView()) { | 3564 | if (mViewManager->currentView()->isEventView()) { |
3617 | if ( incidence && incidence->typeID() == eventID ) { | 3565 | if ( incidence && incidence->typeID() == eventID ) { |
3618 | anEvent = static_cast<Event *>(incidence); | 3566 | anEvent = static_cast<Event *>(incidence); |
3619 | } | 3567 | } |
3620 | } | 3568 | } |
3621 | 3569 | ||
3622 | if (!anEvent) { | 3570 | if (!anEvent) { |
3623 | KNotifyClient::beep(); | 3571 | KNotifyClient::beep(); |
3624 | return; | 3572 | return; |
3625 | } | 3573 | } |
3626 | 3574 | ||
3627 | showEvent(anEvent); | 3575 | showEvent(anEvent); |
3628 | } | 3576 | } |
3629 | 3577 | ||
3630 | void CalendarView::appointment_edit() | 3578 | void CalendarView::appointment_edit() |
3631 | { | 3579 | { |
3632 | Event *anEvent = 0; | 3580 | Event *anEvent = 0; |
3633 | 3581 | ||
3634 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3582 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3635 | 3583 | ||
3636 | if (mViewManager->currentView()->isEventView()) { | 3584 | if (mViewManager->currentView()->isEventView()) { |
3637 | if ( incidence && incidence->typeID() == eventID ) { | 3585 | if ( incidence && incidence->typeID() == eventID ) { |
3638 | anEvent = static_cast<Event *>(incidence); | 3586 | anEvent = static_cast<Event *>(incidence); |
3639 | } | 3587 | } |
3640 | } | 3588 | } |
3641 | 3589 | ||
3642 | if (!anEvent) { | 3590 | if (!anEvent) { |
3643 | KNotifyClient::beep(); | 3591 | KNotifyClient::beep(); |
3644 | return; | 3592 | return; |
3645 | } | 3593 | } |
3646 | 3594 | ||
3647 | editEvent(anEvent); | 3595 | editEvent(anEvent); |
3648 | } | 3596 | } |
3649 | 3597 | ||
3650 | void CalendarView::appointment_delete() | 3598 | void CalendarView::appointment_delete() |
3651 | { | 3599 | { |
3652 | Event *anEvent = 0; | 3600 | Event *anEvent = 0; |
3653 | 3601 | ||
3654 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3602 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3655 | 3603 | ||
3656 | if (mViewManager->currentView()->isEventView()) { | 3604 | if (mViewManager->currentView()->isEventView()) { |
3657 | if ( incidence && incidence->typeID() == eventID ) { | 3605 | if ( incidence && incidence->typeID() == eventID ) { |
3658 | anEvent = static_cast<Event *>(incidence); | 3606 | anEvent = static_cast<Event *>(incidence); |
3659 | } | 3607 | } |
3660 | } | 3608 | } |
3661 | 3609 | ||
3662 | if (!anEvent) { | 3610 | if (!anEvent) { |
3663 | KNotifyClient::beep(); | 3611 | KNotifyClient::beep(); |
3664 | return; | 3612 | return; |
3665 | } | 3613 | } |
3666 | 3614 | ||
3667 | deleteEvent(anEvent); | 3615 | deleteEvent(anEvent); |
3668 | } | 3616 | } |
3669 | 3617 | ||
3670 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3618 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3671 | { | 3619 | { |
3672 | if (!sub) return; | 3620 | if (!sub) return; |
3673 | if ( sub->relatedTo() == parent ) | 3621 | if ( sub->relatedTo() == parent ) |
3674 | return; | 3622 | return; |
3675 | sub->setRelatedTo(parent); | 3623 | sub->setRelatedTo(parent); |
3676 | sub->updated(); | 3624 | sub->updated(); |
3677 | setModified(true); | 3625 | setModified(true); |
3678 | updateView(); | 3626 | updateView(); |
3679 | } | 3627 | } |
3680 | void CalendarView::todo_unsub(Todo *anTodo ) | 3628 | void CalendarView::todo_unsub(Todo *anTodo ) |
3681 | { | 3629 | { |
3682 | todo_resub( 0, anTodo ); | 3630 | todo_resub( 0, anTodo ); |
3683 | } | 3631 | } |
3684 | 3632 | ||
3685 | void CalendarView::deleteTodo(Todo *todo) | 3633 | void CalendarView::deleteTodo(Todo *todo) |
3686 | { | 3634 | { |
3687 | if (!todo) { | 3635 | if (!todo) { |
3688 | KNotifyClient::beep(); | 3636 | KNotifyClient::beep(); |
3689 | return; | 3637 | return; |
3690 | } | 3638 | } |
3691 | if (KOPrefs::instance()->mConfirm) { | 3639 | if (KOPrefs::instance()->mConfirm) { |
3692 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3640 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3693 | if (!todo->relations().isEmpty()) { | 3641 | if (!todo->relations().isEmpty()) { |
3694 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3642 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3695 | 3643 | ||
3696 | } | 3644 | } |
3697 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3645 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3698 | case KMessageBox::Continue: // OK | 3646 | case KMessageBox::Continue: // OK |
3699 | bool deleteT = false; | 3647 | bool deleteT = false; |
3700 | if (!todo->relations().isEmpty()) { | 3648 | if (!todo->relations().isEmpty()) { |
3701 | deleteT = removeCompletedSubTodos( todo ); | 3649 | deleteT = removeCompletedSubTodos( todo ); |
3702 | } | 3650 | } |
3703 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3651 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3704 | if ( !deleteT ) { | 3652 | if ( !deleteT ) { |
3705 | checkExternalId( todo ); | 3653 | checkExternalId( todo ); |
3706 | calendar()->deleteTodo(todo); | 3654 | calendar()->deleteTodo(todo); |
3707 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3655 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3708 | updateView(); | 3656 | updateView(); |
3709 | } | 3657 | } |
3710 | break; | 3658 | break; |
3711 | } // switch | 3659 | } // switch |
3712 | } else { | 3660 | } else { |
3713 | checkExternalId( todo ); | 3661 | checkExternalId( todo ); |
3714 | mCalendar->deleteTodo(todo); | 3662 | mCalendar->deleteTodo(todo); |
3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3663 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3716 | updateView(); | 3664 | updateView(); |
3717 | } | 3665 | } |
3718 | 3666 | ||
3719 | emit updateSearchDialog(); | 3667 | emit updateSearchDialog(); |
3720 | } | 3668 | } |
3721 | void CalendarView::deleteJournal(Journal *jour) | 3669 | void CalendarView::deleteJournal(Journal *jour) |
3722 | { | 3670 | { |
3723 | if (!jour) { | 3671 | if (!jour) { |
3724 | KNotifyClient::beep(); | 3672 | KNotifyClient::beep(); |
3725 | return; | 3673 | return; |
3726 | } | 3674 | } |
3727 | if (KOPrefs::instance()->mConfirm) { | 3675 | if (KOPrefs::instance()->mConfirm) { |
3728 | 3676 | ||
3729 | QString des; | 3677 | QString des; |
3730 | if ( !jour->summary().isEmpty() ) { | 3678 | if ( !jour->summary().isEmpty() ) { |
3731 | des = jour->summary(); | 3679 | des = jour->summary(); |
3732 | } else { | 3680 | } else { |
3733 | des = jour->description().left(30); | 3681 | des = jour->description().left(30); |
3734 | des = des.simplifyWhiteSpace (); | 3682 | des = des.simplifyWhiteSpace (); |
3735 | des.replace (QRegExp ("\\n"),"" ); | 3683 | des.replace (QRegExp ("\\n"),"" ); |
3736 | des.replace (QRegExp ("\\r"),"" ); | 3684 | des.replace (QRegExp ("\\r"),"" ); |
3737 | } | 3685 | } |
3738 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3686 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3739 | case KMessageBox::Continue: // OK | 3687 | case KMessageBox::Continue: // OK |
3740 | calendar()->deleteJournal(jour); | 3688 | calendar()->deleteJournal(jour); |
3741 | updateView(); | 3689 | updateView(); |
3742 | break; | 3690 | break; |
3743 | } // switch | 3691 | } // switch |
3744 | } else { | 3692 | } else { |
3745 | calendar()->deleteJournal(jour);; | 3693 | calendar()->deleteJournal(jour);; |
3746 | updateView(); | 3694 | updateView(); |
3747 | } | 3695 | } |
3748 | emit updateSearchDialog(); | 3696 | emit updateSearchDialog(); |
3749 | } | 3697 | } |
3750 | 3698 | ||
3751 | void CalendarView::deleteEvent(Event *anEvent) | 3699 | void CalendarView::deleteEvent(Event *anEvent) |
3752 | { | 3700 | { |
3753 | if (!anEvent) { | 3701 | if (!anEvent) { |
3754 | KNotifyClient::beep(); | 3702 | KNotifyClient::beep(); |
3755 | return; | 3703 | return; |
3756 | } | 3704 | } |
3757 | 3705 | ||
3758 | if (anEvent->recurrence()->doesRecur()) { | 3706 | if (anEvent->recurrence()->doesRecur()) { |
3759 | QDate itemDate = mViewManager->currentSelectionDate(); | 3707 | QDate itemDate = mViewManager->currentSelectionDate(); |
3760 | int km; | 3708 | int km; |
3761 | if (!itemDate.isValid()) { | 3709 | if (!itemDate.isValid()) { |
3762 | //kdDebug() << "Date Not Valid" << endl; | 3710 | //kdDebug() << "Date Not Valid" << endl; |
3763 | if (KOPrefs::instance()->mConfirm) { | 3711 | if (KOPrefs::instance()->mConfirm) { |
3764 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3712 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3765 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3713 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3766 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3714 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3767 | if ( km == KMessageBox::Continue ) | 3715 | if ( km == KMessageBox::Continue ) |
3768 | km = KMessageBox::No; // No = all below | 3716 | km = KMessageBox::No; // No = all below |
3769 | } else | 3717 | } else |
3770 | km = KMessageBox::No; | 3718 | km = KMessageBox::No; |
3771 | } else { | 3719 | } else { |
3772 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3720 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3773 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3721 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3774 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3722 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3775 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3723 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3776 | i18n("All")); | 3724 | i18n("All")); |
3777 | } | 3725 | } |
3778 | switch(km) { | 3726 | switch(km) { |
3779 | 3727 | ||
3780 | case KMessageBox::No: // Continue // all | 3728 | case KMessageBox::No: // Continue // all |
3781 | //qDebug("KMessageBox::No "); | 3729 | //qDebug("KMessageBox::No "); |
3782 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3730 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3783 | schedule(Scheduler::Cancel,anEvent); | 3731 | schedule(Scheduler::Cancel,anEvent); |
3784 | 3732 | ||
3785 | checkExternalId( anEvent); | 3733 | checkExternalId( anEvent); |
3786 | mCalendar->deleteEvent(anEvent); | 3734 | mCalendar->deleteEvent(anEvent); |
3787 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3735 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3788 | break; | 3736 | break; |
3789 | 3737 | ||
3790 | // Disabled because it does not work | 3738 | // Disabled because it does not work |
3791 | //#if 0 | 3739 | //#if 0 |
3792 | case KMessageBox::Yes: // just this one | 3740 | case KMessageBox::Yes: // just this one |
3793 | //QDate qd = mNavigator->selectedDates().first(); | 3741 | //QDate qd = mNavigator->selectedDates().first(); |
3794 | //if (!qd.isValid()) { | 3742 | //if (!qd.isValid()) { |
3795 | // kdDebug() << "no date selected, or invalid date" << endl; | 3743 | // kdDebug() << "no date selected, or invalid date" << endl; |
3796 | // KNotifyClient::beep(); | 3744 | // KNotifyClient::beep(); |
3797 | // return; | 3745 | // return; |
3798 | //} | 3746 | //} |
3799 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3747 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3800 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3748 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3801 | anEvent->addExDate(itemDate); | 3749 | anEvent->addExDate(itemDate); |
3802 | int duration = anEvent->recurrence()->duration(); | 3750 | int duration = anEvent->recurrence()->duration(); |
3803 | if ( duration > 0 ) { | 3751 | if ( duration > 0 ) { |
3804 | anEvent->recurrence()->setDuration( duration - 1 ); | 3752 | anEvent->recurrence()->setDuration( duration - 1 ); |
3805 | } | 3753 | } |
3806 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3754 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3807 | } | 3755 | } |
3808 | break; | 3756 | break; |
3809 | //#endif | 3757 | //#endif |
3810 | } // switch | 3758 | } // switch |
3811 | } else { | 3759 | } else { |
3812 | if (KOPrefs::instance()->mConfirm) { | 3760 | if (KOPrefs::instance()->mConfirm) { |
3813 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3761 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3814 | i18n("\nAre you sure you want\nto delete this event?"), | 3762 | i18n("\nAre you sure you want\nto delete this event?"), |
3815 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3763 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3816 | case KMessageBox::Continue: // OK | 3764 | case KMessageBox::Continue: // OK |
3817 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3765 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3818 | schedule(Scheduler::Cancel,anEvent); | 3766 | schedule(Scheduler::Cancel,anEvent); |
3819 | checkExternalId( anEvent); | 3767 | checkExternalId( anEvent); |
3820 | mCalendar->deleteEvent(anEvent); | 3768 | mCalendar->deleteEvent(anEvent); |
3821 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3769 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3822 | break; | 3770 | break; |
3823 | } // switch | 3771 | } // switch |
3824 | } else { | 3772 | } else { |
3825 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3773 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3826 | schedule(Scheduler::Cancel,anEvent); | 3774 | schedule(Scheduler::Cancel,anEvent); |
3827 | checkExternalId( anEvent); | 3775 | checkExternalId( anEvent); |
3828 | mCalendar->deleteEvent(anEvent); | 3776 | mCalendar->deleteEvent(anEvent); |
3829 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3777 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3830 | } | 3778 | } |
3831 | } // if-else | 3779 | } // if-else |
3832 | emit updateSearchDialog(); | 3780 | emit updateSearchDialog(); |
3833 | } | 3781 | } |
3834 | 3782 | ||
3835 | bool CalendarView::deleteEvent(const QString &uid) | 3783 | bool CalendarView::deleteEvent(const QString &uid) |
3836 | { | 3784 | { |
3837 | Event *ev = mCalendar->event(uid); | 3785 | Event *ev = mCalendar->event(uid); |
3838 | if (ev) { | 3786 | if (ev) { |
3839 | deleteEvent(ev); | 3787 | deleteEvent(ev); |
3840 | return true; | 3788 | return true; |
3841 | } else { | 3789 | } else { |
3842 | return false; | 3790 | return false; |
3843 | } | 3791 | } |
3844 | } | 3792 | } |
3845 | 3793 | ||
3846 | /*****************************************************************************/ | 3794 | /*****************************************************************************/ |
3847 | 3795 | ||
3848 | void CalendarView::action_mail() | 3796 | void CalendarView::action_mail() |
3849 | { | 3797 | { |
3850 | #ifndef KORG_NOMAIL | 3798 | #ifndef KORG_NOMAIL |
3851 | KOMailClient mailClient; | 3799 | KOMailClient mailClient; |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index b290020..779f12e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2261 +1,2265 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | 63 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | //delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 156 | int secs = QTime::currentTime().second(); |
157 | minutes->start( (60 - secs +1)*1000 ,true); | 157 | minutes->start( (60 - secs +1)*1000 ,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
183 | } | 183 | } |
184 | 184 | ||
185 | /* | 185 | /* |
186 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
187 | all-day events. | 187 | all-day events. |
188 | */ | 188 | */ |
189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
190 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
191 | { | 191 | { |
192 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
193 | blockResize = false; | 193 | blockResize = false; |
194 | mColumns = columns; | 194 | mColumns = columns; |
195 | mRows = 1; | 195 | mRows = 1; |
196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
198 | mAllDayMode = true; | 198 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 201 | #endif |
202 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
203 | init(); | 203 | init(); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
208 | { | 208 | { |
209 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
214 | { | 214 | { |
215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
220 | { | 220 | { |
221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void KOAgenda::init() | 225 | void KOAgenda::init() |
226 | { | 226 | { |
227 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
229 | 229 | ||
230 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
232 | QString pathString = ""; | 232 | QString pathString = ""; |
233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
234 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
235 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
236 | } else | 236 | } else |
237 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
238 | 238 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
251 | #endif | 251 | #endif |
252 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 258 | //enableClipper(true); |
259 | 259 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
263 | 263 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 267 | ||
268 | mStartCellX = 0; | 268 | mStartCellX = 0; |
269 | mStartCellY = 0; | 269 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
272 | 272 | ||
273 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
276 | 276 | ||
277 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
279 | 279 | ||
280 | mClickedItem = 0; | 280 | mClickedItem = 0; |
281 | 281 | ||
282 | mActionItem = 0; | 282 | mActionItem = 0; |
283 | mActionType = NOP; | 283 | mActionType = NOP; |
284 | mItemMoved = false; | 284 | mItemMoved = false; |
285 | 285 | ||
286 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
287 | 287 | ||
288 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
289 | 289 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 291 | ||
292 | viewport()->update(); | 292 | viewport()->update(); |
293 | 293 | ||
294 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 296 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
303 | else | 303 | else |
304 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
305 | 305 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 307 | ||
308 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
309 | 309 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
312 | 312 | ||
313 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 314 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
316 | else { | 316 | else { |
317 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
319 | } | 319 | } |
320 | mPopupKind = 0; | 320 | mPopupKind = 0; |
321 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 322 | mInvalidPixmap = false; |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | 326 | void KOAgenda::shrinkPixmap() |
327 | { | 327 | { |
328 | mPaintPixmap.resize( 20,20); | 328 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 329 | mInvalidPixmap = true; |
330 | } | 330 | } |
331 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
332 | { | 332 | { |
333 | emit sendPing(); | 333 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 335 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 337 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
342 | { | 342 | { |
343 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
346 | //item->hide(); | 346 | //item->hide(); |
347 | } | 347 | } |
348 | mItems.clear(); | 348 | mItems.clear(); |
349 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
350 | clearSelection(); | 350 | clearSelection(); |
351 | } | 351 | } |
352 | 352 | ||
353 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
354 | { | 354 | { |
355 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
361 | { | 361 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
367 | { | 367 | { |
368 | if (columns == 0) { | 368 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | clear(); | 372 | clear(); |
373 | mColumns = columns; | 373 | mColumns = columns; |
374 | computeSizes(); | 374 | computeSizes(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* | 377 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 380 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 382 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 384 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 390 | ||
391 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
392 | if (!mActionItem) | 392 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
394 | return true; | 394 | return true; |
395 | 395 | ||
396 | default: | 396 | default: |
397 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
401 | { | 401 | { |
402 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 404 | if (mActionItem ) { |
405 | endItemAction(); | 405 | endItemAction(); |
406 | } | 406 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 408 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 414 | ||
415 | } | 415 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 420 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
424 | 424 | ||
425 | } | 425 | } |
426 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 427 | mPopupItem = 0; |
428 | mPopupKind = 0; | 428 | mPopupKind = 0; |
429 | } | 429 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 431 | { |
432 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 435 | item->initColor (); |
436 | item->updateItem(); | 436 | item->updateItem(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 441 | { |
442 | 442 | ||
443 | if ( mInvalidPixmap ) { | 443 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 444 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 445 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 446 | computeSizes(); |
447 | emit updateViewSignal(); | 447 | emit updateViewSignal(); |
448 | return true; | 448 | return true; |
449 | } | 449 | } |
450 | emit sendPing(); | 450 | emit sendPing(); |
451 | static int startX = 0; | 451 | static int startX = 0; |
452 | static int startY = 0; | 452 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
455 | 455 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
463 | dX = -dX; | 463 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
466 | dY = -dY; | 466 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | return true; | 471 | return true; |
472 | } | 472 | } |
473 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
479 | dX = -dX; | 479 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
482 | dY = -dY; | 482 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | return true; | 487 | return true; |
488 | } | 488 | } |
489 | QPoint viewportPos; | 489 | QPoint viewportPos; |
490 | if (object != viewport()) { | 490 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 493 | } else { |
494 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
495 | } | 495 | } |
496 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 497 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
500 | #endif | 500 | #endif |
501 | switch (me->type()) { | 501 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
506 | } | 506 | } |
507 | blockMoving = true; | 507 | blockMoving = true; |
508 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
519 | else | 519 | else |
520 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
521 | } | 521 | } |
522 | bool border = false; | 522 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
525 | diff *= -1; | 525 | diff *= -1; |
526 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
527 | border = true; | 527 | border = true; |
528 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
529 | } | 529 | } |
530 | if ( ! border ) { | 530 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
533 | diff *= -1; | 533 | diff *= -1; |
534 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
535 | border = true; | 535 | border = true; |
536 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | } else { // not allday | 540 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
546 | else | 546 | else |
547 | minH = (blockmoveDist/2); | 547 | minH = (blockmoveDist/2); |
548 | } | 548 | } |
549 | bool border = false; | 549 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 550 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 551 | if ( diff < 0 ) |
552 | diff *= -1; | 552 | diff *= -1; |
553 | if ( diff < minH ) { | 553 | if ( diff < minH ) { |
554 | border = true; | 554 | border = true; |
555 | objIsNotViewport = false; | 555 | objIsNotViewport = false; |
556 | } | 556 | } |
557 | if ( ! border ) { | 557 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 559 | if ( diff < 0 ) |
560 | diff *= -1; | 560 | diff *= -1; |
561 | if ( diff < minH ) { | 561 | if ( diff < minH ) { |
562 | border = true; | 562 | border = true; |
563 | objIsNotViewport = false; | 563 | objIsNotViewport = false; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | } | 566 | } |
567 | } | 567 | } |
568 | } | 568 | } |
569 | if ( objIsNotViewport ) { | 569 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 570 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 571 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 572 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 573 | mPopupKind = 3; |
574 | popupMenu(); | 574 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 575 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 576 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 577 | if (mActionItem) { |
578 | emit signalClearSelection(); | 578 | emit signalClearSelection(); |
579 | slotClearSelection(); | 579 | slotClearSelection(); |
580 | selectItem(mActionItem); | 580 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 581 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
583 | mActionItem = 0; | 583 | mActionItem = 0; |
584 | } else { | 584 | } else { |
585 | startItemAction(viewportPos); | 585 | startItemAction(viewportPos); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } else { // ---------- viewport() | 589 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 590 | mPopupItem = 0; |
591 | mPopupKind = 2; | 591 | mPopupKind = 2; |
592 | selectItem(0); | 592 | selectItem(0); |
593 | mActionItem = 0; | 593 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 594 | if (me->button() == RightButton) { |
595 | int x,y; | 595 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 597 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 598 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 599 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 600 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 601 | mStartCellX = gx; |
602 | mStartCellY = gy; | 602 | mStartCellY = gy; |
603 | mPopupKind = 4; | 603 | mPopupKind = 4; |
604 | popupMenu(); | 604 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 605 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 606 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 607 | startSelectAction(viewportPos); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | 611 | ||
612 | case QEvent::MouseButtonRelease: | 612 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 613 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 614 | mPopupTimer->stop(); |
615 | } | 615 | } |
616 | if (object != viewport()) { | 616 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 617 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 618 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 622 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 623 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 624 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 625 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 626 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 627 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 628 | mActionItem = 0; |
629 | mActionType = NOP; | 629 | mActionType = NOP; |
630 | mItemMoved = 0; | 630 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 631 | mLeftMouseDown = false; |
632 | return true; | 632 | return true; |
633 | } | 633 | } |
634 | endItemAction(); | 634 | endItemAction(); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | } else { // ---------- viewport() | 638 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 640 | endSelectAction( true ); // emit new event signal |
641 | } | 641 | } |
642 | } | 642 | } |
643 | if (me->button() == LeftButton) | 643 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 644 | mLeftMouseDown = false; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case QEvent::MouseMove: | 648 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 649 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 650 | if ( !mLeftMouseDown ) |
651 | return false; | 651 | return false; |
652 | if ( blockMoving ) { | 652 | if ( blockMoving ) { |
653 | int dX, dY; | 653 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 654 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 655 | if ( dX < 0 ) |
656 | dX = -dX; | 656 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 657 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 658 | if ( dY < 0 ) |
659 | dY = -dY; | 659 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 662 | blockMoving = false; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | if ( ! blockMoving ) | 665 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 666 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 667 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 669 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 670 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 671 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 672 | else { |
673 | if ( !blockMoving ) | 673 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 674 | performItemAction(viewportPos); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | } else { // ---------- viewport() | 677 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 679 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 680 | performSelectAction( viewportPos ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | 684 | ||
685 | case QEvent::MouseButtonDblClick: | 685 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 686 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 687 | if (object == viewport()) { |
688 | selectItem(0); | 688 | selectItem(0); |
689 | int x,y; | 689 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 691 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 692 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 693 | emit newEventSignal(gx,gy); |
694 | } else { | 694 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 696 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 698 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 699 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 700 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 701 | } |
702 | break; | 702 | break; |
703 | 703 | ||
704 | default: | 704 | default: |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | return true; | 707 | return true; |
708 | 708 | ||
709 | } | 709 | } |
710 | 710 | ||
711 | void KOAgenda::newItem( int item ) | 711 | void KOAgenda::newItem( int item ) |
712 | { | 712 | { |
713 | if ( item == 1 ) { //new event | 713 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 714 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 715 | } else |
716 | if ( item == 2 ) { //new event | 716 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 717 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 718 | } else |
719 | { | 719 | { |
720 | emit showDateView( item, mStartCellX ); | 720 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 721 | // 3Day view |
722 | // 4Week view | 722 | // 4Week view |
723 | // 5Month view | 723 | // 5Month view |
724 | // 6Journal view | 724 | // 6Journal view |
725 | } | 725 | } |
726 | } | 726 | } |
727 | void KOAgenda::slotClearSelection() | 727 | void KOAgenda::slotClearSelection() |
728 | { | 728 | { |
729 | if (mSelectionHeight) { | 729 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 730 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 731 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 732 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 733 | clearSelection(); |
734 | repaintContents( selectionX, top, | 734 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 735 | mGridSpacingX, hei ,false ); |
736 | } | 736 | } |
737 | 737 | ||
738 | } | 738 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 739 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 740 | { |
741 | 741 | ||
742 | emit signalClearSelection(); | 742 | emit signalClearSelection(); |
743 | slotClearSelection(); | 743 | slotClearSelection(); |
744 | 744 | ||
745 | mActionType = SELECT; | 745 | mActionType = SELECT; |
746 | 746 | ||
747 | int x,y; | 747 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 749 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 750 | contentsToGrid(x,y,gx,gy); |
751 | 751 | ||
752 | mStartCellX = gx; | 752 | mStartCellX = gx; |
753 | mStartCellY = gy; | 753 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 754 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 755 | mCurrentCellY = gy; |
756 | 756 | ||
757 | // Store new selection | 757 | // Store new selection |
758 | mSelectionCellX = gx; | 758 | mSelectionCellX = gx; |
759 | mSelectionYTop = gy * mGridSpacingY; | 759 | mSelectionYTop = gy * mGridSpacingY; |
760 | mSelectionHeight = mGridSpacingY; | 760 | mSelectionHeight = mGridSpacingY; |
761 | 761 | ||
762 | // Paint new selection | 762 | // Paint new selection |
763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
764 | mGridSpacingX-1, mSelectionHeight ); | 764 | mGridSpacingX-1, mSelectionHeight ); |
765 | } | 765 | } |
766 | 766 | ||
767 | void KOAgenda::performSelectAction(QPoint viewportPos) | 767 | void KOAgenda::performSelectAction(QPoint viewportPos) |
768 | { | 768 | { |
769 | int x,y; | 769 | int x,y; |
770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
771 | int gx,gy; | 771 | int gx,gy; |
772 | contentsToGrid(x,y,gx,gy); | 772 | contentsToGrid(x,y,gx,gy); |
773 | 773 | ||
774 | QPoint clipperPos = clipper()-> | 774 | QPoint clipperPos = clipper()-> |
775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
776 | 776 | ||
777 | // Scroll if cursor was moved to upper or lower end of agenda. | 777 | // Scroll if cursor was moved to upper or lower end of agenda. |
778 | if (clipperPos.y() < mScrollBorderWidth) { | 778 | if (clipperPos.y() < mScrollBorderWidth) { |
779 | mScrollUpTimer.start(mScrollDelay); | 779 | mScrollUpTimer.start(mScrollDelay); |
780 | } else if (visibleHeight() - clipperPos.y() < | 780 | } else if (visibleHeight() - clipperPos.y() < |
781 | mScrollBorderWidth) { | 781 | mScrollBorderWidth) { |
782 | mScrollDownTimer.start(mScrollDelay); | 782 | mScrollDownTimer.start(mScrollDelay); |
783 | } else { | 783 | } else { |
784 | mScrollUpTimer.stop(); | 784 | mScrollUpTimer.stop(); |
785 | mScrollDownTimer.stop(); | 785 | mScrollDownTimer.stop(); |
786 | } | 786 | } |
787 | 787 | ||
788 | if ( gy > mCurrentCellY ) { | 788 | if ( gy > mCurrentCellY ) { |
789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
790 | 790 | ||
791 | 791 | ||
792 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 792 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
794 | mGridSpacingX, mSelectionYTop, | 794 | mGridSpacingX, mSelectionYTop, |
795 | mGridSpacingX, mSelectionHeight , false); | 795 | mGridSpacingX, mSelectionHeight , false); |
796 | 796 | ||
797 | mCurrentCellY = gy; | 797 | mCurrentCellY = gy; |
798 | } else if ( gy < mCurrentCellY ) { | 798 | } else if ( gy < mCurrentCellY ) { |
799 | if ( gy >= mStartCellY ) { | 799 | if ( gy >= mStartCellY ) { |
800 | int selectionHeight = mSelectionHeight; | 800 | int selectionHeight = mSelectionHeight; |
801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
802 | 802 | ||
803 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 803 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
805 | mGridSpacingX, mSelectionYTop, | 805 | mGridSpacingX, mSelectionYTop, |
806 | mGridSpacingX, selectionHeight,false ); | 806 | mGridSpacingX, selectionHeight,false ); |
807 | 807 | ||
808 | mCurrentCellY = gy; | 808 | mCurrentCellY = gy; |
809 | } else { | 809 | } else { |
810 | } | 810 | } |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 814 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
815 | { | 815 | { |
816 | mActionType = NOP; | 816 | mActionType = NOP; |
817 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
819 | 819 | ||
820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | void KOAgenda::startItemAction(QPoint viewportPos) | 826 | void KOAgenda::startItemAction(QPoint viewportPos) |
827 | { | 827 | { |
828 | int x,y; | 828 | int x,y; |
829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
830 | int gx,gy; | 830 | int gx,gy; |
831 | contentsToGrid(x,y,gx,gy); | 831 | contentsToGrid(x,y,gx,gy); |
832 | 832 | ||
833 | mStartCellX = gx; | 833 | mStartCellX = gx; |
834 | mStartCellY = gy; | 834 | mStartCellY = gy; |
835 | mCurrentCellX = gx; | 835 | mCurrentCellX = gx; |
836 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
837 | 837 | ||
838 | if (mAllDayMode) { | 838 | if (mAllDayMode) { |
839 | int gridDistanceX = (x - gx * mGridSpacingX); | 839 | int gridDistanceX = (x - gx * mGridSpacingX); |
840 | if (gridDistanceX < mResizeBorderWidth && | 840 | if (gridDistanceX < mResizeBorderWidth && |
841 | mActionItem->cellX() == mCurrentCellX) { | 841 | mActionItem->cellX() == mCurrentCellX) { |
842 | mActionType = RESIZELEFT; | 842 | mActionType = RESIZELEFT; |
843 | setCursor(sizeHorCursor); | 843 | setCursor(sizeHorCursor); |
844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
845 | mActionItem->cellXWidth() == mCurrentCellX) { | 845 | mActionItem->cellXWidth() == mCurrentCellX) { |
846 | mActionType = RESIZERIGHT; | 846 | mActionType = RESIZERIGHT; |
847 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
848 | } else { | 848 | } else { |
849 | mActionType = MOVE; | 849 | mActionType = MOVE; |
850 | mActionItem->startMove(); | 850 | mActionItem->startMove(); |
851 | setCursor(sizeAllCursor); | 851 | setCursor(sizeAllCursor); |
852 | } | 852 | } |
853 | } else { | 853 | } else { |
854 | int gridDistanceY = (y - gy * mGridSpacingY); | 854 | int gridDistanceY = (y - gy * mGridSpacingY); |
855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
856 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 856 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
857 | mActionItem->cellYTop() == mCurrentCellY && | 857 | mActionItem->cellYTop() == mCurrentCellY && |
858 | !mActionItem->firstMultiItem()) { | 858 | !mActionItem->firstMultiItem()) { |
859 | mActionType = RESIZETOP; | 859 | mActionType = RESIZETOP; |
860 | setCursor(sizeVerCursor); | 860 | setCursor(sizeVerCursor); |
861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
862 | mActionItem->cellYBottom() == mCurrentCellY && | 862 | mActionItem->cellYBottom() == mCurrentCellY && |
863 | !mActionItem->lastMultiItem()) { | 863 | !mActionItem->lastMultiItem()) { |
864 | mActionType = RESIZEBOTTOM; | 864 | mActionType = RESIZEBOTTOM; |
865 | setCursor(sizeVerCursor); | 865 | setCursor(sizeVerCursor); |
866 | } else { | 866 | } else { |
867 | mActionType = MOVE; | 867 | mActionType = MOVE; |
868 | mActionItem->startMove(); | 868 | mActionItem->startMove(); |
869 | setCursor(sizeAllCursor); | 869 | setCursor(sizeAllCursor); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void KOAgenda::performItemAction(QPoint viewportPos) | 874 | void KOAgenda::performItemAction(QPoint viewportPos) |
875 | { | 875 | { |
876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
877 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 877 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
879 | // point = clipper()->mapFromGlobal(point); | 879 | // point = clipper()->mapFromGlobal(point); |
880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
881 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 881 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
882 | int x,y; | 882 | int x,y; |
883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
885 | int gx,gy; | 885 | int gx,gy; |
886 | contentsToGrid(x,y,gx,gy); | 886 | contentsToGrid(x,y,gx,gy); |
887 | QPoint clipperPos = clipper()-> | 887 | QPoint clipperPos = clipper()-> |
888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
889 | 889 | ||
890 | // Cursor left active agenda area. | 890 | // Cursor left active agenda area. |
891 | // This starts a drag. | 891 | // This starts a drag. |
892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
894 | if ( mActionType == MOVE ) { | 894 | if ( mActionType == MOVE ) { |
895 | mScrollUpTimer.stop(); | 895 | mScrollUpTimer.stop(); |
896 | mScrollDownTimer.stop(); | 896 | mScrollDownTimer.stop(); |
897 | mActionItem->resetMove(); | 897 | mActionItem->resetMove(); |
898 | placeSubCells( mActionItem ); | 898 | placeSubCells( mActionItem ); |
899 | // emit startDragSignal( mActionItem->incidence() ); | 899 | // emit startDragSignal( mActionItem->incidence() ); |
900 | setCursor( arrowCursor ); | 900 | setCursor( arrowCursor ); |
901 | mActionItem = 0; | 901 | mActionItem = 0; |
902 | mActionType = NOP; | 902 | mActionType = NOP; |
903 | mItemMoved = 0; | 903 | mItemMoved = 0; |
904 | return; | 904 | return; |
905 | } | 905 | } |
906 | } else { | 906 | } else { |
907 | switch ( mActionType ) { | 907 | switch ( mActionType ) { |
908 | case MOVE: | 908 | case MOVE: |
909 | setCursor( sizeAllCursor ); | 909 | setCursor( sizeAllCursor ); |
910 | break; | 910 | break; |
911 | case RESIZETOP: | 911 | case RESIZETOP: |
912 | case RESIZEBOTTOM: | 912 | case RESIZEBOTTOM: |
913 | setCursor( sizeVerCursor ); | 913 | setCursor( sizeVerCursor ); |
914 | break; | 914 | break; |
915 | case RESIZELEFT: | 915 | case RESIZELEFT: |
916 | case RESIZERIGHT: | 916 | case RESIZERIGHT: |
917 | setCursor( sizeHorCursor ); | 917 | setCursor( sizeHorCursor ); |
918 | break; | 918 | break; |
919 | default: | 919 | default: |
920 | setCursor( arrowCursor ); | 920 | setCursor( arrowCursor ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | 923 | ||
924 | // Scroll if item was moved to upper or lower end of agenda. | 924 | // Scroll if item was moved to upper or lower end of agenda. |
925 | if (clipperPos.y() < mScrollBorderWidth) { | 925 | if (clipperPos.y() < mScrollBorderWidth) { |
926 | mScrollUpTimer.start(mScrollDelay); | 926 | mScrollUpTimer.start(mScrollDelay); |
927 | } else if (visibleHeight() - clipperPos.y() < | 927 | } else if (visibleHeight() - clipperPos.y() < |
928 | mScrollBorderWidth) { | 928 | mScrollBorderWidth) { |
929 | mScrollDownTimer.start(mScrollDelay); | 929 | mScrollDownTimer.start(mScrollDelay); |
930 | } else { | 930 | } else { |
931 | mScrollUpTimer.stop(); | 931 | mScrollUpTimer.stop(); |
932 | mScrollDownTimer.stop(); | 932 | mScrollDownTimer.stop(); |
933 | } | 933 | } |
934 | 934 | ||
935 | // Move or resize item if necessary | 935 | // Move or resize item if necessary |
936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
937 | mItemMoved = true; | 937 | mItemMoved = true; |
938 | mActionItem->raise(); | 938 | mActionItem->raise(); |
939 | if (mActionType == MOVE) { | 939 | if (mActionType == MOVE) { |
940 | // Move all items belonging to a multi item | 940 | // Move all items belonging to a multi item |
941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
943 | if (!moveItem) moveItem = mActionItem; | 943 | if (!moveItem) moveItem = mActionItem; |
944 | while (moveItem) { | 944 | while (moveItem) { |
945 | int dy; | 945 | int dy; |
946 | if (isMultiItem) dy = 0; | 946 | if (isMultiItem) dy = 0; |
947 | else dy = gy - mCurrentCellY; | 947 | else dy = gy - mCurrentCellY; |
948 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 948 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
949 | int x,y; | 949 | int x,y; |
950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
952 | mGridSpacingY * moveItem->cellHeight()); | 952 | mGridSpacingY * moveItem->cellHeight()); |
953 | moveItem->raise(); | 953 | moveItem->raise(); |
954 | moveChild(moveItem,x,y); | 954 | moveChild(moveItem,x,y); |
955 | moveItem = moveItem->nextMultiItem(); | 955 | moveItem = moveItem->nextMultiItem(); |
956 | } | 956 | } |
957 | } else if (mActionType == RESIZETOP) { | 957 | } else if (mActionType == RESIZETOP) { |
958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
959 | mActionItem->expandTop(gy - mCurrentCellY); | 959 | mActionItem->expandTop(gy - mCurrentCellY); |
960 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
961 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
962 | int x,y; | 962 | int x,y; |
963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
964 | //moveChild(mActionItem,childX(mActionItem),y); | 964 | //moveChild(mActionItem,childX(mActionItem),y); |
965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
966 | } | 966 | } |
967 | } else if (mActionType == RESIZEBOTTOM) { | 967 | } else if (mActionType == RESIZEBOTTOM) { |
968 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 968 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
969 | mActionItem->expandBottom(gy - mCurrentCellY); | 969 | mActionItem->expandBottom(gy - mCurrentCellY); |
970 | mActionItem->resize(mActionItem->width(), | 970 | mActionItem->resize(mActionItem->width(), |
971 | mGridSpacingY * mActionItem->cellHeight()); | 971 | mGridSpacingY * mActionItem->cellHeight()); |
972 | } | 972 | } |
973 | } else if (mActionType == RESIZELEFT) { | 973 | } else if (mActionType == RESIZELEFT) { |
974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
975 | mActionItem->expandLeft(gx - mCurrentCellX); | 975 | mActionItem->expandLeft(gx - mCurrentCellX); |
976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
977 | mActionItem->height()); | 977 | mActionItem->height()); |
978 | int x,y; | 978 | int x,y; |
979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
980 | moveChild(mActionItem,x,childY(mActionItem)); | 980 | moveChild(mActionItem,x,childY(mActionItem)); |
981 | } | 981 | } |
982 | } else if (mActionType == RESIZERIGHT) { | 982 | } else if (mActionType == RESIZERIGHT) { |
983 | if (mCurrentCellX >= mActionItem->cellX()) { | 983 | if (mCurrentCellX >= mActionItem->cellX()) { |
984 | mActionItem->expandRight(gx - mCurrentCellX); | 984 | mActionItem->expandRight(gx - mCurrentCellX); |
985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
986 | mActionItem->height()); | 986 | mActionItem->height()); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | mCurrentCellX = gx; | 989 | mCurrentCellX = gx; |
990 | mCurrentCellY = gy; | 990 | mCurrentCellY = gy; |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | void KOAgenda::endItemAction() | 994 | void KOAgenda::endItemAction() |
995 | { | 995 | { |
996 | 996 | ||
997 | if ( mItemMoved ) { | 997 | if ( mItemMoved ) { |
998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
999 | if ( !placeItem ) { | 999 | if ( !placeItem ) { |
1000 | placeItem = mActionItem; | 1000 | placeItem = mActionItem; |
1001 | } | 1001 | } |
1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1003 | Incidence* oldInc = placeItem->incidence(); | 1003 | Incidence* oldInc = placeItem->incidence(); |
1004 | placeItem->recreateIncidence(); | 1004 | placeItem->recreateIncidence(); |
1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1006 | } | 1006 | } |
1007 | int type = mActionType; | 1007 | int type = mActionType; |
1008 | if ( mAllDayMode ) | 1008 | if ( mAllDayMode ) |
1009 | type = -1; | 1009 | type = -1; |
1010 | KOAgendaItem *modifiedItem = placeItem; | 1010 | KOAgendaItem *modifiedItem = placeItem; |
1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1013 | KOAgendaItem *item; | 1013 | KOAgendaItem *item; |
1014 | 1014 | ||
1015 | if ( placeItem->incidence()->typeID() == todoID ) { | 1015 | if ( placeItem->incidence()->typeID() == todoID ) { |
1016 | mSelectedItem = 0; | 1016 | mSelectedItem = 0; |
1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1019 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1020 | } | 1020 | } |
1021 | else { | 1021 | else { |
1022 | 1022 | ||
1023 | 1023 | ||
1024 | globalFlagBlockAgendaItemPaint = 1; | 1024 | globalFlagBlockAgendaItemPaint = 1; |
1025 | for ( item=oldconflictItems.first(); item != 0; | 1025 | for ( item=oldconflictItems.first(); item != 0; |
1026 | item=oldconflictItems.next() ) { | 1026 | item=oldconflictItems.next() ) { |
1027 | placeSubCells(item); | 1027 | placeSubCells(item); |
1028 | } | 1028 | } |
1029 | while ( placeItem ) { | 1029 | while ( placeItem ) { |
1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1031 | oldconflictItems = placeItem->conflictItems(); | 1031 | oldconflictItems = placeItem->conflictItems(); |
1032 | for ( item=oldconflictItems.first(); item != 0; | 1032 | for ( item=oldconflictItems.first(); item != 0; |
1033 | item=oldconflictItems.next() ) { | 1033 | item=oldconflictItems.next() ) { |
1034 | placeSubCells(item); | 1034 | placeSubCells(item); |
1035 | } | 1035 | } |
1036 | placeSubCells( placeItem ); | 1036 | placeSubCells( placeItem ); |
1037 | placeItem = placeItem->nextMultiItem(); | 1037 | placeItem = placeItem->nextMultiItem(); |
1038 | } | 1038 | } |
1039 | globalFlagBlockAgendaItemPaint = 0; | 1039 | globalFlagBlockAgendaItemPaint = 0; |
1040 | for ( item=oldconflictItems.first(); item != 0; | 1040 | for ( item=oldconflictItems.first(); item != 0; |
1041 | item=oldconflictItems.next() ) { | 1041 | item=oldconflictItems.next() ) { |
1042 | globalFlagBlockAgendaItemUpdate = 0; | 1042 | globalFlagBlockAgendaItemUpdate = 0; |
1043 | item->repaintMe(); | 1043 | item->repaintMe(); |
1044 | globalFlagBlockAgendaItemUpdate = 1; | 1044 | globalFlagBlockAgendaItemUpdate = 1; |
1045 | item->repaint( false ); | 1045 | item->repaint( false ); |
1046 | } | 1046 | } |
1047 | placeItem = modifiedItem; | 1047 | placeItem = modifiedItem; |
1048 | 1048 | ||
1049 | while ( placeItem ) { | 1049 | while ( placeItem ) { |
1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1051 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | placeItem->repaintMe(); | 1052 | placeItem->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1053 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | placeItem->repaint(false); | 1054 | placeItem->repaint(false); |
1055 | placeItem = placeItem->nextMultiItem(); | 1055 | placeItem = placeItem->nextMultiItem(); |
1056 | } | 1056 | } |
1057 | emit itemModified( modifiedItem, mActionType ); | 1057 | emit itemModified( modifiedItem, mActionType ); |
1058 | 1058 | ||
1059 | 1059 | ||
1060 | placeItem = modifiedItem; | 1060 | placeItem = modifiedItem; |
1061 | while ( placeItem ) { | 1061 | while ( placeItem ) { |
1062 | oldconflictItems = placeItem->conflictItems(); | 1062 | oldconflictItems = placeItem->conflictItems(); |
1063 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1064 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1065 | placeSubCells(item); | 1065 | placeSubCells(item); |
1066 | } | 1066 | } |
1067 | placeSubCells( placeItem ); | 1067 | placeSubCells( placeItem ); |
1068 | placeItem = placeItem->nextMultiItem(); | 1068 | placeItem = placeItem->nextMultiItem(); |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | placeItem = modifiedItem; | 1071 | placeItem = modifiedItem; |
1072 | while ( placeItem ) { | 1072 | while ( placeItem ) { |
1073 | oldconflictItems = placeItem->conflictItems(); | 1073 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1074 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1075 | item=oldconflictItems.next() ) { |
1076 | globalFlagBlockAgendaItemUpdate = 0; | 1076 | globalFlagBlockAgendaItemUpdate = 0; |
1077 | item->repaintMe(); | 1077 | item->repaintMe(); |
1078 | globalFlagBlockAgendaItemUpdate = 1; | 1078 | globalFlagBlockAgendaItemUpdate = 1; |
1079 | item->repaint(false); | 1079 | item->repaint(false); |
1080 | } | 1080 | } |
1081 | placeItem = placeItem->nextMultiItem(); | 1081 | placeItem = placeItem->nextMultiItem(); |
1082 | } | 1082 | } |
1083 | /* | 1083 | /* |
1084 | 1084 | ||
1085 | oldconflictItems = modifiedItem->conflictItems(); | 1085 | oldconflictItems = modifiedItem->conflictItems(); |
1086 | for ( item=oldconflictItems.first(); item != 0; | 1086 | for ( item=oldconflictItems.first(); item != 0; |
1087 | item=oldconflictItems.next() ) { | 1087 | item=oldconflictItems.next() ) { |
1088 | globalFlagBlockAgendaItemUpdate = 0; | 1088 | globalFlagBlockAgendaItemUpdate = 0; |
1089 | item->paintMe(false); | 1089 | item->paintMe(false); |
1090 | globalFlagBlockAgendaItemUpdate = 1; | 1090 | globalFlagBlockAgendaItemUpdate = 1; |
1091 | item->repaint(false); | 1091 | item->repaint(false); |
1092 | } | 1092 | } |
1093 | */ | 1093 | */ |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | } | 1098 | } |
1099 | if ( mActionItem ) | 1099 | if ( mActionItem ) |
1100 | emit incidenceSelected( mActionItem->incidence() ); | 1100 | emit incidenceSelected( mActionItem->incidence() ); |
1101 | mScrollUpTimer.stop(); | 1101 | mScrollUpTimer.stop(); |
1102 | mScrollDownTimer.stop(); | 1102 | mScrollDownTimer.stop(); |
1103 | setCursor( arrowCursor ); | 1103 | setCursor( arrowCursor ); |
1104 | mActionItem = 0; | 1104 | mActionItem = 0; |
1105 | mActionType = NOP; | 1105 | mActionType = NOP; |
1106 | mItemMoved = 0; | 1106 | mItemMoved = 0; |
1107 | 1107 | ||
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1111 | { | 1111 | { |
1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1115 | // point = clipper()->mapFromGlobal(point); | 1115 | // point = clipper()->mapFromGlobal(point); |
1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1117 | 1117 | ||
1118 | int x,y; | 1118 | int x,y; |
1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1121 | int gx,gy; | 1121 | int gx,gy; |
1122 | contentsToGrid(x,y,gx,gy); | 1122 | contentsToGrid(x,y,gx,gy); |
1123 | 1123 | ||
1124 | // Change cursor to resize cursor if appropriate | 1124 | // Change cursor to resize cursor if appropriate |
1125 | if (mAllDayMode) { | 1125 | if (mAllDayMode) { |
1126 | int gridDistanceX = (x - gx * mGridSpacingX); | 1126 | int gridDistanceX = (x - gx * mGridSpacingX); |
1127 | if (gridDistanceX < mResizeBorderWidth && | 1127 | if (gridDistanceX < mResizeBorderWidth && |
1128 | moveItem->cellX() == gx) { | 1128 | moveItem->cellX() == gx) { |
1129 | setCursor(sizeHorCursor); | 1129 | setCursor(sizeHorCursor); |
1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1131 | moveItem->cellXWidth() == gx) { | 1131 | moveItem->cellXWidth() == gx) { |
1132 | setCursor(sizeHorCursor); | 1132 | setCursor(sizeHorCursor); |
1133 | } else { | 1133 | } else { |
1134 | setCursor(arrowCursor); | 1134 | setCursor(arrowCursor); |
1135 | } | 1135 | } |
1136 | } else { | 1136 | } else { |
1137 | int gridDistanceY = (y - gy * mGridSpacingY); | 1137 | int gridDistanceY = (y - gy * mGridSpacingY); |
1138 | if (gridDistanceY < mResizeBorderWidth && | 1138 | if (gridDistanceY < mResizeBorderWidth && |
1139 | moveItem->cellYTop() == gy && | 1139 | moveItem->cellYTop() == gy && |
1140 | !moveItem->firstMultiItem()) { | 1140 | !moveItem->firstMultiItem()) { |
1141 | setCursor(sizeVerCursor); | 1141 | setCursor(sizeVerCursor); |
1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1143 | moveItem->cellYBottom() == gy && | 1143 | moveItem->cellYBottom() == gy && |
1144 | !moveItem->lastMultiItem()) { | 1144 | !moveItem->lastMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1145 | setCursor(sizeVerCursor); |
1146 | } else { | 1146 | } else { |
1147 | setCursor(arrowCursor); | 1147 | setCursor(arrowCursor); |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | /* | 1153 | /* |
1154 | Place item in cell and take care that multiple items using the same cell do | 1154 | Place item in cell and take care that multiple items using the same cell do |
1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1156 | it can get in all cases. | 1156 | it can get in all cases. |
1157 | At the moment the method has a bug: When an item is placed only the sub cell | 1157 | At the moment the method has a bug: When an item is placed only the sub cell |
1158 | widths of the items are changed, which are within the Y region the item to | 1158 | widths of the items are changed, which are within the Y region the item to |
1159 | place spans. When the sub cell width change of one of this items affects a | 1159 | place spans. When the sub cell width change of one of this items affects a |
1160 | cell, where other items are, which do not overlap in Y with the item to place, | 1160 | cell, where other items are, which do not overlap in Y with the item to place, |
1161 | the display gets corrupted, although the corruption looks quite nice. | 1161 | the display gets corrupted, although the corruption looks quite nice. |
1162 | */ | 1162 | */ |
1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1164 | { | 1164 | { |
1165 | 1165 | ||
1166 | QPtrList<KOAgendaItem> conflictItems; | 1166 | QPtrList<KOAgendaItem> conflictItems; |
1167 | int maxSubCells = 0; | 1167 | int maxSubCells = 0; |
1168 | QIntDict<KOAgendaItem> subCellDict(7); | 1168 | QIntDict<KOAgendaItem> subCellDict(7); |
1169 | 1169 | ||
1170 | KOAgendaItem *item; | 1170 | KOAgendaItem *item; |
1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1172 | if (item != placeItem) { | 1172 | if (item != placeItem) { |
1173 | if (placeItem->cellX() <= item->cellXWidth() && | 1173 | if (placeItem->cellX() <= item->cellXWidth() && |
1174 | placeItem->cellXWidth() >= item->cellX()) { | 1174 | placeItem->cellXWidth() >= item->cellX()) { |
1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1176 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1176 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1177 | conflictItems.append(item); | 1177 | conflictItems.append(item); |
1178 | if (item->subCells() > maxSubCells) | 1178 | if (item->subCells() > maxSubCells) |
1179 | maxSubCells = item->subCells(); | 1179 | maxSubCells = item->subCells(); |
1180 | subCellDict.insert(item->subCell(),item); | 1180 | subCellDict.insert(item->subCell(),item); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | if (conflictItems.count() > 0) { | 1186 | if (conflictItems.count() > 0) { |
1187 | // Look for unused sub cell and insert item | 1187 | // Look for unused sub cell and insert item |
1188 | int i; | 1188 | int i; |
1189 | for(i=0;i<maxSubCells;++i) { | 1189 | for(i=0;i<maxSubCells;++i) { |
1190 | if (!subCellDict.find(i)) { | 1190 | if (!subCellDict.find(i)) { |
1191 | placeItem->setSubCell(i); | 1191 | placeItem->setSubCell(i); |
1192 | break; | 1192 | break; |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | if (i == maxSubCells) { | 1195 | if (i == maxSubCells) { |
1196 | placeItem->setSubCell(maxSubCells); | 1196 | placeItem->setSubCell(maxSubCells); |
1197 | maxSubCells++; // add new item to number of sub cells | 1197 | maxSubCells++; // add new item to number of sub cells |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | // Prepare for sub cell geometry adjustment | 1200 | // Prepare for sub cell geometry adjustment |
1201 | int newSubCellWidth; | 1201 | int newSubCellWidth; |
1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1204 | conflictItems.append(placeItem); | 1204 | conflictItems.append(placeItem); |
1205 | 1205 | ||
1206 | 1206 | ||
1207 | // Adjust sub cell geometry of all direct conflict items | 1207 | // Adjust sub cell geometry of all direct conflict items |
1208 | for ( item=conflictItems.first(); item != 0; | 1208 | for ( item=conflictItems.first(); item != 0; |
1209 | item=conflictItems.next() ) { | 1209 | item=conflictItems.next() ) { |
1210 | item->setSubCells(maxSubCells); | 1210 | item->setSubCells(maxSubCells); |
1211 | if (mAllDayMode) { | 1211 | if (mAllDayMode) { |
1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1213 | } else { | 1213 | } else { |
1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1215 | } | 1215 | } |
1216 | int x,y; | 1216 | int x,y; |
1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1218 | if (mAllDayMode) { | 1218 | if (mAllDayMode) { |
1219 | y += item->subCell() * newSubCellWidth; | 1219 | y += item->subCell() * newSubCellWidth; |
1220 | } else { | 1220 | } else { |
1221 | x += item->subCell() * newSubCellWidth; | 1221 | x += item->subCell() * newSubCellWidth; |
1222 | } | 1222 | } |
1223 | moveChild(item,x,y); | 1223 | moveChild(item,x,y); |
1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1225 | //item->updateItem(); | 1225 | //item->updateItem(); |
1226 | } | 1226 | } |
1227 | // Adjust sub cell geometry of all conflict items of all conflict items | 1227 | // Adjust sub cell geometry of all conflict items of all conflict items |
1228 | for ( item=conflictItems.first(); item != 0; | 1228 | for ( item=conflictItems.first(); item != 0; |
1229 | item=conflictItems.next() ) { | 1229 | item=conflictItems.next() ) { |
1230 | if ( placeItem != item ) { | 1230 | if ( placeItem != item ) { |
1231 | KOAgendaItem *item2; | 1231 | KOAgendaItem *item2; |
1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1233 | for ( item2=conflictItems2.first(); item2 != 0; | 1233 | for ( item2=conflictItems2.first(); item2 != 0; |
1234 | item2=conflictItems2.next() ) { | 1234 | item2=conflictItems2.next() ) { |
1235 | if ( item2->subCells() != maxSubCells) { | 1235 | if ( item2->subCells() != maxSubCells) { |
1236 | item2->setSubCells(maxSubCells); | 1236 | item2->setSubCells(maxSubCells); |
1237 | if (mAllDayMode) { | 1237 | if (mAllDayMode) { |
1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1239 | } else { | 1239 | } else { |
1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1241 | } | 1241 | } |
1242 | int x,y; | 1242 | int x,y; |
1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1244 | if (mAllDayMode) { | 1244 | if (mAllDayMode) { |
1245 | y += item2->subCell() * newSubCellWidth; | 1245 | y += item2->subCell() * newSubCellWidth; |
1246 | } else { | 1246 | } else { |
1247 | x += item2->subCell() * newSubCellWidth; | 1247 | x += item2->subCell() * newSubCellWidth; |
1248 | } | 1248 | } |
1249 | moveChild(item2,x,y); | 1249 | moveChild(item2,x,y); |
1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | } else { | 1255 | } else { |
1256 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1257 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1260 | int x,y; | 1260 | int x,y; |
1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1262 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1263 | } | 1263 | } |
1264 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1265 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1266 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1267 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1269 | // } | 1269 | // } |
1270 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1274 | { | 1274 | { |
1275 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1276 | return; | 1276 | return; |
1277 | 1277 | ||
1278 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1279 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1280 | qDebug("KO: Upsizing Pixmaps "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1281 | computeSizes(); | 1281 | computeSizes(); |
1282 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1283 | return; | 1283 | return; |
1284 | } | 1284 | } |
1285 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1286 | // currently not working for | 1286 | // currently not working for |
1287 | 1287 | ||
1288 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1289 | #if 0 | 1289 | #if 0 |
1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1291 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1292 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1293 | } | 1293 | } |
1294 | #endif | 1294 | #endif |
1295 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1296 | p->end(); | 1296 | p->end(); |
1297 | int vx, vy; | 1297 | int vx, vy; |
1298 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1300 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1301 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1303 | 1303 | ||
1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1307 | 1307 | ||
1308 | int vxSel, vySel; | 1308 | int vxSel, vySel; |
1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1310 | int off = mSelectionHeight; | 1310 | int off = mSelectionHeight; |
1311 | if ( vySel < 0 ) | 1311 | if ( vySel < 0 ) |
1312 | off += vySel; | 1312 | off += vySel; |
1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1315 | } else { | 1315 | } else { |
1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | if ( mSelectionHeight > 0 ) { | 1319 | if ( mSelectionHeight > 0 ) { |
1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1325 | int hei = mSelectionHeight; | 1325 | int hei = mSelectionHeight; |
1326 | int offset = 0; | 1326 | int offset = 0; |
1327 | while ( hei > 0 ) { | 1327 | while ( hei > 0 ) { |
1328 | int p_hei = 5; | 1328 | int p_hei = 5; |
1329 | if ( hei < 5 ) p_hei = hei; | 1329 | if ( hei < 5 ) p_hei = hei; |
1330 | hei -= 5; | 1330 | hei -= 5; |
1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1332 | offset += 5; | 1332 | offset += 5; |
1333 | } | 1333 | } |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | p->begin( pd ); | 1336 | p->begin( pd ); |
1337 | } else { | 1337 | } else { |
1338 | #if 0 | 1338 | #if 0 |
1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1341 | qDebug("WAUWAU "); | 1341 | qDebug("WAUWAU "); |
1342 | drawContentsToPainter(); | 1342 | drawContentsToPainter(); |
1343 | } | 1343 | } |
1344 | #endif | 1344 | #endif |
1345 | QPaintDevice* pd = p->device(); | 1345 | QPaintDevice* pd = p->device(); |
1346 | p->end(); | 1346 | p->end(); |
1347 | int vx, vy; | 1347 | int vx, vy; |
1348 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1348 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1350 | mSelectionCellX * mGridSpacingX; | 1350 | mSelectionCellX * mGridSpacingX; |
1351 | contentsToViewport ( cx, cy, vx,vy); | 1351 | contentsToViewport ( cx, cy, vx,vy); |
1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1355 | 1355 | ||
1356 | if ( mSelectionHeight > 0 ) { | 1356 | if ( mSelectionHeight > 0 ) { |
1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1362 | int hei = mSelectionHeight; | 1362 | int hei = mSelectionHeight; |
1363 | int offset = 0; | 1363 | int offset = 0; |
1364 | while ( hei > 0 ) { | 1364 | while ( hei > 0 ) { |
1365 | int p_hei = 5; | 1365 | int p_hei = 5; |
1366 | if ( hei < 5 ) p_hei = hei; | 1366 | if ( hei < 5 ) p_hei = hei; |
1367 | hei -= 5; | 1367 | hei -= 5; |
1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1369 | offset += 5; | 1369 | offset += 5; |
1370 | } | 1370 | } |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | p->begin( pd ); | 1373 | p->begin( pd ); |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void KOAgenda::finishUpdate() | 1378 | void KOAgenda::finishUpdate() |
1379 | { | 1379 | { |
1380 | 1380 | ||
1381 | KOAgendaItem *item; | 1381 | KOAgendaItem *item; |
1382 | globalFlagBlockAgendaItemPaint = 1; | 1382 | globalFlagBlockAgendaItemPaint = 1; |
1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1385 | if ( !item->checkLayout() ) { | 1385 | if ( !item->checkLayout() ) { |
1386 | //qDebug(" conflictitem found "); | 1386 | //qDebug(" conflictitem found "); |
1387 | int newSubCellWidth; | 1387 | int newSubCellWidth; |
1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1390 | 1390 | ||
1391 | if (mAllDayMode) { | 1391 | if (mAllDayMode) { |
1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1393 | } else { | 1393 | } else { |
1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1395 | } | 1395 | } |
1396 | int x,y; | 1396 | int x,y; |
1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1398 | if (mAllDayMode) { | 1398 | if (mAllDayMode) { |
1399 | y += item->subCell() * newSubCellWidth; | 1399 | y += item->subCell() * newSubCellWidth; |
1400 | } else { | 1400 | } else { |
1401 | x += item->subCell() * newSubCellWidth; | 1401 | x += item->subCell() * newSubCellWidth; |
1402 | } | 1402 | } |
1403 | moveChild(item,x,y); | 1403 | moveChild(item,x,y); |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1407 | if ( !item->isVisible() ) | 1407 | if ( !item->isVisible() ) |
1408 | item->show(); | 1408 | item->show(); |
1409 | 1409 | ||
1410 | } | 1410 | } |
1411 | globalFlagBlockAgendaItemUpdate = 0; | 1411 | globalFlagBlockAgendaItemUpdate = 0; |
1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1413 | item->repaintMe( ); | 1413 | item->repaintMe( ); |
1414 | } | 1414 | } |
1415 | globalFlagBlockAgendaItemUpdate = 1; | 1415 | globalFlagBlockAgendaItemUpdate = 1; |
1416 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1417 | globalFlagBlockAgendaItemPaint = 0; | 1417 | globalFlagBlockAgendaItemPaint = 0; |
1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1419 | item->repaint( false ); | 1419 | item->repaint( false ); |
1420 | } | 1420 | } |
1421 | marcus_bains(); | 1421 | marcus_bains(); |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | /* | 1424 | /* |
1425 | Draw grid in the background of the agenda. | 1425 | Draw grid in the background of the agenda. |
1426 | */ | 1426 | */ |
1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1428 | { | 1428 | { |
1429 | 1429 | ||
1430 | 1430 | ||
1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1432 | return; | 1432 | return; |
1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1434 | return; | 1434 | return; |
1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1436 | if ( ch < 1 ) | 1436 | if ( ch < 1 ) |
1437 | ch = 1; | 1437 | ch = 1; |
1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1440 | } | 1440 | } |
1441 | mCurPixWid = contentsWidth(); | 1441 | mCurPixWid = contentsWidth(); |
1442 | mCurPixHei = ch; | 1442 | mCurPixHei = ch; |
1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1446 | } | 1446 | } |
1447 | mPixPainter.begin( &mPaintPixmap) ; | 1447 | mPixPainter.begin( &mPaintPixmap) ; |
1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1449 | QPainter * p ; | 1449 | QPainter * p ; |
1450 | if (paint == 0) { | 1450 | if (paint == 0) { |
1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1452 | p = &mPixPainter; | 1452 | p = &mPixPainter; |
1453 | } | 1453 | } |
1454 | else | 1454 | else |
1455 | p = paint ; | 1455 | p = paint ; |
1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1457 | 1457 | ||
1458 | //--cx;++cw; | 1458 | //--cx;++cw; |
1459 | int lGridSpacingY = mGridSpacingY*2; | 1459 | int lGridSpacingY = mGridSpacingY*2; |
1460 | int selDay; | 1460 | int selDay; |
1461 | QDate curDate = QDate::currentDate(); | 1461 | QDate curDate = QDate::currentDate(); |
1462 | if ( !backgroundOnly ) { | 1462 | if ( !backgroundOnly ) { |
1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1464 | { | 1464 | { |
1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1466 | int x1 = cx; | 1466 | int x1 = cx; |
1467 | int y1 = 0; | 1467 | int y1 = 0; |
1468 | if (y1 < cy) y1 = cy; | 1468 | if (y1 < cy) y1 = cy; |
1469 | int x2 = cx+cw-1; | 1469 | int x2 = cx+cw-1; |
1470 | int y2 = contentsHeight(); | 1470 | int y2 = contentsHeight(); |
1471 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1471 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1472 | if (x2 >= x1 && y2 >= y1) { | 1472 | if (x2 >= x1 && y2 >= y1) { |
1473 | int gxStart = selDay; | 1473 | int gxStart = selDay; |
1474 | int gxEnd = gxStart ; | 1474 | int gxEnd = gxStart ; |
1475 | int xStart = KOGlobals::self()->reverseLayout() ? | 1475 | int xStart = KOGlobals::self()->reverseLayout() ? |
1476 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1476 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1477 | gxStart*mGridSpacingX; | 1477 | gxStart*mGridSpacingX; |
1478 | if (xStart < x1) xStart = x1; | 1478 | if (xStart < x1) xStart = x1; |
1479 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1479 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1480 | (mColumns - gxStart)*mGridSpacingX-1 : | 1480 | (mColumns - gxStart)*mGridSpacingX-1 : |
1481 | (gxStart+1)*mGridSpacingX-1; | 1481 | (gxStart+1)*mGridSpacingX-1; |
1482 | if (xEnd > x2) xEnd = x2; | 1482 | if (xEnd > x2) xEnd = x2; |
1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1485 | KOPrefs::instance()->mAgendaBgColor.light()); | 1485 | KOPrefs::instance()->mAgendaBgColor.light()); |
1486 | else | 1486 | else |
1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1488 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1488 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1489 | 1489 | ||
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | } | 1492 | } |
1493 | } | 1493 | } |
1494 | // Highlight working hours | 1494 | // Highlight working hours |
1495 | 1495 | ||
1496 | if ( !backgroundOnly ) | 1496 | if ( !backgroundOnly ) |
1497 | if (mWorkingHoursEnable) { | 1497 | if (mWorkingHoursEnable) { |
1498 | int x1 = cx; | 1498 | int x1 = cx; |
1499 | int y1 = mWorkingHoursYTop; | 1499 | int y1 = mWorkingHoursYTop; |
1500 | if (y1 < cy) y1 = cy; | 1500 | if (y1 < cy) y1 = cy; |
1501 | int x2 = cx+cw-1; | 1501 | int x2 = cx+cw-1; |
1502 | // int x2 = mGridSpacingX * 5 - 1; | 1502 | // int x2 = mGridSpacingX * 5 - 1; |
1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1504 | int y2 = mWorkingHoursYBottom; | 1504 | int y2 = mWorkingHoursYBottom; |
1505 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1505 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1506 | 1506 | ||
1507 | if (x2 >= x1 && y2 >= y1) { | 1507 | if (x2 >= x1 && y2 >= y1) { |
1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1509 | int gxStart = x1/mGridSpacingX; | 1509 | int gxStart = x1/mGridSpacingX; |
1510 | int gxEnd = x2/mGridSpacingX; | 1510 | int gxEnd = x2/mGridSpacingX; |
1511 | while(gxStart <= gxEnd) { | 1511 | while(gxStart <= gxEnd) { |
1512 | if (gxStart < int(mHolidayMask->count()) && | 1512 | if (gxStart < int(mHolidayMask->count()) && |
1513 | !mHolidayMask->at(gxStart)) { | 1513 | !mHolidayMask->at(gxStart)) { |
1514 | int xStart = KOGlobals::self()->reverseLayout() ? | 1514 | int xStart = KOGlobals::self()->reverseLayout() ? |
1515 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1515 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1516 | gxStart*mGridSpacingX; | 1516 | gxStart*mGridSpacingX; |
1517 | if (xStart < x1) xStart = x1; | 1517 | if (xStart < x1) xStart = x1; |
1518 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1518 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1519 | (mColumns - gxStart)*mGridSpacingX-1 : | 1519 | (mColumns - gxStart)*mGridSpacingX-1 : |
1520 | (gxStart+1)*mGridSpacingX-1; | 1520 | (gxStart+1)*mGridSpacingX-1; |
1521 | if (xEnd > x2) xEnd = x2; | 1521 | if (xEnd > x2) xEnd = x2; |
1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1525 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1525 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1526 | else | 1526 | else |
1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1529 | } else { | 1529 | } else { |
1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1531 | KOPrefs::instance()->mWorkingHoursColor); | 1531 | KOPrefs::instance()->mWorkingHoursColor); |
1532 | } | 1532 | } |
1533 | } | 1533 | } |
1534 | ++gxStart; | 1534 | ++gxStart; |
1535 | } | 1535 | } |
1536 | } | 1536 | } |
1537 | } | 1537 | } |
1538 | /* | 1538 | /* |
1539 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1539 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1541 | mSelectionCellX * mGridSpacingX; | 1541 | mSelectionCellX * mGridSpacingX; |
1542 | 1542 | ||
1543 | // Draw selection | 1543 | // Draw selection |
1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1546 | // TODO: paint only part within cx,cy,cw,ch | 1546 | // TODO: paint only part within cx,cy,cw,ch |
1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1549 | } | 1549 | } |
1550 | */ | 1550 | */ |
1551 | // Draw vertical lines of grid | 1551 | // Draw vertical lines of grid |
1552 | 1552 | ||
1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1554 | if ( mGridSpacingX > 0 ) { | 1554 | if ( mGridSpacingX > 0 ) { |
1555 | while (x < cx + cw) { | 1555 | while (x < cx + cw) { |
1556 | p->drawLine(x,cy,x,cy+ch); | 1556 | p->drawLine(x,cy,x,cy+ch); |
1557 | x+=mGridSpacingX; | 1557 | x+=mGridSpacingX; |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | // Draw horizontal lines of grid | 1560 | // Draw horizontal lines of grid |
1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1562 | if ( lGridSpacingY > 0 ) { | 1562 | if ( lGridSpacingY > 0 ) { |
1563 | while (y < cy + ch) { | 1563 | while (y < cy + ch) { |
1564 | p->setPen( SolidLine ); | 1564 | p->setPen( SolidLine ); |
1565 | p->drawLine(cx,y,cx+cw,y); | 1565 | p->drawLine(cx,y,cx+cw,y); |
1566 | y+=lGridSpacingY; | 1566 | y+=lGridSpacingY; |
1567 | p->setPen( DotLine ); | 1567 | p->setPen( DotLine ); |
1568 | p->drawLine(cx,y,cx+cw,y); | 1568 | p->drawLine(cx,y,cx+cw,y); |
1569 | y+=lGridSpacingY; | 1569 | y+=lGridSpacingY; |
1570 | } | 1570 | } |
1571 | p->setPen( SolidLine ); | 1571 | p->setPen( SolidLine ); |
1572 | } | 1572 | } |
1573 | mPixPainter.end() ; | 1573 | mPixPainter.end() ; |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | /* | 1576 | /* |
1577 | Convert srcollview contents coordinates to agenda grid coordinates. | 1577 | Convert srcollview contents coordinates to agenda grid coordinates. |
1578 | */ | 1578 | */ |
1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1580 | { | 1580 | { |
1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1582 | x/mGridSpacingX; | 1582 | x/mGridSpacingX; |
1583 | gy = y/mGridSpacingY; | 1583 | gy = y/mGridSpacingY; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /* | 1586 | /* |
1587 | Convert agenda grid coordinates to scrollview contents coordinates. | 1587 | Convert agenda grid coordinates to scrollview contents coordinates. |
1588 | */ | 1588 | */ |
1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1590 | { | 1590 | { |
1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1592 | gx*mGridSpacingX; | 1592 | gx*mGridSpacingX; |
1593 | y = gy*mGridSpacingY; | 1593 | y = gy*mGridSpacingY; |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | 1596 | ||
1597 | /* | 1597 | /* |
1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1599 | the grid. | 1599 | the grid. |
1600 | */ | 1600 | */ |
1601 | int KOAgenda::timeToY(const QTime &time) | 1601 | int KOAgenda::timeToY(const QTime &time) |
1602 | { | 1602 | { |
1603 | int minutesPerCell = 24 * 60 / mRows; | 1603 | int minutesPerCell = 24 * 60 / mRows; |
1604 | int timeMinutes = time.hour() * 60 + time.minute(); | 1604 | int timeMinutes = time.hour() * 60 + time.minute(); |
1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1606 | return Y; | 1606 | return Y; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | 1609 | ||
1610 | /* | 1610 | /* |
1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1612 | fit into the grid. | 1612 | fit into the grid. |
1613 | */ | 1613 | */ |
1614 | QTime KOAgenda::gyToTime(int gy) | 1614 | QTime KOAgenda::gyToTime(int gy) |
1615 | { | 1615 | { |
1616 | 1616 | ||
1617 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1617 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1618 | 1618 | ||
1619 | int timeSeconds = secondsPerCell * gy; | 1619 | int timeSeconds = secondsPerCell * gy; |
1620 | 1620 | ||
1621 | QTime time( 0, 0, 0 ); | 1621 | QTime time( 0, 0, 0 ); |
1622 | if ( timeSeconds < 24 * 60 * 60 ) { | 1622 | if ( timeSeconds < 24 * 60 * 60 ) { |
1623 | time = time.addSecs(timeSeconds); | 1623 | time = time.addSecs(timeSeconds); |
1624 | } else { | 1624 | } else { |
1625 | time.setHMS( 23, 59, 59 ); | 1625 | time.setHMS( 23, 59, 59 ); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | return time; | 1628 | return time; |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | void KOAgenda::setStartHour(int startHour) | 1631 | void KOAgenda::setStartHour(int startHour) |
1632 | { | 1632 | { |
1633 | int startCell = startHour * mRows / 24; | 1633 | int startCell = startHour * mRows / 24; |
1634 | setContentsPos(0,startCell * gridSpacingY()); | 1634 | setContentsPos(0,startCell * gridSpacingY()); |
1635 | } | 1635 | } |
1636 | QTime KOAgenda::getEndTime() | ||
1637 | { | ||
1638 | return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0); | ||
1639 | } | ||
1636 | void KOAgenda::hideUnused() | 1640 | void KOAgenda::hideUnused() |
1637 | { | 1641 | { |
1638 | // experimental only | 1642 | // experimental only |
1639 | // return; | 1643 | // return; |
1640 | KOAgendaItem *item; | 1644 | KOAgendaItem *item; |
1641 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1645 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1642 | item->hide(); | 1646 | item->hide(); |
1643 | } | 1647 | } |
1644 | } | 1648 | } |
1645 | 1649 | ||
1646 | 1650 | ||
1647 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1651 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1648 | { | 1652 | { |
1649 | 1653 | ||
1650 | KOAgendaItem *fi; | 1654 | KOAgendaItem *fi; |
1651 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1655 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1652 | if ( fi->incidence() == event ) { | 1656 | if ( fi->incidence() == event ) { |
1653 | mUnusedItems.remove(); | 1657 | mUnusedItems.remove(); |
1654 | fi->init( event, qd ); | 1658 | fi->init( event, qd ); |
1655 | return fi; | 1659 | return fi; |
1656 | } | 1660 | } |
1657 | } | 1661 | } |
1658 | fi=mUnusedItems.first(); | 1662 | fi=mUnusedItems.first(); |
1659 | if ( fi ) { | 1663 | if ( fi ) { |
1660 | mUnusedItems.remove(); | 1664 | mUnusedItems.remove(); |
1661 | fi->init( event, qd ); | 1665 | fi->init( event, qd ); |
1662 | return fi; | 1666 | return fi; |
1663 | } | 1667 | } |
1664 | // qDebug("new KOAgendaItem "); | 1668 | // qDebug("new KOAgendaItem "); |
1665 | 1669 | ||
1666 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1670 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1667 | agendaItem->installEventFilter(this); | 1671 | agendaItem->installEventFilter(this); |
1668 | addChild(agendaItem,0,0); | 1672 | addChild(agendaItem,0,0); |
1669 | return agendaItem; | 1673 | return agendaItem; |
1670 | } | 1674 | } |
1671 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1675 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1672 | { | 1676 | { |
1673 | KOAgendaItem *item; | 1677 | KOAgendaItem *item; |
1674 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1678 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1675 | if ( item->incidence() == todo ) { | 1679 | if ( item->incidence() == todo ) { |
1676 | mItems.remove(); | 1680 | mItems.remove(); |
1677 | return item; | 1681 | return item; |
1678 | } | 1682 | } |
1679 | } | 1683 | } |
1680 | return 0; | 1684 | return 0; |
1681 | } | 1685 | } |
1682 | 1686 | ||
1683 | 1687 | ||
1684 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1688 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1685 | { | 1689 | { |
1686 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1690 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1687 | KOAgendaItem *item; | 1691 | KOAgendaItem *item; |
1688 | item = getItemForTodo ( todo ); | 1692 | item = getItemForTodo ( todo ); |
1689 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1693 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1690 | if ( item ) { | 1694 | if ( item ) { |
1691 | blockSignals( true ); | 1695 | blockSignals( true ); |
1692 | //qDebug("item found "); | 1696 | //qDebug("item found "); |
1693 | item->hide(); | 1697 | item->hide(); |
1694 | item->setCellX(-2, -1 ); | 1698 | item->setCellX(-2, -1 ); |
1695 | item->select(false); | 1699 | item->select(false); |
1696 | mUnusedItems.append( item ); | 1700 | mUnusedItems.append( item ); |
1697 | mItems.remove( item ); | 1701 | mItems.remove( item ); |
1698 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1702 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1699 | KOAgendaItem *itemit; | 1703 | KOAgendaItem *itemit; |
1700 | //globalFlagBlockAgendaItemPaint = 1; | 1704 | //globalFlagBlockAgendaItemPaint = 1; |
1701 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1705 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1702 | itemit=oldconflictItems.next() ) { | 1706 | itemit=oldconflictItems.next() ) { |
1703 | if ( itemit != item ) | 1707 | if ( itemit != item ) |
1704 | placeSubCells(itemit); | 1708 | placeSubCells(itemit); |
1705 | } | 1709 | } |
1706 | qApp->processEvents(); | 1710 | qApp->processEvents(); |
1707 | //globalFlagBlockAgendaItemPaint = 0; | 1711 | //globalFlagBlockAgendaItemPaint = 0; |
1708 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1712 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1709 | itemit=oldconflictItems.next() ) { | 1713 | itemit=oldconflictItems.next() ) { |
1710 | globalFlagBlockAgendaItemUpdate = 0; | 1714 | globalFlagBlockAgendaItemUpdate = 0; |
1711 | if ( itemit != item ) | 1715 | if ( itemit != item ) |
1712 | itemit->repaintMe(); | 1716 | itemit->repaintMe(); |
1713 | globalFlagBlockAgendaItemUpdate = 1; | 1717 | globalFlagBlockAgendaItemUpdate = 1; |
1714 | //qDebug("sigleshot "); | 1718 | //qDebug("sigleshot "); |
1715 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1719 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1716 | //itemit->repaint( false ); repaintItem() | 1720 | //itemit->repaint( false ); repaintItem() |
1717 | } | 1721 | } |
1718 | blockSignals( false ); | 1722 | blockSignals( false ); |
1719 | } | 1723 | } |
1720 | if ( remove ) { | 1724 | if ( remove ) { |
1721 | //qDebug("remove****************************************** "); | 1725 | //qDebug("remove****************************************** "); |
1722 | return; | 1726 | return; |
1723 | } | 1727 | } |
1724 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1728 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1725 | return; | 1729 | return; |
1726 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1730 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1727 | QDate currentDate = QDate::currentDate(); | 1731 | QDate currentDate = QDate::currentDate(); |
1728 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1732 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1729 | QDateTime dt; | 1733 | QDateTime dt; |
1730 | if ( todo->hasCompletedDate() ) | 1734 | if ( todo->hasCompletedDate() ) |
1731 | dt = todo->completed(); | 1735 | dt = todo->completed(); |
1732 | else | 1736 | else |
1733 | dt = todo->dtDue(); | 1737 | dt = todo->dtDue(); |
1734 | if ( overdue ) { | 1738 | if ( overdue ) { |
1735 | days += todo->dtDue().date().daysTo( currentDate ); | 1739 | days += todo->dtDue().date().daysTo( currentDate ); |
1736 | } | 1740 | } |
1737 | else | 1741 | else |
1738 | currentDate = dt.date(); | 1742 | currentDate = dt.date(); |
1739 | 1743 | ||
1740 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1744 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1741 | if ( ! mAllDayMode ) return; | 1745 | if ( ! mAllDayMode ) return; |
1742 | // aldayagenda | 1746 | // aldayagenda |
1743 | globalFlagBlockAgendaItemPaint = 1; | 1747 | globalFlagBlockAgendaItemPaint = 1; |
1744 | item = insertAllDayItem(todo, currentDate,days, days); | 1748 | item = insertAllDayItem(todo, currentDate,days, days); |
1745 | item->show(); | 1749 | item->show(); |
1746 | 1750 | ||
1747 | } | 1751 | } |
1748 | else { | 1752 | else { |
1749 | if ( mAllDayMode ) return; | 1753 | if ( mAllDayMode ) return; |
1750 | // mAgenda | 1754 | // mAgenda |
1751 | globalFlagBlockAgendaItemPaint = 1; | 1755 | globalFlagBlockAgendaItemPaint = 1; |
1752 | int endY = timeToY(dt.time()) - 1; | 1756 | int endY = timeToY(dt.time()) - 1; |
1753 | int hi = 12/KOPrefs::instance()->mHourSize; | 1757 | int hi = 12/KOPrefs::instance()->mHourSize; |
1754 | int startY = endY - 1-hi; | 1758 | int startY = endY - 1-hi; |
1755 | item = insertItem(todo,currentDate,days,startY,endY); | 1759 | item = insertItem(todo,currentDate,days,startY,endY); |
1756 | item->show(); | 1760 | item->show(); |
1757 | } | 1761 | } |
1758 | qApp->processEvents(); | 1762 | qApp->processEvents(); |
1759 | globalFlagBlockAgendaItemPaint = 0; | 1763 | globalFlagBlockAgendaItemPaint = 0; |
1760 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1764 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1761 | KOAgendaItem *itemit; | 1765 | KOAgendaItem *itemit; |
1762 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1766 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1763 | itemit=oldconflictItems.next() ) { | 1767 | itemit=oldconflictItems.next() ) { |
1764 | globalFlagBlockAgendaItemUpdate = 0; | 1768 | globalFlagBlockAgendaItemUpdate = 0; |
1765 | itemit->repaintMe(); | 1769 | itemit->repaintMe(); |
1766 | globalFlagBlockAgendaItemUpdate = 1; | 1770 | globalFlagBlockAgendaItemUpdate = 1; |
1767 | itemit->repaint(); | 1771 | itemit->repaint(); |
1768 | } | 1772 | } |
1769 | globalFlagBlockAgendaItemUpdate = 0; | 1773 | globalFlagBlockAgendaItemUpdate = 0; |
1770 | item->repaintMe(); | 1774 | item->repaintMe(); |
1771 | globalFlagBlockAgendaItemUpdate = 1; | 1775 | globalFlagBlockAgendaItemUpdate = 1; |
1772 | item->repaint(); | 1776 | item->repaint(); |
1773 | } | 1777 | } |
1774 | /* | 1778 | /* |
1775 | Insert KOAgendaItem into agenda. | 1779 | Insert KOAgendaItem into agenda. |
1776 | */ | 1780 | */ |
1777 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1781 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1778 | { | 1782 | { |
1779 | if (mAllDayMode) { | 1783 | if (mAllDayMode) { |
1780 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1784 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1781 | return 0; | 1785 | return 0; |
1782 | } | 1786 | } |
1783 | 1787 | ||
1784 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1788 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1785 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1789 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1786 | 1790 | ||
1787 | int YSize = YBottom - YTop + 1; | 1791 | int YSize = YBottom - YTop + 1; |
1788 | if (YSize < 0) { | 1792 | if (YSize < 0) { |
1789 | YSize = 1; | 1793 | YSize = 1; |
1790 | } | 1794 | } |
1791 | int iheight = mGridSpacingY * YSize; | 1795 | int iheight = mGridSpacingY * YSize; |
1792 | 1796 | ||
1793 | agendaItem->resize(mGridSpacingX,iheight ); | 1797 | agendaItem->resize(mGridSpacingX,iheight ); |
1794 | agendaItem->setCellXY(X,YTop,YBottom); | 1798 | agendaItem->setCellXY(X,YTop,YBottom); |
1795 | agendaItem->setCellXWidth(X); | 1799 | agendaItem->setCellXWidth(X); |
1796 | 1800 | ||
1797 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1801 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1798 | mItems.append(agendaItem); | 1802 | mItems.append(agendaItem); |
1799 | 1803 | ||
1800 | placeSubCells(agendaItem); | 1804 | placeSubCells(agendaItem); |
1801 | 1805 | ||
1802 | //agendaItem->show(); | 1806 | //agendaItem->show(); |
1803 | 1807 | ||
1804 | 1808 | ||
1805 | return agendaItem; | 1809 | return agendaItem; |
1806 | } | 1810 | } |
1807 | 1811 | ||
1808 | 1812 | ||
1809 | /* | 1813 | /* |
1810 | Insert all-day KOAgendaItem into agenda. | 1814 | Insert all-day KOAgendaItem into agenda. |
1811 | */ | 1815 | */ |
1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1816 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1813 | { | 1817 | { |
1814 | if (!mAllDayMode) { | 1818 | if (!mAllDayMode) { |
1815 | return 0; | 1819 | return 0; |
1816 | } | 1820 | } |
1817 | 1821 | ||
1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1822 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1819 | 1823 | ||
1820 | agendaItem->setCellXY(XBegin,0,0); | 1824 | agendaItem->setCellXY(XBegin,0,0); |
1821 | agendaItem->setCellXWidth(XEnd); | 1825 | agendaItem->setCellXWidth(XEnd); |
1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1826 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1823 | 1827 | ||
1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1828 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1825 | mItems.append(agendaItem); | 1829 | mItems.append(agendaItem); |
1826 | 1830 | ||
1827 | placeSubCells(agendaItem); | 1831 | placeSubCells(agendaItem); |
1828 | 1832 | ||
1829 | //agendaItem->show(); | 1833 | //agendaItem->show(); |
1830 | 1834 | ||
1831 | return agendaItem; | 1835 | return agendaItem; |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | 1838 | ||
1835 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1839 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1836 | int YTop,int YBottom) | 1840 | int YTop,int YBottom) |
1837 | { | 1841 | { |
1838 | if (mAllDayMode) { | 1842 | if (mAllDayMode) { |
1839 | ; | 1843 | ; |
1840 | return; | 1844 | return; |
1841 | } | 1845 | } |
1842 | 1846 | ||
1843 | int cellX,cellYTop,cellYBottom; | 1847 | int cellX,cellYTop,cellYBottom; |
1844 | QString newtext; | 1848 | QString newtext; |
1845 | int width = XEnd - XBegin + 1; | 1849 | int width = XEnd - XBegin + 1; |
1846 | int count = 0; | 1850 | int count = 0; |
1847 | KOAgendaItem *current = 0; | 1851 | KOAgendaItem *current = 0; |
1848 | QPtrList<KOAgendaItem> multiItems; | 1852 | QPtrList<KOAgendaItem> multiItems; |
1849 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1853 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1850 | if (cellX == XBegin) cellYTop = YTop; | 1854 | if (cellX == XBegin) cellYTop = YTop; |
1851 | else cellYTop = 0; | 1855 | else cellYTop = 0; |
1852 | if (cellX == XEnd) cellYBottom = YBottom; | 1856 | if (cellX == XEnd) cellYBottom = YBottom; |
1853 | else cellYBottom = rows() - 1; | 1857 | else cellYBottom = rows() - 1; |
1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1858 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1855 | newtext.append(event->summary()); | 1859 | newtext.append(event->summary()); |
1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1860 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1857 | current->setText(newtext); | 1861 | current->setText(newtext); |
1858 | multiItems.append(current); | 1862 | multiItems.append(current); |
1859 | } | 1863 | } |
1860 | 1864 | ||
1861 | KOAgendaItem *next = 0; | 1865 | KOAgendaItem *next = 0; |
1862 | KOAgendaItem *last = multiItems.last(); | 1866 | KOAgendaItem *last = multiItems.last(); |
1863 | KOAgendaItem *first = multiItems.first(); | 1867 | KOAgendaItem *first = multiItems.first(); |
1864 | KOAgendaItem *setFirst,*setLast; | 1868 | KOAgendaItem *setFirst,*setLast; |
1865 | current = first; | 1869 | current = first; |
1866 | while (current) { | 1870 | while (current) { |
1867 | next = multiItems.next(); | 1871 | next = multiItems.next(); |
1868 | if (current == first) setFirst = 0; | 1872 | if (current == first) setFirst = 0; |
1869 | else setFirst = first; | 1873 | else setFirst = first; |
1870 | if (current == last) setLast = 0; | 1874 | if (current == last) setLast = 0; |
1871 | else setLast = last; | 1875 | else setLast = last; |
1872 | 1876 | ||
1873 | current->setMultiItem(setFirst,next,setLast); | 1877 | current->setMultiItem(setFirst,next,setLast); |
1874 | current = next; | 1878 | current = next; |
1875 | } | 1879 | } |
1876 | } | 1880 | } |
1877 | 1881 | ||
1878 | 1882 | ||
1879 | //QSizePolicy KOAgenda::sizePolicy() const | 1883 | //QSizePolicy KOAgenda::sizePolicy() const |
1880 | //{ | 1884 | //{ |
1881 | // Thought this would make the all-day event agenda minimum size and the | 1885 | // Thought this would make the all-day event agenda minimum size and the |
1882 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1886 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1883 | // don´t seem to think that an Expanding widget needs more space than a | 1887 | // don´t seem to think that an Expanding widget needs more space than a |
1884 | // Preferred one. | 1888 | // Preferred one. |
1885 | // But it doesn´t hurt, so it stays. | 1889 | // But it doesn´t hurt, so it stays. |
1886 | // if (mAllDayMode) { | 1890 | // if (mAllDayMode) { |
1887 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1891 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1888 | // } else { | 1892 | // } else { |
1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1893 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1890 | // } | 1894 | // } |
1891 | //} | 1895 | //} |
1892 | void KOAgenda::finishResize ( ) | 1896 | void KOAgenda::finishResize ( ) |
1893 | { | 1897 | { |
1894 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1898 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1895 | if ( globalFlagBlockAgenda == 0 ) { | 1899 | if ( globalFlagBlockAgenda == 0 ) { |
1896 | finishUpdate(); | 1900 | finishUpdate(); |
1897 | //qDebug("finishUpdate() called "); | 1901 | //qDebug("finishUpdate() called "); |
1898 | } | 1902 | } |
1899 | } | 1903 | } |
1900 | /* | 1904 | /* |
1901 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1905 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1902 | */ | 1906 | */ |
1903 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1907 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1904 | { | 1908 | { |
1905 | mSelectionHeight = 0; | 1909 | mSelectionHeight = 0; |
1906 | mResizeTimer.start( 150 , true ); | 1910 | mResizeTimer.start( 150 , true ); |
1907 | computeSizes(); | 1911 | computeSizes(); |
1908 | return; | 1912 | return; |
1909 | 1913 | ||
1910 | } | 1914 | } |
1911 | void KOAgenda::computeSizes() | 1915 | void KOAgenda::computeSizes() |
1912 | { | 1916 | { |
1913 | if ( globalFlagBlockStartup ) | 1917 | if ( globalFlagBlockStartup ) |
1914 | return; | 1918 | return; |
1915 | int frameOffset = frameWidth() * 2 +1; | 1919 | int frameOffset = frameWidth() * 2 +1; |
1916 | if (mAllDayMode) { | 1920 | if (mAllDayMode) { |
1917 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1921 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1918 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1922 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1919 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1923 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1920 | // mGridSpacingY = height(); | 1924 | // mGridSpacingY = height(); |
1921 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1925 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1922 | 1926 | ||
1923 | KOAgendaItem *item; | 1927 | KOAgendaItem *item; |
1924 | int subCellWidth; | 1928 | int subCellWidth; |
1925 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1929 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1926 | subCellWidth = mGridSpacingY / item->subCells(); | 1930 | subCellWidth = mGridSpacingY / item->subCells(); |
1927 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1931 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1928 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1932 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1929 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1933 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1930 | item->cellX() * mGridSpacingX, | 1934 | item->cellX() * mGridSpacingX, |
1931 | item->subCell() * subCellWidth); | 1935 | item->subCell() * subCellWidth); |
1932 | } | 1936 | } |
1933 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1937 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1934 | } else { | 1938 | } else { |
1935 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1939 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1936 | if (height() > mGridSpacingY * mRows + 1 ) { | 1940 | if (height() > mGridSpacingY * mRows + 1 ) { |
1937 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1941 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1938 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1942 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1939 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1943 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1940 | emit resizedSignal(); | 1944 | emit resizedSignal(); |
1941 | } else | 1945 | } else |
1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1946 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1943 | KOAgendaItem *item; | 1947 | KOAgendaItem *item; |
1944 | int subCellWidth; | 1948 | int subCellWidth; |
1945 | 1949 | ||
1946 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1950 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1947 | subCellWidth = mGridSpacingX / item->subCells(); | 1951 | subCellWidth = mGridSpacingX / item->subCells(); |
1948 | item->resize(subCellWidth,item->height()); | 1952 | item->resize(subCellWidth,item->height()); |
1949 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1953 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1950 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1954 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1951 | item->cellX() * mGridSpacingX) + | 1955 | item->cellX() * mGridSpacingX) + |
1952 | item->subCell() * subCellWidth,childY(item)); | 1956 | item->subCell() * subCellWidth,childY(item)); |
1953 | } | 1957 | } |
1954 | } | 1958 | } |
1955 | int cw = contentsWidth(); | 1959 | int cw = contentsWidth(); |
1956 | int ch = contentsHeight(); | 1960 | int ch = contentsHeight(); |
1957 | if ( mAllDayMode ) { | 1961 | if ( mAllDayMode ) { |
1958 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1962 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1959 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1963 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1960 | //qDebug("paintPixAll->resize "); | 1964 | //qDebug("paintPixAll->resize "); |
1961 | paintPixAll->resize( cw, ch ); | 1965 | paintPixAll->resize( cw, ch ); |
1962 | } | 1966 | } |
1963 | } else { | 1967 | } else { |
1964 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1968 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1965 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1969 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1966 | //qDebug("paintPix->resize "); | 1970 | //qDebug("paintPix->resize "); |
1967 | paintPix->resize( cw , ch ); | 1971 | paintPix->resize( cw , ch ); |
1968 | } | 1972 | } |
1969 | } | 1973 | } |
1970 | 1974 | ||
1971 | checkScrollBoundaries(); | 1975 | checkScrollBoundaries(); |
1972 | drawContentsToPainter(); | 1976 | drawContentsToPainter(); |
1973 | viewport()->repaint(false); | 1977 | viewport()->repaint(false); |
1974 | } | 1978 | } |
1975 | 1979 | ||
1976 | void KOAgenda::scrollUp() | 1980 | void KOAgenda::scrollUp() |
1977 | { | 1981 | { |
1978 | scrollBy(0,-mScrollOffset); | 1982 | scrollBy(0,-mScrollOffset); |
1979 | } | 1983 | } |
1980 | 1984 | ||
1981 | 1985 | ||
1982 | void KOAgenda::scrollDown() | 1986 | void KOAgenda::scrollDown() |
1983 | { | 1987 | { |
1984 | scrollBy(0,mScrollOffset); | 1988 | scrollBy(0,mScrollOffset); |
1985 | } | 1989 | } |
1986 | 1990 | ||
1987 | void KOAgenda::popupAlarm() | 1991 | void KOAgenda::popupAlarm() |
1988 | { | 1992 | { |
1989 | if (!mClickedItem) { | 1993 | if (!mClickedItem) { |
1990 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1994 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1991 | return; | 1995 | return; |
1992 | } | 1996 | } |
1993 | // TODO: deal correctly with multiple alarms | 1997 | // TODO: deal correctly with multiple alarms |
1994 | Alarm* alarm; | 1998 | Alarm* alarm; |
1995 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1999 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1996 | for(alarm=list.first();alarm;alarm=list.next()) { | 2000 | for(alarm=list.first();alarm;alarm=list.next()) { |
1997 | alarm->toggleAlarm(); | 2001 | alarm->toggleAlarm(); |
1998 | } | 2002 | } |
1999 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2003 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2000 | mClickedItem->paintMe( true ); | 2004 | mClickedItem->paintMe( true ); |
2001 | mClickedItem->repaint( false ); | 2005 | mClickedItem->repaint( false ); |
2002 | } | 2006 | } |
2003 | 2007 | ||
2004 | /* | 2008 | /* |
2005 | Calculates the minimum width | 2009 | Calculates the minimum width |
2006 | */ | 2010 | */ |
2007 | int KOAgenda::minimumWidth() const | 2011 | int KOAgenda::minimumWidth() const |
2008 | { | 2012 | { |
2009 | // TODO:: develop a way to dynamically determine the minimum width | 2013 | // TODO:: develop a way to dynamically determine the minimum width |
2010 | int min = 100; | 2014 | int min = 100; |
2011 | 2015 | ||
2012 | return min; | 2016 | return min; |
2013 | } | 2017 | } |
2014 | 2018 | ||
2015 | void KOAgenda::updateConfig() | 2019 | void KOAgenda::updateConfig() |
2016 | { | 2020 | { |
2017 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2021 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2018 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2022 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2019 | if ( mAllDayMode ) { | 2023 | if ( mAllDayMode ) { |
2020 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2024 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2021 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2025 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2022 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2026 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2023 | // setMaximumHeight( mGridSpacingY+1 ); | 2027 | // setMaximumHeight( mGridSpacingY+1 ); |
2024 | viewport()->repaint( false ); | 2028 | viewport()->repaint( false ); |
2025 | //setFixedHeight( mGridSpacingY+1 ); | 2029 | //setFixedHeight( mGridSpacingY+1 ); |
2026 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2030 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2027 | } | 2031 | } |
2028 | else { | 2032 | else { |
2029 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2033 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2030 | calculateWorkingHours(); | 2034 | calculateWorkingHours(); |
2031 | } | 2035 | } |
2032 | } | 2036 | } |
2033 | 2037 | ||
2034 | void KOAgenda::checkScrollBoundaries() | 2038 | void KOAgenda::checkScrollBoundaries() |
2035 | { | 2039 | { |
2036 | // Invalidate old values to force update | 2040 | // Invalidate old values to force update |
2037 | mOldLowerScrollValue = -1; | 2041 | mOldLowerScrollValue = -1; |
2038 | mOldUpperScrollValue = -1; | 2042 | mOldUpperScrollValue = -1; |
2039 | 2043 | ||
2040 | checkScrollBoundaries(verticalScrollBar()->value()); | 2044 | checkScrollBoundaries(verticalScrollBar()->value()); |
2041 | } | 2045 | } |
2042 | 2046 | ||
2043 | void KOAgenda::checkScrollBoundaries(int v) | 2047 | void KOAgenda::checkScrollBoundaries(int v) |
2044 | { | 2048 | { |
2045 | if ( mGridSpacingY == 0 ) | 2049 | if ( mGridSpacingY == 0 ) |
2046 | return; | 2050 | return; |
2047 | int yMin = v/mGridSpacingY; | 2051 | int yMin = v/mGridSpacingY; |
2048 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2052 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2049 | 2053 | ||
2050 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2054 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2051 | 2055 | ||
2052 | if (yMin != mOldLowerScrollValue) { | 2056 | if (yMin != mOldLowerScrollValue) { |
2053 | mOldLowerScrollValue = yMin; | 2057 | mOldLowerScrollValue = yMin; |
2054 | emit lowerYChanged(yMin); | 2058 | emit lowerYChanged(yMin); |
2055 | } | 2059 | } |
2056 | if (yMax != mOldUpperScrollValue) { | 2060 | if (yMax != mOldUpperScrollValue) { |
2057 | mOldUpperScrollValue = yMax; | 2061 | mOldUpperScrollValue = yMax; |
2058 | emit upperYChanged(yMax); | 2062 | emit upperYChanged(yMax); |
2059 | } | 2063 | } |
2060 | } | 2064 | } |
2061 | 2065 | ||
2062 | void KOAgenda::deselectItem() | 2066 | void KOAgenda::deselectItem() |
2063 | { | 2067 | { |
2064 | if (mSelectedItem.isNull()) return; | 2068 | if (mSelectedItem.isNull()) return; |
2065 | mSelectedItem->select(false); | 2069 | mSelectedItem->select(false); |
2066 | mSelectedItem = 0; | 2070 | mSelectedItem = 0; |
2067 | } | 2071 | } |
2068 | 2072 | ||
2069 | void KOAgenda::selectItem(KOAgendaItem *item) | 2073 | void KOAgenda::selectItem(KOAgendaItem *item) |
2070 | { | 2074 | { |
2071 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2075 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2072 | deselectItem(); | 2076 | deselectItem(); |
2073 | if (item == 0) { | 2077 | if (item == 0) { |
2074 | emit incidenceSelected( 0 ); | 2078 | emit incidenceSelected( 0 ); |
2075 | return; | 2079 | return; |
2076 | } | 2080 | } |
2077 | mSelectedItem = item; | 2081 | mSelectedItem = item; |
2078 | mSelectedItem->select(); | 2082 | mSelectedItem->select(); |
2079 | emit incidenceSelected( mSelectedItem->incidence() ); | 2083 | emit incidenceSelected( mSelectedItem->incidence() ); |
2080 | } | 2084 | } |
2081 | 2085 | ||
2082 | // This function seems never be called. | 2086 | // This function seems never be called. |
2083 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2087 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2084 | { | 2088 | { |
2085 | switch(kev->key()) { | 2089 | switch(kev->key()) { |
2086 | case Key_PageDown: | 2090 | case Key_PageDown: |
2087 | verticalScrollBar()->addPage(); | 2091 | verticalScrollBar()->addPage(); |
2088 | break; | 2092 | break; |
2089 | case Key_PageUp: | 2093 | case Key_PageUp: |
2090 | verticalScrollBar()->subtractPage(); | 2094 | verticalScrollBar()->subtractPage(); |
2091 | break; | 2095 | break; |
2092 | case Key_Down: | 2096 | case Key_Down: |
2093 | verticalScrollBar()->addLine(); | 2097 | verticalScrollBar()->addLine(); |
2094 | break; | 2098 | break; |
2095 | case Key_Up: | 2099 | case Key_Up: |
2096 | verticalScrollBar()->subtractLine(); | 2100 | verticalScrollBar()->subtractLine(); |
2097 | break; | 2101 | break; |
2098 | default: | 2102 | default: |
2099 | ; | 2103 | ; |
2100 | } | 2104 | } |
2101 | } | 2105 | } |
2102 | 2106 | ||
2103 | void KOAgenda::calculateWorkingHours() | 2107 | void KOAgenda::calculateWorkingHours() |
2104 | { | 2108 | { |
2105 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2109 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2106 | mWorkingHoursEnable = !mAllDayMode; | 2110 | mWorkingHoursEnable = !mAllDayMode; |
2107 | 2111 | ||
2108 | mWorkingHoursYTop = mGridSpacingY * | 2112 | mWorkingHoursYTop = mGridSpacingY * |
2109 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2113 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2110 | mWorkingHoursYBottom = mGridSpacingY * | 2114 | mWorkingHoursYBottom = mGridSpacingY * |
2111 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2115 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2112 | } | 2116 | } |
2113 | 2117 | ||
2114 | 2118 | ||
2115 | DateList KOAgenda::dateList() const | 2119 | DateList KOAgenda::dateList() const |
2116 | { | 2120 | { |
2117 | return mSelectedDates; | 2121 | return mSelectedDates; |
2118 | } | 2122 | } |
2119 | 2123 | ||
2120 | void KOAgenda::setDateList(const DateList &selectedDates) | 2124 | void KOAgenda::setDateList(const DateList &selectedDates) |
2121 | { | 2125 | { |
2122 | mSelectedDates = selectedDates; | 2126 | mSelectedDates = selectedDates; |
2123 | } | 2127 | } |
2124 | 2128 | ||
2125 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2129 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2126 | { | 2130 | { |
2127 | mHolidayMask = mask; | 2131 | mHolidayMask = mask; |
2128 | 2132 | ||
2129 | /* | 2133 | /* |
2130 | kdDebug() << "HolidayMask: "; | 2134 | kdDebug() << "HolidayMask: "; |
2131 | for(uint i=0;i<mask->count();++i) { | 2135 | for(uint i=0;i<mask->count();++i) { |
2132 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2136 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2133 | } | 2137 | } |
2134 | kdDebug() << endl; | 2138 | kdDebug() << endl; |
2135 | */ | 2139 | */ |
2136 | } | 2140 | } |
2137 | 2141 | ||
2138 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2142 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2139 | { | 2143 | { |
2140 | 2144 | ||
2141 | QScrollView::contentsMousePressEvent(event); | 2145 | QScrollView::contentsMousePressEvent(event); |
2142 | } | 2146 | } |
2143 | 2147 | ||
2144 | void KOAgenda::storePosition() | 2148 | void KOAgenda::storePosition() |
2145 | { | 2149 | { |
2146 | //mContentPosition | 2150 | //mContentPosition |
2147 | int max = mGridSpacingY*4*24; | 2151 | int max = mGridSpacingY*4*24; |
2148 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2152 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2149 | mContentPosition = 0; | 2153 | mContentPosition = 0; |
2150 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2154 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2151 | mContentPosition = -1.0; | 2155 | mContentPosition = -1.0; |
2152 | else | 2156 | else |
2153 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2157 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2154 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2158 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2155 | 2159 | ||
2156 | } | 2160 | } |
2157 | void KOAgenda::restorePosition() | 2161 | void KOAgenda::restorePosition() |
2158 | { | 2162 | { |
2159 | int posY; | 2163 | int posY; |
2160 | int max = mGridSpacingY*4*24; | 2164 | int max = mGridSpacingY*4*24; |
2161 | if ( mContentPosition < 0 ) | 2165 | if ( mContentPosition < 0 ) |
2162 | posY = max-viewport()->height(); | 2166 | posY = max-viewport()->height(); |
2163 | else | 2167 | else |
2164 | if ( mContentPosition == 0 ) | 2168 | if ( mContentPosition == 0 ) |
2165 | posY = 0; | 2169 | posY = 0; |
2166 | else | 2170 | else |
2167 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2171 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2168 | setContentsPos (0, posY ); | 2172 | setContentsPos (0, posY ); |
2169 | //qDebug("posY %d hei %d", posY, max); | 2173 | //qDebug("posY %d hei %d", posY, max); |
2170 | 2174 | ||
2171 | } | 2175 | } |
2172 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2176 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2173 | { | 2177 | { |
2174 | ++x; | 2178 | ++x; |
2175 | QScrollView::moveChild( w, x , y ); | 2179 | QScrollView::moveChild( w, x , y ); |
2176 | } | 2180 | } |
2177 | #include <qmessagebox.h> | 2181 | #include <qmessagebox.h> |
2178 | #ifdef DESKTOP_VERSION | 2182 | #ifdef DESKTOP_VERSION |
2179 | #include <qprinter.h> | 2183 | #include <qprinter.h> |
2180 | #include <qpainter.h> | 2184 | #include <qpainter.h> |
2181 | #include <qpaintdevicemetrics.h> | 2185 | #include <qpaintdevicemetrics.h> |
2182 | 2186 | ||
2183 | #endif | 2187 | #endif |
2184 | void KOAgenda::printSelection() | 2188 | void KOAgenda::printSelection() |
2185 | { | 2189 | { |
2186 | #ifdef DESKTOP_VERSION | 2190 | #ifdef DESKTOP_VERSION |
2187 | if ( mStartCellY == mCurrentCellY ) { | 2191 | if ( mStartCellY == mCurrentCellY ) { |
2188 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2192 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2189 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2193 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2190 | i18n("OK"), 0, 0, | 2194 | i18n("OK"), 0, 0, |
2191 | 0, 1 ); | 2195 | 0, 1 ); |
2192 | return; | 2196 | return; |
2193 | } | 2197 | } |
2194 | 2198 | ||
2195 | float dx, dy; | 2199 | float dx, dy; |
2196 | int x,y,w,h; | 2200 | int x,y,w,h; |
2197 | x= 0; | 2201 | x= 0; |
2198 | w= contentsWidth()+2; | 2202 | w= contentsWidth()+2; |
2199 | // h= contentsHeight(); | 2203 | // h= contentsHeight(); |
2200 | y = mGridSpacingY*mStartCellY; | 2204 | y = mGridSpacingY*mStartCellY; |
2201 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2205 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2202 | 2206 | ||
2203 | //return; | 2207 | //return; |
2204 | QPrinter* printer = new QPrinter(); | 2208 | QPrinter* printer = new QPrinter(); |
2205 | if ( !printer->setup()) { | 2209 | if ( !printer->setup()) { |
2206 | delete printer; | 2210 | delete printer; |
2207 | return; | 2211 | return; |
2208 | } | 2212 | } |
2209 | QPainter p( printer ); | 2213 | QPainter p( printer ); |
2210 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2214 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2211 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2215 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2212 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2216 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2213 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2217 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2214 | // p.drawText( 0, 0, date ); | 2218 | // p.drawText( 0, 0, date ); |
2215 | int offset = m.width()/8; | 2219 | int offset = m.width()/8; |
2216 | // compute the scale | 2220 | // compute the scale |
2217 | dx = ((float) m.width()-offset) / (float)w; | 2221 | dx = ((float) m.width()-offset) / (float)w; |
2218 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2222 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2219 | float scale; | 2223 | float scale; |
2220 | // scale to fit the width or height of the paper | 2224 | // scale to fit the width or height of the paper |
2221 | if ( dx < dy ) | 2225 | if ( dx < dy ) |
2222 | scale = dx; | 2226 | scale = dx; |
2223 | else | 2227 | else |
2224 | scale = dy; | 2228 | scale = dy; |
2225 | // set the scale | 2229 | // set the scale |
2226 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2230 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2227 | 2231 | ||
2228 | int selDay; | 2232 | int selDay; |
2229 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2233 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2230 | float startX = 1; | 2234 | float startX = 1; |
2231 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2235 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2232 | { | 2236 | { |
2233 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2237 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2234 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2238 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2235 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2239 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2236 | startX += widOffset; | 2240 | startX += widOffset; |
2237 | 2241 | ||
2238 | } | 2242 | } |
2239 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2243 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2240 | p.scale( scale, scale ); | 2244 | p.scale( scale, scale ); |
2241 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2245 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2242 | // now printing with y offset: 2 hei | 2246 | // now printing with y offset: 2 hei |
2243 | // p.translate( 0, -y*scale); | 2247 | // p.translate( 0, -y*scale); |
2244 | 2248 | ||
2245 | drawContentsToPainter(&p, true ); | 2249 | drawContentsToPainter(&p, true ); |
2246 | globalFlagBlockAgendaItemUpdate = false; | 2250 | globalFlagBlockAgendaItemUpdate = false; |
2247 | KOAgendaItem *item; | 2251 | KOAgendaItem *item; |
2248 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2252 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2249 | item->select(false); | 2253 | item->select(false); |
2250 | item->paintMe( false, &p ); | 2254 | item->paintMe( false, &p ); |
2251 | } | 2255 | } |
2252 | globalFlagBlockAgendaItemUpdate = true; | 2256 | globalFlagBlockAgendaItemUpdate = true; |
2253 | p.end(); | 2257 | p.end(); |
2254 | delete printer; | 2258 | delete printer; |
2255 | #else | 2259 | #else |
2256 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2260 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2257 | i18n("Not supported \non PDA!\n"), | 2261 | i18n("Not supported \non PDA!\n"), |
2258 | i18n("OK"), 0, 0, | 2262 | i18n("OK"), 0, 0, |
2259 | 0, 1 ); | 2263 | 0, 1 ); |
2260 | #endif | 2264 | #endif |
2261 | } | 2265 | } |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 0e3aed8..86cf2f4 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,306 +1,307 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | bool mInvalidPixmap; | 78 | bool mInvalidPixmap; |
79 | 79 | ||
80 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
81 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
82 | 82 | ||
83 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
84 | 84 | ||
85 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
86 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
87 | 87 | ||
88 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
89 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
90 | 90 | ||
91 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
92 | 92 | ||
93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
96 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
97 | 97 | ||
98 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
99 | 99 | ||
100 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
101 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
102 | 102 | ||
103 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
104 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
105 | 105 | ||
106 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
107 | 107 | ||
108 | void clear(); | 108 | void clear(); |
109 | 109 | ||
110 | void clearSelection(); | 110 | void clearSelection(); |
111 | void hideUnused(); | 111 | void hideUnused(); |
112 | 112 | ||
113 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
114 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
115 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
116 | void updateConfig(); | 116 | void updateConfig(); |
117 | 117 | ||
118 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
119 | 119 | ||
120 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
121 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
122 | DateList dateList() const; | 122 | DateList dateList() const; |
123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
124 | void finishUpdate(); | 124 | void finishUpdate(); |
125 | void printSelection(); | 125 | void printSelection(); |
126 | void storePosition(); | 126 | void storePosition(); |
127 | void restorePosition(); | 127 | void restorePosition(); |
128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | 129 | void shrinkPixmap(); |
130 | QTime getEndTime(); | ||
130 | 131 | ||
131 | public slots: | 132 | public slots: |
132 | void slotContentMove(int,int); | 133 | void slotContentMove(int,int); |
133 | void categoryChanged(Incidence * inc); | 134 | void categoryChanged(Incidence * inc); |
134 | void slotClearSelection(); | 135 | void slotClearSelection(); |
135 | void popupMenu(); | 136 | void popupMenu(); |
136 | void newItem( int ); | 137 | void newItem( int ); |
137 | void moveChild( QWidget *, int, int ); | 138 | void moveChild( QWidget *, int, int ); |
138 | void scrollUp(); | 139 | void scrollUp(); |
139 | void scrollDown(); | 140 | void scrollDown(); |
140 | void updateTodo( Todo * t, int , bool ); | 141 | void updateTodo( Todo * t, int , bool ); |
141 | void popupAlarm(); | 142 | void popupAlarm(); |
142 | 143 | ||
143 | void checkScrollBoundaries(int); | 144 | void checkScrollBoundaries(int); |
144 | 145 | ||
145 | /** Deselect selected items. This function does not emit any signals. */ | 146 | /** Deselect selected items. This function does not emit any signals. */ |
146 | void deselectItem(); | 147 | void deselectItem(); |
147 | /** Select item. If the argument is 0, the currently selected item gets | 148 | /** Select item. If the argument is 0, the currently selected item gets |
148 | deselected. This function emits the itemSelected(bool) signal to inform | 149 | deselected. This function emits the itemSelected(bool) signal to inform |
149 | about selection/deseelction of events. */ | 150 | about selection/deseelction of events. */ |
150 | void selectItem(KOAgendaItem *); | 151 | void selectItem(KOAgendaItem *); |
151 | void finishResize(); | 152 | void finishResize(); |
152 | 153 | ||
153 | signals: | 154 | signals: |
154 | void signalClearSelection(); | 155 | void signalClearSelection(); |
155 | void showDateView( int, int); | 156 | void showDateView( int, int); |
156 | void newEventSignal(); | 157 | void newEventSignal(); |
157 | void newEventSignal(int gx,int gy); | 158 | void newEventSignal(int gx,int gy); |
158 | void newTodoSignal(int gx,int gy); | 159 | void newTodoSignal(int gx,int gy); |
159 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
160 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
161 | void newStartSelectSignal(); | 162 | void newStartSelectSignal(); |
162 | void showIncidenceSignal(Incidence *); | 163 | void showIncidenceSignal(Incidence *); |
163 | void editIncidenceSignal(Incidence *); | 164 | void editIncidenceSignal(Incidence *); |
164 | void deleteIncidenceSignal(Incidence *); | 165 | void deleteIncidenceSignal(Incidence *); |
165 | void showIncidencePopupSignal(Incidence *); | 166 | void showIncidencePopupSignal(Incidence *); |
166 | 167 | ||
167 | void itemModified(KOAgendaItem *item, int ); | 168 | void itemModified(KOAgendaItem *item, int ); |
168 | void incidenceSelected(Incidence *); | 169 | void incidenceSelected(Incidence *); |
169 | 170 | ||
170 | void lowerYChanged(int); | 171 | void lowerYChanged(int); |
171 | void upperYChanged(int); | 172 | void upperYChanged(int); |
172 | 173 | ||
173 | void startDragSignal(Incidence *); | 174 | void startDragSignal(Incidence *); |
174 | void addToCalSignal(Incidence *, Incidence *); | 175 | void addToCalSignal(Incidence *, Incidence *); |
175 | void resizedSignal(); | 176 | void resizedSignal(); |
176 | void updateViewSignal(); | 177 | void updateViewSignal(); |
177 | void sendPing(); | 178 | void sendPing(); |
178 | 179 | ||
179 | protected: | 180 | protected: |
180 | KOEventPopupMenu * mAllAgendaPopup; | 181 | KOEventPopupMenu * mAllAgendaPopup; |
181 | QPainter mPixPainter; | 182 | QPainter mPixPainter; |
182 | QPixmap mPaintPixmap; | 183 | QPixmap mPaintPixmap; |
183 | QPixmap mHighlightPixmap; | 184 | QPixmap mHighlightPixmap; |
184 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
185 | virtual void resizeEvent ( QResizeEvent * ); | 186 | virtual void resizeEvent ( QResizeEvent * ); |
186 | 187 | ||
187 | /** Handles mouse events. Called from eventFilter */ | 188 | /** Handles mouse events. Called from eventFilter */ |
188 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
189 | 190 | ||
190 | /** Start selecting time span. */ | 191 | /** Start selecting time span. */ |
191 | void startSelectAction(QPoint viewportPos); | 192 | void startSelectAction(QPoint viewportPos); |
192 | 193 | ||
193 | /** Select time span. */ | 194 | /** Select time span. */ |
194 | void performSelectAction(QPoint viewportPos); | 195 | void performSelectAction(QPoint viewportPos); |
195 | 196 | ||
196 | /** Emd selecting time span. */ | 197 | /** Emd selecting time span. */ |
197 | void endSelectAction( bool emitNewEvent = false ); | 198 | void endSelectAction( bool emitNewEvent = false ); |
198 | 199 | ||
199 | /** Start moving/resizing agenda item */ | 200 | /** Start moving/resizing agenda item */ |
200 | void startItemAction(QPoint viewportPos); | 201 | void startItemAction(QPoint viewportPos); |
201 | 202 | ||
202 | /** Move/resize agenda item */ | 203 | /** Move/resize agenda item */ |
203 | void performItemAction(QPoint viewportPos); | 204 | void performItemAction(QPoint viewportPos); |
204 | 205 | ||
205 | /** End moving/resizing agenda item */ | 206 | /** End moving/resizing agenda item */ |
206 | void endItemAction(); | 207 | void endItemAction(); |
207 | 208 | ||
208 | /** Set cursor, when no item action is in progress */ | 209 | /** Set cursor, when no item action is in progress */ |
209 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
210 | 211 | ||
211 | /** Place agenda item in agenda and adjust other cells if necessary */ | 212 | /** Place agenda item in agenda and adjust other cells if necessary */ |
212 | void placeSubCells(KOAgendaItem *placeItem); | 213 | void placeSubCells(KOAgendaItem *placeItem); |
213 | 214 | ||
214 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
215 | * Implements pgup/pgdn and cursor key navigation in the view. | 216 | * Implements pgup/pgdn and cursor key navigation in the view. |
216 | */ | 217 | */ |
217 | void keyPressEvent( QKeyEvent * ); | 218 | void keyPressEvent( QKeyEvent * ); |
218 | 219 | ||
219 | void calculateWorkingHours(); | 220 | void calculateWorkingHours(); |
220 | 221 | ||
221 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 222 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
222 | 223 | ||
223 | private: | 224 | private: |
224 | void init(); | 225 | void init(); |
225 | void marcus_bains(); | 226 | void marcus_bains(); |
226 | bool mAllDayMode; | 227 | bool mAllDayMode; |
227 | bool blockResize; | 228 | bool blockResize; |
228 | bool mLeftMouseDown; | 229 | bool mLeftMouseDown; |
229 | KOAgendaItem *mPopupItem; | 230 | KOAgendaItem *mPopupItem; |
230 | QTimer* mPopupTimer; | 231 | QTimer* mPopupTimer; |
231 | int mPopupKind; | 232 | int mPopupKind; |
232 | QPoint mPopupPos; | 233 | QPoint mPopupPos; |
233 | QTimer mResizeTimer; | 234 | QTimer mResizeTimer; |
234 | double mContentPosition; | 235 | double mContentPosition; |
235 | 236 | ||
236 | // Width and height of agenda cells | 237 | // Width and height of agenda cells |
237 | int mGridSpacingX; | 238 | int mGridSpacingX; |
238 | int mGridSpacingY; | 239 | int mGridSpacingY; |
239 | 240 | ||
240 | // size of border, where mouse action will resize the KOAgendaItem | 241 | // size of border, where mouse action will resize the KOAgendaItem |
241 | int mResizeBorderWidth; | 242 | int mResizeBorderWidth; |
242 | 243 | ||
243 | // size of border, where mouse mve will cause a scroll of the agenda | 244 | // size of border, where mouse mve will cause a scroll of the agenda |
244 | int mScrollBorderWidth; | 245 | int mScrollBorderWidth; |
245 | int mScrollDelay; | 246 | int mScrollDelay; |
246 | int mScrollOffset; | 247 | int mScrollOffset; |
247 | 248 | ||
248 | QTimer mScrollUpTimer; | 249 | QTimer mScrollUpTimer; |
249 | QTimer mScrollDownTimer; | 250 | QTimer mScrollDownTimer; |
250 | 251 | ||
251 | // Number of Columns/Rows of agenda grid | 252 | // Number of Columns/Rows of agenda grid |
252 | int mColumns; | 253 | int mColumns; |
253 | int mRows; | 254 | int mRows; |
254 | 255 | ||
255 | // Cells to store Move and Resize coordiantes | 256 | // Cells to store Move and Resize coordiantes |
256 | int mStartCellX; | 257 | int mStartCellX; |
257 | int mStartCellY; | 258 | int mStartCellY; |
258 | int mCurrentCellX; | 259 | int mCurrentCellX; |
259 | int mCurrentCellY; | 260 | int mCurrentCellY; |
260 | 261 | ||
261 | // Working Hour coordiantes | 262 | // Working Hour coordiantes |
262 | bool mWorkingHoursEnable; | 263 | bool mWorkingHoursEnable; |
263 | int mWorkingHoursYTop; | 264 | int mWorkingHoursYTop; |
264 | int mWorkingHoursYBottom; | 265 | int mWorkingHoursYBottom; |
265 | 266 | ||
266 | // Selection | 267 | // Selection |
267 | int mSelectionCellX; | 268 | int mSelectionCellX; |
268 | int mSelectionYTop; | 269 | int mSelectionYTop; |
269 | int mSelectionHeight; | 270 | int mSelectionHeight; |
270 | 271 | ||
271 | // List of dates to be displayed | 272 | // List of dates to be displayed |
272 | DateList mSelectedDates; | 273 | DateList mSelectedDates; |
273 | 274 | ||
274 | // The KOAgendaItem, which has been right-clicked last | 275 | // The KOAgendaItem, which has been right-clicked last |
275 | KOAgendaItem *mClickedItem; | 276 | KOAgendaItem *mClickedItem; |
276 | 277 | ||
277 | // The KOAgendaItem, which is being moved/resized | 278 | // The KOAgendaItem, which is being moved/resized |
278 | QGuardedPtr<KOAgendaItem> mActionItem; | 279 | QGuardedPtr<KOAgendaItem> mActionItem; |
279 | 280 | ||
280 | // Currently selected item | 281 | // Currently selected item |
281 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 282 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
282 | 283 | ||
283 | // The Marcus Bains Line widget. | 284 | // The Marcus Bains Line widget. |
284 | MarcusBains *mMarcusBains; | 285 | MarcusBains *mMarcusBains; |
285 | void computeSizes(); | 286 | void computeSizes(); |
286 | 287 | ||
287 | MouseActionType mActionType; | 288 | MouseActionType mActionType; |
288 | 289 | ||
289 | bool mItemMoved; | 290 | bool mItemMoved; |
290 | 291 | ||
291 | // List of all Items contained in agenda | 292 | // List of all Items contained in agenda |
292 | QPtrList<KOAgendaItem> mItems; | 293 | QPtrList<KOAgendaItem> mItems; |
293 | QPtrList<KOAgendaItem> mUnusedItems; | 294 | QPtrList<KOAgendaItem> mUnusedItems; |
294 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
295 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
296 | QPopupMenu *mNewItemPopup; | 297 | QPopupMenu *mNewItemPopup; |
297 | 298 | ||
298 | int mOldLowerScrollValue; | 299 | int mOldLowerScrollValue; |
299 | int mOldUpperScrollValue; | 300 | int mOldUpperScrollValue; |
300 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 301 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
301 | QMemArray<bool> *mHolidayMask; | 302 | QMemArray<bool> *mHolidayMask; |
302 | int mCurPixWid; | 303 | int mCurPixWid; |
303 | int mCurPixHei; | 304 | int mCurPixHei; |
304 | }; | 305 | }; |
305 | 306 | ||
306 | #endif // KOAGENDA_H | 307 | #endif // KOAGENDA_H |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 53bbe28..b5a59af 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,2321 +1,2324 @@ | |||
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 <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
146 | } | 146 | } |
147 | 147 | ||
148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
149 | { | 149 | { |
150 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
151 | if ( ! item ) { | 151 | if ( ! item ) { |
152 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
153 | } | 153 | } |
154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
155 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
156 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
157 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
158 | } | 158 | } |
159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
160 | { | 160 | { |
161 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
162 | switch(e->key()) { | 162 | switch(e->key()) { |
163 | case Key_Right: | 163 | case Key_Right: |
164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
165 | { | 165 | { |
166 | e->ignore(); | 166 | e->ignore(); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | scrollBy(10,0); | 169 | scrollBy(10,0); |
170 | break; | 170 | break; |
171 | case Key_Left: | 171 | case Key_Left: |
172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
173 | { | 173 | { |
174 | e->ignore(); | 174 | e->ignore(); |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | scrollBy(-10,0); | 177 | scrollBy(-10,0); |
178 | break; | 178 | break; |
179 | case Key_Up: | 179 | case Key_Up: |
180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
181 | e->ignore(); | 181 | e->ignore(); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if ( count() ) { | 184 | if ( count() ) { |
185 | if ( currentItem() == 0 ) { | 185 | if ( currentItem() == 0 ) { |
186 | emit prevCell(); | 186 | emit prevCell(); |
187 | } else { | 187 | } else { |
188 | setCurrentItem((currentItem()+count()-1)%count()); | 188 | setCurrentItem((currentItem()+count()-1)%count()); |
189 | if(!itemVisible(currentItem())) { | 189 | if(!itemVisible(currentItem())) { |
190 | if((unsigned int) currentItem() == (count()-1)) { | 190 | if((unsigned int) currentItem() == (count()-1)) { |
191 | setTopItem(currentItem()-numItemsVisible()+1); | 191 | setTopItem(currentItem()-numItemsVisible()+1); |
192 | } else { | 192 | } else { |
193 | setTopItem(topItem()-1); | 193 | setTopItem(topItem()-1); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case Key_Down: | 199 | case Key_Down: |
200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
201 | e->ignore(); | 201 | e->ignore(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | if ( count () ) { | 204 | if ( count () ) { |
205 | if ( ((uint)currentItem()+1) == count () ) { | 205 | if ( ((uint)currentItem()+1) == count () ) { |
206 | emit nextCell(); | 206 | emit nextCell(); |
207 | } else { | 207 | } else { |
208 | setCurrentItem((currentItem()+1)%count()); | 208 | setCurrentItem((currentItem()+1)%count()); |
209 | if(!itemVisible(currentItem())) { | 209 | if(!itemVisible(currentItem())) { |
210 | if(currentItem() == 0) { | 210 | if(currentItem() == 0) { |
211 | setTopItem(0); | 211 | setTopItem(0); |
212 | } else { | 212 | } else { |
213 | setTopItem(topItem()+1); | 213 | setTopItem(topItem()+1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | case Key_I: | 219 | case Key_I: |
220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | case Key_Return: | 223 | case Key_Return: |
224 | case Key_Enter: | 224 | case Key_Enter: |
225 | { | 225 | { |
226 | if ( currentItem() >= 0 ) { | 226 | if ( currentItem() >= 0 ) { |
227 | emit doubleClicked( item( currentItem() ) ); | 227 | emit doubleClicked( item( currentItem() ) ); |
228 | e->accept(); | 228 | e->accept(); |
229 | } else { | 229 | } else { |
230 | e->ignore(); | 230 | e->ignore(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case Key_Shift: | 234 | case Key_Shift: |
235 | emit shiftDown(); | 235 | emit shiftDown(); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | e->ignore(); | 238 | e->ignore(); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void KNoScrollListBox::oneDown() | 243 | void KNoScrollListBox::oneDown() |
244 | { | 244 | { |
245 | if ( count () ) { | 245 | if ( count () ) { |
246 | if ( ((uint)currentItem()+1) == count () ) { | 246 | if ( ((uint)currentItem()+1) == count () ) { |
247 | emit nextCell(); | 247 | emit nextCell(); |
248 | } else { | 248 | } else { |
249 | resetOnFocusIn = false; | 249 | resetOnFocusIn = false; |
250 | setCurrentItem((currentItem()+1)%count()); | 250 | setCurrentItem((currentItem()+1)%count()); |
251 | if(!itemVisible(currentItem())) { | 251 | if(!itemVisible(currentItem())) { |
252 | if(currentItem() == 0) { | 252 | if(currentItem() == 0) { |
253 | setTopItem(0); | 253 | setTopItem(0); |
254 | } else { | 254 | } else { |
255 | setTopItem(topItem()+1); | 255 | setTopItem(topItem()+1); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
262 | { | 262 | { |
263 | switch(e->key()) { | 263 | switch(e->key()) { |
264 | case Key_Shift: | 264 | case Key_Shift: |
265 | emit shiftUp(); | 265 | emit shiftUp(); |
266 | break; | 266 | break; |
267 | default: | 267 | default: |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
273 | { | 273 | { |
274 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
275 | 275 | ||
276 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mblockRepaint = true; | 284 | mblockRepaint = true; |
285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | 286 | recycle( incidence, s ); |
287 | } | 287 | } |
288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
289 | { | 289 | { |
290 | mDisplayHighlighted = false; | 290 | mDisplayHighlighted = false; |
291 | setText( s ); | 291 | setText( s ); |
292 | mMultiday = 0; | 292 | mMultiday = 0; |
293 | mIncidence = incidence; | 293 | mIncidence = incidence; |
294 | mRecur = false; | 294 | mRecur = false; |
295 | mAlarm = false; | 295 | mAlarm = false; |
296 | mReply = false; | 296 | mReply = false; |
297 | mInfo = false; | 297 | mInfo = false; |
298 | mdayPos = 0; | 298 | mdayPos = 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
302 | { | 302 | { |
303 | if ( !mDisplayHighlighted ) | 303 | if ( !mDisplayHighlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHighlighted = false; | 305 | mDisplayHighlighted = false; |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | bool MonthViewItem::setHighlighted( Incidence * inc ) | 309 | bool MonthViewItem::setHighlighted( Incidence * inc ) |
310 | { | 310 | { |
311 | if ( inc == mIncidence ) { | 311 | if ( inc == mIncidence ) { |
312 | if ( mDisplayHighlighted ) | 312 | if ( mDisplayHighlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHighlighted = true; | 314 | mDisplayHighlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHighlighted ) | 317 | if ( !mDisplayHighlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHighlighted = false; | 319 | mDisplayHighlighted = false; |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
325 | { | 325 | { |
326 | if ( mblockRepaint || !mIncidence ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
330 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
331 | #else | 331 | #else |
332 | bool sel = selected(); | 332 | bool sel = selected(); |
333 | #endif | 333 | #endif |
334 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
335 | int x = 1; | 335 | int x = 1; |
336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) |
337 | { | 337 | { |
338 | 338 | ||
339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
342 | } | 342 | } |
343 | 343 | ||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | if ( sel ) p->setPen( Qt::white ); | 377 | if ( sel ) p->setPen( Qt::white ); |
378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
379 | 379 | ||
380 | #if 0 | 380 | #if 0 |
381 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 381 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
383 | #endif | 383 | #endif |
384 | QColor textColor = p->pen().color(); | 384 | QColor textColor = p->pen().color(); |
385 | 385 | ||
386 | 386 | ||
387 | if ( mMultiday ) { | 387 | if ( mMultiday ) { |
388 | int yyy = y+(size/2); | 388 | int yyy = y+(size/2); |
389 | int sizeM = size+2; | 389 | int sizeM = size+2; |
390 | p->setBrush( QBrush( textColor ) ); | 390 | p->setBrush( QBrush( textColor ) ); |
391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
392 | if ( mMultiday == 2 || mMultiday == 3 ) { | 392 | if ( mMultiday == 2 || mMultiday == 3 ) { |
393 | QPointArray pa ( 3 ); | 393 | QPointArray pa ( 3 ); |
394 | pa.setPoint (0, x, yyy ); | 394 | pa.setPoint (0, x, yyy ); |
395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
397 | p->drawPolygon( pa ); | 397 | p->drawPolygon( pa ); |
398 | } | 398 | } |
399 | if ( mMultiday == 2 || mMultiday == 1 ) { | 399 | if ( mMultiday == 2 || mMultiday == 1 ) { |
400 | QPointArray pa ( 3 ); | 400 | QPointArray pa ( 3 ); |
401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
404 | p->drawPolygon( pa ); | 404 | p->drawPolygon( pa ); |
405 | } | 405 | } |
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->recurrence()->doesRecur() ); | 790 | item->setRecur( event->recurrence()->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->recurrence()->doesRecur() ); | 881 | item->setRecur( todo->recurrence()->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1109 | Incidence *incidence = eventItem->incidence(); | 1109 | Incidence *incidence = eventItem->incidence(); |
1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void MonthViewCell::selection( QListBoxItem *item ) | 1113 | void MonthViewCell::selection( QListBoxItem *item ) |
1114 | { | 1114 | { |
1115 | if ( !item ) { | 1115 | if ( !item ) { |
1116 | emit highlightIncidence( 0 , this, 0 ); | 1116 | emit highlightIncidence( 0 , this, 0 ); |
1117 | return; | 1117 | return; |
1118 | } | 1118 | } |
1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1121 | mMonthView->setSelectedCell( this ); | 1121 | mMonthView->setSelectedCell( this ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void MonthViewCell::deHighLight() | 1124 | void MonthViewCell::deHighLight() |
1125 | { | 1125 | { |
1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1127 | while ( mitem ) { | 1127 | while ( mitem ) { |
1128 | if ( mitem->setHighlightedFalse() ) | 1128 | if ( mitem->setHighlightedFalse() ) |
1129 | updateItem ( mitem ); | 1129 | updateItem ( mitem ); |
1130 | mitem = (MonthViewItem *)mitem->next(); | 1130 | mitem = (MonthViewItem *)mitem->next(); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | // returns true if no inc found | 1133 | // returns true if no inc found |
1134 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1134 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1135 | { | 1135 | { |
1136 | 1136 | ||
1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1138 | while ( mitem ) { | 1138 | while ( mitem ) { |
1139 | if ( mitem->incidence() == inc ) { | 1139 | if ( mitem->incidence() == inc ) { |
1140 | if ( mitem->setHighlighted( inc ) ) | 1140 | if ( mitem->setHighlighted( inc ) ) |
1141 | updateItem ( mitem ); | 1141 | updateItem ( mitem ); |
1142 | return false; | 1142 | return false; |
1143 | } | 1143 | } |
1144 | mitem = (MonthViewItem *)mitem->next(); | 1144 | mitem = (MonthViewItem *)mitem->next(); |
1145 | } | 1145 | } |
1146 | return true; | 1146 | return true; |
1147 | } | 1147 | } |
1148 | // ******************************************************************************* | 1148 | // ******************************************************************************* |
1149 | // ******************************************************************************* | 1149 | // ******************************************************************************* |
1150 | // ******************************************************************************* | 1150 | // ******************************************************************************* |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1154 | : KOEventView( calendar, parent, name ), | 1154 | : KOEventView( calendar, parent, name ), |
1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1157 | { | 1157 | { |
1158 | mFlagKeyPressed = false; | 1158 | mFlagKeyPressed = false; |
1159 | mShortDayLabelsM = false; | 1159 | mShortDayLabelsM = false; |
1160 | mShortDayLabelsW = false; | 1160 | mShortDayLabelsW = false; |
1161 | skipResize = false; | 1161 | skipResize = false; |
1162 | clPending = true; | 1162 | clPending = true; |
1163 | mPopupCell = 0; | 1163 | mPopupCell = 0; |
1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1165 | mWidStack = new QWidgetStack( this ); | 1165 | mWidStack = new QWidgetStack( this ); |
1166 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1166 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1167 | mMonthView = new QWidget( mWidStack ); | 1167 | mMonthView = new QWidget( mWidStack ); |
1168 | mWeekView = new QWidget( mWidStack ); | 1168 | mWeekView = new QWidget( mWidStack ); |
1169 | #if QT_VERSION >= 0x030000 | 1169 | #if QT_VERSION >= 0x030000 |
1170 | mWidStack->addWidget(mMonthView ); | 1170 | mWidStack->addWidget(mMonthView ); |
1171 | mWidStack->addWidget(mWeekView ); | 1171 | mWidStack->addWidget(mWeekView ); |
1172 | #else | 1172 | #else |
1173 | mWidStack->addWidget( mMonthView, 1 ); | 1173 | mWidStack->addWidget( mMonthView, 1 ); |
1174 | mWidStack->addWidget( mWeekView , 1 ); | 1174 | mWidStack->addWidget( mWeekView , 1 ); |
1175 | #endif | 1175 | #endif |
1176 | hb->addWidget( mNavigatorBar ); | 1176 | hb->addWidget( mNavigatorBar ); |
1177 | hb->addWidget( mWidStack ); | 1177 | hb->addWidget( mWidStack ); |
1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1179 | updatePossible = false; | 1179 | updatePossible = false; |
1180 | //updatePossible = true; | 1180 | //updatePossible = true; |
1181 | mCells.setAutoDelete( true ); | 1181 | mCells.setAutoDelete( true ); |
1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1183 | mDayLabels.resize( mDaysPerWeek ); | 1183 | mDayLabels.resize( mDaysPerWeek ); |
1184 | mDayLabelsW.resize( mDaysPerWeek ); | 1184 | mDayLabelsW.resize( mDaysPerWeek ); |
1185 | QFont bfont = font(); | 1185 | QFont bfont = font(); |
1186 | if ( QApplication::desktop()->width() < 650 ) { | 1186 | if ( QApplication::desktop()->width() < 650 ) { |
1187 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1187 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1188 | } | 1188 | } |
1189 | bfont.setBold( true ); | 1189 | bfont.setBold( true ); |
1190 | int i; | 1190 | int i; |
1191 | 1191 | ||
1192 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1192 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1193 | QLabel *label = new QLabel( mMonthView ); | 1193 | QLabel *label = new QLabel( mMonthView ); |
1194 | label->setFont(bfont); | 1194 | label->setFont(bfont); |
1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1196 | label->setLineWidth(1); | 1196 | label->setLineWidth(1); |
1197 | label->setAlignment(AlignCenter); | 1197 | label->setAlignment(AlignCenter); |
1198 | mDayLabels.insert( i, label ); | 1198 | mDayLabels.insert( i, label ); |
1199 | label = new QLabel( mWeekView ); | 1199 | label = new QLabel( mWeekView ); |
1200 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1202 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1203 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1204 | mDayLabelsW.insert( i, label ); | 1204 | mDayLabelsW.insert( i, label ); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | bfont.setBold( false ); | 1207 | bfont.setBold( false ); |
1208 | mWeekLabels.resize( mNumWeeks+1 ); | 1208 | mWeekLabels.resize( mNumWeeks+1 ); |
1209 | mWeekLabelsW.resize( 2 ); | 1209 | mWeekLabelsW.resize( 2 ); |
1210 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1210 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1212 | label->setFocusPolicy(NoFocus); | 1212 | label->setFocusPolicy(NoFocus); |
1213 | label->setFont(bfont); | 1213 | label->setFont(bfont); |
1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1215 | label->setFlat(true); | 1215 | label->setFlat(true); |
1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1218 | //label->setLineWidth(1); | 1218 | //label->setLineWidth(1); |
1219 | //label->setAlignment(AlignCenter); | 1219 | //label->setAlignment(AlignCenter); |
1220 | mWeekLabels.insert( i, label ); | 1220 | mWeekLabels.insert( i, label ); |
1221 | } | 1221 | } |
1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1225 | 1225 | ||
1226 | for( i = 0; i < 1+1; i++ ) { | 1226 | for( i = 0; i < 1+1; i++ ) { |
1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1228 | label->setFocusPolicy(NoFocus); | 1228 | label->setFocusPolicy(NoFocus); |
1229 | label->setFont(bfont); | 1229 | label->setFont(bfont); |
1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1231 | label->setFlat(true); | 1231 | label->setFlat(true); |
1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1234 | //label->setLineWidth(1); | 1234 | //label->setLineWidth(1); |
1235 | //label->setAlignment(AlignCenter); | 1235 | //label->setAlignment(AlignCenter); |
1236 | mWeekLabelsW.insert( i, label ); | 1236 | mWeekLabelsW.insert( i, label ); |
1237 | } | 1237 | } |
1238 | mWeekLabelsW[1]->setText( i18n("W")); | 1238 | mWeekLabelsW[1]->setText( i18n("W")); |
1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | int row, col; | 1242 | int row, col; |
1243 | mCells.resize( mNumCells ); | 1243 | mCells.resize( mNumCells ); |
1244 | for( row = 0; row < mNumWeeks; ++row ) { | 1244 | for( row = 0; row < mNumWeeks; ++row ) { |
1245 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1245 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1247 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1247 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1248 | 1248 | ||
1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1250 | SLOT( defaultAction( Incidence * ) ) ); | 1250 | SLOT( defaultAction( Incidence * ) ) ); |
1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1252 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1252 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1254 | SIGNAL( showDaySignal( QDate ) ) ); | 1254 | SIGNAL( showDaySignal( QDate ) ) ); |
1255 | connect( cell, SIGNAL( nextCell() ), | 1255 | connect( cell, SIGNAL( nextCell() ), |
1256 | SLOT( nextCell() ) ); | 1256 | SLOT( nextCell() ) ); |
1257 | connect( cell, SIGNAL( prevCell() ), | 1257 | connect( cell, SIGNAL( prevCell() ), |
1258 | SLOT( prevCell() ) ); | 1258 | SLOT( prevCell() ) ); |
1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | mCellsW.resize( mDaysPerWeek ); | 1263 | mCellsW.resize( mDaysPerWeek ); |
1264 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1264 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1266 | mCellsW.insert( col, cell ); | 1266 | mCellsW.insert( col, cell ); |
1267 | 1267 | ||
1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1269 | SLOT( defaultAction( Incidence * ) ) ); | 1269 | SLOT( defaultAction( Incidence * ) ) ); |
1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1271 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1271 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1273 | SIGNAL( showDaySignal( QDate ) ) ); | 1273 | SIGNAL( showDaySignal( QDate ) ) ); |
1274 | connect( cell, SIGNAL( nextCell() ), | 1274 | connect( cell, SIGNAL( nextCell() ), |
1275 | SLOT( nextCell() ) ); | 1275 | SLOT( nextCell() ) ); |
1276 | connect( cell, SIGNAL( prevCell() ), | 1276 | connect( cell, SIGNAL( prevCell() ), |
1277 | SLOT( prevCell() ) ); | 1277 | SLOT( prevCell() ) ); |
1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1284 | mContextMenu = eventPopup(); | 1284 | mContextMenu = eventPopup(); |
1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1286 | i18n("New Event..."),this, | 1286 | i18n("New Event..."),this, |
1287 | SLOT(slotNewEvent()),false); | 1287 | SLOT(slotNewEvent()),false); |
1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1289 | i18n("New Todo..."),this, | 1289 | i18n("New Todo..."),this, |
1290 | SLOT(slotNewTodo()),false); | 1290 | SLOT(slotNewTodo()),false); |
1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1292 | i18n("Journal"),this, | 1292 | i18n("Journal"),this, |
1293 | SLOT(slotEditJournal()),false); | 1293 | SLOT(slotEditJournal()),false); |
1294 | 1294 | ||
1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1296 | SLOT( catChanged( Incidence * ) )); | 1296 | SLOT( catChanged( Incidence * ) )); |
1297 | 1297 | ||
1298 | 1298 | ||
1299 | QString pathString = ""; | 1299 | QString pathString = ""; |
1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1301 | if ( QApplication::desktop()->width() < 480 ) | 1301 | if ( QApplication::desktop()->width() < 480 ) |
1302 | pathString += "icons16/"; | 1302 | pathString += "icons16/"; |
1303 | } else | 1303 | } else |
1304 | pathString += "iconsmini/"; | 1304 | pathString += "iconsmini/"; |
1305 | mNewItemMenu = new QPopupMenu( this ); | 1305 | mNewItemMenu = new QPopupMenu( this ); |
1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1309 | 1309 | ||
1310 | // updateConfig(); //useless here... | 1310 | // updateConfig(); //useless here... |
1311 | // ... but we need mWidthLongDayLabel computed | 1311 | // ... but we need mWidthLongDayLabel computed |
1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1313 | mWidthLongDayLabel = 0; | 1313 | mWidthLongDayLabel = 0; |
1314 | for (int i = 0; i < 7; i++) { | 1314 | for (int i = 0; i < 7; i++) { |
1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1320 | 1320 | ||
1321 | #if 0 | 1321 | #if 0 |
1322 | if ( mShowWeekView ) | 1322 | if ( mShowWeekView ) |
1323 | mWidStack->raiseWidget( mWeekView ); | 1323 | mWidStack->raiseWidget( mWeekView ); |
1324 | else | 1324 | else |
1325 | mWidStack->raiseWidget( mMonthView ); | 1325 | mWidStack->raiseWidget( mMonthView ); |
1326 | #endif | 1326 | #endif |
1327 | 1327 | ||
1328 | emit incidenceSelected( 0 ); | 1328 | emit incidenceSelected( 0 ); |
1329 | 1329 | ||
1330 | mComputeLayoutTimer = new QTimer( this ); | 1330 | mComputeLayoutTimer = new QTimer( this ); |
1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1332 | 1332 | ||
1333 | 1333 | ||
1334 | #ifndef DESKTOP_VERSION | 1334 | #ifndef DESKTOP_VERSION |
1335 | resize( QApplication::desktop()->size() ); | 1335 | resize( QApplication::desktop()->size() ); |
1336 | #else | 1336 | #else |
1337 | resize(640, 480 ); | 1337 | resize(640, 480 ); |
1338 | updatePossible = true; | 1338 | updatePossible = true; |
1339 | #endif | 1339 | #endif |
1340 | computeLayout(); | 1340 | computeLayout(); |
1341 | 1341 | ||
1342 | if ( mShowWeekView ) | 1342 | if ( mShowWeekView ) |
1343 | mWidStack->raiseWidget( mWeekView ); | 1343 | mWidStack->raiseWidget( mWeekView ); |
1344 | else | 1344 | else |
1345 | mWidStack->raiseWidget( mMonthView ); | 1345 | mWidStack->raiseWidget( mMonthView ); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | KOMonthView::~KOMonthView() | 1348 | KOMonthView::~KOMonthView() |
1349 | { | 1349 | { |
1350 | delete mContextMenu; | 1350 | delete mContextMenu; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | void KOMonthView::catChanged( Incidence * ) | 1353 | void KOMonthView::catChanged( Incidence * ) |
1354 | { | 1354 | { |
1355 | updateView(); | 1355 | updateView(); |
1356 | } | 1356 | } |
1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1358 | { | 1358 | { |
1359 | static Incidence * lastInc = 0; | 1359 | static Incidence * lastInc = 0; |
1360 | static MonthViewCell * lastCell = 0; | 1360 | static MonthViewCell * lastCell = 0; |
1361 | 1361 | ||
1362 | if ( lastInc == inc && lastCell == mc ) | 1362 | if ( lastInc == inc && lastCell == mc ) |
1363 | return; | 1363 | return; |
1364 | lastInc = inc; | 1364 | lastInc = inc; |
1365 | lastCell = mc; | 1365 | lastCell = mc; |
1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1367 | 1367 | ||
1368 | bool weekview = false; | 1368 | bool weekview = false; |
1369 | uint index = 0; | 1369 | uint index = 0; |
1370 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1370 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1371 | if ( mCellsW[i] == mc ) { | 1371 | if ( mCellsW[i] == mc ) { |
1372 | weekview = true; | 1372 | weekview = true; |
1373 | index = i; | 1373 | index = i; |
1374 | break; | 1374 | break; |
1375 | } | 1375 | } |
1376 | } | 1376 | } |
1377 | QPtrVector<MonthViewCell> *cells; | 1377 | QPtrVector<MonthViewCell> *cells; |
1378 | if ( weekview ) | 1378 | if ( weekview ) |
1379 | cells = &mCellsW; | 1379 | cells = &mCellsW; |
1380 | else { | 1380 | else { |
1381 | for (uint i = 0; i < mCells.count(); ++i) { | 1381 | for (uint i = 0; i < mCells.count(); ++i) { |
1382 | if ( mCells[i] == mc ) { | 1382 | if ( mCells[i] == mc ) { |
1383 | index = i; | 1383 | index = i; |
1384 | break; | 1384 | break; |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | cells = &mCells; | 1387 | cells = &mCells; |
1388 | } | 1388 | } |
1389 | for (uint i = 0; i < (*cells).count(); ++i) { | 1389 | for (uint i = 0; i < (*cells).count(); ++i) { |
1390 | (*cells)[i]->deHighLight(); | 1390 | (*cells)[i]->deHighLight(); |
1391 | } | 1391 | } |
1392 | if ( ! inc ) | 1392 | if ( ! inc ) |
1393 | return; | 1393 | return; |
1394 | 1394 | ||
1395 | uint count = (*cells).count(); | 1395 | uint count = (*cells).count(); |
1396 | bool goLeft = (mday > 1 && index > 0); | 1396 | bool goLeft = (mday > 1 && index > 0); |
1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1398 | for (uint iii = 1; iii < count; ++iii) { | 1398 | for (uint iii = 1; iii < count; ++iii) { |
1399 | if ( goLeft ) { | 1399 | if ( goLeft ) { |
1400 | int left = index - iii; | 1400 | int left = index - iii; |
1401 | if ( left >= 0 ) { | 1401 | if ( left >= 0 ) { |
1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1403 | goLeft = false; | 1403 | goLeft = false; |
1404 | } else | 1404 | } else |
1405 | goLeft = false; | 1405 | goLeft = false; |
1406 | } | 1406 | } |
1407 | if ( goRight ) { | 1407 | if ( goRight ) { |
1408 | uint right = index + iii; | 1408 | uint right = index + iii; |
1409 | if ( right < count ) { | 1409 | if ( right < count ) { |
1410 | if ( (*cells)[right]->doHighLight(inc) ) | 1410 | if ( (*cells)[right]->doHighLight(inc) ) |
1411 | goRight = false; | 1411 | goRight = false; |
1412 | 1412 | ||
1413 | } else | 1413 | } else |
1414 | goRight = false; | 1414 | goRight = false; |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | #if 0 | 1418 | #if 0 |
1419 | if ( mday > 1 && index > 0 ) | 1419 | if ( mday > 1 && index > 0 ) |
1420 | for (int i = index-1; i >= 0; --i) { | 1420 | for (int i = index-1; i >= 0; --i) { |
1421 | //qDebug("index %d iii %d ", index, i); | 1421 | //qDebug("index %d iii %d ", index, i); |
1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1423 | break; | 1423 | break; |
1424 | } | 1424 | } |
1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1426 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1426 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1427 | if ( (*cells)[i]->doHighLight(inc) ) | 1427 | if ( (*cells)[i]->doHighLight(inc) ) |
1428 | break; | 1428 | break; |
1429 | } | 1429 | } |
1430 | #endif | 1430 | #endif |
1431 | 1431 | ||
1432 | } | 1432 | } |
1433 | void KOMonthView::selectInternalWeekNum ( int n ) | 1433 | void KOMonthView::selectInternalWeekNum ( int n ) |
1434 | { | 1434 | { |
1435 | switchView(); | 1435 | switchView(); |
1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1437 | emit selectMonth (); | 1437 | emit selectMonth (); |
1438 | else | 1438 | else |
1439 | emit selectWeekNum ( n ); | 1439 | emit selectWeekNum ( n ); |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | int KOMonthView::currentWeek() | 1442 | int KOMonthView::currentWeek() |
1443 | { | 1443 | { |
1444 | if ( mShowWeekView ) | 1444 | if ( mShowWeekView ) |
1445 | return mWeekLabelsW[0]->getWeekNum(); | 1445 | return mWeekLabelsW[0]->getWeekNum(); |
1446 | return mWeekLabels[0]->getWeekNum(); | 1446 | return mWeekLabels[0]->getWeekNum(); |
1447 | } | 1447 | } |
1448 | void KOMonthView::switchView() | 1448 | void KOMonthView::switchView() |
1449 | { | 1449 | { |
1450 | if ( selectedCell( ) ) | 1450 | if ( selectedCell( ) ) |
1451 | selectedCell()->deselect(); | 1451 | selectedCell()->deselect(); |
1452 | mShowWeekView = !mShowWeekView; | 1452 | mShowWeekView = !mShowWeekView; |
1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1454 | if ( clPending ) { | 1454 | if ( clPending ) { |
1455 | computeLayout(); | 1455 | computeLayout(); |
1456 | updateConfig(); | 1456 | updateConfig(); |
1457 | } | 1457 | } |
1458 | if ( mShowWeekView ) | 1458 | if ( mShowWeekView ) |
1459 | mWidStack->raiseWidget( mWeekView ); | 1459 | mWidStack->raiseWidget( mWeekView ); |
1460 | else | 1460 | else |
1461 | mWidStack->raiseWidget( mMonthView ); | 1461 | mWidStack->raiseWidget( mMonthView ); |
1462 | clPending = false; | 1462 | clPending = false; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | int KOMonthView::maxDatesHint() | 1465 | int KOMonthView::maxDatesHint() |
1466 | { | 1466 | { |
1467 | return mNumCells; | 1467 | return mNumCells; |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | int KOMonthView::currentDateCount() | 1470 | int KOMonthView::currentDateCount() |
1471 | { | 1471 | { |
1472 | return mNumCells; | 1472 | return mNumCells; |
1473 | } | 1473 | } |
1474 | 1474 | ||
1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1476 | { | 1476 | { |
1477 | QPtrList<Incidence> selected; | 1477 | QPtrList<Incidence> selected; |
1478 | 1478 | ||
1479 | if ( mSelectedCell ) { | 1479 | if ( mSelectedCell ) { |
1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1481 | if ( incidence ) selected.append( incidence ); | 1481 | if ( incidence ) selected.append( incidence ); |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | return selected; | 1484 | return selected; |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | DateList KOMonthView::selectedDates() | 1487 | DateList KOMonthView::selectedDates() |
1488 | { | 1488 | { |
1489 | DateList selected; | 1489 | DateList selected; |
1490 | 1490 | ||
1491 | if ( mSelectedCell ) { | 1491 | if ( mSelectedCell ) { |
1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1493 | if ( qd.isValid() ) selected.append( qd ); | 1493 | if ( qd.isValid() ) selected.append( qd ); |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | return selected; | 1496 | return selected; |
1497 | } | 1497 | } |
1498 | #if 0 | 1498 | #if 0 |
1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1500 | const QDate &td) | 1500 | const QDate &td) |
1501 | { | 1501 | { |
1502 | #ifndef KORG_NOPRINTER | 1502 | #ifndef KORG_NOPRINTER |
1503 | calPrinter->preview(CalPrinter::Month, fd, td); | 1503 | calPrinter->preview(CalPrinter::Month, fd, td); |
1504 | #endif | 1504 | #endif |
1505 | } | 1505 | } |
1506 | #endif | 1506 | #endif |
1507 | void KOMonthView::updateConfig() | 1507 | void KOMonthView::updateConfig() |
1508 | { | 1508 | { |
1509 | 1509 | ||
1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1511 | 1511 | ||
1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1513 | mWeekStartsMonday = true; | 1513 | mWeekStartsMonday = true; |
1514 | } | 1514 | } |
1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1516 | mWidthLongDayLabel = 0; | 1516 | mWidthLongDayLabel = 0; |
1517 | 1517 | ||
1518 | for (int i = 0; i < 7; i++) { | 1518 | for (int i = 0; i < 7; i++) { |
1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1521 | } | 1521 | } |
1522 | bool temp = mShowSatSunComp ; | 1522 | bool temp = mShowSatSunComp ; |
1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1524 | if ( ! mShowWeekView ) { | 1524 | if ( ! mShowWeekView ) { |
1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1526 | computeLayout(); | 1526 | computeLayout(); |
1527 | } else | 1527 | } else |
1528 | doComputeLayoutWeek(); | 1528 | doComputeLayoutWeek(); |
1529 | updateDayLabels(); | 1529 | updateDayLabels(); |
1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1532 | //resizeEvent( 0 ); | 1532 | //resizeEvent( 0 ); |
1533 | for (uint i = 0; i < mCells.count(); ++i) { | 1533 | for (uint i = 0; i < mCells.count(); ++i) { |
1534 | mCells[i]->updateConfig(); | 1534 | mCells[i]->updateConfig(); |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1537 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1539 | } | 1539 | } |
1540 | #ifdef DESKTOP_VERSION | 1540 | #ifdef DESKTOP_VERSION |
1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1542 | #endif | 1542 | #endif |
1543 | updateView(); | 1543 | updateView(); |
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | void KOMonthView::updateDayLabels() | 1546 | void KOMonthView::updateDayLabels() |
1547 | { | 1547 | { |
1548 | 1548 | ||
1549 | QPtrVector<QLabel> *mDayLabelsT; | 1549 | QPtrVector<QLabel> *mDayLabelsT; |
1550 | 1550 | ||
1551 | mDayLabelsT = &mDayLabelsW; | 1551 | mDayLabelsT = &mDayLabelsW; |
1552 | for (int i = 0; i < 7; i++) { | 1552 | for (int i = 0; i < 7; i++) { |
1553 | { | 1553 | { |
1554 | bool show = mShortDayLabelsW; | 1554 | bool show = mShortDayLabelsW; |
1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1556 | show = true; | 1556 | show = true; |
1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | mDayLabelsT = &mDayLabels; | 1560 | mDayLabelsT = &mDayLabels; |
1561 | for (int i = 0; i < 7; i++) { | 1561 | for (int i = 0; i < 7; i++) { |
1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1563 | bool show = mShortDayLabelsM; | 1563 | bool show = mShortDayLabelsM; |
1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1565 | show = true; | 1565 | show = true; |
1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1567 | } else { | 1567 | } else { |
1568 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1568 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | void KOMonthView::clearList() | 1576 | void KOMonthView::clearList() |
1577 | { | 1577 | { |
1578 | unsigned int i; | 1578 | unsigned int i; |
1579 | for( i = 0; i < mCells.size(); ++i ) { | 1579 | for( i = 0; i < mCells.size(); ++i ) { |
1580 | mCells[i]->clear(); | 1580 | mCells[i]->clear(); |
1581 | } | 1581 | } |
1582 | for( i = 0; i < mCellsW.size(); ++i ) { | 1582 | for( i = 0; i < mCellsW.size(); ++i ) { |
1583 | mCellsW[i]->clear(); | 1583 | mCellsW[i]->clear(); |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1586 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1587 | { | 1587 | { |
1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1589 | 1589 | ||
1590 | QPtrVector<MonthViewCell> *cells; | 1590 | QPtrVector<MonthViewCell> *cells; |
1591 | QPtrVector<QLabel> *dayLabels; | 1591 | QPtrVector<QLabel> *dayLabels; |
1592 | QPtrVector<KOWeekButton> *weekLabels; | 1592 | QPtrVector<KOWeekButton> *weekLabels; |
1593 | uint weekNum = 6; | 1593 | uint weekNum = 6; |
1594 | mStartDate = start; | 1594 | mStartDate = start; |
1595 | if ( mShowWeekView ) { | 1595 | if ( mShowWeekView ) { |
1596 | weekNum = 1; | 1596 | weekNum = 1; |
1597 | cells = &mCellsW; | 1597 | cells = &mCellsW; |
1598 | dayLabels = &mDayLabelsW; | 1598 | dayLabels = &mDayLabelsW; |
1599 | weekLabels = &mWeekLabelsW; | 1599 | weekLabels = &mWeekLabelsW; |
1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1601 | mStartDate = mStartDate.addDays( 1 ); | 1601 | mStartDate = mStartDate.addDays( 1 ); |
1602 | } | 1602 | } |
1603 | } else { | 1603 | } else { |
1604 | cells = &mCells; | 1604 | cells = &mCells; |
1605 | dayLabels = &mDayLabels; | 1605 | dayLabels = &mDayLabels; |
1606 | weekLabels = &mWeekLabels; | 1606 | weekLabels = &mWeekLabels; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1610 | 1610 | ||
1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1612 | mWeekStartsMonday = true; | 1612 | mWeekStartsMonday = true; |
1613 | } | 1613 | } |
1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1615 | 1615 | ||
1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1617 | mStartDate = mStartDate.addDays( -1 ); | 1617 | mStartDate = mStartDate.addDays( -1 ); |
1618 | } | 1618 | } |
1619 | uint i; | 1619 | uint i; |
1620 | for( i = 0; i < (*cells).size(); ++i ) { | 1620 | for( i = 0; i < (*cells).size(); ++i ) { |
1621 | QDate date = mStartDate.addDays( i ); | 1621 | QDate date = mStartDate.addDays( i ); |
1622 | (*cells)[i]->setDate( date ); | 1622 | (*cells)[i]->setDate( date ); |
1623 | 1623 | ||
1624 | #ifndef KORG_NOPLUGINS | 1624 | #ifndef KORG_NOPLUGINS |
1625 | // add holiday, if present | 1625 | // add holiday, if present |
1626 | QString hstring(KOCore::self()->holiday(date)); | 1626 | QString hstring(KOCore::self()->holiday(date)); |
1627 | (*cells)[i]->setHoliday( hstring ); | 1627 | (*cells)[i]->setHoliday( hstring ); |
1628 | #endif | 1628 | #endif |
1629 | 1629 | ||
1630 | } | 1630 | } |
1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1632 | for( i = 0; i < weekNum; ++i ) { | 1632 | for( i = 0; i < weekNum; ++i ) { |
1633 | int wno; | 1633 | int wno; |
1634 | // remember, according to ISO 8601, the first week of the year is the | 1634 | // remember, according to ISO 8601, the first week of the year is the |
1635 | // first week that contains a thursday. Thus we must subtract off 4, | 1635 | // first week that contains a thursday. Thus we must subtract off 4, |
1636 | // not just 1. | 1636 | // not just 1. |
1637 | int dayOfYear = date.dayOfYear(); | 1637 | int dayOfYear = date.dayOfYear(); |
1638 | if (dayOfYear % 7 != 0) | 1638 | if (dayOfYear % 7 != 0) |
1639 | wno = dayOfYear / 7 + 1; | 1639 | wno = dayOfYear / 7 + 1; |
1640 | else | 1640 | else |
1641 | wno =dayOfYear / 7; | 1641 | wno =dayOfYear / 7; |
1642 | (*weekLabels)[i]->setWeekNum( wno ); | 1642 | (*weekLabels)[i]->setWeekNum( wno ); |
1643 | date = date.addDays( 7 ); | 1643 | date = date.addDays( 7 ); |
1644 | } | 1644 | } |
1645 | updateView(); | 1645 | updateView(); |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | void KOMonthView::showEvents(QPtrList<Event>) | 1648 | void KOMonthView::showEvents(QPtrList<Event>) |
1649 | { | 1649 | { |
1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | void KOMonthView::changeEventDisplay(Event *, int) | 1653 | void KOMonthView::changeEventDisplay(Event *, int) |
1654 | { | 1654 | { |
1655 | // this should be re-written to be much more efficient, but this | 1655 | // this should be re-written to be much more efficient, but this |
1656 | // quick-and-dirty-hack gets the job done for right now. | 1656 | // quick-and-dirty-hack gets the job done for right now. |
1657 | //qDebug("KOMonthView::changeEventDisplay "); | 1657 | //qDebug("KOMonthView::changeEventDisplay "); |
1658 | updateView(); | 1658 | updateView(); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | void KOMonthView::updateView() | 1661 | void KOMonthView::updateView() |
1662 | { | 1662 | { |
1663 | 1663 | ||
1664 | if ( !updatePossible ) | 1664 | if ( !updatePossible ) |
1665 | return; | 1665 | return; |
1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1667 | //QTime ti; | 1667 | //QTime ti; |
1668 | //ti.start(); | 1668 | //ti.start(); |
1669 | clearSelection(); | 1669 | clearSelection(); |
1670 | QPtrVector<MonthViewCell> *cells; | 1670 | QPtrVector<MonthViewCell> *cells; |
1671 | if ( mShowWeekView ) { | 1671 | if ( mShowWeekView ) { |
1672 | cells = &mCellsW; | 1672 | cells = &mCellsW; |
1673 | } else { | 1673 | } else { |
1674 | cells = &mCells; | 1674 | cells = &mCells; |
1675 | } | 1675 | } |
1676 | #if 1 | 1676 | #if 1 |
1677 | int i; | 1677 | int i; |
1678 | int timeSpan = (*cells).size()-1; | 1678 | int timeSpan = (*cells).size()-1; |
1679 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1679 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1680 | timeSpan = 6; | 1680 | timeSpan = 6; |
1681 | for( i = 0; i < timeSpan + 1; ++i ) { | 1681 | for( i = 0; i < timeSpan + 1; ++i ) { |
1682 | (*cells)[i]->startUpdateCell(); | 1682 | (*cells)[i]->startUpdateCell(); |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | QPtrList<Event> events = calendar()->events(); | 1685 | QPtrList<Event> events = calendar()->events(); |
1686 | Event *event; | 1686 | Event *event; |
1687 | QDateTime dt; | 1687 | QDateTime dt; |
1688 | QDate endDate = mStartDate.addDays( timeSpan ); | 1688 | QDate endDate = mStartDate.addDays( timeSpan ); |
1689 | for( event = events.first(); event; event = events.next() ) { // for event | 1689 | for( event = events.first(); event; event = events.next() ) { // for event |
1690 | if ( event->doesRecur() ) { | 1690 | if ( event->doesRecur() ) { |
1691 | bool last; | 1691 | bool last; |
1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1693 | QDateTime incidenceEnd; | 1693 | QDateTime incidenceEnd; |
1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1695 | bool invalid = false; | 1695 | bool invalid = false; |
1696 | while( true ) { | 1696 | while( true ) { |
1697 | if ( incidenceStart.isValid() ) { | 1697 | if ( incidenceStart.isValid() ) { |
1698 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1698 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1699 | int st = incidenceStart.date().daysTo( endDate ); | 1699 | int st = incidenceStart.date().daysTo( endDate ); |
1700 | if ( st >= 0 ) { // start before timeend | 1700 | if ( st >= 0 ) { // start before timeend |
1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1702 | if ( end >= 0 ) { // end after timestart --- got one! | 1702 | if ( end >= 0 ) { // end after timestart --- got one! |
1703 | //normalize | 1703 | //normalize |
1704 | st = timeSpan - st; | 1704 | st = timeSpan - st; |
1705 | if ( st < 0 ) st = 0; | 1705 | if ( st < 0 ) st = 0; |
1706 | if ( end > timeSpan ) end = timeSpan; | 1706 | if ( end > timeSpan ) end = timeSpan; |
1707 | int iii; | 1707 | int iii; |
1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1709 | for ( iii = st;iii<= end;++iii) | 1709 | for ( iii = st;iii<= end;++iii) |
1710 | (*cells)[iii]->insertEvent( event ); | 1710 | (*cells)[iii]->insertEvent( event ); |
1711 | } | 1711 | } |
1712 | } | 1712 | } |
1713 | } else { | 1713 | } else { |
1714 | if ( invalid ) | 1714 | if ( invalid ) |
1715 | break; | 1715 | break; |
1716 | invalid = true; | 1716 | invalid = true; |
1717 | //qDebug("invalid %s", event->summary().latin1()); | 1717 | //qDebug("invalid %s", event->summary().latin1()); |
1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1719 | } | 1719 | } |
1720 | if ( last ) | 1720 | if ( last ) |
1721 | break; | 1721 | break; |
1722 | bool ok; | 1722 | bool ok; |
1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1724 | if ( ! ok ) | 1724 | if ( ! ok ) |
1725 | break; | 1725 | break; |
1726 | if ( incidenceStart.date() > endDate ) | 1726 | if ( incidenceStart.date() > endDate ) |
1727 | break; | 1727 | break; |
1728 | } | 1728 | } |
1729 | } else { // no recur | 1729 | } else { // no recur |
1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1732 | continue; | 1732 | continue; |
1733 | int st = event->dtStart().date().daysTo( endDate ); | 1733 | int st = event->dtStart().date().daysTo( endDate ); |
1734 | if ( st >= 0 ) { // start before timeend | 1734 | if ( st >= 0 ) { // start before timeend |
1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1736 | if ( end >= 0 ) { // end after timestart --- got one! | 1736 | if ( end >= 0 ) { // end after timestart --- got one! |
1737 | //normalize | 1737 | //normalize |
1738 | st = timeSpan - st; | 1738 | st = timeSpan - st; |
1739 | if ( st < 0 ) st = 0; | 1739 | if ( st < 0 ) st = 0; |
1740 | if ( end > timeSpan ) end = timeSpan; | 1740 | if ( end > timeSpan ) end = timeSpan; |
1741 | int iii; | 1741 | int iii; |
1742 | for ( iii = st;iii<= end;++iii) | 1742 | for ( iii = st;iii<= end;++iii) |
1743 | (*cells)[iii]->insertEvent( event ); | 1743 | (*cells)[iii]->insertEvent( event ); |
1744 | } | 1744 | } |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | } | 1747 | } |
1748 | // insert due todos | 1748 | // insert due todos |
1749 | QPtrList<Todo> todos = calendar()->todos( ); | 1749 | QPtrList<Todo> todos = calendar()->todos( ); |
1750 | Todo *todo; | 1750 | Todo *todo; |
1751 | for(todo = todos.first(); todo; todo = todos.next()) { | 1751 | for(todo = todos.first(); todo; todo = todos.next()) { |
1752 | //insertTodo( todo ); | 1752 | //insertTodo( todo ); |
1753 | if ( todo->hasDueDate() ) { | 1753 | if ( todo->hasDueDate() ) { |
1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1755 | if ( day >= 0 && day < timeSpan + 1) { | 1755 | if ( day >= 0 && day < timeSpan + 1) { |
1756 | (*cells)[day]->insertTodo( todo ); | 1756 | (*cells)[day]->insertTodo( todo ); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | for( i = 0; i < timeSpan+1; ++i ) { | 1761 | for( i = 0; i < timeSpan+1; ++i ) { |
1762 | (*cells)[i]->finishUpdateCell(); | 1762 | (*cells)[i]->finishUpdateCell(); |
1763 | } | 1763 | } |
1764 | processSelectionChange(); | 1764 | processSelectionChange(); |
1765 | //qApp->processEvents(); | 1765 | //qApp->processEvents(); |
1766 | for( i = 0; i < timeSpan+1; ++i ) { | 1766 | for( i = 0; i < timeSpan+1; ++i ) { |
1767 | //(*cells)[i]->repaintfinishUpdateCell(); | 1767 | //(*cells)[i]->repaintfinishUpdateCell(); |
1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1769 | } | 1769 | } |
1770 | setKeyBFocus(); | 1770 | setKeyBFocus(); |
1771 | #else | 1771 | #else |
1772 | // old code | 1772 | // old code |
1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1774 | int i; | 1774 | int i; |
1775 | for( i = 0; i < (*cells).count(); ++i ) { | 1775 | for( i = 0; i < (*cells).count(); ++i ) { |
1776 | (*cells)[i]->updateCell(); | 1776 | (*cells)[i]->updateCell(); |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | //qDebug("KOMonthView::updateView() "); | 1779 | //qDebug("KOMonthView::updateView() "); |
1780 | processSelectionChange(); | 1780 | processSelectionChange(); |
1781 | // qDebug("---------------------------------------------------------------------+ "); | 1781 | // qDebug("---------------------------------------------------------------------+ "); |
1782 | (*cells)[0]->setFocus(); | 1782 | (*cells)[0]->setFocus(); |
1783 | #endif | 1783 | #endif |
1784 | 1784 | ||
1785 | //qDebug("update time %d ", ti.elapsed()); | 1785 | //qDebug("update time %d ", ti.elapsed()); |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | void KOMonthView::setKeyBoardFocus() | 1788 | void KOMonthView::setKeyBoardFocus() |
1789 | { | 1789 | { |
1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1791 | bool shootAgain = false; | 1791 | bool shootAgain = false; |
1792 | if ( mShowWeekView ) { | 1792 | if ( mShowWeekView ) { |
1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1794 | mWeekLabelsW[1]->setFocus(); | 1794 | mWeekLabelsW[1]->setFocus(); |
1795 | } | 1795 | } |
1796 | else { | 1796 | else { |
1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1798 | mWeekLabels[mNumWeeks]->setFocus(); | 1798 | mWeekLabels[mNumWeeks]->setFocus(); |
1799 | } | 1799 | } |
1800 | --mKBFcounter; | 1800 | --mKBFcounter; |
1801 | if ( shootAgain && mKBFcounter > 0 ) { | 1801 | if ( shootAgain && mKBFcounter > 0 ) { |
1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1803 | } | 1803 | } |
1804 | } | 1804 | } |
1805 | void KOMonthView::setKeyBFocus() | 1805 | void KOMonthView::setKeyBFocus() |
1806 | { | 1806 | { |
1807 | //qDebug("KOMonthView::setKeyBFocus() "); | 1807 | //qDebug("KOMonthView::setKeyBFocus() "); |
1808 | mKBFcounter = 10; | 1808 | mKBFcounter = 10; |
1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1810 | } | 1810 | } |
1811 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1811 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1812 | { | 1812 | { |
1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1814 | if ( isVisible() ) { | 1814 | if ( isVisible() ) { |
1815 | //qDebug("KOMonthView::isVisible "); | 1815 | //qDebug("KOMonthView::isVisible "); |
1816 | slotComputeLayout(); | 1816 | slotComputeLayout(); |
1817 | } else | 1817 | } else |
1818 | mComputeLayoutTimer->start( 100 ); | 1818 | mComputeLayoutTimer->start( 100 ); |
1819 | if ( e ) | 1819 | if ( e ) |
1820 | KOEventView::resizeEvent( e ); | 1820 | KOEventView::resizeEvent( e ); |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | void KOMonthView::slotComputeLayout() | 1823 | void KOMonthView::slotComputeLayout() |
1824 | { | 1824 | { |
1825 | mComputeLayoutTimer->stop(); | 1825 | mComputeLayoutTimer->stop(); |
1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1827 | computeLayout(); | 1827 | computeLayout(); |
1828 | clPending = true; | 1828 | clPending = true; |
1829 | setKeyBFocus(); | 1829 | setKeyBFocus(); |
1830 | } | 1830 | } |
1831 | 1831 | ||
1832 | void KOMonthView::doComputeLayoutWeek() | 1832 | void KOMonthView::doComputeLayoutWeek() |
1833 | { | 1833 | { |
1834 | 1834 | ||
1835 | int daysToShow; | 1835 | int daysToShow; |
1836 | bool combinedSatSun = false; | 1836 | bool combinedSatSun = false; |
1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1838 | daysToShow = 6; | 1838 | daysToShow = 6; |
1839 | combinedSatSun = true; | 1839 | combinedSatSun = true; |
1840 | } | 1840 | } |
1841 | int wid = width();//e | 1841 | int wid = width();//e |
1842 | int hei = height()-1-mNavigatorBar->height(); | 1842 | int hei = height()-1-mNavigatorBar->height(); |
1843 | #ifdef DESKTOP_VERSION | ||
1843 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | 1844 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { |
1844 | daysToShow = 2; | 1845 | daysToShow = 2; |
1845 | } else { | 1846 | } else |
1847 | #endif | ||
1848 | { | ||
1846 | if ( wid < hei ) | 1849 | if ( wid < hei ) |
1847 | daysToShow = 2; | 1850 | daysToShow = 2; |
1848 | else | 1851 | else |
1849 | daysToShow = 3; | 1852 | daysToShow = 3; |
1850 | } | 1853 | } |
1851 | bool landscape = (daysToShow == 3); | 1854 | bool landscape = (daysToShow == 3); |
1852 | mShowSatSunComp = true; | 1855 | mShowSatSunComp = true; |
1853 | combinedSatSun = true; | 1856 | combinedSatSun = true; |
1854 | 1857 | ||
1855 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1858 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1856 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1859 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1857 | int weeklabelwid = fm.width( "888" ); | 1860 | int weeklabelwid = fm.width( "888" ); |
1858 | wid -= weeklabelwid; | 1861 | wid -= weeklabelwid; |
1859 | 1862 | ||
1860 | int colWid = wid / daysToShow; | 1863 | int colWid = wid / daysToShow; |
1861 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1864 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1862 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1865 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1863 | int colModulo = wid % daysToShow; | 1866 | int colModulo = wid % daysToShow; |
1864 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1867 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1865 | //qDebug("rowmod %d ", rowModulo); | 1868 | //qDebug("rowmod %d ", rowModulo); |
1866 | int i; | 1869 | int i; |
1867 | int x,y,w,h; | 1870 | int x,y,w,h; |
1868 | x= 0; | 1871 | x= 0; |
1869 | y= 0; | 1872 | y= 0; |
1870 | w = colWid; | 1873 | w = colWid; |
1871 | h = dayLabelHei ; | 1874 | h = dayLabelHei ; |
1872 | for ( i = 0; i < 7; i++) { | 1875 | for ( i = 0; i < 7; i++) { |
1873 | if ( i && !( i % daysToShow) && i < 6) { | 1876 | if ( i && !( i % daysToShow) && i < 6) { |
1874 | y += hei/(5-daysToShow); | 1877 | y += hei/(5-daysToShow); |
1875 | x = 0; | 1878 | x = 0; |
1876 | w = colWid; | 1879 | w = colWid; |
1877 | } | 1880 | } |
1878 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1881 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1879 | ++w; | 1882 | ++w; |
1880 | } | 1883 | } |
1881 | int xC,yC,wC,hC; | 1884 | int xC,yC,wC,hC; |
1882 | if ( i >= 5 ) { | 1885 | if ( i >= 5 ) { |
1883 | int wi = width() - x - weeklabelwid; | 1886 | int wi = width() - x - weeklabelwid; |
1884 | if ( i == 5 ) { | 1887 | if ( i == 5 ) { |
1885 | xC = x+weeklabelwid; | 1888 | xC = x+weeklabelwid; |
1886 | yC = y; | 1889 | yC = y; |
1887 | wC = wi/2+wi%2; | 1890 | wC = wi/2+wi%2; |
1888 | hC = h; | 1891 | hC = h; |
1889 | } else { | 1892 | } else { |
1890 | xC = x+weeklabelwid; | 1893 | xC = x+weeklabelwid; |
1891 | yC = y; | 1894 | yC = y; |
1892 | wC = wi; | 1895 | wC = wi; |
1893 | hC = h; | 1896 | hC = h; |
1894 | } | 1897 | } |
1895 | x = x - w + wi - (wi/2 ); | 1898 | x = x - w + wi - (wi/2 ); |
1896 | } | 1899 | } |
1897 | else { | 1900 | else { |
1898 | int wi = w; | 1901 | int wi = w; |
1899 | if ( !(( i+1) % daysToShow)) { | 1902 | if ( !(( i+1) % daysToShow)) { |
1900 | wi = width() - x - weeklabelwid; | 1903 | wi = width() - x - weeklabelwid; |
1901 | } | 1904 | } |
1902 | xC = x+weeklabelwid; | 1905 | xC = x+weeklabelwid; |
1903 | yC = y; | 1906 | yC = y; |
1904 | wC = wi; | 1907 | wC = wi; |
1905 | hC = h; | 1908 | hC = h; |
1906 | } | 1909 | } |
1907 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | 1910 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); |
1908 | 1911 | ||
1909 | 1912 | ||
1910 | x += w; | 1913 | x += w; |
1911 | } | 1914 | } |
1912 | x= 0; | 1915 | x= 0; |
1913 | y= dayLabelHei; | 1916 | y= dayLabelHei; |
1914 | w = colWid; | 1917 | w = colWid; |
1915 | h = cellHei; | 1918 | h = cellHei; |
1916 | int max = 0; | 1919 | int max = 0; |
1917 | int w_count = mCellsW.count(); | 1920 | int w_count = mCellsW.count(); |
1918 | for ( i = 0; i < w_count; ++i) { | 1921 | for ( i = 0; i < w_count; ++i) { |
1919 | if ( i > 6 ) { | 1922 | if ( i > 6 ) { |
1920 | mCellsW[i]->hide(); | 1923 | mCellsW[i]->hide(); |
1921 | continue; | 1924 | continue; |
1922 | } | 1925 | } |
1923 | 1926 | ||
1924 | w = colWid; | 1927 | w = colWid; |
1925 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1928 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1926 | ++w; | 1929 | ++w; |
1927 | } | 1930 | } |
1928 | if ( i == (daysToShow-1-rowModulo)*7) | 1931 | if ( i == (daysToShow-1-rowModulo)*7) |
1929 | ++h; | 1932 | ++h; |
1930 | 1933 | ||
1931 | int xC,yC,wC,hC; | 1934 | int xC,yC,wC,hC; |
1932 | if ( i >= 5 ) { | 1935 | if ( i >= 5 ) { |
1933 | if ( i ==5 ) { | 1936 | if ( i ==5 ) { |
1934 | max = h/2; | 1937 | max = h/2; |
1935 | xC = x+weeklabelwid; | 1938 | xC = x+weeklabelwid; |
1936 | yC = y; | 1939 | yC = y; |
1937 | wC = w; | 1940 | wC = w; |
1938 | hC = max; | 1941 | hC = max; |
1939 | x -= w ;y += h/2; | 1942 | x -= w ;y += h/2; |
1940 | } else { | 1943 | } else { |
1941 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1944 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1942 | ++w; | 1945 | ++w; |
1943 | } | 1946 | } |
1944 | max = h-h/2; | 1947 | max = h-h/2; |
1945 | xC = x+weeklabelwid; | 1948 | xC = x+weeklabelwid; |
1946 | yC = y; | 1949 | yC = y; |
1947 | wC = w; | 1950 | wC = w; |
1948 | hC = max; | 1951 | hC = max; |
1949 | y -= h/2; | 1952 | y -= h/2; |
1950 | } | 1953 | } |
1951 | } else { | 1954 | } else { |
1952 | max = h; | 1955 | max = h; |
1953 | xC = x+weeklabelwid; | 1956 | xC = x+weeklabelwid; |
1954 | yC = y; | 1957 | yC = y; |
1955 | wC = w; | 1958 | wC = w; |
1956 | hC = h; | 1959 | hC = h; |
1957 | } | 1960 | } |
1958 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | 1961 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); |
1959 | 1962 | ||
1960 | 1963 | ||
1961 | x += w; | 1964 | x += w; |
1962 | if ( x + w/2 > wid ) { | 1965 | if ( x + w/2 > wid ) { |
1963 | x = 0; | 1966 | x = 0; |
1964 | y += h+dayLabelHei ; | 1967 | y += h+dayLabelHei ; |
1965 | } | 1968 | } |
1966 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1969 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1967 | } | 1970 | } |
1968 | y= dayLabelHei; | 1971 | y= dayLabelHei; |
1969 | h = cellHei ; | 1972 | h = cellHei ; |
1970 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1973 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1971 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1974 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1972 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1975 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1973 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1976 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1974 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1977 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1975 | updateDayLabels(); | 1978 | updateDayLabels(); |
1976 | //bool forceUpdate = !updatePossible; | 1979 | //bool forceUpdate = !updatePossible; |
1977 | updatePossible = true; | 1980 | updatePossible = true; |
1978 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1981 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1979 | //if ( forceUpdate ) | 1982 | //if ( forceUpdate ) |
1980 | // updateView(); | 1983 | // updateView(); |
1981 | } | 1984 | } |
1982 | void KOMonthView::computeLayoutWeek() | 1985 | void KOMonthView::computeLayoutWeek() |
1983 | { | 1986 | { |
1984 | static int lastWid = 0; | 1987 | static int lastWid = 0; |
1985 | static int lastHei = 0; | 1988 | static int lastHei = 0; |
1986 | int tWid = topLevelWidget()->size().width(); | 1989 | int tWid = topLevelWidget()->size().width(); |
1987 | int tHei = topLevelWidget()->size().height(); | 1990 | int tHei = topLevelWidget()->size().height(); |
1988 | int wid = width();//e | 1991 | int wid = width();//e |
1989 | int hei = height()-1-mNavigatorBar->height(); | 1992 | int hei = height()-1-mNavigatorBar->height(); |
1990 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1993 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1991 | return; | 1994 | return; |
1992 | 1995 | ||
1993 | if ( lastWid == width() && lastHei == height() ) { | 1996 | if ( lastWid == width() && lastHei == height() ) { |
1994 | //qDebug("KOListWeekView::No compute layout needed "); | 1997 | //qDebug("KOListWeekView::No compute layout needed "); |
1995 | return; | 1998 | return; |
1996 | } | 1999 | } |
1997 | lastWid = width(); | 2000 | lastWid = width(); |
1998 | lastHei = height(); | 2001 | lastHei = height(); |
1999 | doComputeLayoutWeek(); | 2002 | doComputeLayoutWeek(); |
2000 | } | 2003 | } |
2001 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | 2004 | int KOMonthView::mapWeekLayout( int index, bool landscape ) |
2002 | { | 2005 | { |
2003 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | 2006 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) |
2004 | return index; | 2007 | return index; |
2005 | int diff = 0; | 2008 | int diff = 0; |
2006 | if ( !landscape ) diff = 1; | 2009 | if ( !landscape ) diff = 1; |
2007 | switch( index ) { | 2010 | switch( index ) { |
2008 | case 0: | 2011 | case 0: |
2009 | case 5: | 2012 | case 5: |
2010 | case 6: | 2013 | case 6: |
2011 | return index; | 2014 | return index; |
2012 | break; | 2015 | break; |
2013 | case 1: | 2016 | case 1: |
2014 | return 2+diff; | 2017 | return 2+diff; |
2015 | break; | 2018 | break; |
2016 | case 2: | 2019 | case 2: |
2017 | return 4-(3*diff); | 2020 | return 4-(3*diff); |
2018 | break; | 2021 | break; |
2019 | case 3: | 2022 | case 3: |
2020 | return 1+(3*diff); | 2023 | return 1+(3*diff); |
2021 | break; | 2024 | break; |
2022 | case 4: | 2025 | case 4: |
2023 | return 3-diff; | 2026 | return 3-diff; |
2024 | break; | 2027 | break; |
2025 | default: | 2028 | default: |
2026 | qDebug("KO: Error in mapping week layout "); | 2029 | qDebug("KO: Error in mapping week layout "); |
2027 | return index; | 2030 | return index; |
2028 | break; | 2031 | break; |
2029 | } | 2032 | } |
2030 | return index; | 2033 | return index; |
2031 | } | 2034 | } |
2032 | void KOMonthView::computeLayout() | 2035 | void KOMonthView::computeLayout() |
2033 | { | 2036 | { |
2034 | 2037 | ||
2035 | 2038 | ||
2036 | static int lastWid = 0; | 2039 | static int lastWid = 0; |
2037 | static int lastHei = 0; | 2040 | static int lastHei = 0; |
2038 | 2041 | ||
2039 | if ( mShowWeekView ){ | 2042 | if ( mShowWeekView ){ |
2040 | computeLayoutWeek(); | 2043 | computeLayoutWeek(); |
2041 | return; | 2044 | return; |
2042 | } | 2045 | } |
2043 | int daysToShow = 7; | 2046 | int daysToShow = 7; |
2044 | bool combinedSatSun = false; | 2047 | bool combinedSatSun = false; |
2045 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2048 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
2046 | daysToShow = 6; | 2049 | daysToShow = 6; |
2047 | combinedSatSun = true; | 2050 | combinedSatSun = true; |
2048 | } | 2051 | } |
2049 | int tWid = topLevelWidget()->size().width(); | 2052 | int tWid = topLevelWidget()->size().width(); |
2050 | int tHei = topLevelWidget()->size().height(); | 2053 | int tHei = topLevelWidget()->size().height(); |
2051 | 2054 | ||
2052 | int wid = width();//e | 2055 | int wid = width();//e |
2053 | int hei = height()-1-mNavigatorBar->height(); | 2056 | int hei = height()-1-mNavigatorBar->height(); |
2054 | 2057 | ||
2055 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2058 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
2056 | return; | 2059 | return; |
2057 | } | 2060 | } |
2058 | if ( lastWid == width() && lastHei == height() ){ | 2061 | if ( lastWid == width() && lastHei == height() ){ |
2059 | //qDebug("KOMonthview::No compute layout needed "); | 2062 | //qDebug("KOMonthview::No compute layout needed "); |
2060 | return; | 2063 | return; |
2061 | } | 2064 | } |
2062 | 2065 | ||
2063 | lastWid = width(); | 2066 | lastWid = width(); |
2064 | lastHei = height(); | 2067 | lastHei = height(); |
2065 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 2068 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
2066 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 2069 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
2067 | int weeklabelwid = fm.width( "888" ); | 2070 | int weeklabelwid = fm.width( "888" ); |
2068 | wid -= weeklabelwid; | 2071 | wid -= weeklabelwid; |
2069 | 2072 | ||
2070 | int colWid = wid / daysToShow; | 2073 | int colWid = wid / daysToShow; |
2071 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 2074 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
2072 | int cellHei = (hei - dayLabelHei) /6; | 2075 | int cellHei = (hei - dayLabelHei) /6; |
2073 | int colModulo = wid % daysToShow; | 2076 | int colModulo = wid % daysToShow; |
2074 | int rowModulo = (hei- dayLabelHei) % 6; | 2077 | int rowModulo = (hei- dayLabelHei) % 6; |
2075 | //qDebug("rowmod %d ", rowModulo); | 2078 | //qDebug("rowmod %d ", rowModulo); |
2076 | int i; | 2079 | int i; |
2077 | int x,y,w,h; | 2080 | int x,y,w,h; |
2078 | x= 0; | 2081 | x= 0; |
2079 | y= 0; | 2082 | y= 0; |
2080 | w = colWid; | 2083 | w = colWid; |
2081 | h = dayLabelHei ; | 2084 | h = dayLabelHei ; |
2082 | for ( i = 0; i < 7; i++) { | 2085 | for ( i = 0; i < 7; i++) { |
2083 | if ( i == daysToShow-colModulo ) | 2086 | if ( i == daysToShow-colModulo ) |
2084 | ++w; | 2087 | ++w; |
2085 | if ( combinedSatSun ) { | 2088 | if ( combinedSatSun ) { |
2086 | if ( i >= daysToShow-1 ) { | 2089 | if ( i >= daysToShow-1 ) { |
2087 | 2090 | ||
2088 | if ( i == 6 ) | 2091 | if ( i == 6 ) |
2089 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 2092 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
2090 | else | 2093 | else |
2091 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 2094 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
2092 | x -= w/2 ; | 2095 | x -= w/2 ; |
2093 | } | 2096 | } |
2094 | else | 2097 | else |
2095 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2098 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2096 | } else | 2099 | } else |
2097 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2098 | x += w; | 2101 | x += w; |
2099 | } | 2102 | } |
2100 | x= 0; | 2103 | x= 0; |
2101 | y= dayLabelHei; | 2104 | y= dayLabelHei; |
2102 | w = colWid; | 2105 | w = colWid; |
2103 | h = cellHei ; | 2106 | h = cellHei ; |
2104 | int max = 0; | 2107 | int max = 0; |
2105 | int mc_count = mCells.count(); | 2108 | int mc_count = mCells.count(); |
2106 | for ( i = 0; i < mc_count; ++i) { | 2109 | for ( i = 0; i < mc_count; ++i) { |
2107 | //qDebug("iii %d ", i); | 2110 | //qDebug("iii %d ", i); |
2108 | w = colWid; | 2111 | w = colWid; |
2109 | if ( ((i) % 7) >= 7-colModulo ) { | 2112 | if ( ((i) % 7) >= 7-colModulo ) { |
2110 | ++w; | 2113 | ++w; |
2111 | } | 2114 | } |
2112 | if ( i == (6-rowModulo)*7) | 2115 | if ( i == (6-rowModulo)*7) |
2113 | ++h; | 2116 | ++h; |
2114 | if ( combinedSatSun ) { | 2117 | if ( combinedSatSun ) { |
2115 | if ( (i)%7 >= daysToShow-1 ) { | 2118 | if ( (i)%7 >= daysToShow-1 ) { |
2116 | if ( (i)%7 == daysToShow-1 ) { | 2119 | if ( (i)%7 == daysToShow-1 ) { |
2117 | w = width()-x-weeklabelwid; | 2120 | w = width()-x-weeklabelwid; |
2118 | max = h/2; | 2121 | max = h/2; |
2119 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2122 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2120 | x -= w ;y += h/2; | 2123 | x -= w ;y += h/2; |
2121 | } else { | 2124 | } else { |
2122 | w = width()-x-weeklabelwid; | 2125 | w = width()-x-weeklabelwid; |
2123 | max = h-h/2; | 2126 | max = h-h/2; |
2124 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2127 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2125 | y -= h/2; | 2128 | y -= h/2; |
2126 | } | 2129 | } |
2127 | } else { | 2130 | } else { |
2128 | max = h; | 2131 | max = h; |
2129 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2132 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2130 | } | 2133 | } |
2131 | 2134 | ||
2132 | } | 2135 | } |
2133 | else { | 2136 | else { |
2134 | max = h; | 2137 | max = h; |
2135 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2138 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2136 | } | 2139 | } |
2137 | x += w; | 2140 | x += w; |
2138 | if ( x + w/2 > wid ) { | 2141 | if ( x + w/2 > wid ) { |
2139 | x = 0; | 2142 | x = 0; |
2140 | y += h; | 2143 | y += h; |
2141 | } | 2144 | } |
2142 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 2145 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
2143 | } | 2146 | } |
2144 | y= dayLabelHei; | 2147 | y= dayLabelHei; |
2145 | h = cellHei ; | 2148 | h = cellHei ; |
2146 | for ( i = 0; i < 6; i++) { | 2149 | for ( i = 0; i < 6; i++) { |
2147 | if ( i == (6-rowModulo)) | 2150 | if ( i == (6-rowModulo)) |
2148 | ++h; | 2151 | ++h; |
2149 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 2152 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
2150 | y += h; | 2153 | y += h; |
2151 | } | 2154 | } |
2152 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 2155 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
2153 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 2156 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
2154 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 2157 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
2155 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 2158 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
2156 | updateDayLabels(); | 2159 | updateDayLabels(); |
2157 | //bool forceUpdate = !updatePossible; | 2160 | //bool forceUpdate = !updatePossible; |
2158 | updatePossible = true; | 2161 | updatePossible = true; |
2159 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 2162 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
2160 | } | 2163 | } |
2161 | 2164 | ||
2162 | void KOMonthView::showContextMenu( Incidence *incidence ) | 2165 | void KOMonthView::showContextMenu( Incidence *incidence ) |
2163 | { | 2166 | { |
2164 | if( incidence ) | 2167 | if( incidence ) |
2165 | mContextMenu->showIncidencePopup(incidence); | 2168 | mContextMenu->showIncidencePopup(incidence); |
2166 | else { | 2169 | else { |
2167 | //qDebug("KOMonthView::showContextMenu "); | 2170 | //qDebug("KOMonthView::showContextMenu "); |
2168 | mNewItemMenu->popup(QCursor::pos()); | 2171 | mNewItemMenu->popup(QCursor::pos()); |
2169 | } | 2172 | } |
2170 | /* | 2173 | /* |
2171 | if( incidence && incidence->typeID() == eventID ) { | 2174 | if( incidence && incidence->typeID() == eventID ) { |
2172 | Event *event = static_cast<Event *>(incidence); | 2175 | Event *event = static_cast<Event *>(incidence); |
2173 | mContextMenu->showEventPopup(event); | 2176 | mContextMenu->showEventPopup(event); |
2174 | } else { | 2177 | } else { |
2175 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 2178 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
2176 | } | 2179 | } |
2177 | */ | 2180 | */ |
2178 | } | 2181 | } |
2179 | MonthViewCell * KOMonthView::selectedCell( ) | 2182 | MonthViewCell * KOMonthView::selectedCell( ) |
2180 | { | 2183 | { |
2181 | return mSelectedCell; | 2184 | return mSelectedCell; |
2182 | } | 2185 | } |
2183 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2186 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2184 | { | 2187 | { |
2185 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2188 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2186 | if ( mSelectedCell && mSelectedCell != cell ) { | 2189 | if ( mSelectedCell && mSelectedCell != cell ) { |
2187 | MonthViewCell * mvc = mSelectedCell; | 2190 | MonthViewCell * mvc = mSelectedCell; |
2188 | mSelectedCell = cell; | 2191 | mSelectedCell = cell; |
2189 | mvc->deselect(); | 2192 | mvc->deselect(); |
2190 | } else | 2193 | } else |
2191 | mSelectedCell = cell; | 2194 | mSelectedCell = cell; |
2192 | // if ( mSelectedCell ) | 2195 | // if ( mSelectedCell ) |
2193 | // mSelectedCell->select(); | 2196 | // mSelectedCell->select(); |
2194 | if ( !mSelectedCell ) | 2197 | if ( !mSelectedCell ) |
2195 | emit incidenceSelected( 0 ); | 2198 | emit incidenceSelected( 0 ); |
2196 | else | 2199 | else |
2197 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2200 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2198 | } | 2201 | } |
2199 | 2202 | ||
2200 | void KOMonthView::processSelectionChange() | 2203 | void KOMonthView::processSelectionChange() |
2201 | { | 2204 | { |
2202 | QPtrList<Incidence> incidences = selectedIncidences(); | 2205 | QPtrList<Incidence> incidences = selectedIncidences(); |
2203 | if (incidences.count() > 0) { | 2206 | if (incidences.count() > 0) { |
2204 | emit incidenceSelected( incidences.first() ); | 2207 | emit incidenceSelected( incidences.first() ); |
2205 | } else { | 2208 | } else { |
2206 | emit incidenceSelected( 0 ); | 2209 | emit incidenceSelected( 0 ); |
2207 | clearSelection(); | 2210 | clearSelection(); |
2208 | } | 2211 | } |
2209 | } | 2212 | } |
2210 | 2213 | ||
2211 | void KOMonthView::clearSelection() | 2214 | void KOMonthView::clearSelection() |
2212 | { | 2215 | { |
2213 | if ( mSelectedCell ) { | 2216 | if ( mSelectedCell ) { |
2214 | mSelectedCell->deselect(); | 2217 | mSelectedCell->deselect(); |
2215 | mSelectedCell = 0; | 2218 | mSelectedCell = 0; |
2216 | } | 2219 | } |
2217 | } | 2220 | } |
2218 | 2221 | ||
2219 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2222 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2220 | { | 2223 | { |
2221 | if ( !e->isAutoRepeat() ) { | 2224 | if ( !e->isAutoRepeat() ) { |
2222 | mFlagKeyPressed = false; | 2225 | mFlagKeyPressed = false; |
2223 | } | 2226 | } |
2224 | } | 2227 | } |
2225 | 2228 | ||
2226 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2229 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2227 | { | 2230 | { |
2228 | 2231 | ||
2229 | qApp->processEvents(); | 2232 | qApp->processEvents(); |
2230 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2233 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2231 | //e->ignore(); | 2234 | //e->ignore(); |
2232 | e->accept(); | 2235 | e->accept(); |
2233 | return; | 2236 | return; |
2234 | } | 2237 | } |
2235 | if (! e->isAutoRepeat() ) | 2238 | if (! e->isAutoRepeat() ) |
2236 | mFlagKeyPressed = true; | 2239 | mFlagKeyPressed = true; |
2237 | switch(e->key()) { | 2240 | switch(e->key()) { |
2238 | case Key_Up: | 2241 | case Key_Up: |
2239 | { | 2242 | { |
2240 | if ( mShowWeekView ) { | 2243 | if ( mShowWeekView ) { |
2241 | emit selectWeekNum ( currentWeek() - 1 ); | 2244 | emit selectWeekNum ( currentWeek() - 1 ); |
2242 | } | 2245 | } |
2243 | else { | 2246 | else { |
2244 | emit prevMonth(); | 2247 | emit prevMonth(); |
2245 | } | 2248 | } |
2246 | } | 2249 | } |
2247 | e->accept(); | 2250 | e->accept(); |
2248 | break; | 2251 | break; |
2249 | case Key_Down: | 2252 | case Key_Down: |
2250 | { | 2253 | { |
2251 | if ( mShowWeekView ) { | 2254 | if ( mShowWeekView ) { |
2252 | emit selectWeekNum ( currentWeek() +1); | 2255 | emit selectWeekNum ( currentWeek() +1); |
2253 | } | 2256 | } |
2254 | else { | 2257 | else { |
2255 | emit nextMonth(); | 2258 | emit nextMonth(); |
2256 | } | 2259 | } |
2257 | 2260 | ||
2258 | } | 2261 | } |
2259 | e->accept(); | 2262 | e->accept(); |
2260 | break; | 2263 | break; |
2261 | case Key_Return: | 2264 | case Key_Return: |
2262 | case Key_Enter: | 2265 | case Key_Enter: |
2263 | { | 2266 | { |
2264 | selectInternalWeekNum ( currentWeek() ); | 2267 | selectInternalWeekNum ( currentWeek() ); |
2265 | } | 2268 | } |
2266 | e->accept(); | 2269 | e->accept(); |
2267 | break; | 2270 | break; |
2268 | case Key_D: | 2271 | case Key_D: |
2269 | if ( mSelectedCell ) { | 2272 | if ( mSelectedCell ) { |
2270 | mSelectedCell->showDay(); | 2273 | mSelectedCell->showDay(); |
2271 | e->accept(); | 2274 | e->accept(); |
2272 | } else { | 2275 | } else { |
2273 | e->ignore(); | 2276 | e->ignore(); |
2274 | } | 2277 | } |
2275 | break; | 2278 | break; |
2276 | default: | 2279 | default: |
2277 | e->ignore(); | 2280 | e->ignore(); |
2278 | break; | 2281 | break; |
2279 | } | 2282 | } |
2280 | } | 2283 | } |
2281 | 2284 | ||
2282 | void KOMonthView::nextCell() | 2285 | void KOMonthView::nextCell() |
2283 | { | 2286 | { |
2284 | focusNextPrevChild ( true ); | 2287 | focusNextPrevChild ( true ); |
2285 | } | 2288 | } |
2286 | void KOMonthView::prevCell() | 2289 | void KOMonthView::prevCell() |
2287 | { | 2290 | { |
2288 | focusNextPrevChild ( false ); | 2291 | focusNextPrevChild ( false ); |
2289 | } | 2292 | } |
2290 | 2293 | ||
2291 | void KOMonthView::slotNewTodo() | 2294 | void KOMonthView::slotNewTodo() |
2292 | { | 2295 | { |
2293 | //qDebug("KOMonthView::slotNewTodo() "); | 2296 | //qDebug("KOMonthView::slotNewTodo() "); |
2294 | if ( mPopupCell ){ | 2297 | if ( mPopupCell ){ |
2295 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2298 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2296 | emit newTodoSignal(dt,true); | 2299 | emit newTodoSignal(dt,true); |
2297 | } | 2300 | } |
2298 | mPopupCell = 0; | 2301 | mPopupCell = 0; |
2299 | } | 2302 | } |
2300 | void KOMonthView::slotNewEvent() | 2303 | void KOMonthView::slotNewEvent() |
2301 | { | 2304 | { |
2302 | if ( mPopupCell ) { | 2305 | if ( mPopupCell ) { |
2303 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2306 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2304 | emit newEventSignal( dt ); | 2307 | emit newEventSignal( dt ); |
2305 | } | 2308 | } |
2306 | //qDebug("KOMonthView::slotNewEvent() "); | 2309 | //qDebug("KOMonthView::slotNewEvent() "); |
2307 | mPopupCell = 0; | 2310 | mPopupCell = 0; |
2308 | } | 2311 | } |
2309 | 2312 | ||
2310 | void KOMonthView::slotEditJournal() | 2313 | void KOMonthView::slotEditJournal() |
2311 | { | 2314 | { |
2312 | if ( mPopupCell ) | 2315 | if ( mPopupCell ) |
2313 | emit showJournalSignal( 7, mPopupCell->date() ); | 2316 | emit showJournalSignal( 7, mPopupCell->date() ); |
2314 | //qDebug("KOMonthView::slotEditJournal() "); | 2317 | //qDebug("KOMonthView::slotEditJournal() "); |
2315 | mPopupCell = 0; | 2318 | mPopupCell = 0; |
2316 | } | 2319 | } |
2317 | 2320 | ||
2318 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2321 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2319 | { | 2322 | { |
2320 | mPopupCell = c; | 2323 | mPopupCell = c; |
2321 | } | 2324 | } |