-rw-r--r-- | bin/kdepim/WhatsNew.txt | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 34 |
2 files changed, 23 insertions, 17 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 8fab725..2ce78c7 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,256 +1,260 @@ | |||
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", shift+q or ctrl +q ). | 8 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). |
9 | Added an option to change the layout of the list week to column mode. | 9 | Added an option to change the layout of the list week to column mode. |
10 | 10 | ||
11 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. | 11 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. |
12 | 12 | ||
13 | Fixed pi-sync problems with the new multi calendar feature. | 13 | Fixed pi-sync problems with the new multi calendar feature. |
14 | Now pi-sync behaviour should be: | 14 | Now pi-sync behaviour should be: |
15 | 1) Local sends file request ( as usual ) | 15 | 1) Local sends file request ( as usual ) |
16 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. | 16 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. |
17 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). | 17 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). |
18 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. | ||
18 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. | 19 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. |
19 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. | 20 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. |
20 | 21 | ||
21 | Summary: If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. | 22 | Summary: |
23 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. | ||
24 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. | ||
25 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. | ||
22 | 26 | ||
23 | ********** VERSION 2.1.13 ************ | 27 | ********** VERSION 2.1.13 ************ |
24 | 28 | ||
25 | Fixed a problem in KA/Pi search. | 29 | Fixed a problem in KA/Pi search. |
26 | Fixed some minor problems in KO/Pi. | 30 | Fixed some minor problems in KO/Pi. |
27 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. | 31 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. |
28 | 32 | ||
29 | Fixed memory usage problems in KA/Pi: | 33 | Fixed memory usage problems in KA/Pi: |
30 | When loading data KA/Pi did load the file data twice. | 34 | When loading data KA/Pi did load the file data twice. |
31 | Example: | 35 | Example: |
32 | A 600k file did consume 1200k memory during loading process. | 36 | A 600k file did consume 1200k memory during loading process. |
33 | This is fixed, it does now consume only 600k during loading process. | 37 | This is fixed, it does now consume only 600k during loading process. |
34 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. | 38 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. |
35 | This is fixed. | 39 | This is fixed. |
36 | Example: | 40 | Example: |
37 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. | 41 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. |
38 | 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. | 42 | 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. |
39 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. | 43 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. |
40 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. | 44 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. |
41 | The saving of data may be a bit slower now. | 45 | The saving of data may be a bit slower now. |
42 | 46 | ||
43 | Fixed memory usage problems in KO/Pi: | 47 | Fixed memory usage problems in KO/Pi: |
44 | When KO/Pi did save the data to file, it did not release the used buffers after saving. | 48 | When KO/Pi did save the data to file, it did not release the used buffers after saving. |
45 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. | 49 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. |
46 | This is fixed. | 50 | This is fixed. |
47 | Example: | 51 | Example: |
48 | When saving a 400k file KO/Pi do now use 400k less memory now. | 52 | When saving a 400k file KO/Pi do now use 400k less memory now. |
49 | 53 | ||
50 | Optimized memory usage in KO/Pi Agenda view: | 54 | Optimized memory usage in KO/Pi Agenda view: |
51 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. | 55 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. |
52 | These buffers were not made smaller (i.e. downsized) because of performance reasons. | 56 | These buffers were not made smaller (i.e. downsized) because of performance reasons. |
53 | The handling of these buffers are now much smarter: | 57 | The handling of these buffers are now much smarter: |
54 | Two (of six) buffers are removed completely. | 58 | Two (of six) buffers are removed completely. |
55 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. | 59 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. |
56 | 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. | 60 | 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. |
57 | 61 | ||
58 | Worst case example ( for a maximum size agenda content): | 62 | Worst case example ( for a maximum size agenda content): |
59 | 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. | 63 | 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. |
60 | 64 | ||
61 | 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. | 65 | 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. |
62 | 66 | ||
63 | Summary: | 67 | Summary: |
64 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. | 68 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. |
65 | 69 | ||
66 | ********** VERSION 2.1.12 ************ | 70 | ********** VERSION 2.1.12 ************ |
67 | 71 | ||
68 | KO/Pi: | 72 | KO/Pi: |
69 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. | 73 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. |
70 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. | 74 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. |
71 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). | 75 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). |
72 | Fixed some other small problems. | 76 | Fixed some other small problems. |
73 | 77 | ||
74 | ********** VERSION 2.1.11 ************ | 78 | ********** VERSION 2.1.11 ************ |
75 | 79 | ||
76 | KO/Pi: | 80 | KO/Pi: |
77 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. | 81 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. |
78 | Added features to handle (and add ) more than one journal entry per day. | 82 | Added features to handle (and add ) more than one journal entry per day. |
79 | Added option for a journal title. | 83 | Added option for a journal title. |
80 | 84 | ||
81 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. | 85 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. |
82 | Fixed a problem of the alarm of completed recurring todos. | 86 | Fixed a problem of the alarm of completed recurring todos. |
83 | Added to the event/todo editor to set quickly the category of an item. | 87 | Added to the event/todo editor to set quickly the category of an item. |
84 | 88 | ||
85 | 89 | ||
86 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. | 90 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. |
87 | 91 | ||
88 | Added KA/Pi multi sync to the multi sync called from the alarm applet. | 92 | Added KA/Pi multi sync to the multi sync called from the alarm applet. |
89 | 93 | ||
90 | ********** VERSION 2.1.10 ************ | 94 | ********** VERSION 2.1.10 ************ |
91 | 95 | ||
92 | KO/Pi: | 96 | KO/Pi: |
93 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. | 97 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. |
94 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. | 98 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. |
95 | Fixed a bug in searching for a small timerange, i.e. one day. | 99 | Fixed a bug in searching for a small timerange, i.e. one day. |
96 | 100 | ||
97 | KA/Pi: | 101 | KA/Pi: |
98 | Fixed two problems in csv export. | 102 | Fixed two problems in csv export. |
99 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. | 103 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. |
100 | 104 | ||
101 | ********** VERSION 2.1.9 ************ | 105 | ********** VERSION 2.1.9 ************ |
102 | 106 | ||
103 | KO/Pi: | 107 | KO/Pi: |
104 | Fixed some problems of the new search options in the search dialog. | 108 | Fixed some problems of the new search options in the search dialog. |
105 | Fixed some problems in the new resource config options. | 109 | Fixed some problems in the new resource config options. |
106 | 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. | 110 | 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. |
107 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: | 111 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: |
108 | 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. | 112 | 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. |
109 | 113 | ||
110 | Fixed a problem in recurrence range in syncing with DTM. | 114 | Fixed a problem in recurrence range in syncing with DTM. |
111 | 115 | ||
112 | KA/Pi: | 116 | KA/Pi: |
113 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) | 117 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) |
114 | 118 | ||
115 | PwM/Pi: | 119 | PwM/Pi: |
116 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 120 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
117 | 121 | ||
118 | ********** VERSION 2.1.8 ************ | 122 | ********** VERSION 2.1.8 ************ |
119 | 123 | ||
120 | KO/Pi: | 124 | KO/Pi: |
121 | Added info about the completion state of a todo in the ListView/Searchdialog. | 125 | Added info about the completion state of a todo in the ListView/Searchdialog. |
122 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 126 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
123 | Fixed some updating problems when changing the filter. | 127 | Fixed some updating problems when changing the filter. |
124 | 128 | ||
125 | KA/Pi: | 129 | KA/Pi: |
126 | In the addressee selection dialog now the formatted name is shown, if not empty. | 130 | In the addressee selection dialog now the formatted name is shown, if not empty. |
127 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 131 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
128 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 132 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
129 | 133 | ||
130 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 134 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
131 | Fixed the sorting for size in the file selector on the Z. | 135 | Fixed the sorting for size in the file selector on the Z. |
132 | 136 | ||
133 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 137 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
134 | 138 | ||
135 | ********** VERSION 2.1.7 ************ | 139 | ********** VERSION 2.1.7 ************ |
136 | 140 | ||
137 | KO/Pi: | 141 | KO/Pi: |
138 | Fixed several problems in the new Resource handling. | 142 | Fixed several problems in the new Resource handling. |
139 | Added more options to the search dialog. | 143 | Added more options to the search dialog. |
140 | Fixed a problem in the Month view. | 144 | Fixed a problem in the Month view. |
141 | Added more options to the dialog when setting a todo to stopped. | 145 | Added more options to the dialog when setting a todo to stopped. |
142 | 146 | ||
143 | Fixed two small problems in KO/Pi Alarm applet. | 147 | Fixed two small problems in KO/Pi Alarm applet. |
144 | 148 | ||
145 | ********** VERSION 2.1.6 ************ | 149 | ********** VERSION 2.1.6 ************ |
146 | 150 | ||
147 | This release is for testing only. | 151 | This release is for testing only. |
148 | 152 | ||
149 | KO/Pi: | 153 | KO/Pi: |
150 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 154 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
151 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 155 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
152 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 156 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
153 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 157 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
154 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 158 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
155 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 159 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
156 | 160 | ||
157 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 161 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
158 | 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. | 162 | 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. |
159 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 163 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
160 | 164 | ||
161 | A calendar is enabled in the resource view if the "eye" column is checked. | 165 | A calendar is enabled in the resource view if the "eye" column is checked. |
162 | You can set a calendar to be the default for new items( "+" column ). | 166 | You can set a calendar to be the default for new items( "+" column ). |
163 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 167 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
164 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 168 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
165 | 169 | ||
166 | 170 | ||
167 | ********** VERSION 2.1.5 ************ | 171 | ********** VERSION 2.1.5 ************ |
168 | 172 | ||
169 | This is the new stable version. | 173 | This is the new stable version. |
170 | Bugfix: | 174 | Bugfix: |
171 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 175 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
172 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 176 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
173 | Added config option to not display completed todos in agenda view. | 177 | Added config option to not display completed todos in agenda view. |
174 | Addressee view is now using the formatted name, if defined. | 178 | Addressee view is now using the formatted name, if defined. |
175 | That makes it possible to display "lastname, firstname" in that view now. | 179 | That makes it possible to display "lastname, firstname" in that view now. |
176 | To set the formatted name for all contacts, please use menu: | 180 | To set the formatted name for all contacts, please use menu: |
177 | Edit->Change->Set formatted name. | 181 | Edit->Change->Set formatted name. |
178 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 182 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
179 | 183 | ||
180 | ********** VERSION 2.1.4 ************ | 184 | ********** VERSION 2.1.4 ************ |
181 | 185 | ||
182 | Fixed two more bugs in the KA/Pi CSV import dialog: | 186 | Fixed two more bugs in the KA/Pi CSV import dialog: |
183 | Made it possible to read multi-line fields and import it to the "Note" field. | 187 | Made it possible to read multi-line fields and import it to the "Note" field. |
184 | Fixed a problem in mapping custom fields, whatever a custem field is... | 188 | Fixed a problem in mapping custom fields, whatever a custem field is... |
185 | 189 | ||
186 | ********** VERSION 2.1.3 ************ | 190 | ********** VERSION 2.1.3 ************ |
187 | 191 | ||
188 | Changed the menu structure of the alarm applet: | 192 | Changed the menu structure of the alarm applet: |
189 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 193 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
190 | 194 | ||
191 | Fixed several problems in the KA/Pi CSV import dialog: | 195 | Fixed several problems in the KA/Pi CSV import dialog: |
192 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 196 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
193 | 197 | ||
194 | 198 | ||
195 | ********** VERSION 2.1.2 ************ | 199 | ********** VERSION 2.1.2 ************ |
196 | 200 | ||
197 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 201 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
198 | 202 | ||
199 | Fixed a problem when importing data from Outlook with mutiple categories set. | 203 | Fixed a problem when importing data from Outlook with mutiple categories set. |
200 | 204 | ||
201 | Changed display of days in datenavigator: | 205 | Changed display of days in datenavigator: |
202 | Birthdays are now blue, not dark green. | 206 | Birthdays are now blue, not dark green. |
203 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 207 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
204 | When journal view is shown, only holidays are shown and days with journals are blue. | 208 | When journal view is shown, only holidays are shown and days with journals are blue. |
205 | 209 | ||
206 | Added Backup options to global config: | 210 | Added Backup options to global config: |
207 | 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 ). | 211 | 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 ). |
208 | 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. | 212 | 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. |
209 | 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. | 213 | 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. |
210 | 214 | ||
211 | ********** VERSION 2.1.1 ************ | 215 | ********** VERSION 2.1.1 ************ |
212 | 216 | ||
213 | Stable release 2.1.1! | 217 | Stable release 2.1.1! |
214 | 218 | ||
215 | KO/Pi: | 219 | KO/Pi: |
216 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 220 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
217 | 221 | ||
218 | ********** VERSION 2.1.0 ************ | 222 | ********** VERSION 2.1.0 ************ |
219 | 223 | ||
220 | Stable release 2.1.0! | 224 | Stable release 2.1.0! |
221 | 225 | ||
222 | Summary of changes/fixes compared to version 2.0.6: | 226 | Summary of changes/fixes compared to version 2.0.6: |
223 | 227 | ||
224 | Many bugs of version 2.0.6 fixed. | 228 | Many bugs of version 2.0.6 fixed. |
225 | Most of them were small bugs, but some of them were important. | 229 | Most of them were small bugs, but some of them were important. |
226 | It is recommended to use version 2.1.0 and not version 2.0.6. | 230 | It is recommended to use version 2.1.0 and not version 2.0.6. |
227 | 231 | ||
228 | Important changes: | 232 | Important changes: |
229 | 233 | ||
230 | Added recurring todos to KO/Pi. | 234 | Added recurring todos to KO/Pi. |
231 | 235 | ||
232 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 236 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
233 | 237 | ||
234 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 238 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
235 | 239 | ||
236 | Datenavigator can now display many months. Very useful on the desktop. | 240 | Datenavigator can now display many months. Very useful on the desktop. |
237 | 241 | ||
238 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 242 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
239 | 243 | ||
240 | Made alarm sound working on Linux desktop. | 244 | Made alarm sound working on Linux desktop. |
241 | 245 | ||
242 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 246 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
243 | 247 | ||
244 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 248 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
245 | 249 | ||
246 | Many other usebility enhancements. | 250 | Many other usebility enhancements. |
247 | Special thanks to Ben for his suggestions! | 251 | Special thanks to Ben for his suggestions! |
248 | 252 | ||
249 | You can find the complete changelog | 253 | You can find the complete changelog |
250 | from version 1.7.7 to 2.1.0 | 254 | from version 1.7.7 to 2.1.0 |
251 | in the source package or on | 255 | in the source package or on |
252 | 256 | ||
253 | http://www.pi-sync.net/html/changelog.html | 257 | http://www.pi-sync.net/html/changelog.html |
254 | 258 | ||
255 | 259 | ||
256 | 260 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a350c3b..7044e90 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4818 +1,4820 @@ | |||
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 "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | 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>"; |
161 | #else | 161 | #else |
162 | 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>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
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 | 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 ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | 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 ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | 373 | ||
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | 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 & ) ) ); |
597 | 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 & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | 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 & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | 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&)), |
641 | 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&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
659 | { | 659 | { |
660 | 660 | ||
661 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
662 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
663 | while ( test ) { | 663 | while ( test ) { |
664 | test->setTagged( false ); | 664 | test->setTagged( false ); |
665 | test = testlist.next(); | 665 | test = testlist.next(); |
666 | } | 666 | } |
667 | QTime st ( 0,0,0); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 669 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
670 | //qDebug("time %s ", st.toString().latin1()); | 670 | //qDebug("time %s ", st.toString().latin1()); |
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
672 | QDateTime conflict; | 672 | QDateTime conflict; |
673 | QDateTime retVal; | 673 | QDateTime retVal; |
674 | bool found = false; | 674 | bool found = false; |
675 | Event * cE = 0; | 675 | Event * cE = 0; |
676 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
677 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
678 | test = testlist.first(); | 678 | test = testlist.first(); |
679 | bool skip = false; | 679 | bool skip = false; |
680 | while ( test ) { | 680 | while ( test ) { |
681 | skip = false; | 681 | skip = false; |
682 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
683 | if ( !skip ) { | 683 | if ( !skip ) { |
684 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
685 | while ( test2 ) { | 685 | while ( test2 ) { |
686 | skip = false; | 686 | skip = false; |
687 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
688 | if ( !skip ) { | 688 | if ( !skip ) { |
689 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
691 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
692 | if ( ! found ) { | 692 | if ( ! found ) { |
693 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
694 | conflict = retVal; | 694 | conflict = retVal; |
695 | cE = test; | 695 | cE = test; |
696 | cE2 = test2; | 696 | cE2 = test2; |
697 | found = true; | 697 | found = true; |
698 | } | 698 | } |
699 | } else { | 699 | } else { |
700 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
701 | conflict = retVal; | 701 | conflict = retVal; |
702 | cE = test; | 702 | cE = test; |
703 | cE2 = test2; | 703 | cE2 = test2; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |
709 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | test->setTagged( true ); | 712 | test->setTagged( true ); |
713 | test = testlist.next(); | 713 | test = testlist.next(); |
714 | } | 714 | } |
715 | if ( found ) { | 715 | if ( found ) { |
716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
717 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
718 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
719 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
720 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
721 | 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 ) ) ); |
722 | return; | 722 | return; |
723 | } | 723 | } |
724 | 724 | ||
725 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
726 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | 729 | ||
730 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
731 | { | 731 | { |
732 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
733 | } | 733 | } |
734 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
735 | { | 735 | { |
736 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
737 | } | 737 | } |
738 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
739 | { | 739 | { |
740 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
741 | } | 741 | } |
742 | 742 | ||
743 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
744 | { | 744 | { |
745 | if ( readO ) { | 745 | if ( readO ) { |
746 | emit save(); | 746 | emit save(); |
747 | } | 747 | } |
748 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
749 | } | 749 | } |
750 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
751 | { | 751 | { |
752 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
753 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
754 | #endif | 754 | #endif |
755 | } | 755 | } |
756 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
757 | { | 757 | { |
758 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
759 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
760 | static bool block = false; | 760 | static bool block = false; |
761 | if ( block ) return; | 761 | if ( block ) return; |
762 | block = true; | 762 | block = true; |
763 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
764 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
765 | int stepdays = val; | 765 | int stepdays = val; |
766 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
768 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
770 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
771 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
772 | } | 772 | } |
773 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
774 | block = false; | 774 | block = false; |
775 | return; | 775 | return; |
776 | } | 776 | } |
777 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
778 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
780 | block = false; | 780 | block = false; |
781 | #endif | 781 | #endif |
782 | 782 | ||
783 | } | 783 | } |
784 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
785 | { | 785 | { |
786 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
787 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
788 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
789 | //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() ); |
790 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
791 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
792 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
793 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | #endif | 796 | #endif |
797 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
798 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
799 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
800 | } | 800 | } |
801 | 801 | ||
802 | 802 | ||
803 | 803 | ||
804 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
805 | { | 805 | { |
806 | QString message; | 806 | QString message; |
807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
808 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
809 | while ( cal ) { | 809 | while ( cal ) { |
810 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
811 | 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"; |
812 | } | 812 | } |
813 | cal = calendars.next(); | 813 | cal = calendars.next(); |
814 | } | 814 | } |
815 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
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); | 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); |
817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
818 | } | 818 | } |
819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
820 | } | 820 | } |
821 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
822 | { | 822 | { |
823 | 823 | ||
824 | 824 | ||
825 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
826 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
828 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
830 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
833 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
834 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
835 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
839 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
840 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
843 | while ( inL ) { | 843 | while ( inL ) { |
844 | bool ok = false; | 844 | bool ok = false; |
845 | int offset = 0; | 845 | int offset = 0; |
846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
847 | if ( ok ) { | 847 | if ( ok ) { |
848 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
849 | if ( next < cur ) { | 849 | if ( next < cur ) { |
850 | al.append( inL ); | 850 | al.append( inL ); |
851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | inL = el.next(); | 854 | inL = el.next(); |
855 | } | 855 | } |
856 | if ( al.count() ) { | 856 | if ( al.count() ) { |
857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
859 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
860 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
861 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
864 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
866 | int wid = 210; | 866 | int wid = 210; |
867 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
868 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
869 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
870 | } else { | 870 | } else { |
871 | int si = 220; | 871 | int si = 220; |
872 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
873 | si = 400; | 873 | si = 400; |
874 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
875 | } | 875 | } |
876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
877 | dia->show(); | 877 | dia->show(); |
878 | 878 | ||
879 | } | 879 | } |
880 | } | 880 | } |
881 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
882 | { | 882 | { |
883 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
884 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
885 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
886 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
887 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
888 | } | 888 | } |
889 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
890 | { | 890 | { |
891 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
892 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
893 | } | 893 | } |
894 | 894 | ||
895 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
896 | { | 896 | { |
897 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
898 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
899 | 899 | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
903 | { | 903 | { |
904 | 904 | ||
905 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
906 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
907 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
908 | 908 | ||
909 | 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 ); |
910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
915 | { | 915 | { |
916 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
920 | { | 920 | { |
921 | 921 | ||
922 | QString mess = msg; | 922 | QString mess = msg; |
923 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
924 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
925 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
926 | QString tempfilename; | 926 | QString tempfilename; |
927 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
928 | bool error = false; | 928 | bool error = false; |
929 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
930 | if ( len < 2 ) | 930 | if ( len < 2 ) |
931 | error = true; | 931 | error = true; |
932 | else { | 932 | else { |
933 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
934 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
935 | error = true; | 935 | error = true; |
936 | } | 936 | } |
937 | if ( ! error ) { | 937 | if ( ! error ) { |
938 | filename = tempfilename; | 938 | filename = tempfilename; |
939 | } | 939 | } |
940 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
941 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
942 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
943 | return; | 943 | return; |
944 | } | 944 | } |
945 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
946 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
947 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
948 | return; | 948 | return; |
949 | } | 949 | } |
950 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
951 | bool error = false; | 951 | bool error = false; |
952 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
953 | if ( len < 2 ) | 953 | if ( len < 2 ) |
954 | error = true; | 954 | error = true; |
955 | else { | 955 | else { |
956 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
957 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
958 | error = true; | 958 | error = true; |
959 | } | 959 | } |
960 | if ( error ) { | 960 | if ( error ) { |
961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
962 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
963 | } else { | 963 | } else { |
964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
965 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
966 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
967 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
968 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | #else | 971 | #else |
972 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
973 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
974 | p->start(); | 974 | p->start(); |
975 | return; | 975 | return; |
976 | #endif | 976 | #endif |
977 | 977 | ||
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | 980 | ||
981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
982 | } | 982 | } |
983 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
984 | bool error = false; | 984 | bool error = false; |
985 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
986 | if ( len < 2 ) | 986 | if ( len < 2 ) |
987 | error = true; | 987 | error = true; |
988 | else { | 988 | else { |
989 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
990 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
991 | error = true; | 991 | error = true; |
992 | } | 992 | } |
993 | if ( ! error ) { | 993 | if ( ! error ) { |
994 | filename = tempfilename; | 994 | filename = tempfilename; |
995 | } | 995 | } |
996 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
997 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
998 | } | 998 | } |
999 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1000 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1009 | { | 1009 | { |
1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1011 | 1011 | ||
1012 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1015 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1016 | 1016 | ||
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1020 | { | 1020 | { |
1021 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1024 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1026 | #endif | 1026 | #endif |
1027 | return; | 1027 | return; |
1028 | } | 1028 | } |
1029 | int maxSec; | 1029 | int maxSec; |
1030 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1031 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1032 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1034 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1036 | // 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 ); |
1037 | return; | 1037 | return; |
1038 | } else { | 1038 | } else { |
1039 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1040 | } | 1040 | } |
1041 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1042 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1046 | // 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 |
1047 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1048 | { | 1048 | { |
1049 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1050 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1051 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1052 | } | 1052 | } |
1053 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1055 | #else | 1055 | #else |
1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1057 | #endif | 1057 | #endif |
1058 | { | 1058 | { |
1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1061 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1063 | #endif | 1063 | #endif |
1064 | return; | 1064 | return; |
1065 | } | 1065 | } |
1066 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1067 | } | 1067 | } |
1068 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1069 | { | 1069 | { |
1070 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1071 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1072 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1073 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1074 | } | 1074 | } |
1075 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1076 | { | 1076 | { |
1077 | return mViewManager; | 1077 | return mViewManager; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1081 | { | 1081 | { |
1082 | return mDialogManager; | 1082 | return mDialogManager; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1086 | { | 1086 | { |
1087 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1088 | 1088 | ||
1089 | return dates.first(); | 1089 | return dates.first(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1093 | { | 1093 | { |
1094 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1095 | 1095 | ||
1096 | return dates.last(); | 1096 | return dates.last(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1101 | { | 1101 | { |
1102 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1103 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1104 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1106 | } | 1106 | } |
1107 | #endif | 1107 | #endif |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1112 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1113 | 1113 | ||
1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1120 | 1120 | ||
1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1122 | { | 1122 | { |
1123 | 1123 | ||
1124 | // 0 equal | 1124 | // 0 equal |
1125 | // 1 take local | 1125 | // 1 take local |
1126 | // 2 take remote | 1126 | // 2 take remote |
1127 | // 3 cancel | 1127 | // 3 cancel |
1128 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1129 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1130 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1132 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1134 | //if ( remCh ) | 1134 | //if ( remCh ) |
1135 | //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() ); |
1136 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1137 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1138 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1139 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1140 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1141 | return 0; | 1141 | return 0; |
1142 | } else { | 1142 | } else { |
1143 | if ( locCh ) { | 1143 | if ( locCh ) { |
1144 | //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()); |
1145 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1146 | if ( !remCh ) | 1146 | if ( !remCh ) |
1147 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1148 | } else { | 1148 | } else { |
1149 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1150 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1151 | if ( remCh ) | 1151 | if ( remCh ) |
1152 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | full = true; | 1156 | full = true; |
1157 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1158 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1159 | } else { | 1159 | } else { |
1160 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1161 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1162 | return 0; | 1162 | return 0; |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | // 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() ); |
1166 | 1166 | ||
1167 | //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()); |
1168 | //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() ); |
1169 | //full = true; //debug only | 1169 | //full = true; //debug only |
1170 | if ( full ) { | 1170 | if ( full ) { |
1171 | bool equ = false; | 1171 | bool equ = false; |
1172 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1173 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1174 | } | 1174 | } |
1175 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1177 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1178 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1179 | if ( equ ) { | 1179 | if ( equ ) { |
1180 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1183 | } | 1183 | } |
1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1185 | return 0; | 1185 | return 0; |
1186 | 1186 | ||
1187 | }//else //debug only | 1187 | }//else //debug only |
1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1189 | } | 1189 | } |
1190 | int result; | 1190 | int result; |
1191 | bool localIsNew; | 1191 | bool localIsNew; |
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() ); | 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() ); |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | // ************************************************ | 1195 | // ************************************************ |
1196 | // ************************************************ | 1196 | // ************************************************ |
1197 | // ************************************************ | 1197 | // ************************************************ |
1198 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1199 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1203 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1204 | 1204 | ||
1205 | switch( mode ) { | 1205 | switch( mode ) { |
1206 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1207 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1208 | return 1; | 1208 | return 1; |
1209 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1210 | return 2; | 1210 | return 2; |
1211 | return 1; | 1211 | return 1; |
1212 | break; | 1212 | break; |
1213 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1214 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1215 | return 2; | 1215 | return 2; |
1216 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1217 | return 1; | 1217 | return 1; |
1218 | return 2; | 1218 | return 2; |
1219 | break; | 1219 | break; |
1220 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1221 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1222 | return 1; | 1222 | return 1; |
1223 | else | 1223 | else |
1224 | return 2; | 1224 | return 2; |
1225 | break; | 1225 | break; |
1226 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1227 | 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() ); |
1228 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1229 | return 0; | 1229 | return 0; |
1230 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1231 | return 1; | 1231 | return 1; |
1232 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1233 | return 2; | 1233 | return 2; |
1234 | 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() ); |
1235 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1236 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1237 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1238 | else | 1238 | else |
1239 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1240 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1241 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1242 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1243 | else | 1243 | else |
1244 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1245 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1246 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1249 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1250 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1251 | return result; | 1251 | return result; |
1252 | 1252 | ||
1253 | break; | 1253 | break; |
1254 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1255 | return 1; | 1255 | return 1; |
1256 | break; | 1256 | break; |
1257 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1258 | return 2; | 1258 | return 2; |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | default: | 1261 | default: |
1262 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1263 | break; | 1263 | break; |
1264 | } | 1264 | } |
1265 | return 0; | 1265 | return 0; |
1266 | } | 1266 | } |
1267 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1268 | { | 1268 | { |
1269 | Event* lse; | 1269 | Event* lse; |
1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1272 | if (!lse) { | 1272 | if (!lse) { |
1273 | lse = new Event(); | 1273 | lse = new Event(); |
1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1275 | QString sum = ""; | 1275 | QString sum = ""; |
1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1277 | sum = "E: "; | 1277 | sum = "E: "; |
1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1279 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1281 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1282 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1283 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | return lse; | 1286 | return lse; |
1287 | 1287 | ||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | // 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 |
1291 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1293 | { | 1293 | { |
1294 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1295 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1299 | return; | 1299 | return; |
1300 | 1300 | ||
1301 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1302 | 1302 | ||
1303 | while ( eve ) { | 1303 | while ( eve ) { |
1304 | 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 |
1305 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1306 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1307 | QString pref = "e"; | 1307 | QString pref = "e"; |
1308 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1309 | pref = "t"; | 1309 | pref = "t"; |
1310 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1311 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1312 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1313 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1314 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1315 | } | 1315 | } |
1316 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1321 | { | 1321 | { |
1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1323 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1327 | { | 1327 | { |
1328 | bool syncOK = true; | 1328 | bool syncOK = true; |
1329 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1330 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1331 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1332 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1333 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1334 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1335 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1336 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1337 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1338 | Event* eventR; | 1338 | Event* eventR; |
1339 | QString uid; | 1339 | QString uid; |
1340 | int take; | 1340 | int take; |
1341 | Event* eventRSync; | 1341 | Event* eventRSync; |
1342 | Event* eventLSync; | 1342 | Event* eventLSync; |
1343 | clearAllViews(); | 1343 | clearAllViews(); |
1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1346 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1347 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1348 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1349 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1350 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1353 | 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() ); |
1354 | } else { | 1354 | } else { |
1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1359 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | qDebug("last-syncEvent on remote found "); | 1362 | qDebug("last-syncEvent on remote found "); |
1363 | eventRSync = (Event*) eventR->clone(); | 1363 | eventRSync = (Event*) eventR->clone(); |
1364 | remote->deleteEvent(eventR ); | 1364 | remote->deleteEvent(eventR ); |
1365 | 1365 | ||
1366 | } else { | 1366 | } else { |
1367 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1367 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1368 | eventRSync = (Event*)eventLSync->clone(); | 1368 | eventRSync = (Event*)eventLSync->clone(); |
1369 | } else { | 1369 | } else { |
1370 | fullDateRange = true; | 1370 | fullDateRange = true; |
1371 | eventRSync = new Event(); | 1371 | eventRSync = new Event(); |
1372 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1372 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1373 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1373 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1374 | eventRSync->setDtStart( mLastCalendarSync ); | 1374 | eventRSync->setDtStart( mLastCalendarSync ); |
1375 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1375 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1376 | eventRSync->setCategories( i18n("SyncEvent") ); | 1376 | eventRSync->setCategories( i18n("SyncEvent") ); |
1377 | } | 1377 | } |
1378 | } | 1378 | } |
1379 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1379 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1380 | fullDateRange = true; | 1380 | fullDateRange = true; |
1381 | 1381 | ||
1382 | if ( ! fullDateRange ) { | 1382 | if ( ! fullDateRange ) { |
1383 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1383 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1384 | 1384 | ||
1385 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1385 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1386 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1386 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1387 | fullDateRange = true; | 1387 | fullDateRange = true; |
1388 | } | 1388 | } |
1389 | } | 1389 | } |
1390 | if ( mSyncManager->syncWithDesktop() ) { | 1390 | if ( mSyncManager->syncWithDesktop() ) { |
1391 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1391 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1392 | } | 1392 | } |
1393 | if ( fullDateRange ) | 1393 | if ( fullDateRange ) |
1394 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1394 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1395 | else | 1395 | else |
1396 | mLastCalendarSync = eventLSync->dtStart(); | 1396 | mLastCalendarSync = eventLSync->dtStart(); |
1397 | // for resyncing if own file has changed | 1397 | // for resyncing if own file has changed |
1398 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1398 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1399 | mLastCalendarSync = loadedFileVersion; | 1399 | mLastCalendarSync = loadedFileVersion; |
1400 | //qDebug("setting mLastCalendarSync "); | 1400 | //qDebug("setting mLastCalendarSync "); |
1401 | } | 1401 | } |
1402 | //qDebug("*************************** "); | 1402 | //qDebug("*************************** "); |
1403 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1403 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1404 | QPtrList<Incidence> er = remote->rawIncidences(); | 1404 | QPtrList<Incidence> er = remote->rawIncidences(); |
1405 | Incidence* inR = er.first(); | 1405 | Incidence* inR = er.first(); |
1406 | Incidence* inL; | 1406 | Incidence* inL; |
1407 | QProgressBar bar( er.count(),0 ); | 1407 | QProgressBar bar( er.count(),0 ); |
1408 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1408 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1409 | 1409 | ||
1410 | // ************** setting up filter ************* | 1410 | // ************** setting up filter ************* |
1411 | CalFilter *filterIN = 0; | 1411 | CalFilter *filterIN = 0; |
1412 | CalFilter *filterOUT = 0; | 1412 | CalFilter *filterOUT = 0; |
1413 | CalFilter *filter = mFilters.first(); | 1413 | CalFilter *filter = mFilters.first(); |
1414 | while(filter) { | 1414 | while(filter) { |
1415 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1415 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1416 | filterIN = filter; | 1416 | filterIN = filter; |
1417 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1417 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1418 | filterOUT = filter; | 1418 | filterOUT = filter; |
1419 | filter = mFilters.next(); | 1419 | filter = mFilters.next(); |
1420 | } | 1420 | } |
1421 | int w = 300; | 1421 | int w = 300; |
1422 | if ( QApplication::desktop()->width() < 320 ) | 1422 | if ( QApplication::desktop()->width() < 320 ) |
1423 | w = 220; | 1423 | w = 220; |
1424 | int h = bar.sizeHint().height() ; | 1424 | int h = bar.sizeHint().height() ; |
1425 | int dw = QApplication::desktop()->width(); | 1425 | int dw = QApplication::desktop()->width(); |
1426 | int dh = QApplication::desktop()->height(); | 1426 | int dh = QApplication::desktop()->height(); |
1427 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1427 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1428 | bar.show(); | 1428 | bar.show(); |
1429 | int modulo = (er.count()/10)+1; | 1429 | int modulo = (er.count()/10)+1; |
1430 | int incCounter = 0; | 1430 | int incCounter = 0; |
1431 | while ( inR ) { | 1431 | while ( inR ) { |
1432 | if ( ! bar.isVisible() ) | 1432 | if ( ! bar.isVisible() ) |
1433 | return false; | 1433 | return false; |
1434 | if ( incCounter % modulo == 0 ) | 1434 | if ( incCounter % modulo == 0 ) |
1435 | bar.setProgress( incCounter ); | 1435 | bar.setProgress( incCounter ); |
1436 | ++incCounter; | 1436 | ++incCounter; |
1437 | uid = inR->uid(); | 1437 | uid = inR->uid(); |
1438 | bool skipIncidence = false; | 1438 | bool skipIncidence = false; |
1439 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1439 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1440 | skipIncidence = true; | 1440 | skipIncidence = true; |
1441 | QString idS; | 1441 | QString idS; |
1442 | qApp->processEvents(); | 1442 | qApp->processEvents(); |
1443 | if ( !skipIncidence ) { | 1443 | if ( !skipIncidence ) { |
1444 | inL = local->incidence( uid ); | 1444 | inL = local->incidenceForUid( uid , false ); |
1445 | if ( inL ) { // maybe conflict - same uid in both calendars | 1445 | if ( inL ) { // maybe conflict - same uid in both calendars |
1446 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1446 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1447 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1447 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1448 | if ( take == 3 ) | 1448 | if ( take == 3 ) |
1449 | return false; | 1449 | return false; |
1450 | if ( take == 1 ) {// take local ********************** | 1450 | if ( take == 1 ) {// take local ********************** |
1451 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1451 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1452 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1452 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1453 | else | 1453 | else |
1454 | idS = inR->IDStr(); | 1454 | idS = inR->IDStr(); |
1455 | int calID = inR->calID(); | 1455 | int calID = inR->calID(); |
1456 | remote->deleteIncidence( inR ); | 1456 | remote->deleteIncidence( inR ); |
1457 | inR = inL->clone(); | 1457 | inR = inL->clone(); |
1458 | inR->setCalID( calID ); | 1458 | inR->setCalID( calID ); |
1459 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1459 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1460 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1460 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1461 | inR->setIDStr( idS ); | 1461 | inR->setIDStr( idS ); |
1462 | remote->addIncidence( inR ); | 1462 | remote->addIncidence( inR ); |
1463 | if ( mSyncManager->syncWithDesktop() ) | 1463 | if ( mSyncManager->syncWithDesktop() ) |
1464 | inR->setPilotId( 2 ); | 1464 | inR->setPilotId( 2 ); |
1465 | ++changedRemote; | 1465 | ++changedRemote; |
1466 | } else {// take remote ********************** | 1466 | } else {// take remote ********************** |
1467 | idS = inL->IDStr(); | 1467 | if ( !inL->isReadOnly() ) { |
1468 | int pid = inL->pilotId(); | 1468 | idS = inL->IDStr(); |
1469 | int calID = inL->calID(); | 1469 | int pid = inL->pilotId(); |
1470 | local->deleteIncidence( inL ); | 1470 | int calID = inL->calID(); |
1471 | inL = inR->clone(); | 1471 | local->deleteIncidence( inL ); |
1472 | inL->setCalID( calID ); | 1472 | inL = inR->clone(); |
1473 | if ( mSyncManager->syncWithDesktop() ) | 1473 | inL->setCalID( calID ); |
1474 | inL->setPilotId( pid ); | 1474 | if ( mSyncManager->syncWithDesktop() ) |
1475 | inL->setIDStr( idS ); | 1475 | inL->setPilotId( pid ); |
1476 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1476 | inL->setIDStr( idS ); |
1477 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1477 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1478 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1478 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1479 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | ||
1480 | } | ||
1481 | local->addIncidence( inL ); | ||
1482 | ++changedLocal; | ||
1479 | } | 1483 | } |
1480 | local->addIncidence( inL ); | ||
1481 | ++changedLocal; | ||
1482 | } | 1484 | } |
1483 | } | 1485 | } |
1484 | } else { // no conflict ********** add or delete remote | 1486 | } else { // no conflict ********** add or delete remote |
1485 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1487 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1486 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1488 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1487 | QString des = eventLSync->description(); | 1489 | QString des = eventLSync->description(); |
1488 | QString pref = "e"; | 1490 | QString pref = "e"; |
1489 | if ( inR->typeID() == todoID ) | 1491 | if ( inR->typeID() == todoID ) |
1490 | pref = "t"; | 1492 | pref = "t"; |
1491 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1493 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1492 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1494 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1493 | //remote->deleteIncidence( inR ); | 1495 | //remote->deleteIncidence( inR ); |
1494 | ++deletedEventR; | 1496 | ++deletedEventR; |
1495 | } else { | 1497 | } else { |
1496 | inR->setLastModified( modifiedCalendar ); | 1498 | inR->setLastModified( modifiedCalendar ); |
1497 | inL = inR->clone(); | 1499 | inL = inR->clone(); |
1498 | inL->setIDStr( ":" ); | 1500 | inL->setIDStr( ":" ); |
1499 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1501 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1500 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1502 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1501 | 1503 | ||
1502 | inL->setCalID( 0 );// add to default cal | 1504 | inL->setCalID( 0 );// add to default cal |
1503 | local->addIncidence( inL ); | 1505 | local->addIncidence( inL ); |
1504 | ++addedEvent; | 1506 | ++addedEvent; |
1505 | 1507 | ||
1506 | } | 1508 | } |
1507 | } else { | 1509 | } else { |
1508 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1510 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1509 | inR->setLastModified( modifiedCalendar ); | 1511 | inR->setLastModified( modifiedCalendar ); |
1510 | inL = inR->clone(); | 1512 | inL = inR->clone(); |
1511 | inL->setIDStr( ":" ); | 1513 | inL->setIDStr( ":" ); |
1512 | inL->setCalID( 0 );// add to default cal | 1514 | inL->setCalID( 0 );// add to default cal |
1513 | local->addIncidence( inL ); | 1515 | local->addIncidence( inL ); |
1514 | ++addedEvent; | 1516 | ++addedEvent; |
1515 | 1517 | ||
1516 | } else { | 1518 | } else { |
1517 | checkExternSyncEvent(eventRSyncSharp, inR); | 1519 | checkExternSyncEvent(eventRSyncSharp, inR); |
1518 | remote->deleteIncidence( inR ); | 1520 | remote->deleteIncidence( inR ); |
1519 | ++deletedEventR; | 1521 | ++deletedEventR; |
1520 | } | 1522 | } |
1521 | } | 1523 | } |
1522 | } else { | 1524 | } else { |
1523 | ++filteredIN; | 1525 | ++filteredIN; |
1524 | } | 1526 | } |
1525 | } | 1527 | } |
1526 | } | 1528 | } |
1527 | inR = er.next(); | 1529 | inR = er.next(); |
1528 | } | 1530 | } |
1529 | QPtrList<Incidence> el = local->rawIncidences(); | 1531 | QPtrList<Incidence> el = local->rawIncidences(); |
1530 | inL = el.first(); | 1532 | inL = el.first(); |
1531 | modulo = (el.count()/10)+1; | 1533 | modulo = (el.count()/10)+1; |
1532 | bar.setCaption (i18n("Add / remove events") ); | 1534 | bar.setCaption (i18n("Add / remove events") ); |
1533 | bar.setTotalSteps ( el.count() ) ; | 1535 | bar.setTotalSteps ( el.count() ) ; |
1534 | bar.show(); | 1536 | bar.show(); |
1535 | incCounter = 0; | 1537 | incCounter = 0; |
1536 | 1538 | ||
1537 | while ( inL ) { | 1539 | while ( inL ) { |
1538 | 1540 | ||
1539 | qApp->processEvents(); | 1541 | qApp->processEvents(); |
1540 | if ( ! bar.isVisible() ) | 1542 | if ( ! bar.isVisible() ) |
1541 | return false; | 1543 | return false; |
1542 | if ( incCounter % modulo == 0 ) | 1544 | if ( incCounter % modulo == 0 ) |
1543 | bar.setProgress( incCounter ); | 1545 | bar.setProgress( incCounter ); |
1544 | ++incCounter; | 1546 | ++incCounter; |
1545 | uid = inL->uid(); | 1547 | uid = inL->uid(); |
1546 | bool skipIncidence = false; | 1548 | bool skipIncidence = false; |
1547 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1549 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1548 | skipIncidence = true; | 1550 | skipIncidence = true; |
1549 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1551 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1550 | skipIncidence = true; | 1552 | skipIncidence = true; |
1551 | if ( !skipIncidence ) { | 1553 | if ( !skipIncidence ) { |
1552 | inR = remote->incidence( uid ); | 1554 | inR = remote->incidenceForUid( uid , true ); |
1553 | if ( ! inR ) { | 1555 | if ( ! inR ) { |
1554 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1556 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1555 | // no conflict ********** add or delete local | 1557 | // no conflict ********** add or delete local |
1556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1558 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1557 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1559 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1558 | checkExternSyncEvent(eventLSyncSharp, inL); | 1560 | checkExternSyncEvent(eventLSyncSharp, inL); |
1559 | local->deleteIncidence( inL ); | 1561 | local->deleteIncidence( inL ); |
1560 | ++deletedEventL; | 1562 | ++deletedEventL; |
1561 | } else { | 1563 | } else { |
1562 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1564 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1563 | inL->removeID(mCurrentSyncDevice ); | 1565 | inL->removeID(mCurrentSyncDevice ); |
1564 | ++addedEventR; | 1566 | ++addedEventR; |
1565 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1567 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1566 | inL->setLastModified( modifiedCalendar ); | 1568 | inL->setLastModified( modifiedCalendar ); |
1567 | inR = inL->clone(); | 1569 | inR = inL->clone(); |
1568 | inR->setIDStr( ":" ); | 1570 | inR->setIDStr( ":" ); |
1569 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1571 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1570 | inR->setCalID( 0 );// add to default cal | 1572 | inR->setCalID( 0 );// add to default cal |
1571 | remote->addIncidence( inR ); | 1573 | remote->addIncidence( inR ); |
1572 | } | 1574 | } |
1573 | } | 1575 | } |
1574 | } else { | 1576 | } else { |
1575 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1577 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1576 | checkExternSyncEvent(eventLSyncSharp, inL); | 1578 | checkExternSyncEvent(eventLSyncSharp, inL); |
1577 | local->deleteIncidence( inL ); | 1579 | local->deleteIncidence( inL ); |
1578 | ++deletedEventL; | 1580 | ++deletedEventL; |
1579 | } else { | 1581 | } else { |
1580 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1582 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1581 | ++addedEventR; | 1583 | ++addedEventR; |
1582 | inL->setLastModified( modifiedCalendar ); | 1584 | inL->setLastModified( modifiedCalendar ); |
1583 | inR = inL->clone(); | 1585 | inR = inL->clone(); |
1584 | inR->setIDStr( ":" ); | 1586 | inR->setIDStr( ":" ); |
1585 | inR->setCalID( 0 );// add to default cal | 1587 | inR->setCalID( 0 );// add to default cal |
1586 | remote->addIncidence( inR ); | 1588 | remote->addIncidence( inR ); |
1587 | } | 1589 | } |
1588 | } | 1590 | } |
1589 | } | 1591 | } |
1590 | } else { | 1592 | } else { |
1591 | ++filteredOUT; | 1593 | ++filteredOUT; |
1592 | } | 1594 | } |
1593 | } | 1595 | } |
1594 | } | 1596 | } |
1595 | inL = el.next(); | 1597 | inL = el.next(); |
1596 | } | 1598 | } |
1597 | int delFut = 0; | 1599 | int delFut = 0; |
1598 | int remRem = 0; | 1600 | int remRem = 0; |
1599 | if ( mSyncManager->mWriteBackInFuture ) { | 1601 | if ( mSyncManager->mWriteBackInFuture ) { |
1600 | er = remote->rawIncidences(); | 1602 | er = remote->rawIncidences(); |
1601 | remRem = er.count(); | 1603 | remRem = er.count(); |
1602 | inR = er.first(); | 1604 | inR = er.first(); |
1603 | QDateTime dt; | 1605 | QDateTime dt; |
1604 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1606 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1605 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1607 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1606 | while ( inR ) { | 1608 | while ( inR ) { |
1607 | if ( inR->typeID() == todoID ) { | 1609 | if ( inR->typeID() == todoID ) { |
1608 | Todo * t = (Todo*)inR; | 1610 | Todo * t = (Todo*)inR; |
1609 | if ( t->hasDueDate() ) | 1611 | if ( t->hasDueDate() ) |
1610 | dt = t->dtDue(); | 1612 | dt = t->dtDue(); |
1611 | else | 1613 | else |
1612 | dt = cur.addSecs( 62 ); | 1614 | dt = cur.addSecs( 62 ); |
1613 | } | 1615 | } |
1614 | else if (inR->typeID() == eventID ) { | 1616 | else if (inR->typeID() == eventID ) { |
1615 | bool ok; | 1617 | bool ok; |
1616 | dt = inR->getNextOccurence( cur, &ok ); | 1618 | dt = inR->getNextOccurence( cur, &ok ); |
1617 | if ( !ok ) | 1619 | if ( !ok ) |
1618 | dt = cur.addSecs( -62 ); | 1620 | dt = cur.addSecs( -62 ); |
1619 | } | 1621 | } |
1620 | else | 1622 | else |
1621 | dt = inR->dtStart(); | 1623 | dt = inR->dtStart(); |
1622 | if ( dt < cur || dt > end ) { | 1624 | if ( dt < cur || dt > end ) { |
1623 | remote->deleteIncidence( inR ); | 1625 | remote->deleteIncidence( inR ); |
1624 | ++delFut; | 1626 | ++delFut; |
1625 | } | 1627 | } |
1626 | inR = er.next(); | 1628 | inR = er.next(); |
1627 | } | 1629 | } |
1628 | } | 1630 | } |
1629 | bar.hide(); | 1631 | bar.hide(); |
1630 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1632 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1631 | eventLSync->setReadOnly( false ); | 1633 | eventLSync->setReadOnly( false ); |
1632 | eventLSync->setDtStart( mLastCalendarSync ); | 1634 | eventLSync->setDtStart( mLastCalendarSync ); |
1633 | eventRSync->setDtStart( mLastCalendarSync ); | 1635 | eventRSync->setDtStart( mLastCalendarSync ); |
1634 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1636 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1635 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1637 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1636 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1638 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1637 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1639 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1638 | eventLSync->setReadOnly( true ); | 1640 | eventLSync->setReadOnly( true ); |
1639 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1641 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1640 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1642 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1641 | remote->addEvent( eventRSync ); | 1643 | remote->addEvent( eventRSync ); |
1642 | else | 1644 | else |
1643 | delete eventRSync; | 1645 | delete eventRSync; |
1644 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1646 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1645 | QString mes; | 1647 | QString mes; |
1646 | 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 ); | 1648 | 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 ); |
1647 | QString delmess; | 1649 | QString delmess; |
1648 | if ( delFut ) { | 1650 | if ( delFut ) { |
1649 | 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); | 1651 | 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); |
1650 | mes += delmess; | 1652 | mes += delmess; |
1651 | } | 1653 | } |
1652 | mes = i18n("Local calendar changed!\n") +mes; | 1654 | mes = i18n("Local calendar changed!\n") +mes; |
1653 | mCalendar->checkAlarmForIncidence( 0, true ); | 1655 | mCalendar->checkAlarmForIncidence( 0, true ); |
1654 | qDebug( mes ); | 1656 | qDebug( mes ); |
1655 | if ( mSyncManager->mShowSyncSummary ) { | 1657 | if ( mSyncManager->mShowSyncSummary ) { |
1656 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1658 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1657 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1659 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1658 | qDebug("KO: WB cancelled "); | 1660 | qDebug("KO: WB cancelled "); |
1659 | mSyncManager->mWriteBackFile = false; | 1661 | mSyncManager->mWriteBackFile = false; |
1660 | return syncOK; | 1662 | return syncOK; |
1661 | } | 1663 | } |
1662 | } | 1664 | } |
1663 | return syncOK; | 1665 | return syncOK; |
1664 | } | 1666 | } |
1665 | 1667 | ||
1666 | void CalendarView::setSyncDevice( QString s ) | 1668 | void CalendarView::setSyncDevice( QString s ) |
1667 | { | 1669 | { |
1668 | mCurrentSyncDevice= s; | 1670 | mCurrentSyncDevice= s; |
1669 | } | 1671 | } |
1670 | void CalendarView::setSyncName( QString s ) | 1672 | void CalendarView::setSyncName( QString s ) |
1671 | { | 1673 | { |
1672 | mCurrentSyncName= s; | 1674 | mCurrentSyncName= s; |
1673 | } | 1675 | } |
1674 | bool CalendarView::syncCalendar(QString filename, int mode) | 1676 | bool CalendarView::syncCalendar(QString filename, int mode) |
1675 | { | 1677 | { |
1676 | //qDebug("syncCalendar %s ", filename.latin1()); | 1678 | //qDebug("syncCalendar %s ", filename.latin1()); |
1677 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1679 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1678 | CalendarLocal* calendar = new CalendarLocal(); | 1680 | CalendarLocal* calendar = new CalendarLocal(); |
1679 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1681 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1680 | FileStorage* storage = new FileStorage( calendar ); | 1682 | FileStorage* storage = new FileStorage( calendar ); |
1681 | bool syncOK = false; | 1683 | bool syncOK = false; |
1682 | storage->setFileName( filename ); | 1684 | storage->setFileName( filename ); |
1683 | // qDebug("loading ... "); | 1685 | // qDebug("loading ... "); |
1684 | if ( storage->load() ) { | 1686 | if ( storage->load() ) { |
1685 | getEventViewerDialog()->setSyncMode( true ); | 1687 | getEventViewerDialog()->setSyncMode( true ); |
1686 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1688 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1687 | getEventViewerDialog()->setSyncMode( false ); | 1689 | getEventViewerDialog()->setSyncMode( false ); |
1688 | if ( syncOK ) { | 1690 | if ( syncOK ) { |
1689 | if ( mSyncManager->mWriteBackFile ) | 1691 | if ( mSyncManager->mWriteBackFile ) |
1690 | { | 1692 | { |
1691 | storage->setSaveFormat( new ICalFormat() ); | 1693 | storage->setSaveFormat( new ICalFormat() ); |
1692 | storage->save(); | 1694 | storage->save(); |
1693 | } | 1695 | } |
1694 | } | 1696 | } |
1695 | setModified( true ); | 1697 | setModified( true ); |
1696 | } | 1698 | } |
1697 | delete storage; | 1699 | delete storage; |
1698 | delete calendar; | 1700 | delete calendar; |
1699 | if ( syncOK ) | 1701 | if ( syncOK ) |
1700 | updateView(); | 1702 | updateView(); |
1701 | return syncOK; | 1703 | return syncOK; |
1702 | } | 1704 | } |
1703 | 1705 | ||
1704 | void CalendarView::syncExternal( int mode ) | 1706 | void CalendarView::syncExternal( int mode ) |
1705 | { | 1707 | { |
1706 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1708 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1707 | 1709 | ||
1708 | qApp->processEvents(); | 1710 | qApp->processEvents(); |
1709 | CalendarLocal* calendar = new CalendarLocal(); | 1711 | CalendarLocal* calendar = new CalendarLocal(); |
1710 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1712 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1711 | bool syncOK = false; | 1713 | bool syncOK = false; |
1712 | bool loadSuccess = false; | 1714 | bool loadSuccess = false; |
1713 | PhoneFormat* phoneFormat = 0; | 1715 | PhoneFormat* phoneFormat = 0; |
1714 | emit tempDisableBR(true); | 1716 | emit tempDisableBR(true); |
1715 | #ifndef DESKTOP_VERSION | 1717 | #ifndef DESKTOP_VERSION |
1716 | SharpFormat* sharpFormat = 0; | 1718 | SharpFormat* sharpFormat = 0; |
1717 | if ( mode == 0 ) { // sharp | 1719 | if ( mode == 0 ) { // sharp |
1718 | sharpFormat = new SharpFormat () ; | 1720 | sharpFormat = new SharpFormat () ; |
1719 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1721 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1720 | 1722 | ||
1721 | } else | 1723 | } else |
1722 | #endif | 1724 | #endif |
1723 | if ( mode == 1 ) { // phone | 1725 | if ( mode == 1 ) { // phone |
1724 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1726 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1725 | mSyncManager->mPhoneDevice, | 1727 | mSyncManager->mPhoneDevice, |
1726 | mSyncManager->mPhoneConnection, | 1728 | mSyncManager->mPhoneConnection, |
1727 | mSyncManager->mPhoneModel); | 1729 | mSyncManager->mPhoneModel); |
1728 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1730 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1729 | 1731 | ||
1730 | } else { | 1732 | } else { |
1731 | emit tempDisableBR(false); | 1733 | emit tempDisableBR(false); |
1732 | return; | 1734 | return; |
1733 | } | 1735 | } |
1734 | if ( loadSuccess ) { | 1736 | if ( loadSuccess ) { |
1735 | getEventViewerDialog()->setSyncMode( true ); | 1737 | getEventViewerDialog()->setSyncMode( true ); |
1736 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1738 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1737 | getEventViewerDialog()->setSyncMode( false ); | 1739 | getEventViewerDialog()->setSyncMode( false ); |
1738 | qApp->processEvents(); | 1740 | qApp->processEvents(); |
1739 | if ( syncOK ) { | 1741 | if ( syncOK ) { |
1740 | if ( mSyncManager->mWriteBackFile ) | 1742 | if ( mSyncManager->mWriteBackFile ) |
1741 | { | 1743 | { |
1742 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1744 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1743 | Incidence* inc = iL.first(); | 1745 | Incidence* inc = iL.first(); |
1744 | if ( phoneFormat ) { | 1746 | if ( phoneFormat ) { |
1745 | while ( inc ) { | 1747 | while ( inc ) { |
1746 | inc->removeID(mCurrentSyncDevice); | 1748 | inc->removeID(mCurrentSyncDevice); |
1747 | inc = iL.next(); | 1749 | inc = iL.next(); |
1748 | } | 1750 | } |
1749 | } | 1751 | } |
1750 | #ifndef DESKTOP_VERSION | 1752 | #ifndef DESKTOP_VERSION |
1751 | if ( sharpFormat ) | 1753 | if ( sharpFormat ) |
1752 | sharpFormat->save(calendar); | 1754 | sharpFormat->save(calendar); |
1753 | #endif | 1755 | #endif |
1754 | if ( phoneFormat ) | 1756 | if ( phoneFormat ) |
1755 | phoneFormat->save(calendar); | 1757 | phoneFormat->save(calendar); |
1756 | iL = calendar->rawIncidences(); | 1758 | iL = calendar->rawIncidences(); |
1757 | inc = iL.first(); | 1759 | inc = iL.first(); |
1758 | Incidence* loc; | 1760 | Incidence* loc; |
1759 | while ( inc ) { | 1761 | while ( inc ) { |
1760 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1762 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1761 | loc = mCalendar->incidence(inc->uid() ); | 1763 | loc = mCalendar->incidence(inc->uid() ); |
1762 | if ( loc ) { | 1764 | if ( loc ) { |
1763 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1765 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1764 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1766 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1765 | } | 1767 | } |
1766 | } | 1768 | } |
1767 | inc = iL.next(); | 1769 | inc = iL.next(); |
1768 | } | 1770 | } |
1769 | Incidence* lse = getLastSyncEvent(); | 1771 | Incidence* lse = getLastSyncEvent(); |
1770 | if ( lse ) { | 1772 | if ( lse ) { |
1771 | lse->setReadOnly( false ); | 1773 | lse->setReadOnly( false ); |
1772 | lse->setDescription( "" ); | 1774 | lse->setDescription( "" ); |
1773 | lse->setReadOnly( true ); | 1775 | lse->setReadOnly( true ); |
1774 | } | 1776 | } |
1775 | } | 1777 | } |
1776 | } else { | 1778 | } else { |
1777 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1779 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1778 | } | 1780 | } |
1779 | setModified( true ); | 1781 | setModified( true ); |
1780 | } else { | 1782 | } else { |
1781 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1783 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1782 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1784 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1783 | question, i18n("Ok")) ; | 1785 | question, i18n("Ok")) ; |
1784 | 1786 | ||
1785 | } | 1787 | } |
1786 | delete calendar; | 1788 | delete calendar; |
1787 | updateView(); | 1789 | updateView(); |
1788 | emit tempDisableBR(false); | 1790 | emit tempDisableBR(false); |
1789 | return ;//syncOK; | 1791 | return ;//syncOK; |
1790 | 1792 | ||
1791 | } | 1793 | } |
1792 | 1794 | ||
1793 | bool CalendarView::importBday() | 1795 | bool CalendarView::importBday() |
1794 | { | 1796 | { |
1795 | #ifndef KORG_NOKABC | 1797 | #ifndef KORG_NOKABC |
1796 | 1798 | ||
1797 | #ifdef DESKTOP_VERSION | 1799 | #ifdef DESKTOP_VERSION |
1798 | int curCal = mCalendar->defaultCalendar(); | 1800 | int curCal = mCalendar->defaultCalendar(); |
1799 | int bd = mCalEditView->getBirtdayID(); | 1801 | int bd = mCalEditView->getBirtdayID(); |
1800 | if ( bd == 0 ) | 1802 | if ( bd == 0 ) |
1801 | return false; | 1803 | return false; |
1802 | mCalendar->setDefaultCalendar( bd ); | 1804 | mCalendar->setDefaultCalendar( bd ); |
1803 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1805 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1804 | KABC::AddressBook::Iterator it; | 1806 | KABC::AddressBook::Iterator it; |
1805 | int count = 0; | 1807 | int count = 0; |
1806 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1808 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1807 | ++count; | 1809 | ++count; |
1808 | } | 1810 | } |
1809 | QProgressBar bar(count,0 ); | 1811 | QProgressBar bar(count,0 ); |
1810 | int w = 300; | 1812 | int w = 300; |
1811 | if ( QApplication::desktop()->width() < 320 ) | 1813 | if ( QApplication::desktop()->width() < 320 ) |
1812 | w = 220; | 1814 | w = 220; |
1813 | int h = bar.sizeHint().height() ; | 1815 | int h = bar.sizeHint().height() ; |
1814 | int dw = QApplication::desktop()->width(); | 1816 | int dw = QApplication::desktop()->width(); |
1815 | int dh = QApplication::desktop()->height(); | 1817 | int dh = QApplication::desktop()->height(); |
1816 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1818 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1817 | bar.show(); | 1819 | bar.show(); |
1818 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1820 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1819 | qApp->processEvents(); | 1821 | qApp->processEvents(); |
1820 | count = 0; | 1822 | count = 0; |
1821 | int addCount = 0; | 1823 | int addCount = 0; |
1822 | KCal::Attendee* a = 0; | 1824 | KCal::Attendee* a = 0; |
1823 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1825 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1824 | if ( ! bar.isVisible() ) | 1826 | if ( ! bar.isVisible() ) |
1825 | return false; | 1827 | return false; |
1826 | bar.setProgress( count++ ); | 1828 | bar.setProgress( count++ ); |
1827 | qApp->processEvents(); | 1829 | qApp->processEvents(); |
1828 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1830 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1829 | if ( (*it).birthday().date().isValid() ){ | 1831 | if ( (*it).birthday().date().isValid() ){ |
1830 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1832 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1831 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1833 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1832 | ++addCount; | 1834 | ++addCount; |
1833 | } | 1835 | } |
1834 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1836 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1835 | if ( anni.isValid() ){ | 1837 | if ( anni.isValid() ){ |
1836 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1838 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1837 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1839 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1838 | ++addCount; | 1840 | ++addCount; |
1839 | } | 1841 | } |
1840 | } | 1842 | } |
1841 | mCalendar->setDefaultCalendar( curCal ); | 1843 | mCalendar->setDefaultCalendar( curCal ); |
1842 | updateView(); | 1844 | updateView(); |
1843 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1845 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1844 | #else //DESKTOP_VERSION | 1846 | #else //DESKTOP_VERSION |
1845 | 1847 | ||
1846 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1848 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1847 | // the result should now arrive through method insertBirthdays | 1849 | // the result should now arrive through method insertBirthdays |
1848 | 1850 | ||
1849 | #endif //DESKTOP_VERSION | 1851 | #endif //DESKTOP_VERSION |
1850 | 1852 | ||
1851 | #endif //KORG_NOKABC | 1853 | #endif //KORG_NOKABC |
1852 | 1854 | ||
1853 | 1855 | ||
1854 | return true; | 1856 | return true; |
1855 | } | 1857 | } |
1856 | 1858 | ||
1857 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1859 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1858 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1860 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1859 | const QStringList& anniversaryList, const QStringList& realNameList, | 1861 | const QStringList& anniversaryList, const QStringList& realNameList, |
1860 | const QStringList& emailList, const QStringList& assembledNameList, | 1862 | const QStringList& emailList, const QStringList& assembledNameList, |
1861 | const QStringList& uidList) | 1863 | const QStringList& uidList) |
1862 | { | 1864 | { |
1863 | 1865 | ||
1864 | //qDebug("KO::CalendarView::insertBirthdays"); | 1866 | //qDebug("KO::CalendarView::insertBirthdays"); |
1865 | if (uid == this->name()) | 1867 | if (uid == this->name()) |
1866 | { | 1868 | { |
1867 | int curCal = mCalendar->defaultCalendar(); | 1869 | int curCal = mCalendar->defaultCalendar(); |
1868 | int bd = mCalEditView->getBirtdayID(); | 1870 | int bd = mCalEditView->getBirtdayID(); |
1869 | if ( bd == 0 ) | 1871 | if ( bd == 0 ) |
1870 | return; | 1872 | return; |
1871 | mCalendar->setDefaultCalendar( bd ); | 1873 | mCalendar->setDefaultCalendar( bd ); |
1872 | 1874 | ||
1873 | 1875 | ||
1874 | int count = birthdayList.count(); | 1876 | int count = birthdayList.count(); |
1875 | int addCount = 0; | 1877 | int addCount = 0; |
1876 | KCal::Attendee* a = 0; | 1878 | KCal::Attendee* a = 0; |
1877 | 1879 | ||
1878 | //qDebug("CalView 1 %i", count); | 1880 | //qDebug("CalView 1 %i", count); |
1879 | 1881 | ||
1880 | QProgressBar bar(count,0 ); | 1882 | QProgressBar bar(count,0 ); |
1881 | int w = 300; | 1883 | int w = 300; |
1882 | if ( QApplication::desktop()->width() < 320 ) | 1884 | if ( QApplication::desktop()->width() < 320 ) |
1883 | w = 220; | 1885 | w = 220; |
1884 | int h = bar.sizeHint().height() ; | 1886 | int h = bar.sizeHint().height() ; |
1885 | int dw = QApplication::desktop()->width(); | 1887 | int dw = QApplication::desktop()->width(); |
1886 | int dh = QApplication::desktop()->height(); | 1888 | int dh = QApplication::desktop()->height(); |
1887 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1889 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1888 | bar.show(); | 1890 | bar.show(); |
1889 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1891 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1890 | qApp->processEvents(); | 1892 | qApp->processEvents(); |
1891 | 1893 | ||
1892 | QDate birthday; | 1894 | QDate birthday; |
1893 | QDate anniversary; | 1895 | QDate anniversary; |
1894 | QString realName; | 1896 | QString realName; |
1895 | QString email; | 1897 | QString email; |
1896 | QString assembledName; | 1898 | QString assembledName; |
1897 | QString uid; | 1899 | QString uid; |
1898 | bool ok = true; | 1900 | bool ok = true; |
1899 | for ( int i = 0; i < count; i++) | 1901 | for ( int i = 0; i < count; i++) |
1900 | { | 1902 | { |
1901 | if ( ! bar.isVisible() ) | 1903 | if ( ! bar.isVisible() ) |
1902 | return; | 1904 | return; |
1903 | bar.setProgress( i ); | 1905 | bar.setProgress( i ); |
1904 | qApp->processEvents(); | 1906 | qApp->processEvents(); |
1905 | 1907 | ||
1906 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1908 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1907 | if (!ok) { | 1909 | if (!ok) { |
1908 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1910 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1909 | } | 1911 | } |
1910 | 1912 | ||
1911 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1913 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1912 | if (!ok) { | 1914 | if (!ok) { |
1913 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1915 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1914 | } | 1916 | } |
1915 | realName = realNameList[i]; | 1917 | realName = realNameList[i]; |
1916 | email = emailList[i]; | 1918 | email = emailList[i]; |
1917 | assembledName = assembledNameList[i]; | 1919 | assembledName = assembledNameList[i]; |
1918 | uid = uidList[i]; | 1920 | uid = uidList[i]; |
1919 | //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() ); | 1921 | //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() ); |
1920 | 1922 | ||
1921 | if ( birthday.isValid() ){ | 1923 | if ( birthday.isValid() ){ |
1922 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1924 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1923 | KCal::Attendee::ReqParticipant,uid) ; | 1925 | KCal::Attendee::ReqParticipant,uid) ; |
1924 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1926 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1925 | ++addCount; | 1927 | ++addCount; |
1926 | } | 1928 | } |
1927 | 1929 | ||
1928 | if ( anniversary.isValid() ){ | 1930 | if ( anniversary.isValid() ){ |
1929 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1931 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1930 | KCal::Attendee::ReqParticipant,uid) ; | 1932 | KCal::Attendee::ReqParticipant,uid) ; |
1931 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1933 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1932 | ++addCount; | 1934 | ++addCount; |
1933 | } | 1935 | } |
1934 | } | 1936 | } |
1935 | 1937 | ||
1936 | mCalendar->setDefaultCalendar( curCal ); | 1938 | mCalendar->setDefaultCalendar( curCal ); |
1937 | updateView(); | 1939 | updateView(); |
1938 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1940 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1939 | 1941 | ||
1940 | } | 1942 | } |
1941 | 1943 | ||
1942 | } | 1944 | } |
1943 | 1945 | ||
1944 | 1946 | ||
1945 | 1947 | ||
1946 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1948 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1947 | { | 1949 | { |
1948 | //qDebug("addAnni "); | 1950 | //qDebug("addAnni "); |
1949 | Event * ev = new Event(); | 1951 | Event * ev = new Event(); |
1950 | ev->setOrganizer(KOPrefs::instance()->email()); | 1952 | ev->setOrganizer(KOPrefs::instance()->email()); |
1951 | if ( a ) { | 1953 | if ( a ) { |
1952 | ev->addAttendee( a ); | 1954 | ev->addAttendee( a ); |
1953 | } | 1955 | } |
1954 | QString kind; | 1956 | QString kind; |
1955 | if ( birthday ) { | 1957 | if ( birthday ) { |
1956 | kind = i18n( "Birthday" ); | 1958 | kind = i18n( "Birthday" ); |
1957 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1959 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1958 | } | 1960 | } |
1959 | else { | 1961 | else { |
1960 | kind = i18n( "Anniversary" ); | 1962 | kind = i18n( "Anniversary" ); |
1961 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1963 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1962 | } | 1964 | } |
1963 | ev->setCategories( kind ); | 1965 | ev->setCategories( kind ); |
1964 | ev->setDtStart( QDateTime(date) ); | 1966 | ev->setDtStart( QDateTime(date) ); |
1965 | ev->setDtEnd( QDateTime(date) ); | 1967 | ev->setDtEnd( QDateTime(date) ); |
1966 | ev->setFloats( true ); | 1968 | ev->setFloats( true ); |
1967 | Recurrence * rec = ev->recurrence(); | 1969 | Recurrence * rec = ev->recurrence(); |
1968 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1970 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1969 | rec->addYearlyNum( date.month() ); | 1971 | rec->addYearlyNum( date.month() ); |
1970 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1972 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1971 | delete ev; | 1973 | delete ev; |
1972 | return false; | 1974 | return false; |
1973 | } | 1975 | } |
1974 | return true; | 1976 | return true; |
1975 | 1977 | ||
1976 | } | 1978 | } |
1977 | bool CalendarView::importQtopia( const QString &categories, | 1979 | bool CalendarView::importQtopia( const QString &categories, |
1978 | const QString &datebook, | 1980 | const QString &datebook, |
1979 | const QString &todolist ) | 1981 | const QString &todolist ) |
1980 | { | 1982 | { |
1981 | 1983 | ||
1982 | QtopiaFormat qtopiaFormat; | 1984 | QtopiaFormat qtopiaFormat; |
1983 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1985 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1984 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1986 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1985 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1987 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1986 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1988 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1987 | 1989 | ||
1988 | updateView(); | 1990 | updateView(); |
1989 | return true; | 1991 | return true; |
1990 | 1992 | ||
1991 | #if 0 | 1993 | #if 0 |
1992 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1994 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1993 | mCurrentSyncDevice = "qtopia-XML"; | 1995 | mCurrentSyncDevice = "qtopia-XML"; |
1994 | if ( mSyncManager->mAskForPreferences ) | 1996 | if ( mSyncManager->mAskForPreferences ) |
1995 | edit_sync_options(); | 1997 | edit_sync_options(); |
1996 | qApp->processEvents(); | 1998 | qApp->processEvents(); |
1997 | CalendarLocal* calendar = new CalendarLocal(); | 1999 | CalendarLocal* calendar = new CalendarLocal(); |
1998 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2000 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1999 | bool syncOK = false; | 2001 | bool syncOK = false; |
2000 | QtopiaFormat qtopiaFormat; | 2002 | QtopiaFormat qtopiaFormat; |
2001 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2003 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2002 | bool loadOk = true; | 2004 | bool loadOk = true; |
2003 | if ( !categories.isEmpty() ) | 2005 | if ( !categories.isEmpty() ) |
2004 | loadOk = qtopiaFormat.load( calendar, categories ); | 2006 | loadOk = qtopiaFormat.load( calendar, categories ); |
2005 | if ( loadOk && !datebook.isEmpty() ) | 2007 | if ( loadOk && !datebook.isEmpty() ) |
2006 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2008 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2007 | if ( loadOk && !todolist.isEmpty() ) | 2009 | if ( loadOk && !todolist.isEmpty() ) |
2008 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2010 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2009 | 2011 | ||
2010 | if ( loadOk ) { | 2012 | if ( loadOk ) { |
2011 | getEventViewerDialog()->setSyncMode( true ); | 2013 | getEventViewerDialog()->setSyncMode( true ); |
2012 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2014 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2013 | getEventViewerDialog()->setSyncMode( false ); | 2015 | getEventViewerDialog()->setSyncMode( false ); |
2014 | qApp->processEvents(); | 2016 | qApp->processEvents(); |
2015 | if ( syncOK ) { | 2017 | if ( syncOK ) { |
2016 | if ( mSyncManager->mWriteBackFile ) | 2018 | if ( mSyncManager->mWriteBackFile ) |
2017 | { | 2019 | { |
2018 | // write back XML file | 2020 | // write back XML file |
2019 | 2021 | ||
2020 | } | 2022 | } |
2021 | setModified( true ); | 2023 | setModified( true ); |
2022 | } | 2024 | } |
2023 | } else { | 2025 | } else { |
2024 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2026 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2025 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2027 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2026 | question, i18n("Ok")) ; | 2028 | question, i18n("Ok")) ; |
2027 | } | 2029 | } |
2028 | delete calendar; | 2030 | delete calendar; |
2029 | updateView(); | 2031 | updateView(); |
2030 | return syncOK; | 2032 | return syncOK; |
2031 | 2033 | ||
2032 | 2034 | ||
2033 | #endif | 2035 | #endif |
2034 | 2036 | ||
2035 | } | 2037 | } |
2036 | 2038 | ||
2037 | void CalendarView::setSyncEventsReadOnly() | 2039 | void CalendarView::setSyncEventsReadOnly() |
2038 | { | 2040 | { |
2039 | mCalendar->setSyncEventsReadOnly(); | 2041 | mCalendar->setSyncEventsReadOnly(); |
2040 | } | 2042 | } |
2041 | 2043 | ||
2042 | bool CalendarView::loadCalendars() | 2044 | bool CalendarView::loadCalendars() |
2043 | { | 2045 | { |
2044 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2046 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2045 | KopiCalendarFile * cal = calendars.first(); | 2047 | KopiCalendarFile * cal = calendars.first(); |
2046 | mCalendar->setDefaultCalendar( 1 ); | 2048 | mCalendar->setDefaultCalendar( 1 ); |
2047 | openCalendar( MainWindow::defaultFileName(), false ); | 2049 | openCalendar( MainWindow::defaultFileName(), false ); |
2048 | cal = calendars.next(); | 2050 | cal = calendars.next(); |
2049 | while ( cal ) { | 2051 | while ( cal ) { |
2050 | addCalendar( cal ); | 2052 | addCalendar( cal ); |
2051 | cal = calendars.next(); | 2053 | cal = calendars.next(); |
2052 | } | 2054 | } |
2053 | restoreCalendarSettings(); | 2055 | restoreCalendarSettings(); |
2054 | return true; | 2056 | return true; |
2055 | } | 2057 | } |
2056 | bool CalendarView::restoreCalendarSettings() | 2058 | bool CalendarView::restoreCalendarSettings() |
2057 | { | 2059 | { |
2058 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2060 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2059 | KopiCalendarFile * cal = calendars.first(); | 2061 | KopiCalendarFile * cal = calendars.first(); |
2060 | while ( cal ) { | 2062 | while ( cal ) { |
2061 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2063 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2062 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2064 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2063 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2065 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2064 | if ( cal->isStandard ) | 2066 | if ( cal->isStandard ) |
2065 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2067 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2066 | cal = calendars.next(); | 2068 | cal = calendars.next(); |
2067 | } | 2069 | } |
2068 | setSyncEventsReadOnly(); | 2070 | setSyncEventsReadOnly(); |
2069 | mCalendar->reInitAlarmSettings(); | 2071 | mCalendar->reInitAlarmSettings(); |
2070 | updateUnmanagedViews(); | 2072 | updateUnmanagedViews(); |
2071 | updateView(); | 2073 | updateView(); |
2072 | return true; | 2074 | return true; |
2073 | } | 2075 | } |
2074 | void CalendarView::addCalendarId( int id ) | 2076 | void CalendarView::addCalendarId( int id ) |
2075 | { | 2077 | { |
2076 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2078 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2077 | if ( cal ) | 2079 | if ( cal ) |
2078 | addCalendar( cal ); | 2080 | addCalendar( cal ); |
2079 | } | 2081 | } |
2080 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2082 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2081 | { | 2083 | { |
2082 | cal->mErrorOnLoad = false; | 2084 | cal->mErrorOnLoad = false; |
2083 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2085 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2084 | cal->mLoadDt = QDateTime::currentDateTime(); | 2086 | cal->mLoadDt = QDateTime::currentDateTime(); |
2085 | return true; | 2087 | return true; |
2086 | } | 2088 | } |
2087 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2089 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2088 | cal->mErrorOnLoad = true; | 2090 | cal->mErrorOnLoad = true; |
2089 | return false; | 2091 | return false; |
2090 | } | 2092 | } |
2091 | bool CalendarView::openCalendar(QString filename, bool merge) | 2093 | bool CalendarView::openCalendar(QString filename, bool merge) |
2092 | { | 2094 | { |
2093 | 2095 | ||
2094 | if (filename.isEmpty()) { | 2096 | if (filename.isEmpty()) { |
2095 | return false; | 2097 | return false; |
2096 | } | 2098 | } |
2097 | 2099 | ||
2098 | if (!QFile::exists(filename)) { | 2100 | if (!QFile::exists(filename)) { |
2099 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2101 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2100 | return false; | 2102 | return false; |
2101 | } | 2103 | } |
2102 | 2104 | ||
2103 | globalFlagBlockAgenda = 1; | 2105 | globalFlagBlockAgenda = 1; |
2104 | clearAllViews(); | 2106 | clearAllViews(); |
2105 | if (!merge) { | 2107 | if (!merge) { |
2106 | mViewManager->setDocumentId( filename ); | 2108 | mViewManager->setDocumentId( filename ); |
2107 | mCalendar->close(); | 2109 | mCalendar->close(); |
2108 | } | 2110 | } |
2109 | mStorage->setFileName( filename ); | 2111 | mStorage->setFileName( filename ); |
2110 | 2112 | ||
2111 | if ( mStorage->load() ) { | 2113 | if ( mStorage->load() ) { |
2112 | if ( merge ) ;//setModified( true ); | 2114 | if ( merge ) ;//setModified( true ); |
2113 | else { | 2115 | else { |
2114 | //setModified( true ); | 2116 | //setModified( true ); |
2115 | mViewManager->setDocumentId( filename ); | 2117 | mViewManager->setDocumentId( filename ); |
2116 | mDialogManager->setDocumentId( filename ); | 2118 | mDialogManager->setDocumentId( filename ); |
2117 | mTodoList->setDocumentId( filename ); | 2119 | mTodoList->setDocumentId( filename ); |
2118 | } | 2120 | } |
2119 | globalFlagBlockAgenda = 2; | 2121 | globalFlagBlockAgenda = 2; |
2120 | // if ( getLastSyncEvent() ) | 2122 | // if ( getLastSyncEvent() ) |
2121 | // getLastSyncEvent()->setReadOnly( true ); | 2123 | // getLastSyncEvent()->setReadOnly( true ); |
2122 | mCalendar->reInitAlarmSettings(); | 2124 | mCalendar->reInitAlarmSettings(); |
2123 | setSyncEventsReadOnly(); | 2125 | setSyncEventsReadOnly(); |
2124 | updateUnmanagedViews(); | 2126 | updateUnmanagedViews(); |
2125 | updateView(); | 2127 | updateView(); |
2126 | if ( filename != MainWindow::defaultFileName() ) { | 2128 | if ( filename != MainWindow::defaultFileName() ) { |
2127 | saveCalendar( MainWindow::defaultFileName() ); | 2129 | saveCalendar( MainWindow::defaultFileName() ); |
2128 | } else { | 2130 | } else { |
2129 | QFileInfo finf ( MainWindow::defaultFileName()); | 2131 | QFileInfo finf ( MainWindow::defaultFileName()); |
2130 | if ( finf.exists() ) { | 2132 | if ( finf.exists() ) { |
2131 | setLoadedFileVersion( finf.lastModified () ); | 2133 | setLoadedFileVersion( finf.lastModified () ); |
2132 | } | 2134 | } |
2133 | } | 2135 | } |
2134 | return true; | 2136 | return true; |
2135 | } else { | 2137 | } else { |
2136 | // while failing to load, the calendar object could | 2138 | // while failing to load, the calendar object could |
2137 | // have become partially populated. Clear it out. | 2139 | // have become partially populated. Clear it out. |
2138 | if ( !merge ) { | 2140 | if ( !merge ) { |
2139 | mCalendar->close(); | 2141 | mCalendar->close(); |
2140 | mViewManager->setDocumentId( filename ); | 2142 | mViewManager->setDocumentId( filename ); |
2141 | mDialogManager->setDocumentId( filename ); | 2143 | mDialogManager->setDocumentId( filename ); |
2142 | mTodoList->setDocumentId( filename ); | 2144 | mTodoList->setDocumentId( filename ); |
2143 | } | 2145 | } |
2144 | 2146 | ||
2145 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2147 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2146 | 2148 | ||
2147 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2149 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2148 | globalFlagBlockAgenda = 2; | 2150 | globalFlagBlockAgenda = 2; |
2149 | mCalendar->reInitAlarmSettings(); | 2151 | mCalendar->reInitAlarmSettings(); |
2150 | setSyncEventsReadOnly(); | 2152 | setSyncEventsReadOnly(); |
2151 | updateUnmanagedViews(); | 2153 | updateUnmanagedViews(); |
2152 | updateView(); | 2154 | updateView(); |
2153 | } | 2155 | } |
2154 | return false; | 2156 | return false; |
2155 | } | 2157 | } |
2156 | void CalendarView::mergeFile( QString fn ) | 2158 | void CalendarView::mergeFile( QString fn ) |
2157 | { | 2159 | { |
2158 | clearAllViews(); | 2160 | clearAllViews(); |
2159 | mCalendar->mergeCalendarFile( fn ); | 2161 | mCalendar->mergeCalendarFile( fn ); |
2160 | mCalendar->reInitAlarmSettings(); | 2162 | mCalendar->reInitAlarmSettings(); |
2161 | setSyncEventsReadOnly(); | 2163 | setSyncEventsReadOnly(); |
2162 | updateUnmanagedViews(); | 2164 | updateUnmanagedViews(); |
2163 | updateView(); | 2165 | updateView(); |
2164 | } | 2166 | } |
2165 | void CalendarView::showOpenError() | 2167 | void CalendarView::showOpenError() |
2166 | { | 2168 | { |
2167 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2169 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2168 | } | 2170 | } |
2169 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2171 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2170 | { | 2172 | { |
2171 | loadedFileVersion = dt; | 2173 | loadedFileVersion = dt; |
2172 | } | 2174 | } |
2173 | bool CalendarView::checkFileChanged(QString fn) | 2175 | bool CalendarView::checkFileChanged(QString fn) |
2174 | { | 2176 | { |
2175 | QFileInfo finf ( fn ); | 2177 | QFileInfo finf ( fn ); |
2176 | if ( !finf.exists() ) | 2178 | if ( !finf.exists() ) |
2177 | return true; | 2179 | return true; |
2178 | QDateTime dt = finf.lastModified (); | 2180 | QDateTime dt = finf.lastModified (); |
2179 | if ( dt <= loadedFileVersion ) | 2181 | if ( dt <= loadedFileVersion ) |
2180 | return false; | 2182 | return false; |
2181 | return true; | 2183 | return true; |
2182 | 2184 | ||
2183 | } | 2185 | } |
2184 | void CalendarView::watchSavedFile() | 2186 | void CalendarView::watchSavedFile() |
2185 | { | 2187 | { |
2186 | QFileInfo finf ( MainWindow::defaultFileName()); | 2188 | QFileInfo finf ( MainWindow::defaultFileName()); |
2187 | if ( !finf.exists() ) | 2189 | if ( !finf.exists() ) |
2188 | return; | 2190 | return; |
2189 | QDateTime dt = finf.lastModified (); | 2191 | QDateTime dt = finf.lastModified (); |
2190 | if ( dt < loadedFileVersion ) { | 2192 | if ( dt < loadedFileVersion ) { |
2191 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2193 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2192 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2194 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2193 | return; | 2195 | return; |
2194 | } | 2196 | } |
2195 | loadedFileVersion = dt; | 2197 | loadedFileVersion = dt; |
2196 | } | 2198 | } |
2197 | bool CalendarView::checkAllFileVersions() | 2199 | bool CalendarView::checkAllFileVersions() |
2198 | { | 2200 | { |
2199 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2201 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2200 | KopiCalendarFile * cal = calendars.first(); | 2202 | KopiCalendarFile * cal = calendars.first(); |
2201 | mCalendar->setDefaultCalendar( 1 ); | 2203 | mCalendar->setDefaultCalendar( 1 ); |
2202 | mCalendar->setDefaultCalendarEnabledOnly(); | 2204 | mCalendar->setDefaultCalendarEnabledOnly(); |
2203 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2205 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2204 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2206 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2205 | restoreCalendarSettings(); | 2207 | restoreCalendarSettings(); |
2206 | return false; | 2208 | return false; |
2207 | } | 2209 | } |
2208 | } | 2210 | } |
2209 | cal = calendars.next(); | 2211 | cal = calendars.next(); |
2210 | QDateTime storeTemp = loadedFileVersion; | 2212 | QDateTime storeTemp = loadedFileVersion; |
2211 | while ( cal ) { | 2213 | while ( cal ) { |
2212 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2214 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2213 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2215 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2214 | mCalendar->setDefaultCalendarEnabledOnly(); | 2216 | mCalendar->setDefaultCalendarEnabledOnly(); |
2215 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2217 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2216 | if ( !checkFileVersion(cal->mFileName )) { | 2218 | if ( !checkFileVersion(cal->mFileName )) { |
2217 | loadedFileVersion = storeTemp; | 2219 | loadedFileVersion = storeTemp; |
2218 | restoreCalendarSettings(); | 2220 | restoreCalendarSettings(); |
2219 | return false; | 2221 | return false; |
2220 | } | 2222 | } |
2221 | } | 2223 | } |
2222 | cal = calendars.next(); | 2224 | cal = calendars.next(); |
2223 | } | 2225 | } |
2224 | loadedFileVersion = storeTemp; | 2226 | loadedFileVersion = storeTemp; |
2225 | return true; | 2227 | return true; |
2226 | } | 2228 | } |
2227 | bool CalendarView::checkFileVersion(QString fn) | 2229 | bool CalendarView::checkFileVersion(QString fn) |
2228 | { | 2230 | { |
2229 | QFileInfo finf ( fn ); | 2231 | QFileInfo finf ( fn ); |
2230 | if ( !finf.exists() ) | 2232 | if ( !finf.exists() ) |
2231 | return true; | 2233 | return true; |
2232 | QDateTime dt = finf.lastModified (); | 2234 | QDateTime dt = finf.lastModified (); |
2233 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2235 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2234 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2236 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2235 | if ( dt <= loadedFileVersion ) | 2237 | if ( dt <= loadedFileVersion ) |
2236 | return true; | 2238 | return true; |
2237 | 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)) , | 2239 | 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)) , |
2238 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2240 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2239 | i18n("Sync+save")); | 2241 | i18n("Sync+save")); |
2240 | 2242 | ||
2241 | if ( km == KMessageBox::Cancel ) | 2243 | if ( km == KMessageBox::Cancel ) |
2242 | return false; | 2244 | return false; |
2243 | if ( km == KMessageBox::Yes ) | 2245 | if ( km == KMessageBox::Yes ) |
2244 | return true; | 2246 | return true; |
2245 | 2247 | ||
2246 | setSyncDevice("deleteaftersync" ); | 2248 | setSyncDevice("deleteaftersync" ); |
2247 | mSyncManager->mAskForPreferences = true; | 2249 | mSyncManager->mAskForPreferences = true; |
2248 | mSyncManager->mSyncAlgoPrefs = 3; | 2250 | mSyncManager->mSyncAlgoPrefs = 3; |
2249 | mSyncManager->mWriteBackFile = false; | 2251 | mSyncManager->mWriteBackFile = false; |
2250 | mSyncManager->mWriteBackExistingOnly = false; | 2252 | mSyncManager->mWriteBackExistingOnly = false; |
2251 | mSyncManager->mShowSyncSummary = false; | 2253 | mSyncManager->mShowSyncSummary = false; |
2252 | syncCalendar( fn, 3 ); | 2254 | syncCalendar( fn, 3 ); |
2253 | Event * e = getLastSyncEvent(); | 2255 | Event * e = getLastSyncEvent(); |
2254 | if ( e ) | 2256 | if ( e ) |
2255 | mCalendar->deleteEvent( e ); | 2257 | mCalendar->deleteEvent( e ); |
2256 | return true; | 2258 | return true; |
2257 | } | 2259 | } |
2258 | bool CalendarView::saveCalendars() | 2260 | bool CalendarView::saveCalendars() |
2259 | { | 2261 | { |
2260 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2262 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2261 | KopiCalendarFile * cal = calendars.first(); | 2263 | KopiCalendarFile * cal = calendars.first(); |
2262 | mCalendar->setDefaultCalendar( 1 ); | 2264 | mCalendar->setDefaultCalendar( 1 ); |
2263 | mCalendar->setDefaultCalendarEnabledOnly(); | 2265 | mCalendar->setDefaultCalendarEnabledOnly(); |
2264 | saveCalendar( MainWindow::defaultFileName() ); | 2266 | saveCalendar( MainWindow::defaultFileName() ); |
2265 | cal = calendars.next(); | 2267 | cal = calendars.next(); |
2266 | while ( cal ) { | 2268 | while ( cal ) { |
2267 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2269 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2268 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2270 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2269 | mCalendar->setDefaultCalendarEnabledOnly(); | 2271 | mCalendar->setDefaultCalendarEnabledOnly(); |
2270 | if ( saveCalendar( cal->mFileName ) ) | 2272 | if ( saveCalendar( cal->mFileName ) ) |
2271 | cal->mLoadDt = QDateTime::currentDateTime(); | 2273 | cal->mLoadDt = QDateTime::currentDateTime(); |
2272 | } | 2274 | } |
2273 | cal = calendars.next(); | 2275 | cal = calendars.next(); |
2274 | } | 2276 | } |
2275 | restoreCalendarSettings(); | 2277 | restoreCalendarSettings(); |
2276 | return true; | 2278 | return true; |
2277 | } | 2279 | } |
2278 | bool CalendarView::saveCalendar( QString filename ) | 2280 | bool CalendarView::saveCalendar( QString filename ) |
2279 | { | 2281 | { |
2280 | 2282 | ||
2281 | // Store back all unsaved data into calendar object | 2283 | // Store back all unsaved data into calendar object |
2282 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2284 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2283 | if ( mViewManager->currentView() ) | 2285 | if ( mViewManager->currentView() ) |
2284 | mViewManager->currentView()->flushView(); | 2286 | mViewManager->currentView()->flushView(); |
2285 | 2287 | ||
2286 | 2288 | ||
2287 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2289 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2288 | mStorage->setSaveFormat( new ICalFormat() ); | 2290 | mStorage->setSaveFormat( new ICalFormat() ); |
2289 | mStorage->setFileName( filename ); | 2291 | mStorage->setFileName( filename ); |
2290 | bool success; | 2292 | bool success; |
2291 | success = mStorage->save(); | 2293 | success = mStorage->save(); |
2292 | if ( !success ) { | 2294 | if ( !success ) { |
2293 | return false; | 2295 | return false; |
2294 | } | 2296 | } |
2295 | if ( filename == MainWindow::defaultFileName() ) { | 2297 | if ( filename == MainWindow::defaultFileName() ) { |
2296 | setLoadedFileVersion( lfv ); | 2298 | setLoadedFileVersion( lfv ); |
2297 | watchSavedFile(); | 2299 | watchSavedFile(); |
2298 | } | 2300 | } |
2299 | return true; | 2301 | return true; |
2300 | } | 2302 | } |
2301 | 2303 | ||
2302 | void CalendarView::closeCalendar() | 2304 | void CalendarView::closeCalendar() |
2303 | { | 2305 | { |
2304 | 2306 | ||
2305 | // child windows no longer valid | 2307 | // child windows no longer valid |
2306 | clearAllViews(); | 2308 | clearAllViews(); |
2307 | emit closingDown(); | 2309 | emit closingDown(); |
2308 | 2310 | ||
2309 | mCalendar->close(); | 2311 | mCalendar->close(); |
2310 | setModified(false); | 2312 | setModified(false); |
2311 | updateView(); | 2313 | updateView(); |
2312 | } | 2314 | } |
2313 | 2315 | ||
2314 | void CalendarView::archiveCalendar() | 2316 | void CalendarView::archiveCalendar() |
2315 | { | 2317 | { |
2316 | mDialogManager->showArchiveDialog(); | 2318 | mDialogManager->showArchiveDialog(); |
2317 | } | 2319 | } |
2318 | 2320 | ||
2319 | 2321 | ||
2320 | void CalendarView::readSettings() | 2322 | void CalendarView::readSettings() |
2321 | { | 2323 | { |
2322 | 2324 | ||
2323 | 2325 | ||
2324 | // mViewManager->showAgendaView(); | 2326 | // mViewManager->showAgendaView(); |
2325 | QString str; | 2327 | QString str; |
2326 | //qDebug("CalendarView::readSettings() "); | 2328 | //qDebug("CalendarView::readSettings() "); |
2327 | // read settings from the KConfig, supplying reasonable | 2329 | // read settings from the KConfig, supplying reasonable |
2328 | // defaults where none are to be found | 2330 | // defaults where none are to be found |
2329 | KConfig *config = KOGlobals::config(); | 2331 | KConfig *config = KOGlobals::config(); |
2330 | #ifndef KORG_NOSPLITTER | 2332 | #ifndef KORG_NOSPLITTER |
2331 | config->setGroup("KOrganizer Geometry"); | 2333 | config->setGroup("KOrganizer Geometry"); |
2332 | 2334 | ||
2333 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2335 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2334 | if (sizes.count() != 2) { | 2336 | if (sizes.count() != 2) { |
2335 | sizes << mDateNavigator->minimumSizeHint().width(); | 2337 | sizes << mDateNavigator->minimumSizeHint().width(); |
2336 | sizes << 300; | 2338 | sizes << 300; |
2337 | } | 2339 | } |
2338 | mPanner->setSizes(sizes); | 2340 | mPanner->setSizes(sizes); |
2339 | 2341 | ||
2340 | sizes = config->readIntListEntry("Separator2"); | 2342 | sizes = config->readIntListEntry("Separator2"); |
2341 | if ( ( mResourceView && sizes.count() == 4 ) || | 2343 | if ( ( mResourceView && sizes.count() == 4 ) || |
2342 | ( !mResourceView && sizes.count() == 3 ) ) { | 2344 | ( !mResourceView && sizes.count() == 3 ) ) { |
2343 | mLeftSplitter->setSizes(sizes); | 2345 | mLeftSplitter->setSizes(sizes); |
2344 | } | 2346 | } |
2345 | #endif | 2347 | #endif |
2346 | globalFlagBlockAgenda = 1; | 2348 | globalFlagBlockAgenda = 1; |
2347 | mViewManager->showAgendaView(); | 2349 | mViewManager->showAgendaView(); |
2348 | //mViewManager->readSettings( config ); | 2350 | //mViewManager->readSettings( config ); |
2349 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2351 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2350 | readFilterSettings(config); | 2352 | readFilterSettings(config); |
2351 | 2353 | ||
2352 | #ifdef DESKTOP_VERSION | 2354 | #ifdef DESKTOP_VERSION |
2353 | config->setGroup("WidgetLayout"); | 2355 | config->setGroup("WidgetLayout"); |
2354 | QStringList list; | 2356 | QStringList list; |
2355 | list = config->readListEntry("MainLayout"); | 2357 | list = config->readListEntry("MainLayout"); |
2356 | int x,y,w,h; | 2358 | int x,y,w,h; |
2357 | if ( ! list.isEmpty() ) { | 2359 | if ( ! list.isEmpty() ) { |
2358 | x = list[0].toInt(); | 2360 | x = list[0].toInt(); |
2359 | y = list[1].toInt(); | 2361 | y = list[1].toInt(); |
2360 | w = list[2].toInt(); | 2362 | w = list[2].toInt(); |
2361 | h = list[3].toInt(); | 2363 | h = list[3].toInt(); |
2362 | KApplication::testCoords( &x,&y,&w,&h ); | 2364 | KApplication::testCoords( &x,&y,&w,&h ); |
2363 | topLevelWidget()->setGeometry(x,y,w,h); | 2365 | topLevelWidget()->setGeometry(x,y,w,h); |
2364 | 2366 | ||
2365 | } else { | 2367 | } else { |
2366 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2368 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2367 | } | 2369 | } |
2368 | list = config->readListEntry("EditEventLayout"); | 2370 | list = config->readListEntry("EditEventLayout"); |
2369 | if ( ! list.isEmpty() ) { | 2371 | if ( ! list.isEmpty() ) { |
2370 | x = list[0].toInt(); | 2372 | x = list[0].toInt(); |
2371 | y = list[1].toInt(); | 2373 | y = list[1].toInt(); |
2372 | w = list[2].toInt(); | 2374 | w = list[2].toInt(); |
2373 | h = list[3].toInt(); | 2375 | h = list[3].toInt(); |
2374 | KApplication::testCoords( &x,&y,&w,&h ); | 2376 | KApplication::testCoords( &x,&y,&w,&h ); |
2375 | mEventEditor->setGeometry(x,y,w,h); | 2377 | mEventEditor->setGeometry(x,y,w,h); |
2376 | 2378 | ||
2377 | } | 2379 | } |
2378 | list = config->readListEntry("EditTodoLayout"); | 2380 | list = config->readListEntry("EditTodoLayout"); |
2379 | if ( ! list.isEmpty() ) { | 2381 | if ( ! list.isEmpty() ) { |
2380 | x = list[0].toInt(); | 2382 | x = list[0].toInt(); |
2381 | y = list[1].toInt(); | 2383 | y = list[1].toInt(); |
2382 | w = list[2].toInt(); | 2384 | w = list[2].toInt(); |
2383 | h = list[3].toInt(); | 2385 | h = list[3].toInt(); |
2384 | KApplication::testCoords( &x,&y,&w,&h ); | 2386 | KApplication::testCoords( &x,&y,&w,&h ); |
2385 | mTodoEditor->setGeometry(x,y,w,h); | 2387 | mTodoEditor->setGeometry(x,y,w,h); |
2386 | 2388 | ||
2387 | } | 2389 | } |
2388 | list = config->readListEntry("ViewerLayout"); | 2390 | list = config->readListEntry("ViewerLayout"); |
2389 | if ( ! list.isEmpty() ) { | 2391 | if ( ! list.isEmpty() ) { |
2390 | x = list[0].toInt(); | 2392 | x = list[0].toInt(); |
2391 | y = list[1].toInt(); | 2393 | y = list[1].toInt(); |
2392 | w = list[2].toInt(); | 2394 | w = list[2].toInt(); |
2393 | h = list[3].toInt(); | 2395 | h = list[3].toInt(); |
2394 | KApplication::testCoords( &x,&y,&w,&h ); | 2396 | KApplication::testCoords( &x,&y,&w,&h ); |
2395 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2397 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2396 | } | 2398 | } |
2397 | #endif | 2399 | #endif |
2398 | config->setGroup( "Views" ); | 2400 | config->setGroup( "Views" ); |
2399 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2401 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2400 | 2402 | ||
2401 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2403 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2402 | 2404 | ||
2403 | int resetval = 0; | 2405 | int resetval = 0; |
2404 | int maxVal = 0; | 2406 | int maxVal = 0; |
2405 | if (sizes.count() != 3) { | 2407 | if (sizes.count() != 3) { |
2406 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2408 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2407 | resetval = mDateNavigator->sizeHint().width()+2; | 2409 | resetval = mDateNavigator->sizeHint().width()+2; |
2408 | } else { | 2410 | } else { |
2409 | resetval = mDateNavigator->sizeHint().height()+2; | 2411 | resetval = mDateNavigator->sizeHint().height()+2; |
2410 | } | 2412 | } |
2411 | } | 2413 | } |
2412 | if ( resetval ) { | 2414 | if ( resetval ) { |
2413 | sizes.clear(); | 2415 | sizes.clear(); |
2414 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2416 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2415 | maxVal = QApplication::desktop()->width() -10; | 2417 | maxVal = QApplication::desktop()->width() -10; |
2416 | } else { | 2418 | } else { |
2417 | maxVal = QApplication::desktop()->height()-10; | 2419 | maxVal = QApplication::desktop()->height()-10; |
2418 | } | 2420 | } |
2419 | sizes << resetval; | 2421 | sizes << resetval; |
2420 | if ( maxVal < resetval + resetval) | 2422 | if ( maxVal < resetval + resetval) |
2421 | resetval = maxVal - resetval; | 2423 | resetval = maxVal - resetval; |
2422 | sizes << resetval; | 2424 | sizes << resetval; |
2423 | sizes << 100; | 2425 | sizes << 100; |
2424 | } | 2426 | } |
2425 | mLeftFrame->setSizes(sizes); | 2427 | mLeftFrame->setSizes(sizes); |
2426 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2428 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2427 | resetval = 0; | 2429 | resetval = 0; |
2428 | maxVal = 0; | 2430 | maxVal = 0; |
2429 | if (sizes.count() != 2) { | 2431 | if (sizes.count() != 2) { |
2430 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2432 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2431 | resetval = mDateNavigator->sizeHint().width()+2; | 2433 | resetval = mDateNavigator->sizeHint().width()+2; |
2432 | } else { | 2434 | } else { |
2433 | resetval = mDateNavigator->sizeHint().height()+2; | 2435 | resetval = mDateNavigator->sizeHint().height()+2; |
2434 | } | 2436 | } |
2435 | } | 2437 | } |
2436 | if ( resetval ) { | 2438 | if ( resetval ) { |
2437 | sizes.clear(); | 2439 | sizes.clear(); |
2438 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2440 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2439 | maxVal = QApplication::desktop()->width() -10; | 2441 | maxVal = QApplication::desktop()->width() -10; |
2440 | } else { | 2442 | } else { |
2441 | maxVal = QApplication::desktop()->height()-10; | 2443 | maxVal = QApplication::desktop()->height()-10; |
2442 | } | 2444 | } |
2443 | sizes << resetval; | 2445 | sizes << resetval; |
2444 | if ( maxVal < resetval + resetval) | 2446 | if ( maxVal < resetval + resetval) |
2445 | resetval = maxVal - resetval; | 2447 | resetval = maxVal - resetval; |
2446 | sizes << resetval; | 2448 | sizes << resetval; |
2447 | } | 2449 | } |
2448 | mMainFrame->setSizes(sizes); | 2450 | mMainFrame->setSizes(sizes); |
2449 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2451 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2450 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2452 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2451 | else mNavigator->selectDates( dateCount ); | 2453 | else mNavigator->selectDates( dateCount ); |
2452 | // mViewManager->readSettings( config ); | 2454 | // mViewManager->readSettings( config ); |
2453 | updateConfig(); | 2455 | updateConfig(); |
2454 | globalFlagBlockAgenda = 2; | 2456 | globalFlagBlockAgenda = 2; |
2455 | mViewManager->readSettings( config ); | 2457 | mViewManager->readSettings( config ); |
2456 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2458 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2457 | } | 2459 | } |
2458 | 2460 | ||
2459 | void CalendarView::checkSuspendAlarm() | 2461 | void CalendarView::checkSuspendAlarm() |
2460 | { | 2462 | { |
2461 | if ( mSuspendTimer->isActive() ) { | 2463 | if ( mSuspendTimer->isActive() ) { |
2462 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2464 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2463 | } | 2465 | } |
2464 | } | 2466 | } |
2465 | void CalendarView::writeSettings() | 2467 | void CalendarView::writeSettings() |
2466 | { | 2468 | { |
2467 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2469 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2468 | 2470 | ||
2469 | KConfig *config = KOGlobals::config(); | 2471 | KConfig *config = KOGlobals::config(); |
2470 | 2472 | ||
2471 | mViewManager->writeSettings( config ); | 2473 | mViewManager->writeSettings( config ); |
2472 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2474 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2473 | mDialogManager->writeSettings( config ); | 2475 | mDialogManager->writeSettings( config ); |
2474 | //KOPrefs::instance()->usrWriteConfig(); | 2476 | //KOPrefs::instance()->usrWriteConfig(); |
2475 | KOPrefs::instance()->writeConfig(); | 2477 | KOPrefs::instance()->writeConfig(); |
2476 | 2478 | ||
2477 | writeFilterSettings(config); | 2479 | writeFilterSettings(config); |
2478 | config->setGroup( "AppRun" ); | 2480 | config->setGroup( "AppRun" ); |
2479 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2481 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2480 | int days = dt.daysTo( QDate::currentDate() ); | 2482 | int days = dt.daysTo( QDate::currentDate() ); |
2481 | dt = dt.addDays( days ); | 2483 | dt = dt.addDays( days ); |
2482 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2484 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2483 | config->writeEntry( "LatestProgramStopDays", days ); | 2485 | config->writeEntry( "LatestProgramStopDays", days ); |
2484 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2486 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2485 | //qDebug("KO: Writing stop time: %d ", secs); | 2487 | //qDebug("KO: Writing stop time: %d ", secs); |
2486 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2488 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2487 | //QDateTime latest = dt.addSecs ( secs ); | 2489 | //QDateTime latest = dt.addSecs ( secs ); |
2488 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2490 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2489 | config->setGroup( "Views" ); | 2491 | config->setGroup( "Views" ); |
2490 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2492 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2491 | 2493 | ||
2492 | #if 0 | 2494 | #if 0 |
2493 | qDebug("********************* "); | 2495 | qDebug("********************* "); |
2494 | qDebug("Testcode secsto "); | 2496 | qDebug("Testcode secsto "); |
2495 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2497 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2496 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2498 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2497 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2499 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2498 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2500 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2499 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2501 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2500 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2502 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2501 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2503 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2502 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2504 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2503 | qDebug("********************* testcode end"); | 2505 | qDebug("********************* testcode end"); |
2504 | 2506 | ||
2505 | #endif | 2507 | #endif |
2506 | 2508 | ||
2507 | QValueList<int> listINT = mLeftFrame->sizes(); | 2509 | QValueList<int> listINT = mLeftFrame->sizes(); |
2508 | config->writeEntry("Left Splitter Frame",listINT); | 2510 | config->writeEntry("Left Splitter Frame",listINT); |
2509 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2511 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2510 | config->writeEntry("Main Splitter Frame",listINT2); | 2512 | config->writeEntry("Main Splitter Frame",listINT2); |
2511 | #ifdef DESKTOP_VERSION | 2513 | #ifdef DESKTOP_VERSION |
2512 | config->setGroup("WidgetLayout"); | 2514 | config->setGroup("WidgetLayout"); |
2513 | QStringList list ;//= config->readListEntry("MainLayout"); | 2515 | QStringList list ;//= config->readListEntry("MainLayout"); |
2514 | int x,y,w,h; | 2516 | int x,y,w,h; |
2515 | QWidget* wid; | 2517 | QWidget* wid; |
2516 | wid = topLevelWidget(); | 2518 | wid = topLevelWidget(); |
2517 | x = wid->geometry().x(); | 2519 | x = wid->geometry().x(); |
2518 | y = wid->geometry().y(); | 2520 | y = wid->geometry().y(); |
2519 | w = wid->width(); | 2521 | w = wid->width(); |
2520 | h = wid->height(); | 2522 | h = wid->height(); |
2521 | list.clear(); | 2523 | list.clear(); |
2522 | list << QString::number( x ); | 2524 | list << QString::number( x ); |
2523 | list << QString::number( y ); | 2525 | list << QString::number( y ); |
2524 | list << QString::number( w ); | 2526 | list << QString::number( w ); |
2525 | list << QString::number( h ); | 2527 | list << QString::number( h ); |
2526 | config->writeEntry("MainLayout",list ); | 2528 | config->writeEntry("MainLayout",list ); |
2527 | 2529 | ||
2528 | wid = mEventEditor; | 2530 | wid = mEventEditor; |
2529 | x = wid->geometry().x(); | 2531 | x = wid->geometry().x(); |
2530 | y = wid->geometry().y(); | 2532 | y = wid->geometry().y(); |
2531 | w = wid->width(); | 2533 | w = wid->width(); |
2532 | h = wid->height(); | 2534 | h = wid->height(); |
2533 | list.clear(); | 2535 | list.clear(); |
2534 | list << QString::number( x ); | 2536 | list << QString::number( x ); |
2535 | list << QString::number( y ); | 2537 | list << QString::number( y ); |
2536 | list << QString::number( w ); | 2538 | list << QString::number( w ); |
2537 | list << QString::number( h ); | 2539 | list << QString::number( h ); |
2538 | config->writeEntry("EditEventLayout",list ); | 2540 | config->writeEntry("EditEventLayout",list ); |
2539 | 2541 | ||
2540 | wid = mTodoEditor; | 2542 | wid = mTodoEditor; |
2541 | x = wid->geometry().x(); | 2543 | x = wid->geometry().x(); |
2542 | y = wid->geometry().y(); | 2544 | y = wid->geometry().y(); |
2543 | w = wid->width(); | 2545 | w = wid->width(); |
2544 | h = wid->height(); | 2546 | h = wid->height(); |
2545 | list.clear(); | 2547 | list.clear(); |
2546 | list << QString::number( x ); | 2548 | list << QString::number( x ); |
2547 | list << QString::number( y ); | 2549 | list << QString::number( y ); |
2548 | list << QString::number( w ); | 2550 | list << QString::number( w ); |
2549 | list << QString::number( h ); | 2551 | list << QString::number( h ); |
2550 | config->writeEntry("EditTodoLayout",list ); | 2552 | config->writeEntry("EditTodoLayout",list ); |
2551 | wid = getEventViewerDialog(); | 2553 | wid = getEventViewerDialog(); |
2552 | x = wid->geometry().x(); | 2554 | x = wid->geometry().x(); |
2553 | y = wid->geometry().y(); | 2555 | y = wid->geometry().y(); |
2554 | w = wid->width(); | 2556 | w = wid->width(); |
2555 | h = wid->height(); | 2557 | h = wid->height(); |
2556 | list.clear(); | 2558 | list.clear(); |
2557 | list << QString::number( x ); | 2559 | list << QString::number( x ); |
2558 | list << QString::number( y ); | 2560 | list << QString::number( y ); |
2559 | list << QString::number( w ); | 2561 | list << QString::number( w ); |
2560 | list << QString::number( h ); | 2562 | list << QString::number( h ); |
2561 | config->writeEntry("ViewerLayout",list ); | 2563 | config->writeEntry("ViewerLayout",list ); |
2562 | wid = mDialogManager->getSearchDialog(); | 2564 | wid = mDialogManager->getSearchDialog(); |
2563 | if ( wid ) { | 2565 | if ( wid ) { |
2564 | x = wid->geometry().x(); | 2566 | x = wid->geometry().x(); |
2565 | y = wid->geometry().y(); | 2567 | y = wid->geometry().y(); |
2566 | w = wid->width(); | 2568 | w = wid->width(); |
2567 | h = wid->height(); | 2569 | h = wid->height(); |
2568 | list.clear(); | 2570 | list.clear(); |
2569 | list << QString::number( x ); | 2571 | list << QString::number( x ); |
2570 | list << QString::number( y ); | 2572 | list << QString::number( y ); |
2571 | list << QString::number( w ); | 2573 | list << QString::number( w ); |
2572 | list << QString::number( h ); | 2574 | list << QString::number( h ); |
2573 | config->writeEntry("SearchLayout",list ); | 2575 | config->writeEntry("SearchLayout",list ); |
2574 | } | 2576 | } |
2575 | #endif | 2577 | #endif |
2576 | 2578 | ||
2577 | 2579 | ||
2578 | config->sync(); | 2580 | config->sync(); |
2579 | } | 2581 | } |
2580 | 2582 | ||
2581 | void CalendarView::readFilterSettings(KConfig *config) | 2583 | void CalendarView::readFilterSettings(KConfig *config) |
2582 | { | 2584 | { |
2583 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2585 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2584 | 2586 | ||
2585 | mFilters.clear(); | 2587 | mFilters.clear(); |
2586 | 2588 | ||
2587 | config->setGroup("General"); | 2589 | config->setGroup("General"); |
2588 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2590 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2589 | 2591 | ||
2590 | QStringList::ConstIterator it = filterList.begin(); | 2592 | QStringList::ConstIterator it = filterList.begin(); |
2591 | QStringList::ConstIterator end = filterList.end(); | 2593 | QStringList::ConstIterator end = filterList.end(); |
2592 | while(it != end) { | 2594 | while(it != end) { |
2593 | // kdDebug() << " filter: " << (*it) << endl; | 2595 | // kdDebug() << " filter: " << (*it) << endl; |
2594 | 2596 | ||
2595 | CalFilter *filter; | 2597 | CalFilter *filter; |
2596 | filter = new CalFilter(*it); | 2598 | filter = new CalFilter(*it); |
2597 | config->setGroup("Filter_" + (*it).utf8()); | 2599 | config->setGroup("Filter_" + (*it).utf8()); |
2598 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2600 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2599 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2601 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2600 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2602 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2601 | mFilters.append(filter); | 2603 | mFilters.append(filter); |
2602 | 2604 | ||
2603 | ++it; | 2605 | ++it; |
2604 | } | 2606 | } |
2605 | 2607 | ||
2606 | if (mFilters.count() == 0) { | 2608 | if (mFilters.count() == 0) { |
2607 | CalFilter *filter = new CalFilter(i18n("Default")); | 2609 | CalFilter *filter = new CalFilter(i18n("Default")); |
2608 | mFilters.append(filter); | 2610 | mFilters.append(filter); |
2609 | } | 2611 | } |
2610 | mFilterView->updateFilters(); | 2612 | mFilterView->updateFilters(); |
2611 | config->setGroup("FilterView"); | 2613 | config->setGroup("FilterView"); |
2612 | 2614 | ||
2613 | mFilterView->blockSignals(true); | 2615 | mFilterView->blockSignals(true); |
2614 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2616 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2615 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2617 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2616 | mFilterView->blockSignals(false); | 2618 | mFilterView->blockSignals(false); |
2617 | // We do it manually to avoid it being done twice by the above calls | 2619 | // We do it manually to avoid it being done twice by the above calls |
2618 | updateFilter(); | 2620 | updateFilter(); |
2619 | } | 2621 | } |
2620 | 2622 | ||
2621 | void CalendarView::writeFilterSettings(KConfig *config) | 2623 | void CalendarView::writeFilterSettings(KConfig *config) |
2622 | { | 2624 | { |
2623 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2625 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2624 | 2626 | ||
2625 | QStringList filterList; | 2627 | QStringList filterList; |
2626 | 2628 | ||
2627 | CalFilter *filter = mFilters.first(); | 2629 | CalFilter *filter = mFilters.first(); |
2628 | while(filter) { | 2630 | while(filter) { |
2629 | // kdDebug() << " fn: " << filter->name() << endl; | 2631 | // kdDebug() << " fn: " << filter->name() << endl; |
2630 | filterList << filter->name(); | 2632 | filterList << filter->name(); |
2631 | config->setGroup("Filter_" + filter->name().utf8()); | 2633 | config->setGroup("Filter_" + filter->name().utf8()); |
2632 | config->writeEntry("Criteria",filter->criteria()); | 2634 | config->writeEntry("Criteria",filter->criteria()); |
2633 | config->writeEntry("CategoryList",filter->categoryList()); | 2635 | config->writeEntry("CategoryList",filter->categoryList()); |
2634 | filter = mFilters.next(); | 2636 | filter = mFilters.next(); |
2635 | } | 2637 | } |
2636 | config->setGroup("General"); | 2638 | config->setGroup("General"); |
2637 | config->writeEntry("CalendarFilters",filterList); | 2639 | config->writeEntry("CalendarFilters",filterList); |
2638 | 2640 | ||
2639 | config->setGroup("FilterView"); | 2641 | config->setGroup("FilterView"); |
2640 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2642 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2641 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2643 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2642 | } | 2644 | } |
2643 | 2645 | ||
2644 | 2646 | ||
2645 | void CalendarView::goToday() | 2647 | void CalendarView::goToday() |
2646 | { | 2648 | { |
2647 | if ( mViewManager->currentView()->isMonthView() ) | 2649 | if ( mViewManager->currentView()->isMonthView() ) |
2648 | mNavigator->selectTodayMonth(); | 2650 | mNavigator->selectTodayMonth(); |
2649 | else | 2651 | else |
2650 | mNavigator->selectToday(); | 2652 | mNavigator->selectToday(); |
2651 | } | 2653 | } |
2652 | 2654 | ||
2653 | void CalendarView::goNext() | 2655 | void CalendarView::goNext() |
2654 | { | 2656 | { |
2655 | mNavigator->selectNext(); | 2657 | mNavigator->selectNext(); |
2656 | } | 2658 | } |
2657 | 2659 | ||
2658 | void CalendarView::goPrevious() | 2660 | void CalendarView::goPrevious() |
2659 | { | 2661 | { |
2660 | mNavigator->selectPrevious(); | 2662 | mNavigator->selectPrevious(); |
2661 | } | 2663 | } |
2662 | void CalendarView::goNextMonth() | 2664 | void CalendarView::goNextMonth() |
2663 | { | 2665 | { |
2664 | mNavigator->selectNextMonth(); | 2666 | mNavigator->selectNextMonth(); |
2665 | } | 2667 | } |
2666 | 2668 | ||
2667 | void CalendarView::goPreviousMonth() | 2669 | void CalendarView::goPreviousMonth() |
2668 | { | 2670 | { |
2669 | mNavigator->selectPreviousMonth(); | 2671 | mNavigator->selectPreviousMonth(); |
2670 | } | 2672 | } |
2671 | 2673 | ||
2672 | void CalendarView::updateConfig() | 2674 | void CalendarView::updateConfig() |
2673 | { | 2675 | { |
2674 | if ( KOPrefs::instance()->mUseAppColors ) | 2676 | if ( KOPrefs::instance()->mUseAppColors ) |
2675 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2677 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2676 | emit configChanged(); | 2678 | emit configChanged(); |
2677 | mTodoList->updateConfig(); | 2679 | mTodoList->updateConfig(); |
2678 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2680 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2679 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2681 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2680 | // To make the "fill window" configurations work | 2682 | // To make the "fill window" configurations work |
2681 | //mViewManager->raiseCurrentView(); | 2683 | //mViewManager->raiseCurrentView(); |
2682 | } | 2684 | } |
2683 | 2685 | ||
2684 | 2686 | ||
2685 | void CalendarView::eventChanged(Event *event) | 2687 | void CalendarView::eventChanged(Event *event) |
2686 | { | 2688 | { |
2687 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2689 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2688 | //updateUnmanagedViews(); | 2690 | //updateUnmanagedViews(); |
2689 | } | 2691 | } |
2690 | 2692 | ||
2691 | void CalendarView::eventAdded(Event *event) | 2693 | void CalendarView::eventAdded(Event *event) |
2692 | { | 2694 | { |
2693 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2695 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2694 | } | 2696 | } |
2695 | 2697 | ||
2696 | void CalendarView::eventToBeDeleted(Event *) | 2698 | void CalendarView::eventToBeDeleted(Event *) |
2697 | { | 2699 | { |
2698 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2700 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2699 | } | 2701 | } |
2700 | 2702 | ||
2701 | void CalendarView::eventDeleted() | 2703 | void CalendarView::eventDeleted() |
2702 | { | 2704 | { |
2703 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2705 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2704 | } | 2706 | } |
2705 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2707 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2706 | { | 2708 | { |
2707 | changeIncidenceDisplay((Incidence *)which, action); | 2709 | changeIncidenceDisplay((Incidence *)which, action); |
2708 | mDateNavigator->updateView(); //LR | 2710 | mDateNavigator->updateView(); //LR |
2709 | //mDialogManager->updateSearchDialog(); | 2711 | //mDialogManager->updateSearchDialog(); |
2710 | 2712 | ||
2711 | if (which) { | 2713 | if (which) { |
2712 | mViewManager->updateWNview(); | 2714 | mViewManager->updateWNview(); |
2713 | //mTodoList->updateView(); | 2715 | //mTodoList->updateView(); |
2714 | } | 2716 | } |
2715 | 2717 | ||
2716 | } | 2718 | } |
2717 | 2719 | ||
2718 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2720 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2719 | { | 2721 | { |
2720 | updateUnmanagedViews(); | 2722 | updateUnmanagedViews(); |
2721 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2723 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2722 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2724 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2723 | mCalendar->checkAlarmForIncidence( 0, true ); | 2725 | mCalendar->checkAlarmForIncidence( 0, true ); |
2724 | if ( mEventViewerDialog ) | 2726 | if ( mEventViewerDialog ) |
2725 | mEventViewerDialog->hide(); | 2727 | mEventViewerDialog->hide(); |
2726 | } | 2728 | } |
2727 | else | 2729 | else |
2728 | mCalendar->checkAlarmForIncidence( which , false ); | 2730 | mCalendar->checkAlarmForIncidence( which , false ); |
2729 | } | 2731 | } |
2730 | 2732 | ||
2731 | // most of the changeEventDisplays() right now just call the view's | 2733 | // most of the changeEventDisplays() right now just call the view's |
2732 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2734 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2733 | void CalendarView::changeEventDisplay(Event *which, int action) | 2735 | void CalendarView::changeEventDisplay(Event *which, int action) |
2734 | { | 2736 | { |
2735 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2737 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2736 | changeIncidenceDisplay((Incidence *)which, action); | 2738 | changeIncidenceDisplay((Incidence *)which, action); |
2737 | static bool clearallviews = false; | 2739 | static bool clearallviews = false; |
2738 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2740 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2739 | if ( clearallviews ) { | 2741 | if ( clearallviews ) { |
2740 | clearAllViews(); | 2742 | clearAllViews(); |
2741 | clearallviews = false; | 2743 | clearallviews = false; |
2742 | } | 2744 | } |
2743 | return; | 2745 | return; |
2744 | } | 2746 | } |
2745 | clearallviews = true; | 2747 | clearallviews = true; |
2746 | mDateNavigator->updateView(); | 2748 | mDateNavigator->updateView(); |
2747 | //mDialogManager->updateSearchDialog(); | 2749 | //mDialogManager->updateSearchDialog(); |
2748 | if (which) { | 2750 | if (which) { |
2749 | // If there is an event view visible update the display | 2751 | // If there is an event view visible update the display |
2750 | mViewManager->currentView()->changeEventDisplay(which,action); | 2752 | mViewManager->currentView()->changeEventDisplay(which,action); |
2751 | // TODO: check, if update needed | 2753 | // TODO: check, if update needed |
2752 | // if (which->getTodoStatus()) { | 2754 | // if (which->getTodoStatus()) { |
2753 | mTodoList->updateView(); | 2755 | mTodoList->updateView(); |
2754 | if ( action != KOGlobals::EVENTDELETED ) { | 2756 | if ( action != KOGlobals::EVENTDELETED ) { |
2755 | mConflictingEvent = which ; | 2757 | mConflictingEvent = which ; |
2756 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2758 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2757 | } | 2759 | } |
2758 | // } | 2760 | // } |
2759 | } else { | 2761 | } else { |
2760 | mViewManager->currentView()->updateView(); | 2762 | mViewManager->currentView()->updateView(); |
2761 | } | 2763 | } |
2762 | } | 2764 | } |
2763 | void CalendarView::checkConflictForEvent() | 2765 | void CalendarView::checkConflictForEvent() |
2764 | { | 2766 | { |
2765 | 2767 | ||
2766 | if (!KOPrefs::instance()->mConfirm) | 2768 | if (!KOPrefs::instance()->mConfirm) |
2767 | return; | 2769 | return; |
2768 | if ( ! mConflictingEvent ) return; | 2770 | if ( ! mConflictingEvent ) return; |
2769 | if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) { | 2771 | if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) { |
2770 | mConflictingEvent = 0; | 2772 | mConflictingEvent = 0; |
2771 | return; | 2773 | return; |
2772 | } | 2774 | } |
2773 | QPtrList<Event> testlist = mCalendar->events(); | 2775 | QPtrList<Event> testlist = mCalendar->events(); |
2774 | Event * test = testlist.first(); | 2776 | Event * test = testlist.first(); |
2775 | QDateTime conflict; | 2777 | QDateTime conflict; |
2776 | QDateTime retVal; | 2778 | QDateTime retVal; |
2777 | bool found = false; | 2779 | bool found = false; |
2778 | Event * cE = 0; | 2780 | Event * cE = 0; |
2779 | QDateTime current = QDateTime::currentDateTime(); | 2781 | QDateTime current = QDateTime::currentDateTime(); |
2780 | while ( test ) { | 2782 | while ( test ) { |
2781 | if ( !test->doesFloat() ) { | 2783 | if ( !test->doesFloat() ) { |
2782 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2784 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2783 | if ( ! found ) { | 2785 | if ( ! found ) { |
2784 | conflict = retVal; | 2786 | conflict = retVal; |
2785 | cE = test; | 2787 | cE = test; |
2786 | } else { | 2788 | } else { |
2787 | if ( retVal < conflict ) { | 2789 | if ( retVal < conflict ) { |
2788 | conflict = retVal; | 2790 | conflict = retVal; |
2789 | cE = test; | 2791 | cE = test; |
2790 | } | 2792 | } |
2791 | } | 2793 | } |
2792 | found = true; | 2794 | found = true; |
2793 | } | 2795 | } |
2794 | } | 2796 | } |
2795 | test = testlist.next(); | 2797 | test = testlist.next(); |
2796 | } | 2798 | } |
2797 | if ( found ) { | 2799 | if ( found ) { |
2798 | 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()) ) ; | 2800 | 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()) ) ; |
2799 | qApp->processEvents(); | 2801 | qApp->processEvents(); |
2800 | int km = KMessageBox::warningContinueCancel(this,mess, | 2802 | int km = KMessageBox::warningContinueCancel(this,mess, |
2801 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2803 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2802 | if ( km != KMessageBox::Continue ) | 2804 | if ( km != KMessageBox::Continue ) |
2803 | return; | 2805 | return; |
2804 | 2806 | ||
2805 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2807 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2806 | mViewManager->showDayView(); | 2808 | mViewManager->showDayView(); |
2807 | mNavigator->slotDaySelect( conflict.date() ); | 2809 | mNavigator->slotDaySelect( conflict.date() ); |
2808 | int hour = conflict.time().hour(); | 2810 | int hour = conflict.time().hour(); |
2809 | mViewManager->agendaView()->setStartHour( hour ); | 2811 | mViewManager->agendaView()->setStartHour( hour ); |
2810 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2812 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2811 | } | 2813 | } |
2812 | mConflictingEvent = 0; | 2814 | mConflictingEvent = 0; |
2813 | return; | 2815 | return; |
2814 | 2816 | ||
2815 | } | 2817 | } |
2816 | 2818 | ||
2817 | void CalendarView::updateTodoViews() | 2819 | void CalendarView::updateTodoViews() |
2818 | { | 2820 | { |
2819 | mTodoList->updateView(); | 2821 | mTodoList->updateView(); |
2820 | mViewManager->currentView()->updateView(); | 2822 | mViewManager->currentView()->updateView(); |
2821 | 2823 | ||
2822 | } | 2824 | } |
2823 | 2825 | ||
2824 | 2826 | ||
2825 | 2827 | ||
2826 | void CalendarView::clearAllViews() | 2828 | void CalendarView::clearAllViews() |
2827 | { | 2829 | { |
2828 | mTodoList->clearList(); | 2830 | mTodoList->clearList(); |
2829 | mViewManager->clearAllViews(); | 2831 | mViewManager->clearAllViews(); |
2830 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2832 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2831 | if ( sd ) { | 2833 | if ( sd ) { |
2832 | KOListView* kol = sd->listview(); | 2834 | KOListView* kol = sd->listview(); |
2833 | if ( kol ) | 2835 | if ( kol ) |
2834 | kol->clearList(); | 2836 | kol->clearList(); |
2835 | } | 2837 | } |
2836 | } | 2838 | } |
2837 | void CalendarView::updateView() | 2839 | void CalendarView::updateView() |
2838 | { | 2840 | { |
2839 | static bool clearallviews = false; | 2841 | static bool clearallviews = false; |
2840 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2842 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2841 | if ( clearallviews ) { | 2843 | if ( clearallviews ) { |
2842 | clearAllViews(); | 2844 | clearAllViews(); |
2843 | clearallviews = false; | 2845 | clearallviews = false; |
2844 | } | 2846 | } |
2845 | return; | 2847 | return; |
2846 | } | 2848 | } |
2847 | clearallviews = true; | 2849 | clearallviews = true; |
2848 | DateList tmpList = mNavigator->selectedDates(); | 2850 | DateList tmpList = mNavigator->selectedDates(); |
2849 | 2851 | ||
2850 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2852 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2851 | mTodoList->updateView(); | 2853 | mTodoList->updateView(); |
2852 | // We assume that the navigator only selects consecutive days. | 2854 | // We assume that the navigator only selects consecutive days. |
2853 | updateView( tmpList.first(), tmpList.last() ); | 2855 | updateView( tmpList.first(), tmpList.last() ); |
2854 | } | 2856 | } |
2855 | 2857 | ||
2856 | void CalendarView::updateUnmanagedViews() | 2858 | void CalendarView::updateUnmanagedViews() |
2857 | { | 2859 | { |
2858 | mDateNavigator->updateDayMatrix(); | 2860 | mDateNavigator->updateDayMatrix(); |
2859 | } | 2861 | } |
2860 | 2862 | ||
2861 | int CalendarView::msgItemDelete(const QString name) | 2863 | int CalendarView::msgItemDelete(const QString name) |
2862 | { | 2864 | { |
2863 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2865 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2864 | i18n("This item will be\npermanently deleted."), | 2866 | i18n("This item will be\npermanently deleted."), |
2865 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2867 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2866 | } | 2868 | } |
2867 | 2869 | ||
2868 | 2870 | ||
2869 | void CalendarView::edit_cut() | 2871 | void CalendarView::edit_cut() |
2870 | { | 2872 | { |
2871 | Event *anEvent=0; | 2873 | Event *anEvent=0; |
2872 | 2874 | ||
2873 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2875 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2874 | 2876 | ||
2875 | if (mViewManager->currentView()->isEventView()) { | 2877 | if (mViewManager->currentView()->isEventView()) { |
2876 | if ( incidence && incidence->typeID() == eventID ) { | 2878 | if ( incidence && incidence->typeID() == eventID ) { |
2877 | anEvent = static_cast<Event *>(incidence); | 2879 | anEvent = static_cast<Event *>(incidence); |
2878 | } | 2880 | } |
2879 | } | 2881 | } |
2880 | 2882 | ||
2881 | if (!anEvent) { | 2883 | if (!anEvent) { |
2882 | KNotifyClient::beep(); | 2884 | KNotifyClient::beep(); |
2883 | return; | 2885 | return; |
2884 | } | 2886 | } |
2885 | DndFactory factory( mCalendar ); | 2887 | DndFactory factory( mCalendar ); |
2886 | factory.cutIncidence(anEvent); | 2888 | factory.cutIncidence(anEvent); |
2887 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2889 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2888 | } | 2890 | } |
2889 | 2891 | ||
2890 | void CalendarView::edit_copy() | 2892 | void CalendarView::edit_copy() |
2891 | { | 2893 | { |
2892 | Event *anEvent=0; | 2894 | Event *anEvent=0; |
2893 | 2895 | ||
2894 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2896 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2895 | 2897 | ||
2896 | if (mViewManager->currentView()->isEventView()) { | 2898 | if (mViewManager->currentView()->isEventView()) { |
2897 | if ( incidence && incidence->typeID() == eventID ) { | 2899 | if ( incidence && incidence->typeID() == eventID ) { |
2898 | anEvent = static_cast<Event *>(incidence); | 2900 | anEvent = static_cast<Event *>(incidence); |
2899 | } | 2901 | } |
2900 | } | 2902 | } |
2901 | 2903 | ||
2902 | if (!anEvent) { | 2904 | if (!anEvent) { |
2903 | KNotifyClient::beep(); | 2905 | KNotifyClient::beep(); |
2904 | return; | 2906 | return; |
2905 | } | 2907 | } |
2906 | DndFactory factory( mCalendar ); | 2908 | DndFactory factory( mCalendar ); |
2907 | factory.copyIncidence(anEvent); | 2909 | factory.copyIncidence(anEvent); |
2908 | } | 2910 | } |
2909 | 2911 | ||
2910 | void CalendarView::edit_paste() | 2912 | void CalendarView::edit_paste() |
2911 | { | 2913 | { |
2912 | QDate date = mNavigator->selectedDates().first(); | 2914 | QDate date = mNavigator->selectedDates().first(); |
2913 | 2915 | ||
2914 | DndFactory factory( mCalendar ); | 2916 | DndFactory factory( mCalendar ); |
2915 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2917 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2916 | 2918 | ||
2917 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2919 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2918 | } | 2920 | } |
2919 | void CalendarView::edit_global_options() | 2921 | void CalendarView::edit_global_options() |
2920 | { | 2922 | { |
2921 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2923 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2922 | emit save(); | 2924 | emit save(); |
2923 | emit saveStopTimer(); | 2925 | emit saveStopTimer(); |
2924 | mDialogManager->showGlobalOptionsDialog(); | 2926 | mDialogManager->showGlobalOptionsDialog(); |
2925 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2927 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2926 | emit saveStopTimer(); | 2928 | emit saveStopTimer(); |
2927 | 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!"), | 2929 | 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!"), |
2928 | i18n("Timezone settings"),i18n("Reload"))) { | 2930 | i18n("Timezone settings"),i18n("Reload"))) { |
2929 | qDebug("KO: TZ reload cancelled "); | 2931 | qDebug("KO: TZ reload cancelled "); |
2930 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2932 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2931 | return; | 2933 | return; |
2932 | } | 2934 | } |
2933 | qDebug("KO: Timezone change "); | 2935 | qDebug("KO: Timezone change "); |
2934 | loadCalendars(); | 2936 | loadCalendars(); |
2935 | setModified(true); | 2937 | setModified(true); |
2936 | } | 2938 | } |
2937 | else | 2939 | else |
2938 | qDebug("KO: No tz change "); | 2940 | qDebug("KO: No tz change "); |
2939 | } | 2941 | } |
2940 | void CalendarView::edit_options() | 2942 | void CalendarView::edit_options() |
2941 | { | 2943 | { |
2942 | mDialogManager->showOptionsDialog(); | 2944 | mDialogManager->showOptionsDialog(); |
2943 | } | 2945 | } |
2944 | 2946 | ||
2945 | 2947 | ||
2946 | void CalendarView::slotSelectPickerDate( QDate d) | 2948 | void CalendarView::slotSelectPickerDate( QDate d) |
2947 | { | 2949 | { |
2948 | mDateFrame->hide(); | 2950 | mDateFrame->hide(); |
2949 | if ( mDatePickerMode == 1 ) { | 2951 | if ( mDatePickerMode == 1 ) { |
2950 | mNavigator->slotDaySelect( d ); | 2952 | mNavigator->slotDaySelect( d ); |
2951 | } else if ( mDatePickerMode == 2 ) { | 2953 | } else if ( mDatePickerMode == 2 ) { |
2952 | if ( mMoveIncidence->typeID() == todoID ) { | 2954 | if ( mMoveIncidence->typeID() == todoID ) { |
2953 | Todo * to = (Todo *) mMoveIncidence; | 2955 | Todo * to = (Todo *) mMoveIncidence; |
2954 | QTime tim; | 2956 | QTime tim; |
2955 | int len = 0; | 2957 | int len = 0; |
2956 | if ( to->hasStartDate() && to->hasDueDate() ) | 2958 | if ( to->hasStartDate() && to->hasDueDate() ) |
2957 | len = to->dtStart().secsTo( to->dtDue()); | 2959 | len = to->dtStart().secsTo( to->dtDue()); |
2958 | if ( to->hasDueDate() ) | 2960 | if ( to->hasDueDate() ) |
2959 | tim = to->dtDue().time(); | 2961 | tim = to->dtDue().time(); |
2960 | else { | 2962 | else { |
2961 | tim = QTime ( 0,0,0 ); | 2963 | tim = QTime ( 0,0,0 ); |
2962 | to->setFloats( true ); | 2964 | to->setFloats( true ); |
2963 | to->setHasDueDate( true ); | 2965 | to->setHasDueDate( true ); |
2964 | } | 2966 | } |
2965 | QDateTime dt ( d,tim ); | 2967 | QDateTime dt ( d,tim ); |
2966 | to->setDtDue( dt ); | 2968 | to->setDtDue( dt ); |
2967 | 2969 | ||
2968 | if ( to->hasStartDate() ) { | 2970 | if ( to->hasStartDate() ) { |
2969 | if ( len>0 ) | 2971 | if ( len>0 ) |
2970 | to->setDtStart(to->dtDue().addSecs( -len )); | 2972 | to->setDtStart(to->dtDue().addSecs( -len )); |
2971 | else | 2973 | else |
2972 | if (to->dtStart() > to->dtDue() ) | 2974 | if (to->dtStart() > to->dtDue() ) |
2973 | to->setDtStart(to->dtDue().addDays( -3 )); | 2975 | to->setDtStart(to->dtDue().addDays( -3 )); |
2974 | } | 2976 | } |
2975 | 2977 | ||
2976 | todoChanged( to ); | 2978 | todoChanged( to ); |
2977 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2979 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2978 | if ( mMoveIncidence->doesRecur() ) { | 2980 | if ( mMoveIncidence->doesRecur() ) { |
2979 | #if 0 | 2981 | #if 0 |
2980 | // PENDING implement this | 2982 | // PENDING implement this |
2981 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2983 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2982 | mCalendar()->addIncidence( newInc ); | 2984 | mCalendar()->addIncidence( newInc ); |
2983 | if ( mMoveIncidence->typeID() == todoID ) | 2985 | if ( mMoveIncidence->typeID() == todoID ) |
2984 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2986 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2985 | else | 2987 | else |
2986 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2988 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2987 | mMoveIncidence = newInc; | 2989 | mMoveIncidence = newInc; |
2988 | 2990 | ||
2989 | #endif | 2991 | #endif |
2990 | } | 2992 | } |
2991 | QTime tim = mMoveIncidence->dtStart().time(); | 2993 | QTime tim = mMoveIncidence->dtStart().time(); |
2992 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2994 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2993 | QDateTime dt ( d,tim ); | 2995 | QDateTime dt ( d,tim ); |
2994 | mMoveIncidence->setDtStart( dt ); | 2996 | mMoveIncidence->setDtStart( dt ); |
2995 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2997 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2996 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2998 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2997 | } else if ( mMoveIncidence->typeID() == journalID ) { | 2999 | } else if ( mMoveIncidence->typeID() == journalID ) { |
2998 | QTime tim = mMoveIncidence->dtStart().time(); | 3000 | QTime tim = mMoveIncidence->dtStart().time(); |
2999 | QDateTime dt ( d,tim ); | 3001 | QDateTime dt ( d,tim ); |
3000 | mMoveIncidence->setDtStart( dt ); | 3002 | mMoveIncidence->setDtStart( dt ); |
3001 | updateView(); | 3003 | updateView(); |
3002 | } | 3004 | } |
3003 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3005 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3004 | } | 3006 | } |
3005 | } | 3007 | } |
3006 | 3008 | ||
3007 | void CalendarView::removeCategories() | 3009 | void CalendarView::removeCategories() |
3008 | { | 3010 | { |
3009 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3011 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3010 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3012 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3011 | QStringList catIncList; | 3013 | QStringList catIncList; |
3012 | QStringList newCatList; | 3014 | QStringList newCatList; |
3013 | Incidence* inc = incList.first(); | 3015 | Incidence* inc = incList.first(); |
3014 | uint i; | 3016 | uint i; |
3015 | while ( inc ) { | 3017 | while ( inc ) { |
3016 | newCatList.clear(); | 3018 | newCatList.clear(); |
3017 | catIncList = inc->categories() ; | 3019 | catIncList = inc->categories() ; |
3018 | for( i = 0; i< catIncList.count(); ++i ) { | 3020 | for( i = 0; i< catIncList.count(); ++i ) { |
3019 | if ( catList.contains (catIncList[i])) | 3021 | if ( catList.contains (catIncList[i])) |
3020 | newCatList.append( catIncList[i] ); | 3022 | newCatList.append( catIncList[i] ); |
3021 | } | 3023 | } |
3022 | newCatList.sort(); | 3024 | newCatList.sort(); |
3023 | inc->setCategories( newCatList.join(",") ); | 3025 | inc->setCategories( newCatList.join(",") ); |
3024 | inc = incList.next(); | 3026 | inc = incList.next(); |
3025 | } | 3027 | } |
3026 | } | 3028 | } |
3027 | 3029 | ||
3028 | int CalendarView::addCategories() | 3030 | int CalendarView::addCategories() |
3029 | { | 3031 | { |
3030 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3032 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3031 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3033 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3032 | QStringList catIncList; | 3034 | QStringList catIncList; |
3033 | Incidence* inc = incList.first(); | 3035 | Incidence* inc = incList.first(); |
3034 | uint i; | 3036 | uint i; |
3035 | int count = 0; | 3037 | int count = 0; |
3036 | while ( inc ) { | 3038 | while ( inc ) { |
3037 | catIncList = inc->categories() ; | 3039 | catIncList = inc->categories() ; |
3038 | for( i = 0; i< catIncList.count(); ++i ) { | 3040 | for( i = 0; i< catIncList.count(); ++i ) { |
3039 | if ( !catList.contains (catIncList[i])) { | 3041 | if ( !catList.contains (catIncList[i])) { |
3040 | catList.append( catIncList[i] ); | 3042 | catList.append( catIncList[i] ); |
3041 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3043 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3042 | ++count; | 3044 | ++count; |
3043 | } | 3045 | } |
3044 | } | 3046 | } |
3045 | inc = incList.next(); | 3047 | inc = incList.next(); |
3046 | } | 3048 | } |
3047 | catList.sort(); | 3049 | catList.sort(); |
3048 | KOPrefs::instance()->mCustomCategories = catList; | 3050 | KOPrefs::instance()->mCustomCategories = catList; |
3049 | return count; | 3051 | return count; |
3050 | } | 3052 | } |
3051 | 3053 | ||
3052 | void CalendarView::editCategories() | 3054 | void CalendarView::editCategories() |
3053 | { | 3055 | { |
3054 | qDebug("CalendarView::editCategories() "); | 3056 | qDebug("CalendarView::editCategories() "); |
3055 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3057 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3056 | ced.exec(); | 3058 | ced.exec(); |
3057 | } | 3059 | } |
3058 | void CalendarView::manageCategories() | 3060 | void CalendarView::manageCategories() |
3059 | { | 3061 | { |
3060 | KOCatPrefs* cp = new KOCatPrefs(); | 3062 | KOCatPrefs* cp = new KOCatPrefs(); |
3061 | cp->show(); | 3063 | cp->show(); |
3062 | int w =cp->sizeHint().width() ; | 3064 | int w =cp->sizeHint().width() ; |
3063 | int h = cp->sizeHint().height() ; | 3065 | int h = cp->sizeHint().height() ; |
3064 | int dw = QApplication::desktop()->width(); | 3066 | int dw = QApplication::desktop()->width(); |
3065 | int dh = QApplication::desktop()->height(); | 3067 | int dh = QApplication::desktop()->height(); |
3066 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3068 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3067 | if ( !cp->exec() ) { | 3069 | if ( !cp->exec() ) { |
3068 | delete cp; | 3070 | delete cp; |
3069 | return; | 3071 | return; |
3070 | } | 3072 | } |
3071 | int count = 0; | 3073 | int count = 0; |
3072 | if ( cp->addCat() ) { | 3074 | if ( cp->addCat() ) { |
3073 | count = addCategories(); | 3075 | count = addCategories(); |
3074 | if ( count ) { | 3076 | if ( count ) { |
3075 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3077 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3076 | writeSettings(); | 3078 | writeSettings(); |
3077 | } else | 3079 | } else |
3078 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3080 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3079 | } else { | 3081 | } else { |
3080 | removeCategories(); | 3082 | removeCategories(); |
3081 | updateView(); | 3083 | updateView(); |
3082 | } | 3084 | } |
3083 | delete cp; | 3085 | delete cp; |
3084 | } | 3086 | } |
3085 | 3087 | ||
3086 | void CalendarView::beamIncidence(Incidence * Inc) | 3088 | void CalendarView::beamIncidence(Incidence * Inc) |
3087 | { | 3089 | { |
3088 | QPtrList<Incidence> delSel ; | 3090 | QPtrList<Incidence> delSel ; |
3089 | delSel.append(Inc); | 3091 | delSel.append(Inc); |
3090 | beamIncidenceList( delSel ); | 3092 | beamIncidenceList( delSel ); |
3091 | } | 3093 | } |
3092 | void CalendarView::beamCalendar() | 3094 | void CalendarView::beamCalendar() |
3093 | { | 3095 | { |
3094 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3096 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3095 | //qDebug("beamCalendar() "); | 3097 | //qDebug("beamCalendar() "); |
3096 | beamIncidenceList( delSel ); | 3098 | beamIncidenceList( delSel ); |
3097 | } | 3099 | } |
3098 | void CalendarView::beamFilteredCalendar() | 3100 | void CalendarView::beamFilteredCalendar() |
3099 | { | 3101 | { |
3100 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3102 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3101 | //qDebug("beamFilteredCalendar() "); | 3103 | //qDebug("beamFilteredCalendar() "); |
3102 | beamIncidenceList( delSel ); | 3104 | beamIncidenceList( delSel ); |
3103 | } | 3105 | } |
3104 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3106 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3105 | { | 3107 | { |
3106 | 3108 | ||
3107 | KOBeamPrefs beamDialog; | 3109 | KOBeamPrefs beamDialog; |
3108 | if ( beamDialog.exec () == QDialog::Rejected ) | 3110 | if ( beamDialog.exec () == QDialog::Rejected ) |
3109 | return; | 3111 | return; |
3110 | #ifdef DESKTOP_VERSION | 3112 | #ifdef DESKTOP_VERSION |
3111 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3113 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3112 | #else | 3114 | #else |
3113 | QString fn = "/tmp/kopibeamfile"; | 3115 | QString fn = "/tmp/kopibeamfile"; |
3114 | #endif | 3116 | #endif |
3115 | QString mes; | 3117 | QString mes; |
3116 | bool createbup = true; | 3118 | bool createbup = true; |
3117 | if ( createbup ) { | 3119 | if ( createbup ) { |
3118 | QString description = "\n"; | 3120 | QString description = "\n"; |
3119 | CalendarLocal* cal = new CalendarLocal(); | 3121 | CalendarLocal* cal = new CalendarLocal(); |
3120 | if ( beamDialog.beamLocal() ) | 3122 | if ( beamDialog.beamLocal() ) |
3121 | cal->setLocalTime(); | 3123 | cal->setLocalTime(); |
3122 | else | 3124 | else |
3123 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3125 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3124 | Incidence *incidence = delSel.first(); | 3126 | Incidence *incidence = delSel.first(); |
3125 | bool addText = false; | 3127 | bool addText = false; |
3126 | if ( delSel.count() < 10 ) | 3128 | if ( delSel.count() < 10 ) |
3127 | addText = true; | 3129 | addText = true; |
3128 | else { | 3130 | else { |
3129 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3131 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3130 | } | 3132 | } |
3131 | while ( incidence ) { | 3133 | while ( incidence ) { |
3132 | Incidence *in = incidence->clone(); | 3134 | Incidence *in = incidence->clone(); |
3133 | if ( ! in->summary().isEmpty() ) { | 3135 | if ( ! in->summary().isEmpty() ) { |
3134 | in->setDescription(""); | 3136 | in->setDescription(""); |
3135 | } else { | 3137 | } else { |
3136 | in->setSummary( in->description().left(20)); | 3138 | in->setSummary( in->description().left(20)); |
3137 | in->setDescription(""); | 3139 | in->setDescription(""); |
3138 | } | 3140 | } |
3139 | if ( addText ) | 3141 | if ( addText ) |
3140 | description += in->summary() + "\n"; | 3142 | description += in->summary() + "\n"; |
3141 | cal->addIncidence( in ); | 3143 | cal->addIncidence( in ); |
3142 | incidence = delSel.next(); | 3144 | incidence = delSel.next(); |
3143 | } | 3145 | } |
3144 | if ( beamDialog.beamVcal() ) { | 3146 | if ( beamDialog.beamVcal() ) { |
3145 | fn += ".vcs"; | 3147 | fn += ".vcs"; |
3146 | FileStorage storage( cal, fn, new VCalFormat ); | 3148 | FileStorage storage( cal, fn, new VCalFormat ); |
3147 | storage.save(); | 3149 | storage.save(); |
3148 | } else { | 3150 | } else { |
3149 | fn += ".ics"; | 3151 | fn += ".ics"; |
3150 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3152 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3151 | storage.save(); | 3153 | storage.save(); |
3152 | } | 3154 | } |
3153 | delete cal; | 3155 | delete cal; |
3154 | mes = i18n("KO/Pi: Ready for beaming"); | 3156 | mes = i18n("KO/Pi: Ready for beaming"); |
3155 | topLevelWidget()->setCaption(mes); | 3157 | topLevelWidget()->setCaption(mes); |
3156 | KApplication::convert2latin1( fn ); | 3158 | KApplication::convert2latin1( fn ); |
3157 | #ifndef DESKTOP_VERSION | 3159 | #ifndef DESKTOP_VERSION |
3158 | Ir *ir = new Ir( this ); | 3160 | Ir *ir = new Ir( this ); |
3159 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3161 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3160 | ir->send( fn, description, "text/x-vCalendar" ); | 3162 | ir->send( fn, description, "text/x-vCalendar" ); |
3161 | #endif | 3163 | #endif |
3162 | } | 3164 | } |
3163 | } | 3165 | } |
3164 | 3166 | ||
3165 | #ifndef DESKTOP_VERSION | 3167 | #ifndef DESKTOP_VERSION |
3166 | void CalendarView::beamDone( Ir *ir ) | 3168 | void CalendarView::beamDone( Ir *ir ) |
3167 | { | 3169 | { |
3168 | delete ir; | 3170 | delete ir; |
3169 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3171 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3170 | topLevelWidget()->raise(); | 3172 | topLevelWidget()->raise(); |
3171 | } | 3173 | } |
3172 | #else | 3174 | #else |
3173 | void CalendarView::beamDone( Ir *){;} | 3175 | void CalendarView::beamDone( Ir *){;} |
3174 | #endif | 3176 | #endif |
3175 | void CalendarView::moveIncidence(Incidence * inc ) | 3177 | void CalendarView::moveIncidence(Incidence * inc ) |
3176 | { | 3178 | { |
3177 | if ( !inc ) return; | 3179 | if ( !inc ) return; |
3178 | showDatePickerPopup(); | 3180 | showDatePickerPopup(); |
3179 | mDatePickerMode = 2; | 3181 | mDatePickerMode = 2; |
3180 | mMoveIncidence = inc ; | 3182 | mMoveIncidence = inc ; |
3181 | QDate da; | 3183 | QDate da; |
3182 | if ( mMoveIncidence->typeID() == todoID ) { | 3184 | if ( mMoveIncidence->typeID() == todoID ) { |
3183 | Todo * to = (Todo *) mMoveIncidence; | 3185 | Todo * to = (Todo *) mMoveIncidence; |
3184 | if ( to->hasDueDate() ) | 3186 | if ( to->hasDueDate() ) |
3185 | da = to->dtDue().date(); | 3187 | da = to->dtDue().date(); |
3186 | else | 3188 | else |
3187 | da = QDate::currentDate(); | 3189 | da = QDate::currentDate(); |
3188 | } else { | 3190 | } else { |
3189 | da = mMoveIncidence->dtStart().date(); | 3191 | da = mMoveIncidence->dtStart().date(); |
3190 | } | 3192 | } |
3191 | //PENDING set date for recurring incidence to date of recurrence | 3193 | //PENDING set date for recurring incidence to date of recurrence |
3192 | //mMoveIncidenceOldDate; | 3194 | //mMoveIncidenceOldDate; |
3193 | mDatePicker->setDate( da ); | 3195 | mDatePicker->setDate( da ); |
3194 | } | 3196 | } |
3195 | void CalendarView::showDatePickerPopup() | 3197 | void CalendarView::showDatePickerPopup() |
3196 | { | 3198 | { |
3197 | if ( mDateFrame->isVisible() ) | 3199 | if ( mDateFrame->isVisible() ) |
3198 | mDateFrame->hide(); | 3200 | mDateFrame->hide(); |
3199 | else { | 3201 | else { |
3200 | int offX = 0, offY = 0; | 3202 | int offX = 0, offY = 0; |
3201 | #ifdef DESKTOP_VERSION | 3203 | #ifdef DESKTOP_VERSION |
3202 | int w =mDatePicker->sizeHint().width() ; | 3204 | int w =mDatePicker->sizeHint().width() ; |
3203 | int h = mDatePicker->sizeHint().height() ; | 3205 | int h = mDatePicker->sizeHint().height() ; |
3204 | int dw = topLevelWidget()->width(); | 3206 | int dw = topLevelWidget()->width(); |
3205 | int dh = topLevelWidget()->height(); | 3207 | int dh = topLevelWidget()->height(); |
3206 | offX = topLevelWidget()->x(); | 3208 | offX = topLevelWidget()->x(); |
3207 | offY = topLevelWidget()->y(); | 3209 | offY = topLevelWidget()->y(); |
3208 | #else | 3210 | #else |
3209 | int w =mDatePicker->sizeHint().width() ; | 3211 | int w =mDatePicker->sizeHint().width() ; |
3210 | int h = mDatePicker->sizeHint().height() ; | 3212 | int h = mDatePicker->sizeHint().height() ; |
3211 | int dw = QApplication::desktop()->width(); | 3213 | int dw = QApplication::desktop()->width(); |
3212 | int dh = QApplication::desktop()->height(); | 3214 | int dh = QApplication::desktop()->height(); |
3213 | #endif | 3215 | #endif |
3214 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3216 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3215 | mDateFrame->show(); | 3217 | mDateFrame->show(); |
3216 | } | 3218 | } |
3217 | } | 3219 | } |
3218 | void CalendarView::showDatePicker( ) | 3220 | void CalendarView::showDatePicker( ) |
3219 | { | 3221 | { |
3220 | showDatePickerPopup(); | 3222 | showDatePickerPopup(); |
3221 | mDatePickerMode = 1; | 3223 | mDatePickerMode = 1; |
3222 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3224 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3223 | } | 3225 | } |
3224 | 3226 | ||
3225 | void CalendarView::showEventEditor() | 3227 | void CalendarView::showEventEditor() |
3226 | { | 3228 | { |
3227 | #ifdef DESKTOP_VERSION | 3229 | #ifdef DESKTOP_VERSION |
3228 | int x,y,w,h; | 3230 | int x,y,w,h; |
3229 | x = mEventEditor->geometry().x(); | 3231 | x = mEventEditor->geometry().x(); |
3230 | y = mEventEditor->geometry().y(); | 3232 | y = mEventEditor->geometry().y(); |
3231 | w = mEventEditor->width(); | 3233 | w = mEventEditor->width(); |
3232 | h = mEventEditor->height(); | 3234 | h = mEventEditor->height(); |
3233 | mEventEditor->show(); | 3235 | mEventEditor->show(); |
3234 | mEventEditor->setGeometry(x,y,w,h); | 3236 | mEventEditor->setGeometry(x,y,w,h); |
3235 | #else | 3237 | #else |
3236 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3238 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3237 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3239 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3238 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3240 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3239 | qApp->processEvents(); | 3241 | qApp->processEvents(); |
3240 | delete mEventEditor; | 3242 | delete mEventEditor; |
3241 | mEventEditor = mDialogManager->getEventEditor(); | 3243 | mEventEditor = mDialogManager->getEventEditor(); |
3242 | topLevelWidget()->setCaption( i18n("") ); | 3244 | topLevelWidget()->setCaption( i18n("") ); |
3243 | } | 3245 | } |
3244 | mEventEditor->showMaximized(); | 3246 | mEventEditor->showMaximized(); |
3245 | #endif | 3247 | #endif |
3246 | } | 3248 | } |
3247 | void CalendarView::showTodoEditor() | 3249 | void CalendarView::showTodoEditor() |
3248 | { | 3250 | { |
3249 | #ifdef DESKTOP_VERSION | 3251 | #ifdef DESKTOP_VERSION |
3250 | int x,y,w,h; | 3252 | int x,y,w,h; |
3251 | x = mTodoEditor->geometry().x(); | 3253 | x = mTodoEditor->geometry().x(); |
3252 | y = mTodoEditor->geometry().y(); | 3254 | y = mTodoEditor->geometry().y(); |
3253 | w = mTodoEditor->width(); | 3255 | w = mTodoEditor->width(); |
3254 | h = mTodoEditor->height(); | 3256 | h = mTodoEditor->height(); |
3255 | mTodoEditor->show(); | 3257 | mTodoEditor->show(); |
3256 | mTodoEditor->setGeometry(x,y,w,h); | 3258 | mTodoEditor->setGeometry(x,y,w,h); |
3257 | #else | 3259 | #else |
3258 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3260 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3259 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3261 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3260 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3262 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3261 | qApp->processEvents(); | 3263 | qApp->processEvents(); |
3262 | delete mTodoEditor; | 3264 | delete mTodoEditor; |
3263 | mTodoEditor = mDialogManager->getTodoEditor(); | 3265 | mTodoEditor = mDialogManager->getTodoEditor(); |
3264 | topLevelWidget()->setCaption( i18n("") ); | 3266 | topLevelWidget()->setCaption( i18n("") ); |
3265 | } | 3267 | } |
3266 | mTodoEditor->showMaximized(); | 3268 | mTodoEditor->showMaximized(); |
3267 | #endif | 3269 | #endif |
3268 | } | 3270 | } |
3269 | 3271 | ||
3270 | void CalendarView::cloneIncidence() | 3272 | void CalendarView::cloneIncidence() |
3271 | { | 3273 | { |
3272 | Incidence *incidence = currentSelection(); | 3274 | Incidence *incidence = currentSelection(); |
3273 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3275 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3274 | if ( incidence ) { | 3276 | if ( incidence ) { |
3275 | cloneIncidence(incidence); | 3277 | cloneIncidence(incidence); |
3276 | } | 3278 | } |
3277 | } | 3279 | } |
3278 | void CalendarView::moveIncidence() | 3280 | void CalendarView::moveIncidence() |
3279 | { | 3281 | { |
3280 | Incidence *incidence = currentSelection(); | 3282 | Incidence *incidence = currentSelection(); |
3281 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3283 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3282 | if ( incidence ) { | 3284 | if ( incidence ) { |
3283 | moveIncidence(incidence); | 3285 | moveIncidence(incidence); |
3284 | } | 3286 | } |
3285 | } | 3287 | } |
3286 | void CalendarView::beamIncidence() | 3288 | void CalendarView::beamIncidence() |
3287 | { | 3289 | { |
3288 | Incidence *incidence = currentSelection(); | 3290 | Incidence *incidence = currentSelection(); |
3289 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3291 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3290 | if ( incidence ) { | 3292 | if ( incidence ) { |
3291 | beamIncidence(incidence); | 3293 | beamIncidence(incidence); |
3292 | } | 3294 | } |
3293 | } | 3295 | } |
3294 | void CalendarView::toggleCancelIncidence() | 3296 | void CalendarView::toggleCancelIncidence() |
3295 | { | 3297 | { |
3296 | Incidence *incidence = currentSelection(); | 3298 | Incidence *incidence = currentSelection(); |
3297 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3299 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3298 | if ( incidence ) { | 3300 | if ( incidence ) { |
3299 | cancelIncidence(incidence); | 3301 | cancelIncidence(incidence); |
3300 | } | 3302 | } |
3301 | } | 3303 | } |
3302 | 3304 | ||
3303 | 3305 | ||
3304 | void CalendarView::cancelIncidence(Incidence * inc ) | 3306 | void CalendarView::cancelIncidence(Incidence * inc ) |
3305 | { | 3307 | { |
3306 | inc->setCancelled( ! inc->cancelled() ); | 3308 | inc->setCancelled( ! inc->cancelled() ); |
3307 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3309 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3308 | updateView(); | 3310 | updateView(); |
3309 | } | 3311 | } |
3310 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3312 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3311 | { | 3313 | { |
3312 | Incidence * newInc = orgInc->clone(); | 3314 | Incidence * newInc = orgInc->clone(); |
3313 | newInc->recreate(); | 3315 | newInc->recreate(); |
3314 | 3316 | ||
3315 | if ( newInc->typeID() == todoID ) { | 3317 | if ( newInc->typeID() == todoID ) { |
3316 | Todo* t = (Todo*) newInc; | 3318 | Todo* t = (Todo*) newInc; |
3317 | bool cloneSub = false; | 3319 | bool cloneSub = false; |
3318 | if ( orgInc->relations().count() ) { | 3320 | if ( orgInc->relations().count() ) { |
3319 | int result = KMessageBox::warningYesNoCancel(this, | 3321 | int result = KMessageBox::warningYesNoCancel(this, |
3320 | 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 ) ), | 3322 | 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 ) ), |
3321 | i18n("Todo has subtodos"), | 3323 | i18n("Todo has subtodos"), |
3322 | i18n("Yes"), | 3324 | i18n("Yes"), |
3323 | i18n("No")); | 3325 | i18n("No")); |
3324 | 3326 | ||
3325 | if ( result == KMessageBox::Cancel ) { | 3327 | if ( result == KMessageBox::Cancel ) { |
3326 | delete t; | 3328 | delete t; |
3327 | return; | 3329 | return; |
3328 | } | 3330 | } |
3329 | if (result == KMessageBox::Yes) cloneSub = true; | 3331 | if (result == KMessageBox::Yes) cloneSub = true; |
3330 | } | 3332 | } |
3331 | showTodoEditor(); | 3333 | showTodoEditor(); |
3332 | mTodoEditor->editTodo( t ); | 3334 | mTodoEditor->editTodo( t ); |
3333 | if ( mTodoEditor->exec() ) { | 3335 | if ( mTodoEditor->exec() ) { |
3334 | if ( cloneSub ) { | 3336 | if ( cloneSub ) { |
3335 | orgInc->cloneRelations( t ); | 3337 | orgInc->cloneRelations( t ); |
3336 | mCalendar->addIncidenceBranch( t ); | 3338 | mCalendar->addIncidenceBranch( t ); |
3337 | updateView(); | 3339 | updateView(); |
3338 | 3340 | ||
3339 | } else { | 3341 | } else { |
3340 | mCalendar->addTodo( t ); | 3342 | mCalendar->addTodo( t ); |
3341 | updateView(); | 3343 | updateView(); |
3342 | } | 3344 | } |
3343 | } else { | 3345 | } else { |
3344 | delete t; | 3346 | delete t; |
3345 | } | 3347 | } |
3346 | } | 3348 | } |
3347 | else if ( newInc->typeID() == eventID ) { | 3349 | else if ( newInc->typeID() == eventID ) { |
3348 | Event* e = (Event*) newInc; | 3350 | Event* e = (Event*) newInc; |
3349 | showEventEditor(); | 3351 | showEventEditor(); |
3350 | mEventEditor->editEvent( e ); | 3352 | mEventEditor->editEvent( e ); |
3351 | if ( mEventEditor->exec() ) { | 3353 | if ( mEventEditor->exec() ) { |
3352 | mCalendar->addEvent( e ); | 3354 | mCalendar->addEvent( e ); |
3353 | updateView(); | 3355 | updateView(); |
3354 | } else { | 3356 | } else { |
3355 | delete e; | 3357 | delete e; |
3356 | } | 3358 | } |
3357 | } if ( newInc->typeID() == journalID ) { | 3359 | } if ( newInc->typeID() == journalID ) { |
3358 | mCalendar->addJournal( (Journal*) newInc ); | 3360 | mCalendar->addJournal( (Journal*) newInc ); |
3359 | editJournal( (Journal*) newInc ); | 3361 | editJournal( (Journal*) newInc ); |
3360 | } | 3362 | } |
3361 | setActiveWindow(); | 3363 | setActiveWindow(); |
3362 | } | 3364 | } |
3363 | 3365 | ||
3364 | void CalendarView::newEvent() | 3366 | void CalendarView::newEvent() |
3365 | { | 3367 | { |
3366 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3368 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3367 | KOAgendaView *aView = mViewManager->agendaView(); | 3369 | KOAgendaView *aView = mViewManager->agendaView(); |
3368 | if (aView) { | 3370 | if (aView) { |
3369 | if (aView->selectionStart().isValid()) { | 3371 | if (aView->selectionStart().isValid()) { |
3370 | if (aView->selectedIsAllDay()) { | 3372 | if (aView->selectedIsAllDay()) { |
3371 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3373 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3372 | } else { | 3374 | } else { |
3373 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3375 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3374 | } | 3376 | } |
3375 | return; | 3377 | return; |
3376 | } | 3378 | } |
3377 | } | 3379 | } |
3378 | 3380 | ||
3379 | QDate date = mNavigator->selectedDates().first(); | 3381 | QDate date = mNavigator->selectedDates().first(); |
3380 | #if 0 | 3382 | #if 0 |
3381 | QDateTime current = QDateTime::currentDateTime(); | 3383 | QDateTime current = QDateTime::currentDateTime(); |
3382 | if ( date <= current.date() ) { | 3384 | if ( date <= current.date() ) { |
3383 | int hour = current.time().hour() +1; | 3385 | int hour = current.time().hour() +1; |
3384 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3386 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3385 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3387 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3386 | } else | 3388 | } else |
3387 | #endif | 3389 | #endif |
3388 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3390 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3389 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3391 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3390 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3392 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3391 | } | 3393 | } |
3392 | 3394 | ||
3393 | void CalendarView::newEvent(QDateTime fh) | 3395 | void CalendarView::newEvent(QDateTime fh) |
3394 | { | 3396 | { |
3395 | newEvent(fh, | 3397 | newEvent(fh, |
3396 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3398 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3397 | } | 3399 | } |
3398 | 3400 | ||
3399 | void CalendarView::newEvent(QDate dt) | 3401 | void CalendarView::newEvent(QDate dt) |
3400 | { | 3402 | { |
3401 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3403 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3402 | QDateTime(dt, QTime(0,0,0)), true); | 3404 | QDateTime(dt, QTime(0,0,0)), true); |
3403 | } | 3405 | } |
3404 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3406 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3405 | { | 3407 | { |
3406 | newEvent(fromHint, toHint, false); | 3408 | newEvent(fromHint, toHint, false); |
3407 | } | 3409 | } |
3408 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3410 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3409 | { | 3411 | { |
3410 | 3412 | ||
3411 | showEventEditor(); | 3413 | showEventEditor(); |
3412 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3414 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3413 | if ( mFilterView->filtersEnabled() ) { | 3415 | if ( mFilterView->filtersEnabled() ) { |
3414 | CalFilter *filter = mFilterView->selectedFilter(); | 3416 | CalFilter *filter = mFilterView->selectedFilter(); |
3415 | if (filter && filter->showCategories()) { | 3417 | if (filter && filter->showCategories()) { |
3416 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3418 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3417 | } | 3419 | } |
3418 | if ( filter ) | 3420 | if ( filter ) |
3419 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3421 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3420 | } | 3422 | } |
3421 | mEventEditor->exec(); | 3423 | mEventEditor->exec(); |
3422 | setActiveWindow(); | 3424 | setActiveWindow(); |
3423 | } | 3425 | } |
3424 | void CalendarView::todoAdded(Todo * t) | 3426 | void CalendarView::todoAdded(Todo * t) |
3425 | { | 3427 | { |
3426 | 3428 | ||
3427 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3429 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3428 | updateTodoViews(); | 3430 | updateTodoViews(); |
3429 | } | 3431 | } |
3430 | void CalendarView::todoChanged(Todo * t) | 3432 | void CalendarView::todoChanged(Todo * t) |
3431 | { | 3433 | { |
3432 | emit todoModified( t, 4 ); | 3434 | emit todoModified( t, 4 ); |
3433 | // updateTodoViews(); | 3435 | // updateTodoViews(); |
3434 | } | 3436 | } |
3435 | void CalendarView::todoToBeDeleted(Todo *) | 3437 | void CalendarView::todoToBeDeleted(Todo *) |
3436 | { | 3438 | { |
3437 | //qDebug("todoToBeDeleted(Todo *) "); | 3439 | //qDebug("todoToBeDeleted(Todo *) "); |
3438 | updateTodoViews(); | 3440 | updateTodoViews(); |
3439 | } | 3441 | } |
3440 | void CalendarView::todoDeleted() | 3442 | void CalendarView::todoDeleted() |
3441 | { | 3443 | { |
3442 | //qDebug(" todoDeleted()"); | 3444 | //qDebug(" todoDeleted()"); |
3443 | updateTodoViews(); | 3445 | updateTodoViews(); |
3444 | } | 3446 | } |
3445 | 3447 | ||
3446 | 3448 | ||
3447 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3449 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3448 | { | 3450 | { |
3449 | showTodoEditor(); | 3451 | showTodoEditor(); |
3450 | mTodoEditor->newTodo(dt,0,allday); | 3452 | mTodoEditor->newTodo(dt,0,allday); |
3451 | if ( mFilterView->filtersEnabled() ) { | 3453 | if ( mFilterView->filtersEnabled() ) { |
3452 | CalFilter *filter = mFilterView->selectedFilter(); | 3454 | CalFilter *filter = mFilterView->selectedFilter(); |
3453 | if (filter && filter->showCategories()) { | 3455 | if (filter && filter->showCategories()) { |
3454 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3456 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3455 | } | 3457 | } |
3456 | if ( filter ) | 3458 | if ( filter ) |
3457 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3459 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3458 | } | 3460 | } |
3459 | mTodoEditor->exec(); | 3461 | mTodoEditor->exec(); |
3460 | setActiveWindow(); | 3462 | setActiveWindow(); |
3461 | } | 3463 | } |
3462 | 3464 | ||
3463 | void CalendarView::newTodo() | 3465 | void CalendarView::newTodo() |
3464 | { | 3466 | { |
3465 | newTodoDateTime( QDateTime(),true ); | 3467 | newTodoDateTime( QDateTime(),true ); |
3466 | } | 3468 | } |
3467 | 3469 | ||
3468 | void CalendarView::newSubTodo() | 3470 | void CalendarView::newSubTodo() |
3469 | { | 3471 | { |
3470 | Todo *todo = selectedTodo(); | 3472 | Todo *todo = selectedTodo(); |
3471 | if ( todo ) newSubTodo( todo ); | 3473 | if ( todo ) newSubTodo( todo ); |
3472 | } | 3474 | } |
3473 | 3475 | ||
3474 | void CalendarView::newSubTodo(Todo *parentEvent) | 3476 | void CalendarView::newSubTodo(Todo *parentEvent) |
3475 | { | 3477 | { |
3476 | 3478 | ||
3477 | showTodoEditor(); | 3479 | showTodoEditor(); |
3478 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3480 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3479 | mTodoEditor->exec(); | 3481 | mTodoEditor->exec(); |
3480 | setActiveWindow(); | 3482 | setActiveWindow(); |
3481 | } | 3483 | } |
3482 | 3484 | ||
3483 | void CalendarView::newFloatingEvent() | 3485 | void CalendarView::newFloatingEvent() |
3484 | { | 3486 | { |
3485 | DateList tmpList = mNavigator->selectedDates(); | 3487 | DateList tmpList = mNavigator->selectedDates(); |
3486 | QDate date = tmpList.first(); | 3488 | QDate date = tmpList.first(); |
3487 | 3489 | ||
3488 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3490 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3489 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3491 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3490 | } | 3492 | } |
3491 | 3493 | ||
3492 | 3494 | ||
3493 | void CalendarView::editEvent( Event *event ) | 3495 | void CalendarView::editEvent( Event *event ) |
3494 | { | 3496 | { |
3495 | 3497 | ||
3496 | if ( !event ) return; | 3498 | if ( !event ) return; |
3497 | if ( event->isReadOnly() ) { | 3499 | if ( event->isReadOnly() ) { |
3498 | showEvent( event ); | 3500 | showEvent( event ); |
3499 | return; | 3501 | return; |
3500 | } | 3502 | } |
3501 | showEventEditor(); | 3503 | showEventEditor(); |
3502 | mEventEditor->editEvent( event , mFlagEditDescription); | 3504 | mEventEditor->editEvent( event , mFlagEditDescription); |
3503 | mEventEditor->exec(); | 3505 | mEventEditor->exec(); |
3504 | setActiveWindow(); | 3506 | setActiveWindow(); |
3505 | 3507 | ||
3506 | } | 3508 | } |
3507 | void CalendarView::editJournal( Journal *jour ) | 3509 | void CalendarView::editJournal( Journal *jour ) |
3508 | { | 3510 | { |
3509 | if ( !jour ) return; | 3511 | if ( !jour ) return; |
3510 | mDialogManager->hideSearchDialog(); | 3512 | mDialogManager->hideSearchDialog(); |
3511 | mViewManager->showJournalView(); | 3513 | mViewManager->showJournalView(); |
3512 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3514 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3513 | } | 3515 | } |
3514 | void CalendarView::editTodo( Todo *todo ) | 3516 | void CalendarView::editTodo( Todo *todo ) |
3515 | { | 3517 | { |
3516 | if ( !todo ) return; | 3518 | if ( !todo ) return; |
3517 | 3519 | ||
3518 | if ( todo->isReadOnly() ) { | 3520 | if ( todo->isReadOnly() ) { |
3519 | showTodo( todo ); | 3521 | showTodo( todo ); |
3520 | return; | 3522 | return; |
3521 | } | 3523 | } |
3522 | showTodoEditor(); | 3524 | showTodoEditor(); |
3523 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3525 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3524 | mTodoEditor->exec(); | 3526 | mTodoEditor->exec(); |
3525 | setActiveWindow(); | 3527 | setActiveWindow(); |
3526 | 3528 | ||
3527 | } | 3529 | } |
3528 | 3530 | ||
3529 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3531 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3530 | { | 3532 | { |
3531 | if ( !mEventViewerDialog ) { | 3533 | if ( !mEventViewerDialog ) { |
3532 | mEventViewerDialog = new KOEventViewerDialog(0); | 3534 | mEventViewerDialog = new KOEventViewerDialog(0); |
3533 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3535 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3534 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3536 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3535 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3537 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3536 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3538 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3537 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3539 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3538 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3540 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3539 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3541 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3540 | this, SLOT( slotViewerClosed() ) ); | 3542 | this, SLOT( slotViewerClosed() ) ); |
3541 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3543 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3542 | this, SLOT( todoChanged(Todo *) ) ); | 3544 | this, SLOT( todoChanged(Todo *) ) ); |
3543 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3545 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3544 | mEventViewerDialog->resize( 640, 480 ); | 3546 | mEventViewerDialog->resize( 640, 480 ); |
3545 | 3547 | ||
3546 | } | 3548 | } |
3547 | return mEventViewerDialog; | 3549 | return mEventViewerDialog; |
3548 | } | 3550 | } |
3549 | void CalendarView::showEvent(Event *event) | 3551 | void CalendarView::showEvent(Event *event) |
3550 | { | 3552 | { |
3551 | getEventViewerDialog()->setEvent(event); | 3553 | getEventViewerDialog()->setEvent(event); |
3552 | getEventViewerDialog()->showMe(); | 3554 | getEventViewerDialog()->showMe(); |
3553 | } | 3555 | } |
3554 | 3556 | ||
3555 | void CalendarView::showTodo(Todo *event) | 3557 | void CalendarView::showTodo(Todo *event) |
3556 | { | 3558 | { |
3557 | getEventViewerDialog()->setTodo(event); | 3559 | getEventViewerDialog()->setTodo(event); |
3558 | getEventViewerDialog()->showMe(); | 3560 | getEventViewerDialog()->showMe(); |
3559 | } | 3561 | } |
3560 | void CalendarView::showJournal( Journal *jour ) | 3562 | void CalendarView::showJournal( Journal *jour ) |
3561 | { | 3563 | { |
3562 | getEventViewerDialog()->setJournal(jour); | 3564 | getEventViewerDialog()->setJournal(jour); |
3563 | getEventViewerDialog()->showMe(); | 3565 | getEventViewerDialog()->showMe(); |
3564 | 3566 | ||
3565 | } | 3567 | } |
3566 | // void CalendarView::todoModified (Todo *event, int changed) | 3568 | // void CalendarView::todoModified (Todo *event, int changed) |
3567 | // { | 3569 | // { |
3568 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3570 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3569 | // // kdDebug() << "Todo modified and open" << endl; | 3571 | // // kdDebug() << "Todo modified and open" << endl; |
3570 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3572 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3571 | // // temp->modified (changed); | 3573 | // // temp->modified (changed); |
3572 | 3574 | ||
3573 | // // } | 3575 | // // } |
3574 | 3576 | ||
3575 | // mViewManager->updateView(); | 3577 | // mViewManager->updateView(); |
3576 | // } | 3578 | // } |
3577 | 3579 | ||
3578 | void CalendarView::appointment_show() | 3580 | void CalendarView::appointment_show() |
3579 | { | 3581 | { |
3580 | Event *anEvent = 0; | 3582 | Event *anEvent = 0; |
3581 | 3583 | ||
3582 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3584 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3583 | 3585 | ||
3584 | if (mViewManager->currentView()->isEventView()) { | 3586 | if (mViewManager->currentView()->isEventView()) { |
3585 | if ( incidence && incidence->typeID() == eventID ) { | 3587 | if ( incidence && incidence->typeID() == eventID ) { |
3586 | anEvent = static_cast<Event *>(incidence); | 3588 | anEvent = static_cast<Event *>(incidence); |
3587 | } | 3589 | } |
3588 | } | 3590 | } |
3589 | 3591 | ||
3590 | if (!anEvent) { | 3592 | if (!anEvent) { |
3591 | KNotifyClient::beep(); | 3593 | KNotifyClient::beep(); |
3592 | return; | 3594 | return; |
3593 | } | 3595 | } |
3594 | 3596 | ||
3595 | showEvent(anEvent); | 3597 | showEvent(anEvent); |
3596 | } | 3598 | } |
3597 | 3599 | ||
3598 | void CalendarView::appointment_edit() | 3600 | void CalendarView::appointment_edit() |
3599 | { | 3601 | { |
3600 | Event *anEvent = 0; | 3602 | Event *anEvent = 0; |
3601 | 3603 | ||
3602 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3604 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3603 | 3605 | ||
3604 | if (mViewManager->currentView()->isEventView()) { | 3606 | if (mViewManager->currentView()->isEventView()) { |
3605 | if ( incidence && incidence->typeID() == eventID ) { | 3607 | if ( incidence && incidence->typeID() == eventID ) { |
3606 | anEvent = static_cast<Event *>(incidence); | 3608 | anEvent = static_cast<Event *>(incidence); |
3607 | } | 3609 | } |
3608 | } | 3610 | } |
3609 | 3611 | ||
3610 | if (!anEvent) { | 3612 | if (!anEvent) { |
3611 | KNotifyClient::beep(); | 3613 | KNotifyClient::beep(); |
3612 | return; | 3614 | return; |
3613 | } | 3615 | } |
3614 | 3616 | ||
3615 | editEvent(anEvent); | 3617 | editEvent(anEvent); |
3616 | } | 3618 | } |
3617 | 3619 | ||
3618 | void CalendarView::appointment_delete() | 3620 | void CalendarView::appointment_delete() |
3619 | { | 3621 | { |
3620 | Event *anEvent = 0; | 3622 | Event *anEvent = 0; |
3621 | 3623 | ||
3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3624 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3623 | 3625 | ||
3624 | if (mViewManager->currentView()->isEventView()) { | 3626 | if (mViewManager->currentView()->isEventView()) { |
3625 | if ( incidence && incidence->typeID() == eventID ) { | 3627 | if ( incidence && incidence->typeID() == eventID ) { |
3626 | anEvent = static_cast<Event *>(incidence); | 3628 | anEvent = static_cast<Event *>(incidence); |
3627 | } | 3629 | } |
3628 | } | 3630 | } |
3629 | 3631 | ||
3630 | if (!anEvent) { | 3632 | if (!anEvent) { |
3631 | KNotifyClient::beep(); | 3633 | KNotifyClient::beep(); |
3632 | return; | 3634 | return; |
3633 | } | 3635 | } |
3634 | 3636 | ||
3635 | deleteEvent(anEvent); | 3637 | deleteEvent(anEvent); |
3636 | } | 3638 | } |
3637 | 3639 | ||
3638 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3640 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3639 | { | 3641 | { |
3640 | if (!sub) return; | 3642 | if (!sub) return; |
3641 | if ( sub->relatedTo() == parent ) | 3643 | if ( sub->relatedTo() == parent ) |
3642 | return; | 3644 | return; |
3643 | sub->setRelatedTo(parent); | 3645 | sub->setRelatedTo(parent); |
3644 | sub->updated(); | 3646 | sub->updated(); |
3645 | setModified(true); | 3647 | setModified(true); |
3646 | updateView(); | 3648 | updateView(); |
3647 | } | 3649 | } |
3648 | void CalendarView::todo_unsub(Todo *anTodo ) | 3650 | void CalendarView::todo_unsub(Todo *anTodo ) |
3649 | { | 3651 | { |
3650 | todo_resub( 0, anTodo ); | 3652 | todo_resub( 0, anTodo ); |
3651 | } | 3653 | } |
3652 | 3654 | ||
3653 | void CalendarView::deleteTodo(Todo *todo) | 3655 | void CalendarView::deleteTodo(Todo *todo) |
3654 | { | 3656 | { |
3655 | if (!todo) { | 3657 | if (!todo) { |
3656 | KNotifyClient::beep(); | 3658 | KNotifyClient::beep(); |
3657 | return; | 3659 | return; |
3658 | } | 3660 | } |
3659 | if (KOPrefs::instance()->mConfirm) { | 3661 | if (KOPrefs::instance()->mConfirm) { |
3660 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3662 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3661 | if (!todo->relations().isEmpty()) { | 3663 | if (!todo->relations().isEmpty()) { |
3662 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3664 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3663 | 3665 | ||
3664 | } | 3666 | } |
3665 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3667 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3666 | case KMessageBox::Continue: // OK | 3668 | case KMessageBox::Continue: // OK |
3667 | bool deleteT = false; | 3669 | bool deleteT = false; |
3668 | if (!todo->relations().isEmpty()) { | 3670 | if (!todo->relations().isEmpty()) { |
3669 | deleteT = removeCompletedSubTodos( todo ); | 3671 | deleteT = removeCompletedSubTodos( todo ); |
3670 | } | 3672 | } |
3671 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3673 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3672 | if ( !deleteT ) { | 3674 | if ( !deleteT ) { |
3673 | checkExternalId( todo ); | 3675 | checkExternalId( todo ); |
3674 | calendar()->deleteTodo(todo); | 3676 | calendar()->deleteTodo(todo); |
3675 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3677 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3676 | updateView(); | 3678 | updateView(); |
3677 | } | 3679 | } |
3678 | break; | 3680 | break; |
3679 | } // switch | 3681 | } // switch |
3680 | } else { | 3682 | } else { |
3681 | checkExternalId( todo ); | 3683 | checkExternalId( todo ); |
3682 | mCalendar->deleteTodo(todo); | 3684 | mCalendar->deleteTodo(todo); |
3683 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3685 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3684 | updateView(); | 3686 | updateView(); |
3685 | } | 3687 | } |
3686 | 3688 | ||
3687 | emit updateSearchDialog(); | 3689 | emit updateSearchDialog(); |
3688 | } | 3690 | } |
3689 | void CalendarView::deleteJournal(Journal *jour) | 3691 | void CalendarView::deleteJournal(Journal *jour) |
3690 | { | 3692 | { |
3691 | if (!jour) { | 3693 | if (!jour) { |
3692 | KNotifyClient::beep(); | 3694 | KNotifyClient::beep(); |
3693 | return; | 3695 | return; |
3694 | } | 3696 | } |
3695 | if (KOPrefs::instance()->mConfirm) { | 3697 | if (KOPrefs::instance()->mConfirm) { |
3696 | 3698 | ||
3697 | QString des; | 3699 | QString des; |
3698 | if ( !jour->summary().isEmpty() ) { | 3700 | if ( !jour->summary().isEmpty() ) { |
3699 | des = jour->summary(); | 3701 | des = jour->summary(); |
3700 | } else { | 3702 | } else { |
3701 | des = jour->description().left(30); | 3703 | des = jour->description().left(30); |
3702 | des = des.simplifyWhiteSpace (); | 3704 | des = des.simplifyWhiteSpace (); |
3703 | des.replace (QRegExp ("\\n"),"" ); | 3705 | des.replace (QRegExp ("\\n"),"" ); |
3704 | des.replace (QRegExp ("\\r"),"" ); | 3706 | des.replace (QRegExp ("\\r"),"" ); |
3705 | } | 3707 | } |
3706 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3708 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3707 | case KMessageBox::Continue: // OK | 3709 | case KMessageBox::Continue: // OK |
3708 | calendar()->deleteJournal(jour); | 3710 | calendar()->deleteJournal(jour); |
3709 | updateView(); | 3711 | updateView(); |
3710 | break; | 3712 | break; |
3711 | } // switch | 3713 | } // switch |
3712 | } else { | 3714 | } else { |
3713 | calendar()->deleteJournal(jour);; | 3715 | calendar()->deleteJournal(jour);; |
3714 | updateView(); | 3716 | updateView(); |
3715 | } | 3717 | } |
3716 | emit updateSearchDialog(); | 3718 | emit updateSearchDialog(); |
3717 | } | 3719 | } |
3718 | 3720 | ||
3719 | void CalendarView::deleteEvent(Event *anEvent) | 3721 | void CalendarView::deleteEvent(Event *anEvent) |
3720 | { | 3722 | { |
3721 | if (!anEvent) { | 3723 | if (!anEvent) { |
3722 | KNotifyClient::beep(); | 3724 | KNotifyClient::beep(); |
3723 | return; | 3725 | return; |
3724 | } | 3726 | } |
3725 | 3727 | ||
3726 | if (anEvent->recurrence()->doesRecur()) { | 3728 | if (anEvent->recurrence()->doesRecur()) { |
3727 | QDate itemDate = mViewManager->currentSelectionDate(); | 3729 | QDate itemDate = mViewManager->currentSelectionDate(); |
3728 | int km; | 3730 | int km; |
3729 | if (!itemDate.isValid()) { | 3731 | if (!itemDate.isValid()) { |
3730 | //kdDebug() << "Date Not Valid" << endl; | 3732 | //kdDebug() << "Date Not Valid" << endl; |
3731 | if (KOPrefs::instance()->mConfirm) { | 3733 | if (KOPrefs::instance()->mConfirm) { |
3732 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3734 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3733 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3735 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3734 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3736 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3735 | if ( km == KMessageBox::Continue ) | 3737 | if ( km == KMessageBox::Continue ) |
3736 | km = KMessageBox::No; // No = all below | 3738 | km = KMessageBox::No; // No = all below |
3737 | } else | 3739 | } else |
3738 | km = KMessageBox::No; | 3740 | km = KMessageBox::No; |
3739 | } else { | 3741 | } else { |
3740 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3742 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3741 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3743 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3742 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3744 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3743 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3745 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3744 | i18n("All")); | 3746 | i18n("All")); |
3745 | } | 3747 | } |
3746 | switch(km) { | 3748 | switch(km) { |
3747 | 3749 | ||
3748 | case KMessageBox::No: // Continue // all | 3750 | case KMessageBox::No: // Continue // all |
3749 | //qDebug("KMessageBox::No "); | 3751 | //qDebug("KMessageBox::No "); |
3750 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3752 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3751 | schedule(Scheduler::Cancel,anEvent); | 3753 | schedule(Scheduler::Cancel,anEvent); |
3752 | 3754 | ||
3753 | checkExternalId( anEvent); | 3755 | checkExternalId( anEvent); |
3754 | mCalendar->deleteEvent(anEvent); | 3756 | mCalendar->deleteEvent(anEvent); |
3755 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3757 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3756 | break; | 3758 | break; |
3757 | 3759 | ||
3758 | // Disabled because it does not work | 3760 | // Disabled because it does not work |
3759 | //#if 0 | 3761 | //#if 0 |
3760 | case KMessageBox::Yes: // just this one | 3762 | case KMessageBox::Yes: // just this one |
3761 | //QDate qd = mNavigator->selectedDates().first(); | 3763 | //QDate qd = mNavigator->selectedDates().first(); |
3762 | //if (!qd.isValid()) { | 3764 | //if (!qd.isValid()) { |
3763 | // kdDebug() << "no date selected, or invalid date" << endl; | 3765 | // kdDebug() << "no date selected, or invalid date" << endl; |
3764 | // KNotifyClient::beep(); | 3766 | // KNotifyClient::beep(); |
3765 | // return; | 3767 | // return; |
3766 | //} | 3768 | //} |
3767 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3769 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3768 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3770 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3769 | anEvent->addExDate(itemDate); | 3771 | anEvent->addExDate(itemDate); |
3770 | int duration = anEvent->recurrence()->duration(); | 3772 | int duration = anEvent->recurrence()->duration(); |
3771 | if ( duration > 0 ) { | 3773 | if ( duration > 0 ) { |
3772 | anEvent->recurrence()->setDuration( duration - 1 ); | 3774 | anEvent->recurrence()->setDuration( duration - 1 ); |
3773 | } | 3775 | } |
3774 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3776 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3775 | } | 3777 | } |
3776 | break; | 3778 | break; |
3777 | //#endif | 3779 | //#endif |
3778 | } // switch | 3780 | } // switch |
3779 | } else { | 3781 | } else { |
3780 | if (KOPrefs::instance()->mConfirm) { | 3782 | if (KOPrefs::instance()->mConfirm) { |
3781 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3783 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3782 | i18n("\nAre you sure you want\nto delete this event?"), | 3784 | i18n("\nAre you sure you want\nto delete this event?"), |
3783 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3785 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3784 | case KMessageBox::Continue: // OK | 3786 | case KMessageBox::Continue: // OK |
3785 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3787 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3786 | schedule(Scheduler::Cancel,anEvent); | 3788 | schedule(Scheduler::Cancel,anEvent); |
3787 | checkExternalId( anEvent); | 3789 | checkExternalId( anEvent); |
3788 | mCalendar->deleteEvent(anEvent); | 3790 | mCalendar->deleteEvent(anEvent); |
3789 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3791 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3790 | break; | 3792 | break; |
3791 | } // switch | 3793 | } // switch |
3792 | } else { | 3794 | } else { |
3793 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3795 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3794 | schedule(Scheduler::Cancel,anEvent); | 3796 | schedule(Scheduler::Cancel,anEvent); |
3795 | checkExternalId( anEvent); | 3797 | checkExternalId( anEvent); |
3796 | mCalendar->deleteEvent(anEvent); | 3798 | mCalendar->deleteEvent(anEvent); |
3797 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3799 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3798 | } | 3800 | } |
3799 | } // if-else | 3801 | } // if-else |
3800 | emit updateSearchDialog(); | 3802 | emit updateSearchDialog(); |
3801 | } | 3803 | } |
3802 | 3804 | ||
3803 | bool CalendarView::deleteEvent(const QString &uid) | 3805 | bool CalendarView::deleteEvent(const QString &uid) |
3804 | { | 3806 | { |
3805 | Event *ev = mCalendar->event(uid); | 3807 | Event *ev = mCalendar->event(uid); |
3806 | if (ev) { | 3808 | if (ev) { |
3807 | deleteEvent(ev); | 3809 | deleteEvent(ev); |
3808 | return true; | 3810 | return true; |
3809 | } else { | 3811 | } else { |
3810 | return false; | 3812 | return false; |
3811 | } | 3813 | } |
3812 | } | 3814 | } |
3813 | 3815 | ||
3814 | /*****************************************************************************/ | 3816 | /*****************************************************************************/ |
3815 | 3817 | ||
3816 | void CalendarView::action_mail() | 3818 | void CalendarView::action_mail() |
3817 | { | 3819 | { |
3818 | #ifndef KORG_NOMAIL | 3820 | #ifndef KORG_NOMAIL |
3819 | KOMailClient mailClient; | 3821 | KOMailClient mailClient; |
3820 | 3822 | ||
3821 | Incidence *incidence = currentSelection(); | 3823 | Incidence *incidence = currentSelection(); |
3822 | 3824 | ||
3823 | if (!incidence) { | 3825 | if (!incidence) { |
3824 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3826 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3825 | return; | 3827 | return; |
3826 | } | 3828 | } |
3827 | if(incidence->attendeeCount() == 0 ) { | 3829 | if(incidence->attendeeCount() == 0 ) { |
3828 | KMessageBox::sorry(this, | 3830 | KMessageBox::sorry(this, |
3829 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3831 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3830 | return; | 3832 | return; |
3831 | } | 3833 | } |
3832 | 3834 | ||
3833 | CalendarLocal cal_tmp; | 3835 | CalendarLocal cal_tmp; |
3834 | Event *event = 0; | 3836 | Event *event = 0; |
3835 | Event *ev = 0; | 3837 | Event *ev = 0; |
3836 | if ( incidence && incidence->typeID() == eventID ) { | 3838 | if ( incidence && incidence->typeID() == eventID ) { |
3837 | event = static_cast<Event *>(incidence); | 3839 | event = static_cast<Event *>(incidence); |
3838 | ev = new Event(*event); | 3840 | ev = new Event(*event); |
3839 | cal_tmp.addEvent(ev); | 3841 | cal_tmp.addEvent(ev); |
3840 | } | 3842 | } |
3841 | ICalFormat mForm(); | 3843 | ICalFormat mForm(); |
3842 | QString attachment = mForm.toString( &cal_tmp ); | 3844 | QString attachment = mForm.toString( &cal_tmp ); |
3843 | if (ev) delete(ev); | 3845 | if (ev) delete(ev); |
3844 | 3846 | ||
3845 | mailClient.mailAttendees(currentSelection(), attachment); | 3847 | mailClient.mailAttendees(currentSelection(), attachment); |
3846 | 3848 | ||
3847 | #endif | 3849 | #endif |
3848 | 3850 | ||
3849 | #if 0 | 3851 | #if 0 |
3850 | Event *anEvent = 0; | 3852 | Event *anEvent = 0; |
3851 | if (mViewManager->currentView()->isEventView()) { | 3853 | if (mViewManager->currentView()->isEventView()) { |
3852 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3854 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3853 | } | 3855 | } |
3854 | 3856 | ||
3855 | if (!anEvent) { | 3857 | if (!anEvent) { |
3856 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3858 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3857 | return; | 3859 | return; |
3858 | } | 3860 | } |
3859 | if(anEvent->attendeeCount() == 0 ) { | 3861 | if(anEvent->attendeeCount() == 0 ) { |
3860 | KMessageBox::sorry(this, | 3862 | KMessageBox::sorry(this, |
3861 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3863 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3862 | return; | 3864 | return; |
3863 | } | 3865 | } |
3864 | 3866 | ||
3865 | mailobject.emailEvent(anEvent); | 3867 | mailobject.emailEvent(anEvent); |
3866 | #endif | 3868 | #endif |
3867 | } | 3869 | } |
3868 | 3870 | ||
3869 | 3871 | ||
3870 | void CalendarView::schedule_publish(Incidence *incidence) | 3872 | void CalendarView::schedule_publish(Incidence *incidence) |
3871 | { | 3873 | { |
3872 | Event *event = 0; | 3874 | Event *event = 0; |
3873 | Todo *todo = 0; | 3875 | Todo *todo = 0; |
3874 | 3876 | ||
3875 | if (incidence == 0) { | 3877 | if (incidence == 0) { |
3876 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3878 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3877 | if (incidence == 0) { | 3879 | if (incidence == 0) { |
3878 | incidence = mTodoList->selectedIncidences().first(); | 3880 | incidence = mTodoList->selectedIncidences().first(); |
3879 | } | 3881 | } |
3880 | } | 3882 | } |
3881 | if ( incidence && incidence->typeID() == eventID ) { | 3883 | if ( incidence && incidence->typeID() == eventID ) { |
3882 | event = static_cast<Event *>(incidence); | 3884 | event = static_cast<Event *>(incidence); |
3883 | } else { | 3885 | } else { |
3884 | if ( incidence && incidence->typeID() == todoID ) { | 3886 | if ( incidence && incidence->typeID() == todoID ) { |
3885 | todo = static_cast<Todo *>(incidence); | 3887 | todo = static_cast<Todo *>(incidence); |
3886 | } | 3888 | } |
3887 | } | 3889 | } |
3888 | 3890 | ||
3889 | if (!event && !todo) { | 3891 | if (!event && !todo) { |
3890 | KMessageBox::sorry(this,i18n("No event selected.")); | 3892 | KMessageBox::sorry(this,i18n("No event selected.")); |
3891 | return; | 3893 | return; |
3892 | } | 3894 | } |
3893 | 3895 | ||
3894 | PublishDialog *publishdlg = new PublishDialog(); | 3896 | PublishDialog *publishdlg = new PublishDialog(); |
3895 | if (incidence->attendeeCount()>0) { | 3897 | if (incidence->attendeeCount()>0) { |
3896 | QPtrList<Attendee> attendees = incidence->attendees(); | 3898 | QPtrList<Attendee> attendees = incidence->attendees(); |
3897 | attendees.first(); | 3899 | attendees.first(); |
3898 | while ( attendees.current()!=0 ) { | 3900 | while ( attendees.current()!=0 ) { |
3899 | publishdlg->addAttendee(attendees.current()); | 3901 | publishdlg->addAttendee(attendees.current()); |
3900 | attendees.next(); | 3902 | attendees.next(); |
3901 | } | 3903 | } |
3902 | } | 3904 | } |
3903 | bool send = true; | 3905 | bool send = true; |
3904 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3906 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3905 | if ( publishdlg->exec() != QDialog::Accepted ) | 3907 | if ( publishdlg->exec() != QDialog::Accepted ) |
3906 | send = false; | 3908 | send = false; |
3907 | } | 3909 | } |
3908 | if ( send ) { | 3910 | if ( send ) { |
3909 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3911 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3910 | if ( event ) { | 3912 | if ( event ) { |
3911 | Event *ev = new Event(*event); | 3913 | Event *ev = new Event(*event); |
3912 | ev->registerObserver(0); | 3914 | ev->registerObserver(0); |
3913 | ev->clearAttendees(); | 3915 | ev->clearAttendees(); |
3914 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3916 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3915 | delete(ev); | 3917 | delete(ev); |
3916 | } | 3918 | } |
3917 | } else { | 3919 | } else { |
3918 | if ( todo ) { | 3920 | if ( todo ) { |
3919 | Todo *ev = new Todo(*todo); | 3921 | Todo *ev = new Todo(*todo); |
3920 | ev->registerObserver(0); | 3922 | ev->registerObserver(0); |
3921 | ev->clearAttendees(); | 3923 | ev->clearAttendees(); |
3922 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3924 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3923 | delete(ev); | 3925 | delete(ev); |
3924 | } | 3926 | } |
3925 | } | 3927 | } |
3926 | } | 3928 | } |
3927 | } | 3929 | } |
3928 | delete publishdlg; | 3930 | delete publishdlg; |
3929 | } | 3931 | } |
3930 | 3932 | ||
3931 | void CalendarView::schedule_request(Incidence *incidence) | 3933 | void CalendarView::schedule_request(Incidence *incidence) |
3932 | { | 3934 | { |
3933 | schedule(Scheduler::Request,incidence); | 3935 | schedule(Scheduler::Request,incidence); |
3934 | } | 3936 | } |
3935 | 3937 | ||
3936 | void CalendarView::schedule_refresh(Incidence *incidence) | 3938 | void CalendarView::schedule_refresh(Incidence *incidence) |
3937 | { | 3939 | { |
3938 | schedule(Scheduler::Refresh,incidence); | 3940 | schedule(Scheduler::Refresh,incidence); |
3939 | } | 3941 | } |
3940 | 3942 | ||
3941 | void CalendarView::schedule_cancel(Incidence *incidence) | 3943 | void CalendarView::schedule_cancel(Incidence *incidence) |
3942 | { | 3944 | { |
3943 | schedule(Scheduler::Cancel,incidence); | 3945 | schedule(Scheduler::Cancel,incidence); |
3944 | } | 3946 | } |
3945 | 3947 | ||
3946 | void CalendarView::schedule_add(Incidence *incidence) | 3948 | void CalendarView::schedule_add(Incidence *incidence) |
3947 | { | 3949 | { |
3948 | schedule(Scheduler::Add,incidence); | 3950 | schedule(Scheduler::Add,incidence); |
3949 | } | 3951 | } |
3950 | 3952 | ||
3951 | void CalendarView::schedule_reply(Incidence *incidence) | 3953 | void CalendarView::schedule_reply(Incidence *incidence) |
3952 | { | 3954 | { |
3953 | schedule(Scheduler::Reply,incidence); | 3955 | schedule(Scheduler::Reply,incidence); |
3954 | } | 3956 | } |
3955 | 3957 | ||
3956 | void CalendarView::schedule_counter(Incidence *incidence) | 3958 | void CalendarView::schedule_counter(Incidence *incidence) |
3957 | { | 3959 | { |
3958 | schedule(Scheduler::Counter,incidence); | 3960 | schedule(Scheduler::Counter,incidence); |
3959 | } | 3961 | } |
3960 | 3962 | ||
3961 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3963 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3962 | { | 3964 | { |
3963 | schedule(Scheduler::Declinecounter,incidence); | 3965 | schedule(Scheduler::Declinecounter,incidence); |
3964 | } | 3966 | } |
3965 | 3967 | ||
3966 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3968 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3967 | { | 3969 | { |
3968 | QDateTime start = QDateTime::currentDateTime(); | 3970 | QDateTime start = QDateTime::currentDateTime(); |
3969 | QDateTime end = start.addDays(daysToPublish); | 3971 | QDateTime end = start.addDays(daysToPublish); |
3970 | 3972 | ||
3971 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3973 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3972 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3974 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3973 | 3975 | ||
3974 | 3976 | ||
3975 | PublishDialog *publishdlg = new PublishDialog(); | 3977 | PublishDialog *publishdlg = new PublishDialog(); |
3976 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3978 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3977 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3979 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3978 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3980 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3979 | delete(freebusy); | 3981 | delete(freebusy); |
3980 | } | 3982 | } |
3981 | } | 3983 | } |
3982 | delete publishdlg; | 3984 | delete publishdlg; |
3983 | } | 3985 | } |
3984 | 3986 | ||
3985 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3987 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3986 | { | 3988 | { |
3987 | Event *event = 0; | 3989 | Event *event = 0; |
3988 | Todo *todo = 0; | 3990 | Todo *todo = 0; |
3989 | 3991 | ||
3990 | if (incidence == 0) { | 3992 | if (incidence == 0) { |
3991 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3993 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3992 | if (incidence == 0) { | 3994 | if (incidence == 0) { |
3993 | incidence = mTodoList->selectedIncidences().first(); | 3995 | incidence = mTodoList->selectedIncidences().first(); |
3994 | } | 3996 | } |
3995 | } | 3997 | } |
3996 | if ( incidence && incidence->typeID() == eventID ) { | 3998 | if ( incidence && incidence->typeID() == eventID ) { |
3997 | event = static_cast<Event *>(incidence); | 3999 | event = static_cast<Event *>(incidence); |
3998 | } | 4000 | } |
3999 | if ( incidence && incidence->typeID() == todoID ) { | 4001 | if ( incidence && incidence->typeID() == todoID ) { |
4000 | todo = static_cast<Todo *>(incidence); | 4002 | todo = static_cast<Todo *>(incidence); |
4001 | } | 4003 | } |
4002 | 4004 | ||
4003 | if (!event && !todo) { | 4005 | if (!event && !todo) { |
4004 | KMessageBox::sorry(this,i18n("No event selected.")); | 4006 | KMessageBox::sorry(this,i18n("No event selected.")); |
4005 | return; | 4007 | return; |
4006 | } | 4008 | } |
4007 | 4009 | ||
4008 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4010 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4009 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4011 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4010 | return; | 4012 | return; |
4011 | } | 4013 | } |
4012 | 4014 | ||
4013 | Event *ev = 0; | 4015 | Event *ev = 0; |
4014 | if (event) ev = new Event(*event); | 4016 | if (event) ev = new Event(*event); |
4015 | Todo *to = 0; | 4017 | Todo *to = 0; |
4016 | if (todo) to = new Todo(*todo); | 4018 | if (todo) to = new Todo(*todo); |
4017 | 4019 | ||
4018 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4020 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4019 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4021 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4020 | if (!me) { | 4022 | if (!me) { |
4021 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4023 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4022 | return; | 4024 | return; |
4023 | } | 4025 | } |
4024 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4026 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4025 | StatusDialog *statdlg = new StatusDialog(this); | 4027 | StatusDialog *statdlg = new StatusDialog(this); |
4026 | if (!statdlg->exec()==QDialog::Accepted) return; | 4028 | if (!statdlg->exec()==QDialog::Accepted) return; |
4027 | me->setStatus( statdlg->status() ); | 4029 | me->setStatus( statdlg->status() ); |
4028 | delete(statdlg); | 4030 | delete(statdlg); |
4029 | } | 4031 | } |
4030 | Attendee *menew = new Attendee(*me); | 4032 | Attendee *menew = new Attendee(*me); |
4031 | if (ev) { | 4033 | if (ev) { |
4032 | ev->clearAttendees(); | 4034 | ev->clearAttendees(); |
4033 | ev->addAttendee(menew,false); | 4035 | ev->addAttendee(menew,false); |
4034 | } else { | 4036 | } else { |
4035 | if (to) { | 4037 | if (to) { |
4036 | todo->clearAttendees(); | 4038 | todo->clearAttendees(); |
4037 | todo->addAttendee(menew,false); | 4039 | todo->addAttendee(menew,false); |
4038 | } | 4040 | } |
4039 | } | 4041 | } |
4040 | } | 4042 | } |
4041 | 4043 | ||
4042 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4044 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4043 | if (ev) { | 4045 | if (ev) { |
4044 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4046 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4045 | } else { | 4047 | } else { |
4046 | if (to) { | 4048 | if (to) { |
4047 | if ( !dlg->addMessage(to,method) ) delete(to); | 4049 | if ( !dlg->addMessage(to,method) ) delete(to); |
4048 | } | 4050 | } |
4049 | } | 4051 | } |
4050 | } | 4052 | } |
4051 | 4053 | ||
4052 | void CalendarView::openAddressbook() | 4054 | void CalendarView::openAddressbook() |
4053 | { | 4055 | { |
4054 | KRun::runCommand("kaddressbook"); | 4056 | KRun::runCommand("kaddressbook"); |
4055 | } | 4057 | } |
4056 | 4058 | ||
4057 | void CalendarView::setModified(bool modified) | 4059 | void CalendarView::setModified(bool modified) |
4058 | { | 4060 | { |
4059 | if ( modified ) | 4061 | if ( modified ) |
4060 | emit signalmodified(); | 4062 | emit signalmodified(); |
4061 | if (mModified != modified) { | 4063 | if (mModified != modified) { |
4062 | mModified = modified; | 4064 | mModified = modified; |
4063 | emit modifiedChanged(mModified); | 4065 | emit modifiedChanged(mModified); |
4064 | } | 4066 | } |
4065 | } | 4067 | } |
4066 | 4068 | ||
4067 | bool CalendarView::isReadOnly() | 4069 | bool CalendarView::isReadOnly() |
4068 | { | 4070 | { |
4069 | return mReadOnly; | 4071 | return mReadOnly; |
4070 | } | 4072 | } |
4071 | 4073 | ||
4072 | void CalendarView::setReadOnly(bool readOnly) | 4074 | void CalendarView::setReadOnly(bool readOnly) |
4073 | { | 4075 | { |
4074 | if (mReadOnly != readOnly) { | 4076 | if (mReadOnly != readOnly) { |
4075 | mReadOnly = readOnly; | 4077 | mReadOnly = readOnly; |
4076 | emit readOnlyChanged(mReadOnly); | 4078 | emit readOnlyChanged(mReadOnly); |
4077 | } | 4079 | } |
4078 | } | 4080 | } |
4079 | 4081 | ||
4080 | bool CalendarView::isModified() | 4082 | bool CalendarView::isModified() |
4081 | { | 4083 | { |
4082 | return mModified; | 4084 | return mModified; |
4083 | } | 4085 | } |
4084 | void CalendarView::slotprintSelInc() | 4086 | void CalendarView::slotprintSelInc() |
4085 | { | 4087 | { |
4086 | if ( currentSelection() == 0 ) { | 4088 | if ( currentSelection() == 0 ) { |
4087 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4089 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4088 | return; | 4090 | return; |
4089 | } | 4091 | } |
4090 | showIncidence(); | 4092 | showIncidence(); |
4091 | getEventViewerDialog()->print(); | 4093 | getEventViewerDialog()->print(); |
4092 | 4094 | ||
4093 | } | 4095 | } |
4094 | void CalendarView::printSetup() | 4096 | void CalendarView::printSetup() |
4095 | { | 4097 | { |
4096 | #ifndef KORG_NOPRINTER | 4098 | #ifndef KORG_NOPRINTER |
4097 | createPrinter(); | 4099 | createPrinter(); |
4098 | 4100 | ||
4099 | mCalPrinter->setupPrinter(); | 4101 | mCalPrinter->setupPrinter(); |
4100 | #endif | 4102 | #endif |
4101 | } | 4103 | } |
4102 | 4104 | ||
4103 | void CalendarView::print() | 4105 | void CalendarView::print() |
4104 | { | 4106 | { |
4105 | #ifndef KORG_NOPRINTER | 4107 | #ifndef KORG_NOPRINTER |
4106 | createPrinter(); | 4108 | createPrinter(); |
4107 | 4109 | ||
4108 | DateList tmpDateList = mNavigator->selectedDates(); | 4110 | DateList tmpDateList = mNavigator->selectedDates(); |
4109 | mCalPrinter->print(CalPrinter::Month, | 4111 | mCalPrinter->print(CalPrinter::Month, |
4110 | tmpDateList.first(), tmpDateList.last()); | 4112 | tmpDateList.first(), tmpDateList.last()); |
4111 | #endif | 4113 | #endif |
4112 | } | 4114 | } |
4113 | 4115 | ||
4114 | void CalendarView::printPreview() | 4116 | void CalendarView::printPreview() |
4115 | { | 4117 | { |
4116 | #ifndef KORG_NOPRINTER | 4118 | #ifndef KORG_NOPRINTER |
4117 | kdDebug() << "CalendarView::printPreview()" << endl; | 4119 | kdDebug() << "CalendarView::printPreview()" << endl; |
4118 | 4120 | ||
4119 | createPrinter(); | 4121 | createPrinter(); |
4120 | 4122 | ||
4121 | DateList tmpDateList = mNavigator->selectedDates(); | 4123 | DateList tmpDateList = mNavigator->selectedDates(); |
4122 | 4124 | ||
4123 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4125 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4124 | tmpDateList.last()); | 4126 | tmpDateList.last()); |
4125 | #endif | 4127 | #endif |
4126 | } | 4128 | } |
4127 | 4129 | ||
4128 | void CalendarView::exportICalendar() | 4130 | void CalendarView::exportICalendar() |
4129 | { | 4131 | { |
4130 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4132 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4131 | 4133 | ||
4132 | // Force correct extension | 4134 | // Force correct extension |
4133 | if (filename.right(4) != ".ics") filename += ".ics"; | 4135 | if (filename.right(4) != ".ics") filename += ".ics"; |
4134 | 4136 | ||
4135 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4137 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4136 | storage.save(); | 4138 | storage.save(); |
4137 | } | 4139 | } |
4138 | 4140 | ||
4139 | bool CalendarView::exportVCalendar( QString filename ) | 4141 | bool CalendarView::exportVCalendar( QString filename ) |
4140 | { | 4142 | { |
4141 | if (mCalendar->journals().count() > 0) { | 4143 | if (mCalendar->journals().count() > 0) { |
4142 | int result = KMessageBox::warningContinueCancel(this, | 4144 | int result = KMessageBox::warningContinueCancel(this, |
4143 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4145 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4144 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4146 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4145 | true); | 4147 | true); |
4146 | if (result != KMessageBox::Continue) return false; | 4148 | if (result != KMessageBox::Continue) return false; |
4147 | } | 4149 | } |
4148 | 4150 | ||
4149 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4151 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4150 | 4152 | ||
4151 | // Force correct extension | 4153 | // Force correct extension |
4152 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4154 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4153 | 4155 | ||
4154 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4156 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4155 | return storage.save(); | 4157 | return storage.save(); |
4156 | 4158 | ||
4157 | } | 4159 | } |
4158 | 4160 | ||
4159 | void CalendarView::eventUpdated(Incidence *) | 4161 | void CalendarView::eventUpdated(Incidence *) |
4160 | { | 4162 | { |
4161 | setModified(); | 4163 | setModified(); |
4162 | // Don't call updateView here. The code, which has caused the update of the | 4164 | // Don't call updateView here. The code, which has caused the update of the |
4163 | // event is responsible for updating the view. | 4165 | // event is responsible for updating the view. |
4164 | // updateView(); | 4166 | // updateView(); |
4165 | } | 4167 | } |
4166 | 4168 | ||
4167 | void CalendarView::adaptNavigationUnits() | 4169 | void CalendarView::adaptNavigationUnits() |
4168 | { | 4170 | { |
4169 | if (mViewManager->currentView()->isEventView()) { | 4171 | if (mViewManager->currentView()->isEventView()) { |
4170 | int days = mViewManager->currentView()->currentDateCount(); | 4172 | int days = mViewManager->currentView()->currentDateCount(); |
4171 | if (days == 1) { | 4173 | if (days == 1) { |
4172 | emit changeNavStringPrev(i18n("&Previous Day")); | 4174 | emit changeNavStringPrev(i18n("&Previous Day")); |
4173 | emit changeNavStringNext(i18n("&Next Day")); | 4175 | emit changeNavStringNext(i18n("&Next Day")); |
4174 | } else { | 4176 | } else { |
4175 | emit changeNavStringPrev(i18n("&Previous Week")); | 4177 | emit changeNavStringPrev(i18n("&Previous Week")); |
4176 | emit changeNavStringNext(i18n("&Next Week")); | 4178 | emit changeNavStringNext(i18n("&Next Week")); |
4177 | } | 4179 | } |
4178 | } | 4180 | } |
4179 | } | 4181 | } |
4180 | 4182 | ||
4181 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4183 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4182 | { | 4184 | { |
4183 | if ( incidence ) mTodoList->clearSelection(); | 4185 | if ( incidence ) mTodoList->clearSelection(); |
4184 | processIncidenceSelection( incidence ); | 4186 | processIncidenceSelection( incidence ); |
4185 | } | 4187 | } |
4186 | 4188 | ||
4187 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4189 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4188 | { | 4190 | { |
4189 | if ( incidence && mViewManager->currentView() ) { | 4191 | if ( incidence && mViewManager->currentView() ) { |
4190 | mViewManager->currentView()->clearSelection(); | 4192 | mViewManager->currentView()->clearSelection(); |
4191 | } | 4193 | } |
4192 | processIncidenceSelection( incidence ); | 4194 | processIncidenceSelection( incidence ); |
4193 | } | 4195 | } |
4194 | 4196 | ||
4195 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4197 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4196 | { | 4198 | { |
4197 | emit incidenceSelected( incidence ); | 4199 | emit incidenceSelected( incidence ); |
4198 | if ( incidence == mSelectedIncidence ) return; | 4200 | if ( incidence == mSelectedIncidence ) return; |
4199 | mSelectedIncidence = incidence; | 4201 | mSelectedIncidence = incidence; |
4200 | 4202 | ||
4201 | if ( incidence && incidence->typeID() == eventID ) { | 4203 | if ( incidence && incidence->typeID() == eventID ) { |
4202 | Event *event = static_cast<Event *>( incidence ); | 4204 | Event *event = static_cast<Event *>( incidence ); |
4203 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4205 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4204 | emit organizerEventsSelected( true ); | 4206 | emit organizerEventsSelected( true ); |
4205 | } else { | 4207 | } else { |
4206 | emit organizerEventsSelected(false); | 4208 | emit organizerEventsSelected(false); |
4207 | } | 4209 | } |
4208 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4210 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4209 | KOPrefs::instance()->email() ) ) { | 4211 | KOPrefs::instance()->email() ) ) { |
4210 | emit groupEventsSelected( true ); | 4212 | emit groupEventsSelected( true ); |
4211 | } else { | 4213 | } else { |
4212 | emit groupEventsSelected(false); | 4214 | emit groupEventsSelected(false); |
4213 | } | 4215 | } |
4214 | return; | 4216 | return; |
4215 | } else { | 4217 | } else { |
4216 | if ( incidence && incidence->typeID() == todoID ) { | 4218 | if ( incidence && incidence->typeID() == todoID ) { |
4217 | emit todoSelected( true ); | 4219 | emit todoSelected( true ); |
4218 | Todo *event = static_cast<Todo *>( incidence ); | 4220 | Todo *event = static_cast<Todo *>( incidence ); |
4219 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4221 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4220 | emit organizerEventsSelected( true ); | 4222 | emit organizerEventsSelected( true ); |
4221 | } else { | 4223 | } else { |
4222 | emit organizerEventsSelected(false); | 4224 | emit organizerEventsSelected(false); |
4223 | } | 4225 | } |
4224 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4226 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4225 | KOPrefs::instance()->email() ) ) { | 4227 | KOPrefs::instance()->email() ) ) { |
4226 | emit groupEventsSelected( true ); | 4228 | emit groupEventsSelected( true ); |
4227 | } else { | 4229 | } else { |
4228 | emit groupEventsSelected(false); | 4230 | emit groupEventsSelected(false); |
4229 | } | 4231 | } |
4230 | return; | 4232 | return; |
4231 | } else { | 4233 | } else { |
4232 | emit todoSelected( false ); | 4234 | emit todoSelected( false ); |
4233 | emit organizerEventsSelected(false); | 4235 | emit organizerEventsSelected(false); |
4234 | emit groupEventsSelected(false); | 4236 | emit groupEventsSelected(false); |
4235 | } | 4237 | } |
4236 | return; | 4238 | return; |
4237 | } | 4239 | } |
4238 | 4240 | ||
4239 | /* if ( incidence && incidence->typeID() == todoID ) { | 4241 | /* if ( incidence && incidence->typeID() == todoID ) { |
4240 | emit todoSelected( true ); | 4242 | emit todoSelected( true ); |
4241 | } else { | 4243 | } else { |
4242 | emit todoSelected( false ); | 4244 | emit todoSelected( false ); |
4243 | }*/ | 4245 | }*/ |
4244 | } | 4246 | } |
4245 | 4247 | ||
4246 | 4248 | ||
4247 | void CalendarView::checkClipboard() | 4249 | void CalendarView::checkClipboard() |
4248 | { | 4250 | { |
4249 | #ifndef KORG_NODND | 4251 | #ifndef KORG_NODND |
4250 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4252 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4251 | emit pasteEnabled(true); | 4253 | emit pasteEnabled(true); |
4252 | } else { | 4254 | } else { |
4253 | emit pasteEnabled(false); | 4255 | emit pasteEnabled(false); |
4254 | } | 4256 | } |
4255 | #endif | 4257 | #endif |
4256 | } | 4258 | } |
4257 | 4259 | ||
4258 | void CalendarView::showDates(const DateList &selectedDates) | 4260 | void CalendarView::showDates(const DateList &selectedDates) |
4259 | { | 4261 | { |
4260 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4262 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4261 | 4263 | ||
4262 | 4264 | ||
4263 | if ( !mBlockShowDates ) { | 4265 | if ( !mBlockShowDates ) { |
4264 | if ( mViewManager->currentView() ) { | 4266 | if ( mViewManager->currentView() ) { |
4265 | updateView( selectedDates.first(), selectedDates.last() ); | 4267 | updateView( selectedDates.first(), selectedDates.last() ); |
4266 | } else { | 4268 | } else { |
4267 | mViewManager->showAgendaView(); | 4269 | mViewManager->showAgendaView(); |
4268 | } | 4270 | } |
4269 | } | 4271 | } |
4270 | 4272 | ||
4271 | QDate date = selectedDates.first(); | 4273 | QDate date = selectedDates.first(); |
4272 | if ( ! date.isValid() ) { | 4274 | if ( ! date.isValid() ) { |
4273 | topLevelWidget()->setCaption(""); | 4275 | topLevelWidget()->setCaption(""); |
4274 | return; | 4276 | return; |
4275 | } | 4277 | } |
4276 | 4278 | ||
4277 | QString selDates; | 4279 | QString selDates; |
4278 | selDates = KGlobal::locale()->formatDate( date, true); | 4280 | selDates = KGlobal::locale()->formatDate( date, true); |
4279 | if (selectedDates.first() < selectedDates.last() ) | 4281 | if (selectedDates.first() < selectedDates.last() ) |
4280 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4282 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4281 | else { | 4283 | else { |
4282 | QString addString; | 4284 | QString addString; |
4283 | if ( date == QDateTime::currentDateTime().date() ) | 4285 | if ( date == QDateTime::currentDateTime().date() ) |
4284 | addString = i18n("Today"); | 4286 | addString = i18n("Today"); |
4285 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4287 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4286 | addString = i18n("Tomorrow"); | 4288 | addString = i18n("Tomorrow"); |
4287 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4289 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4288 | addString = i18n("Yesterday"); | 4290 | addString = i18n("Yesterday"); |
4289 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4291 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4290 | addString = i18n("Day before yesterday"); | 4292 | addString = i18n("Day before yesterday"); |
4291 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4293 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4292 | addString = i18n("Day after tomorrow"); | 4294 | addString = i18n("Day after tomorrow"); |
4293 | if ( !addString.isEmpty() ) { | 4295 | if ( !addString.isEmpty() ) { |
4294 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4296 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4295 | return; | 4297 | return; |
4296 | } | 4298 | } |
4297 | } | 4299 | } |
4298 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4300 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4299 | 4301 | ||
4300 | } | 4302 | } |
4301 | 4303 | ||
4302 | QPtrList<CalFilter> CalendarView::filters() | 4304 | QPtrList<CalFilter> CalendarView::filters() |
4303 | { | 4305 | { |
4304 | return mFilters; | 4306 | return mFilters; |
4305 | 4307 | ||
4306 | } | 4308 | } |
4307 | void CalendarView::editFilters() | 4309 | void CalendarView::editFilters() |
4308 | { | 4310 | { |
4309 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4311 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4310 | 4312 | ||
4311 | CalFilter *filter = mFilters.first(); | 4313 | CalFilter *filter = mFilters.first(); |
4312 | while(filter) { | 4314 | while(filter) { |
4313 | filter = mFilters.next(); | 4315 | filter = mFilters.next(); |
4314 | } | 4316 | } |
4315 | 4317 | ||
4316 | mDialogManager->showFilterEditDialog(&mFilters); | 4318 | mDialogManager->showFilterEditDialog(&mFilters); |
4317 | updateFilter(); | 4319 | updateFilter(); |
4318 | } | 4320 | } |
4319 | void CalendarView::toggleFilter() | 4321 | void CalendarView::toggleFilter() |
4320 | { | 4322 | { |
4321 | if ( mLeftFrame->isHidden() ) { | 4323 | if ( mLeftFrame->isHidden() ) { |
4322 | toggleExpand(); | 4324 | toggleExpand(); |
4323 | showFilter( true ); | 4325 | showFilter( true ); |
4324 | } else | 4326 | } else |
4325 | showFilter(! mCalEditView->isVisible()); | 4327 | showFilter(! mCalEditView->isVisible()); |
4326 | } | 4328 | } |
4327 | 4329 | ||
4328 | KOFilterView *CalendarView::filterView() | 4330 | KOFilterView *CalendarView::filterView() |
4329 | { | 4331 | { |
4330 | return mFilterView; | 4332 | return mFilterView; |
4331 | } | 4333 | } |
4332 | void CalendarView::selectFilter( int fil ) | 4334 | void CalendarView::selectFilter( int fil ) |
4333 | { | 4335 | { |
4334 | mFilterView->setSelectedFilter( fil ); | 4336 | mFilterView->setSelectedFilter( fil ); |
4335 | updateUnmanagedViews(); | 4337 | updateUnmanagedViews(); |
4336 | } | 4338 | } |
4337 | void CalendarView::showFilter(bool visible) | 4339 | void CalendarView::showFilter(bool visible) |
4338 | { | 4340 | { |
4339 | #if 1 | 4341 | #if 1 |
4340 | if (visible) { | 4342 | if (visible) { |
4341 | mCalEditView->readConfig(); | 4343 | mCalEditView->readConfig(); |
4342 | mCalEditView->show(); | 4344 | mCalEditView->show(); |
4343 | QValueList<int> sizes; | 4345 | QValueList<int> sizes; |
4344 | sizes = mLeftFrame->sizes(); | 4346 | sizes = mLeftFrame->sizes(); |
4345 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4347 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4346 | sizes.clear(); | 4348 | sizes.clear(); |
4347 | sizes << 100; | 4349 | sizes << 100; |
4348 | sizes << 0; | 4350 | sizes << 0; |
4349 | sizes << 0; | 4351 | sizes << 0; |
4350 | sizes << 100; | 4352 | sizes << 100; |
4351 | mLeftFrame->setSizes(sizes); | 4353 | mLeftFrame->setSizes(sizes); |
4352 | } | 4354 | } |
4353 | #if 0 | 4355 | #if 0 |
4354 | sizes = mLeftFrame->sizes(); | 4356 | sizes = mLeftFrame->sizes(); |
4355 | int ccc = 0; | 4357 | int ccc = 0; |
4356 | while ( ccc < sizes.count()) { | 4358 | while ( ccc < sizes.count()) { |
4357 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4359 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4358 | ++ccc; | 4360 | ++ccc; |
4359 | } | 4361 | } |
4360 | #endif | 4362 | #endif |
4361 | 4363 | ||
4362 | } | 4364 | } |
4363 | else { | 4365 | else { |
4364 | mCalEditView->hide(); | 4366 | mCalEditView->hide(); |
4365 | } | 4367 | } |
4366 | #else | 4368 | #else |
4367 | if (visible) mFilterView->show(); | 4369 | if (visible) mFilterView->show(); |
4368 | else mFilterView->hide(); | 4370 | else mFilterView->hide(); |
4369 | #endif | 4371 | #endif |
4370 | } | 4372 | } |
4371 | void CalendarView::toggleFilerEnabled( ) | 4373 | void CalendarView::toggleFilerEnabled( ) |
4372 | { | 4374 | { |
4373 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4375 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4374 | if ( !mFilterView->filtersEnabled() ) | 4376 | if ( !mFilterView->filtersEnabled() ) |
4375 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4377 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4376 | updateUnmanagedViews(); | 4378 | updateUnmanagedViews(); |
4377 | 4379 | ||
4378 | } | 4380 | } |
4379 | void CalendarView::updateFilter() | 4381 | void CalendarView::updateFilter() |
4380 | { | 4382 | { |
4381 | CalFilter *filter = mFilterView->selectedFilter(); | 4383 | CalFilter *filter = mFilterView->selectedFilter(); |
4382 | if (filter) { | 4384 | if (filter) { |
4383 | QString mess; | 4385 | QString mess; |
4384 | if (mFilterView->filtersEnabled()) { | 4386 | if (mFilterView->filtersEnabled()) { |
4385 | mess = i18n("Filter selected: ")+filter->name(); | 4387 | mess = i18n("Filter selected: ")+filter->name(); |
4386 | filter->setEnabled(true); | 4388 | filter->setEnabled(true); |
4387 | } | 4389 | } |
4388 | else filter->setEnabled(false); | 4390 | else filter->setEnabled(false); |
4389 | mCalendar->setFilter(filter); | 4391 | mCalendar->setFilter(filter); |
4390 | updateView(); | 4392 | updateView(); |
4391 | if ( !mess.isEmpty() ) | 4393 | if ( !mess.isEmpty() ) |
4392 | topLevelWidget()->setCaption( mess ); | 4394 | topLevelWidget()->setCaption( mess ); |
4393 | 4395 | ||
4394 | } | 4396 | } |
4395 | emit filtersUpdated(); | 4397 | emit filtersUpdated(); |
4396 | } | 4398 | } |
4397 | 4399 | ||
4398 | void CalendarView::filterEdited() | 4400 | void CalendarView::filterEdited() |
4399 | { | 4401 | { |
4400 | mFilterView->updateFilters(); | 4402 | mFilterView->updateFilters(); |
4401 | updateFilter(); | 4403 | updateFilter(); |
4402 | writeSettings(); | 4404 | writeSettings(); |
4403 | } | 4405 | } |
4404 | 4406 | ||
4405 | 4407 | ||
4406 | void CalendarView::takeOverEvent() | 4408 | void CalendarView::takeOverEvent() |
4407 | { | 4409 | { |
4408 | Incidence *incidence = currentSelection(); | 4410 | Incidence *incidence = currentSelection(); |
4409 | 4411 | ||
4410 | if (!incidence) return; | 4412 | if (!incidence) return; |
4411 | 4413 | ||
4412 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4414 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4413 | incidence->recreate(); | 4415 | incidence->recreate(); |
4414 | incidence->setReadOnly(false); | 4416 | incidence->setReadOnly(false); |
4415 | 4417 | ||
4416 | updateView(); | 4418 | updateView(); |
4417 | } | 4419 | } |
4418 | 4420 | ||
4419 | void CalendarView::takeOverCalendar() | 4421 | void CalendarView::takeOverCalendar() |
4420 | { | 4422 | { |
4421 | // TODO: Create Calendar::allIncidences() function and use it here | 4423 | // TODO: Create Calendar::allIncidences() function and use it here |
4422 | 4424 | ||
4423 | clearAllViews(); | 4425 | clearAllViews(); |
4424 | QPtrList<Event> events = mCalendar->events(); | 4426 | QPtrList<Event> events = mCalendar->events(); |
4425 | for(uint i=0; i<events.count(); ++i) { | 4427 | for(uint i=0; i<events.count(); ++i) { |
4426 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4428 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4427 | events.at(i)->recreate(); | 4429 | events.at(i)->recreate(); |
4428 | events.at(i)->setReadOnly(false); | 4430 | events.at(i)->setReadOnly(false); |
4429 | } | 4431 | } |
4430 | 4432 | ||
4431 | QPtrList<Todo> todos = mCalendar->todos(); | 4433 | QPtrList<Todo> todos = mCalendar->todos(); |
4432 | for(uint i=0; i<todos.count(); ++i) { | 4434 | for(uint i=0; i<todos.count(); ++i) { |
4433 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4435 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4434 | todos.at(i)->recreate(); | 4436 | todos.at(i)->recreate(); |
4435 | todos.at(i)->setReadOnly(false); | 4437 | todos.at(i)->setReadOnly(false); |
4436 | } | 4438 | } |
4437 | 4439 | ||
4438 | QPtrList<Journal> journals = mCalendar->journals(); | 4440 | QPtrList<Journal> journals = mCalendar->journals(); |
4439 | for(uint i=0; i<journals.count(); ++i) { | 4441 | for(uint i=0; i<journals.count(); ++i) { |
4440 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4442 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4441 | journals.at(i)->recreate(); | 4443 | journals.at(i)->recreate(); |
4442 | journals.at(i)->setReadOnly(false); | 4444 | journals.at(i)->setReadOnly(false); |
4443 | } | 4445 | } |
4444 | 4446 | ||
4445 | updateView(); | 4447 | updateView(); |
4446 | } | 4448 | } |
4447 | 4449 | ||
4448 | void CalendarView::showIntro() | 4450 | void CalendarView::showIntro() |
4449 | { | 4451 | { |
4450 | kdDebug() << "To be implemented." << endl; | 4452 | kdDebug() << "To be implemented." << endl; |
4451 | } | 4453 | } |
4452 | 4454 | ||
4453 | QWidgetStack *CalendarView::viewStack() | 4455 | QWidgetStack *CalendarView::viewStack() |
4454 | { | 4456 | { |
4455 | return mRightFrame; | 4457 | return mRightFrame; |
4456 | } | 4458 | } |
4457 | 4459 | ||
4458 | QWidget *CalendarView::leftFrame() | 4460 | QWidget *CalendarView::leftFrame() |
4459 | { | 4461 | { |
4460 | return ( QWidget *)mLeftFrame; | 4462 | return ( QWidget *)mLeftFrame; |
4461 | } | 4463 | } |
4462 | 4464 | ||
4463 | DateNavigator *CalendarView::dateNavigator() | 4465 | DateNavigator *CalendarView::dateNavigator() |
4464 | { | 4466 | { |
4465 | return mNavigator; | 4467 | return mNavigator; |
4466 | } | 4468 | } |
4467 | 4469 | ||
4468 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4470 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4469 | { | 4471 | { |
4470 | return mDateNavigator->navigatorView(); | 4472 | return mDateNavigator->navigatorView(); |
4471 | } | 4473 | } |
4472 | void CalendarView::toggleDateNavigatorWidget() | 4474 | void CalendarView::toggleDateNavigatorWidget() |
4473 | { | 4475 | { |
4474 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4476 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4475 | 4477 | ||
4476 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4478 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4477 | mDateNavigator->hide(); | 4479 | mDateNavigator->hide(); |
4478 | else | 4480 | else |
4479 | mDateNavigator->show(); | 4481 | mDateNavigator->show(); |
4480 | } | 4482 | } |
4481 | void CalendarView::addView(KOrg::BaseView *view) | 4483 | void CalendarView::addView(KOrg::BaseView *view) |
4482 | { | 4484 | { |
4483 | mViewManager->addView(view); | 4485 | mViewManager->addView(view); |
4484 | } | 4486 | } |
4485 | 4487 | ||
4486 | void CalendarView::showView(KOrg::BaseView *view) | 4488 | void CalendarView::showView(KOrg::BaseView *view) |
4487 | { | 4489 | { |
4488 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4490 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4489 | } | 4491 | } |
4490 | 4492 | ||
4491 | Incidence *CalendarView::currentSelection() | 4493 | Incidence *CalendarView::currentSelection() |
4492 | { | 4494 | { |
4493 | return mViewManager->currentSelection(); | 4495 | return mViewManager->currentSelection(); |
4494 | } | 4496 | } |
4495 | void CalendarView::toggleAllDaySize() | 4497 | void CalendarView::toggleAllDaySize() |
4496 | { | 4498 | { |
4497 | /* | 4499 | /* |
4498 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4500 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4499 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4501 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4500 | else | 4502 | else |
4501 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4503 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4502 | */ | 4504 | */ |
4503 | viewManager()->agendaView()->toggleAllDay(); | 4505 | viewManager()->agendaView()->toggleAllDay(); |
4504 | } | 4506 | } |
4505 | void CalendarView::toggleExpand() | 4507 | void CalendarView::toggleExpand() |
4506 | { | 4508 | { |
4507 | // if ( mLeftFrame->isHidden() ) { | 4509 | // if ( mLeftFrame->isHidden() ) { |
4508 | // mLeftFrame->show(); | 4510 | // mLeftFrame->show(); |
4509 | // emit calendarViewExpanded( false ); | 4511 | // emit calendarViewExpanded( false ); |
4510 | // } else { | 4512 | // } else { |
4511 | // mLeftFrame->hide(); | 4513 | // mLeftFrame->hide(); |
4512 | // emit calendarViewExpanded( true ); | 4514 | // emit calendarViewExpanded( true ); |
4513 | // } | 4515 | // } |
4514 | //qDebug(" CalendarView::toggleExpand()"); | 4516 | //qDebug(" CalendarView::toggleExpand()"); |
4515 | globalFlagBlockAgenda = 1; | 4517 | globalFlagBlockAgenda = 1; |
4516 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4518 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4517 | globalFlagBlockAgenda = 5; | 4519 | globalFlagBlockAgenda = 5; |
4518 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4520 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4519 | //mViewManager->showView( 0, true ); | 4521 | //mViewManager->showView( 0, true ); |
4520 | } | 4522 | } |
4521 | 4523 | ||
4522 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4524 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4523 | { | 4525 | { |
4524 | setModified( modified ); | 4526 | setModified( modified ); |
4525 | } | 4527 | } |
4526 | 4528 | ||
4527 | Todo *CalendarView::selectedTodo() | 4529 | Todo *CalendarView::selectedTodo() |
4528 | { | 4530 | { |
4529 | Incidence *incidence = currentSelection(); | 4531 | Incidence *incidence = currentSelection(); |
4530 | if ( incidence && incidence->typeID() == todoID ) { | 4532 | if ( incidence && incidence->typeID() == todoID ) { |
4531 | return static_cast<Todo *>( incidence ); | 4533 | return static_cast<Todo *>( incidence ); |
4532 | } | 4534 | } |
4533 | 4535 | ||
4534 | incidence = mTodoList->selectedIncidences().first(); | 4536 | incidence = mTodoList->selectedIncidences().first(); |
4535 | if ( incidence && incidence->typeID() == todoID ) { | 4537 | if ( incidence && incidence->typeID() == todoID ) { |
4536 | return static_cast<Todo *>( incidence ); | 4538 | return static_cast<Todo *>( incidence ); |
4537 | } | 4539 | } |
4538 | 4540 | ||
4539 | return 0; | 4541 | return 0; |
4540 | } | 4542 | } |
4541 | 4543 | ||
4542 | void CalendarView::showIncidence() | 4544 | void CalendarView::showIncidence() |
4543 | { | 4545 | { |
4544 | mViewerCallerIsSearchDialog = false; | 4546 | mViewerCallerIsSearchDialog = false; |
4545 | Incidence *incidence = currentSelection(); | 4547 | Incidence *incidence = currentSelection(); |
4546 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4548 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4547 | if ( incidence ) { | 4549 | if ( incidence ) { |
4548 | ShowIncidenceVisitor v; | 4550 | ShowIncidenceVisitor v; |
4549 | v.act( incidence, this ); | 4551 | v.act( incidence, this ); |
4550 | } | 4552 | } |
4551 | } | 4553 | } |
4552 | void CalendarView::editIncidenceDescription() | 4554 | void CalendarView::editIncidenceDescription() |
4553 | { | 4555 | { |
4554 | mFlagEditDescription = true; | 4556 | mFlagEditDescription = true; |
4555 | editIncidence(); | 4557 | editIncidence(); |
4556 | mFlagEditDescription = false; | 4558 | mFlagEditDescription = false; |
4557 | } | 4559 | } |
4558 | void CalendarView::editIncidence() | 4560 | void CalendarView::editIncidence() |
4559 | { | 4561 | { |
4560 | // qDebug("editIncidence() "); | 4562 | // qDebug("editIncidence() "); |
4561 | Incidence *incidence = currentSelection(); | 4563 | Incidence *incidence = currentSelection(); |
4562 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4564 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4563 | if ( incidence ) { | 4565 | if ( incidence ) { |
4564 | EditIncidenceVisitor v; | 4566 | EditIncidenceVisitor v; |
4565 | v.act( incidence, this ); | 4567 | v.act( incidence, this ); |
4566 | } | 4568 | } |
4567 | } | 4569 | } |
4568 | 4570 | ||
4569 | void CalendarView::deleteIncidence() | 4571 | void CalendarView::deleteIncidence() |
4570 | { | 4572 | { |
4571 | Incidence *incidence = currentSelection(); | 4573 | Incidence *incidence = currentSelection(); |
4572 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4574 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4573 | if ( incidence ) { | 4575 | if ( incidence ) { |
4574 | deleteIncidence(incidence); | 4576 | deleteIncidence(incidence); |
4575 | } | 4577 | } |
4576 | } | 4578 | } |
4577 | void CalendarView::showIncidence(QString uid) | 4579 | void CalendarView::showIncidence(QString uid) |
4578 | { | 4580 | { |
4579 | Incidence *inc = mCalendar->incidence( uid ); | 4581 | Incidence *inc = mCalendar->incidence( uid ); |
4580 | if ( inc ) | 4582 | if ( inc ) |
4581 | showIncidence( inc ); | 4583 | showIncidence( inc ); |
4582 | } | 4584 | } |
4583 | void CalendarView::showIncidence(Incidence *incidence) | 4585 | void CalendarView::showIncidence(Incidence *incidence) |
4584 | { | 4586 | { |
4585 | mViewerCallerIsSearchDialog = false; | 4587 | mViewerCallerIsSearchDialog = false; |
4586 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4588 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4587 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4589 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4588 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4590 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4589 | mViewerCallerIsSearchDialog = true; | 4591 | mViewerCallerIsSearchDialog = true; |
4590 | } | 4592 | } |
4591 | } | 4593 | } |
4592 | if ( incidence ) { | 4594 | if ( incidence ) { |
4593 | ShowIncidenceVisitor v; | 4595 | ShowIncidenceVisitor v; |
4594 | v.act( incidence, this ); | 4596 | v.act( incidence, this ); |
4595 | } | 4597 | } |
4596 | } | 4598 | } |
4597 | 4599 | ||
4598 | void CalendarView::editIncidence(Incidence *incidence) | 4600 | void CalendarView::editIncidence(Incidence *incidence) |
4599 | { | 4601 | { |
4600 | if ( incidence ) { | 4602 | if ( incidence ) { |
4601 | 4603 | ||
4602 | EditIncidenceVisitor v; | 4604 | EditIncidenceVisitor v; |
4603 | v.act( incidence, this ); | 4605 | v.act( incidence, this ); |
4604 | 4606 | ||
4605 | } | 4607 | } |
4606 | } | 4608 | } |
4607 | 4609 | ||
4608 | void CalendarView::deleteIncidence(Incidence *incidence) | 4610 | void CalendarView::deleteIncidence(Incidence *incidence) |
4609 | { | 4611 | { |
4610 | //qDebug(" CalendarView::deleteIncidence "); | 4612 | //qDebug(" CalendarView::deleteIncidence "); |
4611 | if ( incidence == 0 ) { | 4613 | if ( incidence == 0 ) { |
4612 | updateView(); | 4614 | updateView(); |
4613 | emit updateSearchDialog(); | 4615 | emit updateSearchDialog(); |
4614 | return; | 4616 | return; |
4615 | } | 4617 | } |
4616 | if ( incidence ) { | 4618 | if ( incidence ) { |
4617 | DeleteIncidenceVisitor v; | 4619 | DeleteIncidenceVisitor v; |
4618 | v.act( incidence, this ); | 4620 | v.act( incidence, this ); |
4619 | } | 4621 | } |
4620 | } | 4622 | } |
4621 | 4623 | ||
4622 | 4624 | ||
4623 | void CalendarView::lookForOutgoingMessages() | 4625 | void CalendarView::lookForOutgoingMessages() |
4624 | { | 4626 | { |
4625 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4627 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4626 | ogd->loadMessages(); | 4628 | ogd->loadMessages(); |
4627 | } | 4629 | } |
4628 | 4630 | ||
4629 | void CalendarView::lookForIncomingMessages() | 4631 | void CalendarView::lookForIncomingMessages() |
4630 | { | 4632 | { |
4631 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4633 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4632 | icd->retrieve(); | 4634 | icd->retrieve(); |
4633 | } | 4635 | } |
4634 | 4636 | ||
4635 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4637 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4636 | { | 4638 | { |
4637 | bool deleteTodo = true; | 4639 | bool deleteTodo = true; |
4638 | QPtrList<Incidence> subTodos; | 4640 | QPtrList<Incidence> subTodos; |
4639 | Incidence *aTodo; | 4641 | Incidence *aTodo; |
4640 | subTodos = t->relations(); | 4642 | subTodos = t->relations(); |
4641 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4643 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4642 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4644 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4643 | deleteTodo = false; | 4645 | deleteTodo = false; |
4644 | } | 4646 | } |
4645 | if ( deleteTodo ) { | 4647 | if ( deleteTodo ) { |
4646 | if ( t->isCompleted() && !t->doesRecur()) { | 4648 | if ( t->isCompleted() && !t->doesRecur()) { |
4647 | checkExternalId( t ); | 4649 | checkExternalId( t ); |
4648 | mCalendar->deleteTodo( t ); | 4650 | mCalendar->deleteTodo( t ); |
4649 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4651 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4650 | } | 4652 | } |
4651 | else | 4653 | else |
4652 | deleteTodo = false; | 4654 | deleteTodo = false; |
4653 | } | 4655 | } |
4654 | return deleteTodo; | 4656 | return deleteTodo; |
4655 | 4657 | ||
4656 | } | 4658 | } |
4657 | void CalendarView::purgeCompleted() | 4659 | void CalendarView::purgeCompleted() |
4658 | { | 4660 | { |
4659 | int result = KMessageBox::warningContinueCancel(this, | 4661 | int result = KMessageBox::warningContinueCancel(this, |
4660 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4662 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4661 | 4663 | ||
4662 | if (result == KMessageBox::Continue) { | 4664 | if (result == KMessageBox::Continue) { |
4663 | 4665 | ||
4664 | QPtrList<Todo> todoCal; | 4666 | QPtrList<Todo> todoCal; |
4665 | QPtrList<Todo> rootTodos; | 4667 | QPtrList<Todo> rootTodos; |
4666 | //QPtrList<Incidence> rel; | 4668 | //QPtrList<Incidence> rel; |
4667 | Todo *aTodo; | 4669 | Todo *aTodo; |
4668 | todoCal = calendar()->todos(); | 4670 | todoCal = calendar()->todos(); |
4669 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4671 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4670 | if ( !aTodo->relatedTo() ) | 4672 | if ( !aTodo->relatedTo() ) |
4671 | rootTodos.append( aTodo ); | 4673 | rootTodos.append( aTodo ); |
4672 | } | 4674 | } |
4673 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4675 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4674 | removeCompletedSubTodos( aTodo ); | 4676 | removeCompletedSubTodos( aTodo ); |
4675 | } | 4677 | } |
4676 | 4678 | ||
4677 | updateView(); | 4679 | updateView(); |
4678 | } | 4680 | } |
4679 | } | 4681 | } |
4680 | 4682 | ||
4681 | void CalendarView::slotCalendarChanged() | 4683 | void CalendarView::slotCalendarChanged() |
4682 | { | 4684 | { |
4683 | ; | 4685 | ; |
4684 | } | 4686 | } |
4685 | 4687 | ||
4686 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4688 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4687 | { | 4689 | { |
4688 | //qDebug(" alendarView::keyPressEvent "); | 4690 | //qDebug(" alendarView::keyPressEvent "); |
4689 | e->ignore(); | 4691 | e->ignore(); |
4690 | } | 4692 | } |
4691 | 4693 | ||
4692 | 4694 | ||
4693 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4695 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4694 | { | 4696 | { |
4695 | 4697 | ||
4696 | if ( manager != mSyncManager) | 4698 | if ( manager != mSyncManager) |
4697 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4699 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4698 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4700 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4699 | qDebug("KO: SyncKDE request detected!"); | 4701 | qDebug("KO: SyncKDE request detected!"); |
4700 | } | 4702 | } |
4701 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4703 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4702 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4704 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4703 | return syncCalendar( filename, mode ); | 4705 | return syncCalendar( filename, mode ); |
4704 | } | 4706 | } |
4705 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4707 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4706 | { | 4708 | { |
4707 | //mSyncManager = manager; | 4709 | //mSyncManager = manager; |
4708 | if ( manager != mSyncManager) | 4710 | if ( manager != mSyncManager) |
4709 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4711 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4710 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4712 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4711 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4713 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4712 | if ( resource == "sharp" ) | 4714 | if ( resource == "sharp" ) |
4713 | syncExternal( 0 ); | 4715 | syncExternal( 0 ); |
4714 | if ( resource == "phone" ) | 4716 | if ( resource == "phone" ) |
4715 | syncExternal( 1 ); | 4717 | syncExternal( 1 ); |
4716 | // pending setmodified | 4718 | // pending setmodified |
4717 | return true; | 4719 | return true; |
4718 | } | 4720 | } |
4719 | void CalendarView::setSyncManager(KSyncManager* manager) | 4721 | void CalendarView::setSyncManager(KSyncManager* manager) |
4720 | { | 4722 | { |
4721 | mSyncManager = manager; | 4723 | mSyncManager = manager; |
4722 | } | 4724 | } |
4723 | 4725 | ||
4724 | void CalendarView::removeSyncInfo( QString syncProfile) | 4726 | void CalendarView::removeSyncInfo( QString syncProfile) |
4725 | { | 4727 | { |
4726 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4728 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4727 | mCalendar->removeSyncInfo( syncProfile ); | 4729 | mCalendar->removeSyncInfo( syncProfile ); |
4728 | 4730 | ||
4729 | } | 4731 | } |
4730 | 4732 | ||
4731 | void CalendarView::undo_delete() | 4733 | void CalendarView::undo_delete() |
4732 | { | 4734 | { |
4733 | //qDebug("undo_delete() "); | 4735 | //qDebug("undo_delete() "); |
4734 | Incidence* undo = mCalendar->undoIncidence(); | 4736 | Incidence* undo = mCalendar->undoIncidence(); |
4735 | if ( !undo ) { | 4737 | if ( !undo ) { |
4736 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4738 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4737 | i18n("KO/Pi")); | 4739 | i18n("KO/Pi")); |
4738 | return; | 4740 | return; |
4739 | } | 4741 | } |
4740 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4742 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4741 | i18n("\nAre you sure you want\nto restore this?"), | 4743 | i18n("\nAre you sure you want\nto restore this?"), |
4742 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4744 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4743 | mCalendar->undoDeleteIncidence(); | 4745 | mCalendar->undoDeleteIncidence(); |
4744 | updateView(); | 4746 | updateView(); |
4745 | } | 4747 | } |
4746 | } | 4748 | } |
4747 | 4749 | ||
4748 | void CalendarView::slotViewerClosed() | 4750 | void CalendarView::slotViewerClosed() |
4749 | { | 4751 | { |
4750 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4752 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4751 | } | 4753 | } |
4752 | 4754 | ||
4753 | void CalendarView::resetFocus() | 4755 | void CalendarView::resetFocus() |
4754 | { | 4756 | { |
4755 | if ( mViewerCallerIsSearchDialog ) { | 4757 | if ( mViewerCallerIsSearchDialog ) { |
4756 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4758 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4757 | mDialogManager->getSearchDialog()->raise(); | 4759 | mDialogManager->getSearchDialog()->raise(); |
4758 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4760 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4759 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4761 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4760 | } else | 4762 | } else |
4761 | mViewerCallerIsSearchDialog = false; | 4763 | mViewerCallerIsSearchDialog = false; |
4762 | } | 4764 | } |
4763 | if ( !mViewerCallerIsSearchDialog ) { | 4765 | if ( !mViewerCallerIsSearchDialog ) { |
4764 | //mViewManager->currentView()->setFocus(); | 4766 | //mViewManager->currentView()->setFocus(); |
4765 | //qDebug("sssssssssssssssset focus "); | 4767 | //qDebug("sssssssssssssssset focus "); |
4766 | topLevelWidget()->raise(); | 4768 | topLevelWidget()->raise(); |
4767 | setActiveWindow(); | 4769 | setActiveWindow(); |
4768 | //setFocus(); | 4770 | //setFocus(); |
4769 | } | 4771 | } |
4770 | mViewerCallerIsSearchDialog = false; | 4772 | mViewerCallerIsSearchDialog = false; |
4771 | } | 4773 | } |
4772 | 4774 | ||
4773 | void CalendarView::showNextAlarms() | 4775 | void CalendarView::showNextAlarms() |
4774 | { | 4776 | { |
4775 | QString message; | 4777 | QString message; |
4776 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4778 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4777 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4779 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4778 | QString sum = mCalendar->nextSummary(); | 4780 | QString sum = mCalendar->nextSummary(); |
4779 | QDateTime nextA = mNextAlarmDateTime; | 4781 | QDateTime nextA = mNextAlarmDateTime; |
4780 | QDateTime cur = QDateTime::currentDateTime(); | 4782 | QDateTime cur = QDateTime::currentDateTime(); |
4781 | int secs = cur.secsTo( nextA ); | 4783 | int secs = cur.secsTo( nextA ); |
4782 | int min = secs /60; | 4784 | int min = secs /60; |
4783 | int hours = min /60; | 4785 | int hours = min /60; |
4784 | min = min % 60; | 4786 | min = min % 60; |
4785 | int days = hours /24; | 4787 | int days = hours /24; |
4786 | hours = hours % 24; | 4788 | hours = hours % 24; |
4787 | 4789 | ||
4788 | //message = i18n("The next alarm is in:\n"); | 4790 | //message = i18n("The next alarm is in:\n"); |
4789 | if ( days > 1 ) | 4791 | if ( days > 1 ) |
4790 | message += i18n("%1 days\n").arg( days ); | 4792 | message += i18n("%1 days\n").arg( days ); |
4791 | else if ( days == 1 ) | 4793 | else if ( days == 1 ) |
4792 | message += i18n("1 day\n"); | 4794 | message += i18n("1 day\n"); |
4793 | if ( hours > 1 ) | 4795 | if ( hours > 1 ) |
4794 | message += i18n("%1 hours\n").arg( hours ); | 4796 | message += i18n("%1 hours\n").arg( hours ); |
4795 | else if ( hours == 1 ) | 4797 | else if ( hours == 1 ) |
4796 | message += i18n("1 hour\n"); | 4798 | message += i18n("1 hour\n"); |
4797 | if ( min > 1 ) | 4799 | if ( min > 1 ) |
4798 | message += i18n("%1 minutes\n").arg( min ); | 4800 | message += i18n("%1 minutes\n").arg( min ); |
4799 | else if ( min == 1 ) | 4801 | else if ( min == 1 ) |
4800 | message += i18n("1 minute\n"); | 4802 | message += i18n("1 minute\n"); |
4801 | if ( message.isEmpty() ) | 4803 | if ( message.isEmpty() ) |
4802 | message = i18n("The next alarm is in\nless than one minute!"); | 4804 | message = i18n("The next alarm is in\nless than one minute!"); |
4803 | else | 4805 | else |
4804 | message = i18n("The next alarm is in:\n") + message; | 4806 | message = i18n("The next alarm is in:\n") + message; |
4805 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4807 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4806 | } else { | 4808 | } else { |
4807 | message = i18n("There is no next alarm."); | 4809 | message = i18n("There is no next alarm."); |
4808 | 4810 | ||
4809 | } | 4811 | } |
4810 | #ifdef DESKTOP_VERSION | 4812 | #ifdef DESKTOP_VERSION |
4811 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4813 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4812 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4814 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4813 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4815 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4814 | } | 4816 | } |
4815 | 4817 | ||
4816 | #endif | 4818 | #endif |
4817 | KMessageBox::information( this, message); | 4819 | KMessageBox::information( this, message); |
4818 | } | 4820 | } |