author | zautrix <zautrix> | 2004-12-07 09:55:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-07 09:55:57 (UTC) |
commit | 17b25691f0332e648dd1d800e89ccf4e1da8955d (patch) (unidiff) | |
tree | b7bc28e6c57c043fc49328a7ebd86e1b5cd0f17a | |
parent | dcd2bbbc8d3064b35f268a831c567feaafea5fd8 (diff) | |
download | kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.zip kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.tar.gz kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.tar.bz2 |
some kopi usebility fixes
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 13 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 46 | ||||
-rw-r--r-- | korganizer/calendarview.h | 3 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 10 | ||||
-rw-r--r-- | korganizer/komonthview.h | 3 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 7 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 11 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 17 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 | ||||
-rw-r--r-- | version | 2 |
14 files changed, 123 insertions, 14 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 5021212..46d59a3 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,626 +1,639 @@ | |||
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 1.9.15 ************ | ||
4 | |||
5 | Usebilty enhancements in KO/Pi: | ||
6 | When clicking on the date in a month view cell, the day view is shown. | ||
7 | Old behaviour was, that the "new event" dialog popped up. | ||
8 | |||
9 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). | ||
10 | That means, you can restore the latest | ||
11 | event/todo/journal you have deleted. | ||
12 | A journal is deleted, if you clear all the text of the journal. | ||
13 | |||
14 | |||
15 | |||
3 | ********** VERSION 1.9.14 ************ | 16 | ********** VERSION 1.9.14 ************ |
4 | 17 | ||
5 | Fixed some problems with the dialog sizes when switching | 18 | Fixed some problems with the dialog sizes when switching |
6 | portrait/landscape mode on 640x480 PDA display. | 19 | portrait/landscape mode on 640x480 PDA display. |
7 | 20 | ||
8 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. | 21 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. |
9 | 22 | ||
10 | Fixed an ugly bug in KOpieMail: | 23 | Fixed an ugly bug in KOpieMail: |
11 | KOpieMail was not able to write files (mails) to MSDOS file system, | 24 | KOpieMail was not able to write files (mails) to MSDOS file system, |
12 | like on an usual preformatted SD card. That should work now. | 25 | like on an usual preformatted SD card. That should work now. |
13 | To save your mail data on the Sd card do the following: | 26 | To save your mail data on the Sd card do the following: |
14 | Create a dir on the SD card: | 27 | Create a dir on the SD card: |
15 | mkdir /mnt/card/localmail | 28 | mkdir /mnt/card/localmail |
16 | Go to your home dir: | 29 | Go to your home dir: |
17 | cd | 30 | cd |
18 | Go to kopiemail data storage dir: | 31 | Go to kopiemail data storage dir: |
19 | cd kdepim/apps/kopiemail | 32 | cd kdepim/apps/kopiemail |
20 | Create a symlink to the SD card: | 33 | Create a symlink to the SD card: |
21 | ls -s /mnt/card/localmail | 34 | ls -s /mnt/card/localmail |
22 | Now KOpieMail will store all mails on the SD card. | 35 | Now KOpieMail will store all mails on the SD card. |
23 | 36 | ||
24 | KO/Pi Monthview: | 37 | KO/Pi Monthview: |
25 | Now "Go to Today" selects the current month from day 1-end, | 38 | Now "Go to Today" selects the current month from day 1-end, |
26 | not the current date + some days. | 39 | not the current date + some days. |
27 | I.e. "Go to Today" shows now always | 40 | I.e. "Go to Today" shows now always |
28 | the current month with first day of month in the first row. | 41 | the current month with first day of month in the first row. |
29 | 42 | ||
30 | Added missing German translation. | 43 | Added missing German translation. |
31 | 44 | ||
32 | Fixed icons of executeable on Wintendo. | 45 | Fixed icons of executeable on Wintendo. |
33 | 46 | ||
34 | Added a "Show next Mail" button to the OM/Pi | 47 | Added a "Show next Mail" button to the OM/Pi |
35 | mail viewer such that the mail below the current mail | 48 | mail viewer such that the mail below the current mail |
36 | in the mail list view of the current folder | 49 | in the mail list view of the current folder |
37 | can be read with a single click. | 50 | can be read with a single click. |
38 | 51 | ||
39 | 52 | ||
40 | ********** VERSION 1.9.13 ************ | 53 | ********** VERSION 1.9.13 ************ |
41 | 54 | ||
42 | Fixed nasty PwM/Pi file reading bug, when | 55 | Fixed nasty PwM/Pi file reading bug, when |
43 | the used hash algo of file is different then the global | 56 | the used hash algo of file is different then the global |
44 | hash algo. | 57 | hash algo. |
45 | 58 | ||
46 | Added KA/Pi support for opie mailit mailapplication. | 59 | Added KA/Pi support for opie mailit mailapplication. |
47 | 60 | ||
48 | Fixed some bugs in OM/Pi. | 61 | Fixed some bugs in OM/Pi. |
49 | Now character conversion tables are available for the Zaurus | 62 | Now character conversion tables are available for the Zaurus |
50 | to make OM/Pi working properly. | 63 | to make OM/Pi working properly. |
51 | To get the character conversion in OM/Pi working, please download | 64 | To get the character conversion in OM/Pi working, please download |
52 | at the sourceforge project site the package | 65 | at the sourceforge project site the package |
53 | sr-character-conversion_SharpROM_arm.ipk.zip | 66 | sr-character-conversion_SharpROM_arm.ipk.zip |
54 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) | 67 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) |
55 | from the section "general files for KDE/Pim" | 68 | from the section "general files for KDE/Pim" |
56 | Instructions how to install this package are in a ReadMe in this file. | 69 | Instructions how to install this package are in a ReadMe in this file. |
57 | 70 | ||
58 | 71 | ||
59 | Fixed the orientation change problem in KA/Pi when switching | 72 | Fixed the orientation change problem in KA/Pi when switching |
60 | portrait/landscape mode. | 73 | portrait/landscape mode. |
61 | 74 | ||
62 | French translation available for KA/Pi and OM/Pi. | 75 | French translation available for KA/Pi and OM/Pi. |
63 | 76 | ||
64 | Fixed some problems with categories in KO/Pi in DTM sync. | 77 | Fixed some problems with categories in KO/Pi in DTM sync. |
65 | 78 | ||
66 | Added selection dialog for export to phone in KA/Pi. | 79 | Added selection dialog for export to phone in KA/Pi. |
67 | 80 | ||
68 | If in KO/Pi is an attendee selected to add to a meeting and this | 81 | If in KO/Pi is an attendee selected to add to a meeting and this |
69 | attendee is already in the list of attendees, this person is not added | 82 | attendee is already in the list of attendees, this person is not added |
70 | again. | 83 | again. |
71 | 84 | ||
72 | Some menu cleanup in KA/Pi. | 85 | Some menu cleanup in KA/Pi. |
73 | 86 | ||
74 | ********** VERSION 1.9.12 ************ | 87 | ********** VERSION 1.9.12 ************ |
75 | 88 | ||
76 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. | 89 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. |
77 | 90 | ||
78 | Bugfix: Licence file is now shown again. | 91 | Bugfix: Licence file is now shown again. |
79 | 92 | ||
80 | OM/Pi now supports Unicode (utf8 charset). | 93 | OM/Pi now supports Unicode (utf8 charset). |
81 | Fixed some bugs in OM/Pi. | 94 | Fixed some bugs in OM/Pi. |
82 | 95 | ||
83 | KA/Pi has more German translation. | 96 | KA/Pi has more German translation. |
84 | 97 | ||
85 | 98 | ||
86 | ********** VERSION 1.9.11 ************ | 99 | ********** VERSION 1.9.11 ************ |
87 | 100 | ||
88 | Fixed several problems in PWM/Pi, like | 101 | Fixed several problems in PWM/Pi, like |
89 | asking the user, if unsaved changed are pending | 102 | asking the user, if unsaved changed are pending |
90 | when closing the app. | 103 | when closing the app. |
91 | And PwM/Pi handles now different texts for the | 104 | And PwM/Pi handles now different texts for the |
92 | fields Description, Username, Password, configurable per category. | 105 | fields Description, Username, Password, configurable per category. |
93 | 106 | ||
94 | Fixed a crash in KO/Pi , when importing/loading vcs files | 107 | Fixed a crash in KO/Pi , when importing/loading vcs files |
95 | which have an entry with an attendee with state: | 108 | which have an entry with an attendee with state: |
96 | NEEDS ACTION | 109 | NEEDS ACTION |
97 | 110 | ||
98 | Fixed some problems in the German translation of OM/Pi, | 111 | Fixed some problems in the German translation of OM/Pi, |
99 | which makes some dialogs not fitting on the screen | 112 | which makes some dialogs not fitting on the screen |
100 | of the Z 5500. | 113 | of the Z 5500. |
101 | 114 | ||
102 | Fixed Qtopia crash, when disabling/deinstalling | 115 | Fixed Qtopia crash, when disabling/deinstalling |
103 | KO/Pi alarm applet. | 116 | KO/Pi alarm applet. |
104 | 117 | ||
105 | Implemented direct KDE<->KA/Pi sync for KA/Pi running | 118 | Implemented direct KDE<->KA/Pi sync for KA/Pi running |
106 | on Linux desktop. | 119 | on Linux desktop. |
107 | 120 | ||
108 | Added feature "remove sync info" to sync menu. | 121 | Added feature "remove sync info" to sync menu. |
109 | 122 | ||
110 | Tweaked the KO/Pi What's next view a bit, added | 123 | Tweaked the KO/Pi What's next view a bit, added |
111 | setting to hide events that are done. | 124 | setting to hide events that are done. |
112 | 125 | ||
113 | Disabled "beam receive enabled" on startup to | 126 | Disabled "beam receive enabled" on startup to |
114 | avoid problems if Fastload is enabled. | 127 | avoid problems if Fastload is enabled. |
115 | Please set "beam receive enabled", | 128 | Please set "beam receive enabled", |
116 | if you want to receive data via IR. | 129 | if you want to receive data via IR. |
117 | 130 | ||
118 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running | 131 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running |
119 | on Linux desktop. | 132 | on Linux desktop. |
120 | 133 | ||
121 | Made in KA/Pi scrolling possible, if details view is selected. | 134 | Made in KA/Pi scrolling possible, if details view is selected. |
122 | (The keyboard focus is set automatically to the search line) | 135 | (The keyboard focus is set automatically to the search line) |
123 | 136 | ||
124 | Fixed a bug in DMT sync, that a new entry in DTM was added | 137 | Fixed a bug in DMT sync, that a new entry in DTM was added |
125 | on every sync to Kx/Pi. | 138 | on every sync to Kx/Pi. |
126 | 139 | ||
127 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. | 140 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. |
128 | 141 | ||
129 | Fixed a bug in DMT sync with todos created in KO/Pi containing | 142 | Fixed a bug in DMT sync with todos created in KO/Pi containing |
130 | non-latin1 characters. | 143 | non-latin1 characters. |
131 | 144 | ||
132 | Rearranged package contents of Sharp-ipks and made all | 145 | Rearranged package contents of Sharp-ipks and made all |
133 | packages installable on SD again. | 146 | packages installable on SD again. |
134 | 147 | ||
135 | Fixed the writing of addressbook data in DTM sync. | 148 | Fixed the writing of addressbook data in DTM sync. |
136 | Empty fields in KA/Pi were not removed. | 149 | Empty fields in KA/Pi were not removed. |
137 | 150 | ||
138 | Added better category handling in KA/Pi: | 151 | Added better category handling in KA/Pi: |
139 | Added item | 152 | Added item |
140 | Edit Categories and | 153 | Edit Categories and |
141 | Manage new categories | 154 | Manage new categories |
142 | to the settings menu. | 155 | to the settings menu. |
143 | Possible to configure a view to display categories. | 156 | Possible to configure a view to display categories. |
144 | 157 | ||
145 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. | 158 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. |
146 | 159 | ||
147 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. | 160 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. |
148 | 161 | ||
149 | ... and many other bugfixes. | 162 | ... and many other bugfixes. |
150 | 163 | ||
151 | ********** VERSION 1.9.10 ************ | 164 | ********** VERSION 1.9.10 ************ |
152 | 165 | ||
153 | Many internal small bugfixes. | 166 | Many internal small bugfixes. |
154 | And fix of the "big" bug in KO/Pi, | 167 | And fix of the "big" bug in KO/Pi, |
155 | that after Syncing the appointments had an offset by several hours. | 168 | that after Syncing the appointments had an offset by several hours. |
156 | That was a problem with the internal timezone setting, | 169 | That was a problem with the internal timezone setting, |
157 | introduced by the changed timezone configuration settings. | 170 | introduced by the changed timezone configuration settings. |
158 | 171 | ||
159 | German translation for OM/Pi is now available. | 172 | German translation for OM/Pi is now available. |
160 | 173 | ||
161 | 174 | ||
162 | ********** VERSION 1.9.9 ************ | 175 | ********** VERSION 1.9.9 ************ |
163 | 176 | ||
164 | KDE-Pim/Pi has a new Member! | 177 | KDE-Pim/Pi has a new Member! |
165 | It is called PWM/Pi (Passwordmanager/platform-independent) | 178 | It is called PWM/Pi (Passwordmanager/platform-independent) |
166 | and it is available for the Zaurus. | 179 | and it is available for the Zaurus. |
167 | It is planned, that it will be available later for Windows. | 180 | It is planned, that it will be available later for Windows. |
168 | (And for Linux, of course). | 181 | (And for Linux, of course). |
169 | It is a port of the Passwordmanager of KDE. | 182 | It is a port of the Passwordmanager of KDE. |
170 | It will need the MicroKDElibs to run. | 183 | It will need the MicroKDElibs to run. |
171 | 184 | ||
172 | Made loading of addressbooks in KA/Pi up to 7 times faster! | 185 | Made loading of addressbooks in KA/Pi up to 7 times faster! |
173 | The bigger your addressbook file, the more starting speed | 186 | The bigger your addressbook file, the more starting speed |
174 | will you gain. (relatively) | 187 | will you gain. (relatively) |
175 | 188 | ||
176 | The Qtopia addressbook connector is now platform independend | 189 | The Qtopia addressbook connector is now platform independend |
177 | as well and should work on any platform for importing/exporting | 190 | as well and should work on any platform for importing/exporting |
178 | Qtopia and Opie XML files. | 191 | Qtopia and Opie XML files. |
179 | 192 | ||
180 | Added a +30min feature to the timezone settings to make | 193 | Added a +30min feature to the timezone settings to make |
181 | KDE-Pim/Pi useable in Australia and other parts on the | 194 | KDE-Pim/Pi useable in Australia and other parts on the |
182 | world with strange timezones ;-) | 195 | world with strange timezones ;-) |
183 | 196 | ||
184 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. | 197 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. |
185 | 198 | ||
186 | It is now possible to disable the | 199 | It is now possible to disable the |
187 | "receive data via infrared" feature, such that syncing with | 200 | "receive data via infrared" feature, such that syncing with |
188 | Outlook is now possible again with Kx/Pi runing. | 201 | Outlook is now possible again with Kx/Pi runing. |
189 | Please disable it, before syncing Sharp DTM with Outlook. | 202 | Please disable it, before syncing Sharp DTM with Outlook. |
190 | For your convenience, the "receive data via infrared" feature | 203 | For your convenience, the "receive data via infrared" feature |
191 | is disabled automatically, if you sync Kx/Pi with DTM. | 204 | is disabled automatically, if you sync Kx/Pi with DTM. |
192 | You have to enable it again manually after syncing. | 205 | You have to enable it again manually after syncing. |
193 | Enabling this feature makes it impossible to start the | 206 | Enabling this feature makes it impossible to start the |
194 | Sharp DTM apps. If this feature is enabled, you will only get the | 207 | Sharp DTM apps. If this feature is enabled, you will only get the |
195 | alarm notification from KO/Pi and not from the Sharp calendar. | 208 | alarm notification from KO/Pi and not from the Sharp calendar. |
196 | This is very useful if you sync KO/Pi with Sharp DTM, | 209 | This is very useful if you sync KO/Pi with Sharp DTM, |
197 | because after syncing you usually would get notified about | 210 | because after syncing you usually would get notified about |
198 | an alarm by KO/Pi and the Sharp Calendar. | 211 | an alarm by KO/Pi and the Sharp Calendar. |
199 | 212 | ||
200 | Together with the Linux desktop version of KO/Pi | 213 | Together with the Linux desktop version of KO/Pi |
201 | it is now possible to sync KO/Pi on the Zaurus | 214 | it is now possible to sync KO/Pi on the Zaurus |
202 | with the complete KDE-desktop (3.3 or later) | 215 | with the complete KDE-desktop (3.3 or later) |
203 | calendar data easily. | 216 | calendar data easily. |
204 | That makes it possible to sync the Z with one | 217 | That makes it possible to sync the Z with one |
205 | click of a mouse with the KDE-Desktop. | 218 | click of a mouse with the KDE-Desktop. |
206 | This feature it available for all Zaurus platforms KO/Pi | 219 | This feature it available for all Zaurus platforms KO/Pi |
207 | is running on. | 220 | is running on. |
208 | The only thing needed is a running KO/Pi on Linux and | 221 | The only thing needed is a running KO/Pi on Linux and |
209 | a compiled version of the small | 222 | a compiled version of the small |
210 | KDE-Pim/Pi<->KDE-Desktop access command line program, | 223 | KDE-Pim/Pi<->KDE-Desktop access command line program, |
211 | which is in the KDE-Pim/Pi sources available. | 224 | which is in the KDE-Pim/Pi sources available. |
212 | 225 | ||
213 | The "KDE-desktop" syncing feature for KA/Pi will follow | 226 | The "KDE-desktop" syncing feature for KA/Pi will follow |
214 | in the next releases. | 227 | in the next releases. |
215 | 228 | ||
216 | Fixed the vcard export bug, which had the version 1.9.8. | 229 | Fixed the vcard export bug, which had the version 1.9.8. |
217 | 230 | ||
218 | Added missing GERMAN translation to KO/Pi. | 231 | Added missing GERMAN translation to KO/Pi. |
219 | Hi PsionX, could you add the missing french translation?Thx! | 232 | Hi PsionX, could you add the missing french translation?Thx! |
220 | 233 | ||
221 | Translation files for KA/Pi are available as well. | 234 | Translation files for KA/Pi are available as well. |
222 | GERMAN translation will be available in the next release. | 235 | GERMAN translation will be available in the next release. |
223 | PsionX ( yres, you again ;-) ), could you start translating | 236 | PsionX ( yres, you again ;-) ), could you start translating |
224 | KA/Pi? Thx! | 237 | KA/Pi? Thx! |
225 | 238 | ||
226 | You can download the version 1.9.9 at | 239 | You can download the version 1.9.9 at |
227 | 240 | ||
228 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 241 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 |
229 | 242 | ||
230 | Note: | 243 | Note: |
231 | To run the mail program OM/Pi you need libopenssl. | 244 | To run the mail program OM/Pi you need libopenssl. |
232 | A link to a download loaction is available at | 245 | A link to a download loaction is available at |
233 | ZSI at www.killefiz.de | 246 | ZSI at www.killefiz.de |
234 | 247 | ||
235 | 248 | ||
236 | ********** VERSION 1.9.8 ************ | 249 | ********** VERSION 1.9.8 ************ |
237 | 250 | ||
238 | Fixed character decoding in OM/Pi. | 251 | Fixed character decoding in OM/Pi. |
239 | (e.g. German "Umlaute" were not displayed properly.) | 252 | (e.g. German "Umlaute" were not displayed properly.) |
240 | 253 | ||
241 | Made is possible to reparent todos in KO/Pi. | 254 | Made is possible to reparent todos in KO/Pi. |
242 | Use contextmenu or keys (look at Help-Keys + Colors) for that. | 255 | Use contextmenu or keys (look at Help-Keys + Colors) for that. |
243 | 256 | ||
244 | Added the missing Sync-Howto and WhatsNew to the packages. | 257 | Added the missing Sync-Howto and WhatsNew to the packages. |
245 | 258 | ||
246 | KO/Pi on Linux desktop can now sync with KDE desktop. | 259 | KO/Pi on Linux desktop can now sync with KDE desktop. |
247 | That means: When using KO/Pi on Linux desktop for syncing with | 260 | That means: When using KO/Pi on Linux desktop for syncing with |
248 | KDE desktop and the Zaurus, the Zaurus can be synced now | 261 | KDE desktop and the Zaurus, the Zaurus can be synced now |
249 | with all KDE-Calendar resources, not only with one local file. | 262 | with all KDE-Calendar resources, not only with one local file. |
250 | (That makes it possible to sync the Zaurus with the | 263 | (That makes it possible to sync the Zaurus with the |
251 | calendar data on a Kolab server) | 264 | calendar data on a Kolab server) |
252 | 265 | ||
253 | KA/Pi syncing with KDE desktop will be available in the next version. | 266 | KA/Pi syncing with KDE desktop will be available in the next version. |
254 | 267 | ||
255 | 268 | ||
256 | ********** VERSION 1.9.7 ************ | 269 | ********** VERSION 1.9.7 ************ |
257 | 270 | ||
258 | KO/Pi - KA/Pi on Windows: | 271 | KO/Pi - KA/Pi on Windows: |
259 | Now a directory can be defined by the user, where the | 272 | Now a directory can be defined by the user, where the |
260 | application/config data should be saved. | 273 | application/config data should be saved. |
261 | Define your desired path in the evironment variable | 274 | Define your desired path in the evironment variable |
262 | MICROKDEHOME | 275 | MICROKDEHOME |
263 | before starting KO/Pi or KA/Pi. | 276 | before starting KO/Pi or KA/Pi. |
264 | 277 | ||
265 | An easy Kx/Pi to Kx/Pi syncing is now possible | 278 | An easy Kx/Pi to Kx/Pi syncing is now possible |
266 | (it is called Pi-Sync) via network. | 279 | (it is called Pi-Sync) via network. |
267 | Please look at the Sync Howto. | 280 | Please look at the Sync Howto. |
268 | 281 | ||
269 | Exporting of calendar data and contacts to mobile phones is now possible. | 282 | Exporting of calendar data and contacts to mobile phones is now possible. |
270 | The SyncHowto is updated with information howto | 283 | The SyncHowto is updated with information howto |
271 | access/sync mobile phones. | 284 | access/sync mobile phones. |
272 | Please look at the Sync Howto. | 285 | Please look at the Sync Howto. |
273 | 286 | ||
274 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. | 287 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. |
275 | Please disable Fastload for the original contact/calendar applications | 288 | Please disable Fastload for the original contact/calendar applications |
276 | and close them. | 289 | and close them. |
277 | KO/Pi and KA/Pi must be running in order to receive the data. | 290 | KO/Pi and KA/Pi must be running in order to receive the data. |
278 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) | 291 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) |
279 | 292 | ||
280 | In the KA/Pi details view are now the preferred tel. numbers displayed on top | 293 | In the KA/Pi details view are now the preferred tel. numbers displayed on top |
281 | of the other data ( emails/tel.numbers/addresses) | 294 | of the other data ( emails/tel.numbers/addresses) |
282 | 295 | ||
283 | Fixed some syncing problems in KA/Pi. | 296 | Fixed some syncing problems in KA/Pi. |
284 | 297 | ||
285 | Added font settings for the KA/Pi details view. | 298 | Added font settings for the KA/Pi details view. |
286 | Added fields "children's name" and "gender" to KA/Pi. | 299 | Added fields "children's name" and "gender" to KA/Pi. |
287 | 300 | ||
288 | Made searching in KA/Pi better: | 301 | Made searching in KA/Pi better: |
289 | Now the first item in a view is selected after a search automatically and | 302 | Now the first item in a view is selected after a search automatically and |
290 | the views can be scrolled up/down when the search input field has the keyboard focus. | 303 | the views can be scrolled up/down when the search input field has the keyboard focus. |
291 | 304 | ||
292 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. | 305 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. |
293 | 306 | ||
294 | 307 | ||
295 | ********** VERSION 1.9.6 ************ | 308 | ********** VERSION 1.9.6 ************ |
296 | 309 | ||
297 | Changes in the external application communication on the Zaurus | 310 | Changes in the external application communication on the Zaurus |
298 | in order to use less RAM when the apps are running. | 311 | in order to use less RAM when the apps are running. |
299 | First syncing of addressbooks (KA/Pi) is possible. | 312 | First syncing of addressbooks (KA/Pi) is possible. |
300 | 313 | ||
301 | 314 | ||
302 | ********** VERSION 1.9.5a ************ | 315 | ********** VERSION 1.9.5a ************ |
303 | 316 | ||
304 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. | 317 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. |
305 | Fixed some small bugs. | 318 | Fixed some small bugs. |
306 | KA/Pi shows now the birthday in summary view. | 319 | KA/Pi shows now the birthday in summary view. |
307 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi | 320 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi |
308 | for displaying dates. | 321 | for displaying dates. |
309 | 322 | ||
310 | 323 | ||
311 | ********** VERSION 1.9.5 ************ | 324 | ********** VERSION 1.9.5 ************ |
312 | 325 | ||
313 | There is still no Addressbook syncing! | 326 | There is still no Addressbook syncing! |
314 | 327 | ||
315 | New in 1.9.5: | 328 | New in 1.9.5: |
316 | 329 | ||
317 | Many bugfixes. | 330 | Many bugfixes. |
318 | Better searching in KA/Pi. | 331 | Better searching in KA/Pi. |
319 | You can configure in KA/Pi if you want to search only after | 332 | You can configure in KA/Pi if you want to search only after |
320 | <return> key pressed. | 333 | <return> key pressed. |
321 | 334 | ||
322 | Better mail downloading in OM/Pi. | 335 | Better mail downloading in OM/Pi. |
323 | 336 | ||
324 | First experimental alpha version of sync of KO/Pi with mobile phones. | 337 | First experimental alpha version of sync of KO/Pi with mobile phones. |
325 | See gammu documentation for supported phones. | 338 | See gammu documentation for supported phones. |
326 | You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. | 339 | You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. |
327 | Quick hint how to use: | 340 | Quick hint how to use: |
328 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! | 341 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! |
329 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. | 342 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. |
330 | Create syncprofile - mobile device | 343 | Create syncprofile - mobile device |
331 | Remove entry for model. (Leave empty ). | 344 | Remove entry for model. (Leave empty ). |
332 | Enable infrared on Zaurus and your Phone. | 345 | Enable infrared on Zaurus and your Phone. |
333 | Sync. | 346 | Sync. |
334 | To get a more detailed log, start kopi from konsole. | 347 | To get a more detailed log, start kopi from konsole. |
335 | 348 | ||
336 | ********** VERSION 1.9.4 ************ | 349 | ********** VERSION 1.9.4 ************ |
337 | 350 | ||
338 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. | 351 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. |
339 | 352 | ||
340 | WARNING: | 353 | WARNING: |
341 | PLEASE BACKUP ALL YOUR DATA! | 354 | PLEASE BACKUP ALL YOUR DATA! |
342 | We have changed a lot and maybe there are some unknown problems. | 355 | We have changed a lot and maybe there are some unknown problems. |
343 | 356 | ||
344 | SYNC HANDLING HAS CHANGED! | 357 | SYNC HANDLING HAS CHANGED! |
345 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 358 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
346 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 359 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
347 | 360 | ||
348 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. | 361 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. |
349 | If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. | 362 | If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. |
350 | 363 | ||
351 | As programs are available: | 364 | As programs are available: |
352 | KO/Pi (korganizer ipk) - a calendar program. | 365 | KO/Pi (korganizer ipk) - a calendar program. |
353 | KA/Pi (kaddressbook ipk ) - an addressbook | 366 | KA/Pi (kaddressbook ipk ) - an addressbook |
354 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. | 367 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. |
355 | 368 | ||
356 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. | 369 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. |
357 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) | 370 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) |
358 | 371 | ||
359 | All the applications are installed in a "Pim" TAB. | 372 | All the applications are installed in a "Pim" TAB. |
360 | If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk | 373 | If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk |
361 | 374 | ||
362 | All the application are integrated. | 375 | All the application are integrated. |
363 | Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. | 376 | Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. |
364 | 377 | ||
365 | HINT: | 378 | HINT: |
366 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. | 379 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. |
367 | 380 | ||
368 | What's new? | 381 | What's new? |
369 | 382 | ||
370 | SYNC HANDLING HAS CHANGED! | 383 | SYNC HANDLING HAS CHANGED! |
371 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 384 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
372 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 385 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
373 | 386 | ||
374 | New in OM/Pi: | 387 | New in OM/Pi: |
375 | When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. | 388 | When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. |
376 | 389 | ||
377 | New in KO/Pi: | 390 | New in KO/Pi: |
378 | French is now available for KO/Pi. | 391 | French is now available for KO/Pi. |
379 | Choose menu:Actions - Configure:TAB locale | 392 | Choose menu:Actions - Configure:TAB locale |
380 | Syncing has changed. | 393 | Syncing has changed. |
381 | Phone sync available soon. | 394 | Phone sync available soon. |
382 | Not much changes, I cannot remember them ... | 395 | Not much changes, I cannot remember them ... |
383 | 396 | ||
384 | New in KA/Pi: | 397 | New in KA/Pi: |
385 | Beaming possible. | 398 | Beaming possible. |
386 | Sharp DTM readonly access possible( create a new DTM resource ); | 399 | Sharp DTM readonly access possible( create a new DTM resource ); |
387 | Better searching possible. | 400 | Better searching possible. |
388 | Search is performed only after pressing the return key. | 401 | Search is performed only after pressing the return key. |
389 | Use wildcard * to specify parts of a name. | 402 | Use wildcard * to specify parts of a name. |
390 | 403 | ||
391 | Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . | 404 | Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . |
392 | 405 | ||
393 | A big improvement is the new management of the contact access. | 406 | A big improvement is the new management of the contact access. |
394 | In version 1.9.3, every application was using their own addressbook access data. | 407 | In version 1.9.3, every application was using their own addressbook access data. |
395 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. | 408 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. |
396 | That was wasting of memory, if you had several hundreds of contacts. | 409 | That was wasting of memory, if you had several hundreds of contacts. |
397 | 410 | ||
398 | Now only KA/Pi accesses the addressbook. | 411 | Now only KA/Pi accesses the addressbook. |
399 | If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. | 412 | If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. |
400 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. | 413 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. |
401 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. | 414 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. |
402 | 415 | ||
403 | New in the KO/Pi alarm applet: | 416 | New in the KO/Pi alarm applet: |
404 | Configure your own timer popup menu! | 417 | Configure your own timer popup menu! |
405 | (Text and minutes for timer countdown) | 418 | (Text and minutes for timer countdown) |
406 | Just edit the file | 419 | Just edit the file |
407 | (yourhomedir)/.kopialarmtimerrc | 420 | (yourhomedir)/.kopialarmtimerrc |
408 | and start/stop a timer to get a new menu with the data of this file. | 421 | and start/stop a timer to get a new menu with the data of this file. |
409 | 422 | ||
410 | ********** VERSION 1.9.3 ************ | 423 | ********** VERSION 1.9.3 ************ |
411 | 1) | 424 | 1) |
412 | Now KO/Pi on Windows imports directly the calendar data of | 425 | Now KO/Pi on Windows imports directly the calendar data of |
413 | an installed Outlook. Should work with OL version >= 2000. | 426 | an installed Outlook. Should work with OL version >= 2000. |
414 | 427 | ||
415 | ********** VERSION 1.9.2 ************ | 428 | ********** VERSION 1.9.2 ************ |
416 | 1) | 429 | 1) |
417 | KDE-Pim/Pi has got a new member: | 430 | KDE-Pim/Pi has got a new member: |
418 | KmicroMail (KM/Pi) is a mail program, | 431 | KmicroMail (KM/Pi) is a mail program, |
419 | which can handle IMAP and POP mail access. | 432 | which can handle IMAP and POP mail access. |
420 | It is based on Opie-Mail v3. | 433 | It is based on Opie-Mail v3. |
421 | All dependencies to the Opie libraries ar removed, | 434 | All dependencies to the Opie libraries ar removed, |
422 | such that no additional Opie lib is needed. | 435 | such that no additional Opie lib is needed. |
423 | It is already integrated in KO/Pi and KA/Pi. | 436 | It is already integrated in KO/Pi and KA/Pi. |
424 | It it now available for the Zaurus,probably it | 437 | It it now available for the Zaurus,probably it |
425 | will be available for other platforms later. | 438 | will be available for other platforms later. |
426 | Hint: | 439 | Hint: |
427 | Create your own contact (name + email) | 440 | Create your own contact (name + email) |
428 | in KA/Pi, select this contact and choose menu: | 441 | in KA/Pi, select this contact and choose menu: |
429 | Settings - Set Who Am I. | 442 | Settings - Set Who Am I. |
430 | Now the settings of this contact are used as | 443 | Now the settings of this contact are used as |
431 | the sender data in KM/Pi. | 444 | the sender data in KM/Pi. |
432 | 2) | 445 | 2) |
433 | KDE-Pim/Pi is split up in five different | 446 | KDE-Pim/Pi is split up in five different |
434 | packages now precompiled for Sharp Zaurus: | 447 | packages now precompiled for Sharp Zaurus: |
435 | --kmicrokdelibs_1.9.2_arm.ipk | 448 | --kmicrokdelibs_1.9.2_arm.ipk |
436 | The libs are needed for any | 449 | The libs are needed for any |
437 | of the following programs: | 450 | of the following programs: |
438 | --kaddressbook_1.9.2_arm.ipk | 451 | --kaddressbook_1.9.2_arm.ipk |
439 | --kmicromail_1.9.2_arm.ipk | 452 | --kmicromail_1.9.2_arm.ipk |
440 | --korganizer_1.9.2_arm.ipk | 453 | --korganizer_1.9.2_arm.ipk |
441 | Independ from that, there is the alarm applet | 454 | Independ from that, there is the alarm applet |
442 | available for KO/Pi, which also offers | 455 | available for KO/Pi, which also offers |
443 | quick access for a new mail or | 456 | quick access for a new mail or |
444 | showing the addressbook.: | 457 | showing the addressbook.: |
445 | --korganizer-alarm_1.9.2_arm.ipk | 458 | --korganizer-alarm_1.9.2_arm.ipk |
446 | Independend means, that the alarm applet | 459 | Independend means, that the alarm applet |
447 | does not need any of the libs or programs above to run. | 460 | does not need any of the libs or programs above to run. |
448 | But it would be quite useless without these programs. | 461 | But it would be quite useless without these programs. |
449 | NOTE: | 462 | NOTE: |
450 | If you get a | 463 | If you get a |
451 | "This application depends on other programs" | 464 | "This application depends on other programs" |
452 | during installation of | 465 | during installation of |
453 | --kmicrokdelibs_1.9.2_arm.ipk | 466 | --kmicrokdelibs_1.9.2_arm.ipk |
454 | you probably do not have to care about that. | 467 | you probably do not have to care about that. |
455 | kmicrokdelibs_1.9.2 will come with some | 468 | kmicrokdelibs_1.9.2 will come with some |
456 | resource plugins, which needs additional libraries. | 469 | resource plugins, which needs additional libraries. |
457 | (E.g. libopie1, if you want to use the | 470 | (E.g. libopie1, if you want to use the |
458 | opie resource connector in KA/Pi). | 471 | opie resource connector in KA/Pi). |
459 | If you do not have this libraries installed, | 472 | If you do not have this libraries installed, |
460 | you simply cannot use the resource. | 473 | you simply cannot use the resource. |
461 | To make it clear: | 474 | To make it clear: |
462 | If the libraries are missing, the applications | 475 | If the libraries are missing, the applications |
463 | using kmicrokdelibs will start, | 476 | using kmicrokdelibs will start, |
464 | because the resources are plugins. | 477 | because the resources are plugins. |
465 | 3) | 478 | 3) |
466 | KO/Pi and friends are now installable on SD-Card! | 479 | KO/Pi and friends are now installable on SD-Card! |
467 | It is recommended to install all libs and apps | 480 | It is recommended to install all libs and apps |
468 | on the SD card or all in the internal storage. | 481 | on the SD card or all in the internal storage. |
469 | There may be problems, if this is mixed. | 482 | There may be problems, if this is mixed. |
470 | 4) | 483 | 4) |
471 | Fixed two bugs in the alarm notification on Windows. | 484 | Fixed two bugs in the alarm notification on Windows. |
472 | 5) | 485 | 5) |
473 | Great improvement! | 486 | Great improvement! |
474 | KO/Pi uses now the latest version of libical. | 487 | KO/Pi uses now the latest version of libical. |
475 | Libical is the library which actually reads | 488 | Libical is the library which actually reads |
476 | the calendar files and extract the data from it. | 489 | the calendar files and extract the data from it. |
477 | With the old version, there were problems | 490 | With the old version, there were problems |
478 | (crashes or program hangs) when licical did read | 491 | (crashes or program hangs) when licical did read |
479 | files, which were not stored from KO/Pi. | 492 | files, which were not stored from KO/Pi. |
480 | I do not know, if the new libical works perfect, | 493 | I do not know, if the new libical works perfect, |
481 | but actually it works much better than | 494 | but actually it works much better than |
482 | the old version. | 495 | the old version. |
483 | There are no problems with compatibility with | 496 | There are no problems with compatibility with |
484 | old calendar files of KO/Pi, of course! | 497 | old calendar files of KO/Pi, of course! |
485 | 6) | 498 | 6) |
486 | New in KA/Pi: | 499 | New in KA/Pi: |
487 | Opie addressbook resource connector available! | 500 | Opie addressbook resource connector available! |
488 | You will need libopie1 and the opie addressbook, | 501 | You will need libopie1 and the opie addressbook, |
489 | of course. | 502 | of course. |
490 | With the Opie addressbook resource connector, | 503 | With the Opie addressbook resource connector, |
491 | you can access the Opie addressbook readonly in KA/Pi. | 504 | you can access the Opie addressbook readonly in KA/Pi. |
492 | If you want to edit or import the data into KA/Pi, | 505 | If you want to edit or import the data into KA/Pi, |
493 | do this: | 506 | do this: |
494 | a) Create an Opie resource. | 507 | a) Create an Opie resource. |
495 | (Menu: Settings-Configure Resources). | 508 | (Menu: Settings-Configure Resources). |
496 | After configuration and restarting KA/Pi you should see | 509 | After configuration and restarting KA/Pi you should see |
497 | the Opie contacts in KA/Pi. | 510 | the Opie contacts in KA/Pi. |
498 | b) Select some or all Opie contacts. | 511 | b) Select some or all Opie contacts. |
499 | (NOTE: +++++ | 512 | (NOTE: +++++ |
500 | To know exactly, what contacts are Opie contacts, | 513 | To know exactly, what contacts are Opie contacts, |
501 | do this: Choose menu: | 514 | do this: Choose menu: |
502 | View-Modify View - TAB Fields. | 515 | View-Modify View - TAB Fields. |
503 | Select in the above list "Resource" and click | 516 | Select in the above list "Resource" and click |
504 | down arrow to add it to the "Selected fields". | 517 | down arrow to add it to the "Selected fields". |
505 | Click OK. | 518 | Click OK. |
506 | Now you have a new column "Resource" in your list, | 519 | Now you have a new column "Resource" in your list, |
507 | where you can see, what an Opie resource is. | 520 | where you can see, what an Opie resource is. |
508 | ++++ NOTE end.) | 521 | ++++ NOTE end.) |
509 | Ok, we do have now some Opie contacts seleted. | 522 | Ok, we do have now some Opie contacts seleted. |
510 | (Use SHIFT or CTRL key in order to multiple select). | 523 | (Use SHIFT or CTRL key in order to multiple select). |
511 | c) Choose menu: Edit-Copy. | 524 | c) Choose menu: Edit-Copy. |
512 | d) Choose menu: Edit-Paste. | 525 | d) Choose menu: Edit-Paste. |
513 | e) Select the resource, you want to add the contacts to. | 526 | e) Select the resource, you want to add the contacts to. |
514 | Congrats! Now you have read/write access to the copied | 527 | Congrats! Now you have read/write access to the copied |
515 | opie contacts as "real" KA/Pi contacts. | 528 | opie contacts as "real" KA/Pi contacts. |
516 | 529 | ||
517 | 530 | ||
518 | ********** VERSION 1.9.1 ************ | 531 | ********** VERSION 1.9.1 ************ |
519 | 1) | 532 | 1) |
520 | +++ IMPORTANT 1 +++ | 533 | +++ IMPORTANT 1 +++ |
521 | 534 | ||
522 | The storing place of the default calendar | 535 | The storing place of the default calendar |
523 | file has changed! | 536 | file has changed! |
524 | The default calendar file was | 537 | The default calendar file was |
525 | Applications/korganizer/mycalendar.ics | 538 | Applications/korganizer/mycalendar.ics |
526 | on Zaurus and | 539 | on Zaurus and |
527 | (yourHomeDir)/korganizer/mycalendar.ics | 540 | (yourHomeDir)/korganizer/mycalendar.ics |
528 | on Windows/Linux desktop. Now it is | 541 | on Windows/Linux desktop. Now it is |
529 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics | 542 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics |
530 | on Zaurus, Windows and Linux. | 543 | on Zaurus, Windows and Linux. |
531 | To load the old file, choose menu | 544 | To load the old file, choose menu |
532 | File-Load calendar backup. | 545 | File-Load calendar backup. |
533 | (It should be loaded automatically | 546 | (It should be loaded automatically |
534 | at startup with a warning message displayed). | 547 | at startup with a warning message displayed). |
535 | The place of the configuration file has changed too. | 548 | The place of the configuration file has changed too. |
536 | If you want to use your old KO/Pi config, | 549 | If you want to use your old KO/Pi config, |
537 | copy it to | 550 | copy it to |
538 | (yourHomeDir)/kdepim/config/korganizerrc | 551 | (yourHomeDir)/kdepim/config/korganizerrc |
539 | Please read VERSION 1.9.0 - topic 3) as well! | 552 | Please read VERSION 1.9.0 - topic 3) as well! |
540 | 553 | ||
541 | +++ IMPORTANT 2 +++ | 554 | +++ IMPORTANT 2 +++ |
542 | 555 | ||
543 | Because of the new paths, you will need | 556 | Because of the new paths, you will need |
544 | a new version of the KO/Pi alarm applet | 557 | a new version of the KO/Pi alarm applet |
545 | for Zaurus. | 558 | for Zaurus. |
546 | Use version >= 1.9.1 | 559 | Use version >= 1.9.1 |
547 | 560 | ||
548 | 2) | 561 | 2) |
549 | Now the QWhat'sThis Icon works for items | 562 | Now the QWhat'sThis Icon works for items |
550 | in the month view as well. | 563 | in the month view as well. |
551 | (See VERSION 1.7.8 Topic 1) ). | 564 | (See VERSION 1.7.8 Topic 1) ). |
552 | 3) | 565 | 3) |
553 | You can import birtsdays/anniversaries | 566 | You can import birtsdays/anniversaries |
554 | from KA/Pi into KO/Pi. | 567 | from KA/Pi into KO/Pi. |
555 | Choose menu File-Import birthdays. | 568 | Choose menu File-Import birthdays. |
556 | If you import twice, already imported items | 569 | If you import twice, already imported items |
557 | will not be imported again, if they | 570 | will not be imported again, if they |
558 | have not been changed in KO/Pi. | 571 | have not been changed in KO/Pi. |
559 | 4) | 572 | 4) |
560 | When syncing with sharp DTM, now a progress | 573 | When syncing with sharp DTM, now a progress |
561 | is shown, when the data is written back. | 574 | is shown, when the data is written back. |
562 | If there is much data in KO/Pi and no data | 575 | If there is much data in KO/Pi and no data |
563 | in DTM, that can take a long time. | 576 | in DTM, that can take a long time. |
564 | (But only for the first time ). | 577 | (But only for the first time ). |
565 | 5) | 578 | 5) |
566 | In the search dialog, you can search | 579 | In the search dialog, you can search |
567 | now for the name/email of an attendee | 580 | now for the name/email of an attendee |
568 | of an event/todo. | 581 | of an event/todo. |
569 | To get more space for displaying | 582 | To get more space for displaying |
570 | search results, the buttons | 583 | search results, the buttons |
571 | for "search" and "close" on the | 584 | for "search" and "close" on the |
572 | bottom are removed in the PDA version. | 585 | bottom are removed in the PDA version. |
573 | You have to click OK in the top right | 586 | You have to click OK in the top right |
574 | corner to do a search. | 587 | corner to do a search. |
575 | 6) | 588 | 6) |
576 | Now it is possible to disable the displaying | 589 | Now it is possible to disable the displaying |
577 | of todo items in the Allday part of the Agenda. | 590 | of todo items in the Allday part of the Agenda. |
578 | Choose Menu Action-Configure, | 591 | Choose Menu Action-Configure, |
579 | TAB Todo View, checkbox | 592 | TAB Todo View, checkbox |
580 | "Allday Agenda view shows todos" | 593 | "Allday Agenda view shows todos" |
581 | 7) | 594 | 7) |
582 | If FastLoad is enabled, now the settings and the | 595 | If FastLoad is enabled, now the settings and the |
583 | calendar data are saved, when KO/Pi is closed. | 596 | calendar data are saved, when KO/Pi is closed. |
584 | (If no Fastload is enabled, KO/Pi saves | 597 | (If no Fastload is enabled, KO/Pi saves |
585 | the data as well, of course) | 598 | the data as well, of course) |
586 | 8) | 599 | 8) |
587 | The Agenda View has a minimize-splitter now, | 600 | The Agenda View has a minimize-splitter now, |
588 | such that the height of the allday part can be | 601 | such that the height of the allday part can be |
589 | changed quickly. | 602 | changed quickly. |
590 | 603 | ||
591 | ********** VERSION 1.9.0 ************ | 604 | ********** VERSION 1.9.0 ************ |
592 | 1) | 605 | 1) |
593 | KO/Pi is now merged with the new microKDE from KA/Pi. | 606 | KO/Pi is now merged with the new microKDE from KA/Pi. |
594 | KO/Pi accesses now KA/Pi as the addressbook. | 607 | KO/Pi accesses now KA/Pi as the addressbook. |
595 | The other ddressbook-plugins are not working any longer. | 608 | The other ddressbook-plugins are not working any longer. |
596 | (It is planned, that later KA/Pi itself uses these plugins) | 609 | (It is planned, that later KA/Pi itself uses these plugins) |
597 | New versions of KO/Pi are only available | 610 | New versions of KO/Pi are only available |
598 | together with KA/Pi as the KDE-Pim/Pi package. | 611 | together with KA/Pi as the KDE-Pim/Pi package. |
599 | 2) | 612 | 2) |
600 | If you click on an attendee of a meeting in the | 613 | If you click on an attendee of a meeting in the |
601 | event viewer, a detailed summary of the | 614 | event viewer, a detailed summary of the |
602 | attendee is shown. | 615 | attendee is shown. |
603 | 3) | 616 | 3) |
604 | The place of the configuration file has changed. | 617 | The place of the configuration file has changed. |
605 | If you want to use your old KO/Pi config, copy | 618 | If you want to use your old KO/Pi config, copy |
606 | Applications/korganizer/config_korganizerrc | 619 | Applications/korganizer/config_korganizerrc |
607 | to | 620 | to |
608 | Applications/korganizer/config/korganizerrc | 621 | Applications/korganizer/config/korganizerrc |
609 | 622 | ||
610 | ********** VERSION 1.7.8 ************ | 623 | ********** VERSION 1.7.8 ************ |
611 | 1) | 624 | 1) |
612 | Now the QWhat'sThis ist working. | 625 | Now the QWhat'sThis ist working. |
613 | Enable the QWhat'sThis icon in the toolbar. | 626 | Enable the QWhat'sThis icon in the toolbar. |
614 | (You have to restart to reload the changed toolbar config). | 627 | (You have to restart to reload the changed toolbar config). |
615 | Now click on the QWhat'sThis Icon | 628 | Now click on the QWhat'sThis Icon |
616 | in the top right corner of KO/Pi. | 629 | in the top right corner of KO/Pi. |
617 | Then click on an item in the Agenda View: | 630 | Then click on an item in the Agenda View: |
618 | You will get a detailed display of the items content. | 631 | You will get a detailed display of the items content. |
619 | 2) | 632 | 2) |
620 | Some other very minor changes. | 633 | Some other very minor changes. |
621 | But I have forgotten the details ... | 634 | But I have forgotten the details ... |
622 | For that reason I start this log here: | 635 | For that reason I start this log here: |
623 | To document my changes, when I am doing it. | 636 | To document my changes, when I am doing it. |
624 | 637 | ||
625 | ********** VERSION 1.7.7 ************ | 638 | ********** VERSION 1.7.7 ************ |
626 | Stable Version of KO/Pi | 639 | Stable Version of KO/Pi |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 543897a..15c5dd9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3801 +1,3841 @@ | |||
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 (preston.brown@yale.edu) | 8 | Preston Brown (preston.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 "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | |||
495 | void CalendarView::showDay( QDate d ) | ||
496 | { | ||
497 | dateNavigator()->selectDate( d ); | ||
498 | mViewManager->showWeekView(); | ||
499 | dateNavigator()->selectDate( d ); | ||
500 | } | ||
494 | void CalendarView::timerAlarm() | 501 | void CalendarView::timerAlarm() |
495 | { | 502 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 503 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 504 | computeAlarm(mAlarmNotification ); |
498 | } | 505 | } |
499 | 506 | ||
500 | void CalendarView::suspendAlarm() | 507 | void CalendarView::suspendAlarm() |
501 | { | 508 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 509 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 510 | computeAlarm(mSuspendAlarmNotification ); |
504 | 511 | ||
505 | } | 512 | } |
506 | 513 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 514 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 515 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 516 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 517 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 518 | ||
512 | } | 519 | } |
513 | 520 | ||
514 | void CalendarView::checkNextTimerAlarm() | 521 | void CalendarView::checkNextTimerAlarm() |
515 | { | 522 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 523 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 524 | } |
518 | 525 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 526 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 527 | { |
521 | 528 | ||
522 | QString mess = msg; | 529 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 530 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 531 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 532 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 533 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 534 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 535 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 536 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 537 | if ( len < 2 ) |
531 | error = true; | 538 | error = true; |
532 | else { | 539 | else { |
533 | tempfilename = mess.mid( 13, len ); | 540 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 542 | error = true; |
536 | } | 543 | } |
537 | if ( ! error ) { | 544 | if ( ! error ) { |
538 | filename = tempfilename; | 545 | filename = tempfilename; |
539 | } | 546 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 547 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 548 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 549 | startAlarm( mAlarmMessage, filename); |
543 | return; | 550 | return; |
544 | } | 551 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 552 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 553 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 554 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 555 | return; |
549 | } | 556 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 557 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 558 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 559 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 560 | if ( len < 2 ) |
554 | error = true; | 561 | error = true; |
555 | else { | 562 | else { |
556 | tempfilename = mess.mid( 10, len ); | 563 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 564 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 565 | error = true; |
559 | } | 566 | } |
560 | if ( error ) { | 567 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 568 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 569 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 570 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 571 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 572 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 573 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 574 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 575 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 576 | return; |
570 | } | 577 | } |
571 | #else | 578 | #else |
572 | QProcess* p = new QProcess(); | 579 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 580 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 581 | p->start(); |
575 | return; | 582 | return; |
576 | #endif | 583 | #endif |
577 | 584 | ||
578 | return; | 585 | return; |
579 | } | 586 | } |
580 | 587 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 588 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 589 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 590 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 591 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 592 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 593 | if ( len < 2 ) |
587 | error = true; | 594 | error = true; |
588 | else { | 595 | else { |
589 | tempfilename = mess.mid( 11, len ); | 596 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 597 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 598 | error = true; |
592 | } | 599 | } |
593 | if ( ! error ) { | 600 | if ( ! error ) { |
594 | filename = tempfilename; | 601 | filename = tempfilename; |
595 | } | 602 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 603 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 604 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 605 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 606 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 607 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 608 | } |
602 | 609 | ||
603 | startAlarm( mAlarmMessage, filename ); | 610 | startAlarm( mAlarmMessage, filename ); |
604 | 611 | ||
605 | 612 | ||
606 | } | 613 | } |
607 | 614 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 615 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 616 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 617 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 618 | ||
612 | mSuspendAlarmNotification = noti; | 619 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 620 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 621 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 622 | mSuspendTimer->start( ms , true ); |
616 | 623 | ||
617 | } | 624 | } |
618 | 625 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 626 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 627 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 628 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 629 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 630 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 631 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 632 | #endif |
626 | return; | 633 | return; |
627 | } | 634 | } |
628 | int maxSec; | 635 | int maxSec; |
629 | //maxSec = 5; //testing only | 636 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 637 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 638 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 639 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 640 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 641 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 642 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 643 | return; |
637 | } else { | 644 | } else { |
638 | mRecheckAlarmTimer->stop(); | 645 | mRecheckAlarmTimer->stop(); |
639 | } | 646 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 647 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 648 | mAlarmTimer->start( sec *1000 , true ); |
642 | 649 | ||
643 | } | 650 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 651 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 652 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 653 | void CalendarView::recheckTimerAlarm() |
647 | { | 654 | { |
648 | mAlarmTimer->stop(); | 655 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 656 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 657 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 658 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 659 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 660 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 661 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 662 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 663 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 664 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 665 | #endif |
659 | return; | 666 | return; |
660 | } | 667 | } |
661 | mAlarmTimer->stop(); | 668 | mAlarmTimer->stop(); |
662 | } | 669 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 670 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 671 | { |
665 | dateNavigator()->selectWeek( num ); | 672 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 673 | mViewManager->showWeekView(); |
667 | } | 674 | } |
668 | KOViewManager *CalendarView::viewManager() | 675 | KOViewManager *CalendarView::viewManager() |
669 | { | 676 | { |
670 | return mViewManager; | 677 | return mViewManager; |
671 | } | 678 | } |
672 | 679 | ||
673 | KODialogManager *CalendarView::dialogManager() | 680 | KODialogManager *CalendarView::dialogManager() |
674 | { | 681 | { |
675 | return mDialogManager; | 682 | return mDialogManager; |
676 | } | 683 | } |
677 | 684 | ||
678 | QDate CalendarView::startDate() | 685 | QDate CalendarView::startDate() |
679 | { | 686 | { |
680 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
681 | 688 | ||
682 | return dates.first(); | 689 | return dates.first(); |
683 | } | 690 | } |
684 | 691 | ||
685 | QDate CalendarView::endDate() | 692 | QDate CalendarView::endDate() |
686 | { | 693 | { |
687 | DateList dates = mNavigator->selectedDates(); | 694 | DateList dates = mNavigator->selectedDates(); |
688 | 695 | ||
689 | return dates.last(); | 696 | return dates.last(); |
690 | } | 697 | } |
691 | 698 | ||
692 | 699 | ||
693 | void CalendarView::createPrinter() | 700 | void CalendarView::createPrinter() |
694 | { | 701 | { |
695 | #ifndef KORG_NOPRINTER | 702 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 703 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 704 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 705 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 706 | } |
700 | #endif | 707 | #endif |
701 | } | 708 | } |
702 | 709 | ||
703 | 710 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 711 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 712 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 713 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 714 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 715 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 716 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 717 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 718 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 719 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 720 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 721 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 722 | { |
716 | 723 | ||
717 | // 0 equal | 724 | // 0 equal |
718 | // 1 take local | 725 | // 1 take local |
719 | // 2 take remote | 726 | // 2 take remote |
720 | // 3 cancel | 727 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 729 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 730 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 731 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 732 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 733 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 734 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 735 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 736 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 737 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 738 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 739 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 740 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 741 | return 0; |
735 | } else { | 742 | } else { |
736 | if ( locCh ) { | 743 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 744 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 745 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 746 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 747 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 748 | } else { |
742 | //qDebug(" not loc changed "); | 749 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 750 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 751 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 752 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 753 | ||
747 | } | 754 | } |
748 | } | 755 | } |
749 | full = true; | 756 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 757 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 758 | mode = SYNC_PREF_ASK; |
752 | } else { | 759 | } else { |
753 | if ( localMod == remoteMod ) | 760 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 761 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 762 | return 0; |
756 | 763 | ||
757 | } | 764 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 765 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 766 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 767 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 768 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 769 | //full = true; //debug only |
763 | if ( full ) { | 770 | if ( full ) { |
764 | bool equ = false; | 771 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 772 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 773 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 774 | } |
768 | else if ( local->type() =="Todo" ) | 775 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 776 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 777 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 778 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 779 | if ( equ ) { |
773 | //qDebug("equal "); | 780 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 782 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 783 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 784 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 785 | return 0; |
779 | 786 | ||
780 | }//else //debug only | 787 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 788 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 789 | } |
783 | int result; | 790 | int result; |
784 | bool localIsNew; | 791 | bool localIsNew; |
785 | //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() ); | 792 | //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() ); |
786 | 793 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 794 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 795 | mode = SYNC_PREF_ASK; |
789 | 796 | ||
790 | switch( mode ) { | 797 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 798 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
793 | return 1; | 800 | return 1; |
794 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
795 | return 2; | 802 | return 2; |
796 | return 1; | 803 | return 1; |
797 | break; | 804 | break; |
798 | case SYNC_PREF_REMOTE: | 805 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 806 | if ( lastSync > remoteMod ) |
800 | return 1; | 807 | return 1; |
801 | if ( lastSync > localMod ) | 808 | if ( lastSync > localMod ) |
802 | return 2; | 809 | return 2; |
803 | return 2; | 810 | return 2; |
804 | break; | 811 | break; |
805 | case SYNC_PREF_NEWEST: | 812 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 813 | if ( localMod > remoteMod ) |
807 | return 1; | 814 | return 1; |
808 | else | 815 | else |
809 | return 2; | 816 | return 2; |
810 | break; | 817 | break; |
811 | case SYNC_PREF_ASK: | 818 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 820 | if ( lastSync > remoteMod ) |
814 | return 1; | 821 | return 1; |
815 | if ( lastSync > localMod ) | 822 | if ( lastSync > localMod ) |
816 | return 2; | 823 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 824 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 825 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 826 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 828 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 830 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 831 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 832 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 833 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 834 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 835 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 836 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 837 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 838 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 839 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 840 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 841 | return result; |
835 | 842 | ||
836 | break; | 843 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 844 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 845 | return 1; |
839 | break; | 846 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 847 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 848 | return 2; |
842 | break; | 849 | break; |
843 | 850 | ||
844 | default: | 851 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 852 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 853 | break; |
847 | } | 854 | } |
848 | return 0; | 855 | return 0; |
849 | } | 856 | } |
850 | Event* CalendarView::getLastSyncEvent() | 857 | Event* CalendarView::getLastSyncEvent() |
851 | { | 858 | { |
852 | Event* lse; | 859 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 860 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 862 | if (!lse) { |
856 | lse = new Event(); | 863 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 864 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 865 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 866 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 867 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 868 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 869 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 870 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 871 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 872 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 873 | mCalendar->addEvent( lse ); |
867 | } | 874 | } |
868 | 875 | ||
869 | return lse; | 876 | return lse; |
870 | 877 | ||
871 | } | 878 | } |
872 | 879 | ||
873 | // we check, if the to delete event has a id for a profile | 880 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 881 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 882 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 883 | { |
877 | if ( lastSync.count() == 0 ) { | 884 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 885 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 886 | return; |
880 | } | 887 | } |
881 | if ( toDelete->type() == "Journal" ) | 888 | if ( toDelete->type() == "Journal" ) |
882 | return; | 889 | return; |
883 | 890 | ||
884 | Event* eve = lastSync.first(); | 891 | Event* eve = lastSync.first(); |
885 | 892 | ||
886 | while ( eve ) { | 893 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 894 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 895 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 896 | QString des = eve->description(); |
890 | QString pref = "e"; | 897 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 898 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 899 | pref = "t"; |
893 | des += pref+ id + ","; | 900 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 901 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 902 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 903 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 904 | eve->setReadOnly( true ); |
898 | } | 905 | } |
899 | eve = lastSync.next(); | 906 | eve = lastSync.next(); |
900 | } | 907 | } |
901 | 908 | ||
902 | } | 909 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 910 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 911 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 912 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 913 | checkExternSyncEvent( lastSync, inc ); |
907 | 914 | ||
908 | } | 915 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 916 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 917 | { |
911 | bool syncOK = true; | 918 | bool syncOK = true; |
912 | int addedEvent = 0; | 919 | int addedEvent = 0; |
913 | int addedEventR = 0; | 920 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 921 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 922 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 923 | int changedLocal = 0; |
917 | int changedRemote = 0; | 924 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 925 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 926 | Event* eventR; |
920 | QString uid; | 927 | QString uid; |
921 | int take; | 928 | int take; |
922 | Event* eventL; | 929 | Event* eventL; |
923 | Event* eventRSync; | 930 | Event* eventRSync; |
924 | Event* eventLSync; | 931 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 932 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 933 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 934 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 935 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 936 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 937 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 938 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 939 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 940 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 941 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 942 | } else { |
936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 943 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 944 | } |
938 | } | 945 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync; | 946 | QDateTime modifiedCalendar = mLastCalendarSync; |
940 | eventLSync = getLastSyncEvent(); | 947 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 948 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 949 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 950 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 951 | remote->deleteEvent(eventR ); |
945 | 952 | ||
946 | } else { | 953 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 954 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 955 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 956 | } else { |
950 | fullDateRange = true; | 957 | fullDateRange = true; |
951 | eventRSync = new Event(); | 958 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 959 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 960 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 961 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 962 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 963 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 964 | } |
958 | } | 965 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 966 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 967 | fullDateRange = true; |
961 | 968 | ||
962 | if ( ! fullDateRange ) { | 969 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 970 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 971 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 972 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 973 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 974 | fullDateRange = true; |
968 | } | 975 | } |
969 | } | 976 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 977 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 978 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
972 | } | 979 | } |
973 | if ( fullDateRange ) | 980 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 981 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 982 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 983 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 984 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 985 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 986 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 987 | //qDebug("setting mLastCalendarSync "); |
981 | } | 988 | } |
982 | //qDebug("*************************** "); | 989 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 990 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 991 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 992 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 993 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 994 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 995 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 996 | ||
990 | int w = 300; | 997 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 998 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 999 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 1000 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 1001 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 1002 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1003 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 1004 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 1005 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 1006 | int incCounter = 0; |
1000 | while ( inR ) { | 1007 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1008 | if ( ! bar.isVisible() ) |
1002 | return false; | 1009 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1010 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1011 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1012 | ++incCounter; |
1006 | uid = inR->uid(); | 1013 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1014 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1015 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1016 | skipIncidence = true; |
1010 | QString idS; | 1017 | QString idS; |
1011 | qApp->processEvents(); | 1018 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1019 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1020 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1021 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1022 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1023 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1024 | if ( take == 3 ) |
1018 | return false; | 1025 | return false; |
1019 | if ( take == 1 ) {// take local ********************** | 1026 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1028 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1029 | else |
1023 | idS = inR->IDStr(); | 1030 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1031 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1032 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1033 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1034 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1035 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1036 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1037 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1038 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1039 | ++changedRemote; |
1033 | } else {// take remote ********************** | 1040 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1041 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1042 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1043 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1044 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1045 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1046 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1047 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1050 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1051 | } |
1045 | local->addIncidence( inL ); | 1052 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1053 | ++changedLocal; |
1047 | } | 1054 | } |
1048 | } | 1055 | } |
1049 | } else { // no conflict ********** add or delete remote | 1056 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1057 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1058 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1059 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1060 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1061 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1062 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1063 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1064 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1065 | ++deletedEventR; |
1059 | } else { | 1066 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1067 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1068 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1069 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1065 | local->addIncidence( inL ); | 1072 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1073 | ++addedEvent; |
1067 | } | 1074 | } |
1068 | } else { | 1075 | } else { |
1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1076 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1070 | inR->setLastModified( modifiedCalendar ); | 1077 | inR->setLastModified( modifiedCalendar ); |
1071 | inL = inR->clone(); | 1078 | inL = inR->clone(); |
1072 | inL->setIDStr( ":" ); | 1079 | inL->setIDStr( ":" ); |
1073 | local->addIncidence( inL ); | 1080 | local->addIncidence( inL ); |
1074 | ++addedEvent; | 1081 | ++addedEvent; |
1075 | } else { | 1082 | } else { |
1076 | checkExternSyncEvent(eventRSyncSharp, inR); | 1083 | checkExternSyncEvent(eventRSyncSharp, inR); |
1077 | remote->deleteIncidence( inR ); | 1084 | remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1085 | ++deletedEventR; |
1079 | } | 1086 | } |
1080 | } | 1087 | } |
1081 | } | 1088 | } |
1082 | } | 1089 | } |
1083 | inR = er.next(); | 1090 | inR = er.next(); |
1084 | } | 1091 | } |
1085 | QPtrList<Incidence> el = local->rawIncidences(); | 1092 | QPtrList<Incidence> el = local->rawIncidences(); |
1086 | inL = el.first(); | 1093 | inL = el.first(); |
1087 | modulo = (el.count()/10)+1; | 1094 | modulo = (el.count()/10)+1; |
1088 | bar.setCaption (i18n("Add / remove events") ); | 1095 | bar.setCaption (i18n("Add / remove events") ); |
1089 | bar.setTotalSteps ( el.count() ) ; | 1096 | bar.setTotalSteps ( el.count() ) ; |
1090 | bar.show(); | 1097 | bar.show(); |
1091 | incCounter = 0; | 1098 | incCounter = 0; |
1092 | 1099 | ||
1093 | while ( inL ) { | 1100 | while ( inL ) { |
1094 | 1101 | ||
1095 | qApp->processEvents(); | 1102 | qApp->processEvents(); |
1096 | if ( ! bar.isVisible() ) | 1103 | if ( ! bar.isVisible() ) |
1097 | return false; | 1104 | return false; |
1098 | if ( incCounter % modulo == 0 ) | 1105 | if ( incCounter % modulo == 0 ) |
1099 | bar.setProgress( incCounter ); | 1106 | bar.setProgress( incCounter ); |
1100 | ++incCounter; | 1107 | ++incCounter; |
1101 | uid = inL->uid(); | 1108 | uid = inL->uid(); |
1102 | bool skipIncidence = false; | 1109 | bool skipIncidence = false; |
1103 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1110 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1104 | skipIncidence = true; | 1111 | skipIncidence = true; |
1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1106 | skipIncidence = true; | 1113 | skipIncidence = true; |
1107 | if ( !skipIncidence ) { | 1114 | if ( !skipIncidence ) { |
1108 | inR = remote->incidence( uid ); | 1115 | inR = remote->incidence( uid ); |
1109 | if ( ! inR ) { // no conflict ********** add or delete local | 1116 | if ( ! inR ) { // no conflict ********** add or delete local |
1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1119 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1120 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1121 | ++deletedEventL; |
1115 | } else { | 1122 | } else { |
1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1123 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1117 | inL->removeID(mCurrentSyncDevice ); | 1124 | inL->removeID(mCurrentSyncDevice ); |
1118 | ++addedEventR; | 1125 | ++addedEventR; |
1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1120 | inL->setLastModified( modifiedCalendar ); | 1127 | inL->setLastModified( modifiedCalendar ); |
1121 | inR = inL->clone(); | 1128 | inR = inL->clone(); |
1122 | inR->setIDStr( ":" ); | 1129 | inR->setIDStr( ":" ); |
1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1130 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1124 | remote->addIncidence( inR ); | 1131 | remote->addIncidence( inR ); |
1125 | } | 1132 | } |
1126 | } | 1133 | } |
1127 | } else { | 1134 | } else { |
1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1135 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1129 | checkExternSyncEvent(eventLSyncSharp, inL); | 1136 | checkExternSyncEvent(eventLSyncSharp, inL); |
1130 | local->deleteIncidence( inL ); | 1137 | local->deleteIncidence( inL ); |
1131 | ++deletedEventL; | 1138 | ++deletedEventL; |
1132 | } else { | 1139 | } else { |
1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1134 | ++addedEventR; | 1141 | ++addedEventR; |
1135 | inL->setLastModified( modifiedCalendar ); | 1142 | inL->setLastModified( modifiedCalendar ); |
1136 | inR = inL->clone(); | 1143 | inR = inL->clone(); |
1137 | inR->setIDStr( ":" ); | 1144 | inR->setIDStr( ":" ); |
1138 | remote->addIncidence( inR ); | 1145 | remote->addIncidence( inR ); |
1139 | } | 1146 | } |
1140 | } | 1147 | } |
1141 | } | 1148 | } |
1142 | } | 1149 | } |
1143 | } | 1150 | } |
1144 | inL = el.next(); | 1151 | inL = el.next(); |
1145 | } | 1152 | } |
1146 | int delFut = 0; | 1153 | int delFut = 0; |
1147 | int remRem = 0; | 1154 | int remRem = 0; |
1148 | if ( mSyncManager->mWriteBackInFuture ) { | 1155 | if ( mSyncManager->mWriteBackInFuture ) { |
1149 | er = remote->rawIncidences(); | 1156 | er = remote->rawIncidences(); |
1150 | remRem = er.count(); | 1157 | remRem = er.count(); |
1151 | inR = er.first(); | 1158 | inR = er.first(); |
1152 | QDateTime dt; | 1159 | QDateTime dt; |
1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1160 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1161 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1155 | while ( inR ) { | 1162 | while ( inR ) { |
1156 | if ( inR->type() == "Todo" ) { | 1163 | if ( inR->type() == "Todo" ) { |
1157 | Todo * t = (Todo*)inR; | 1164 | Todo * t = (Todo*)inR; |
1158 | if ( t->hasDueDate() ) | 1165 | if ( t->hasDueDate() ) |
1159 | dt = t->dtDue(); | 1166 | dt = t->dtDue(); |
1160 | else | 1167 | else |
1161 | dt = cur.addSecs( 62 ); | 1168 | dt = cur.addSecs( 62 ); |
1162 | } | 1169 | } |
1163 | else if (inR->type() == "Event" ) { | 1170 | else if (inR->type() == "Event" ) { |
1164 | bool ok; | 1171 | bool ok; |
1165 | dt = inR->getNextOccurence( cur, &ok ); | 1172 | dt = inR->getNextOccurence( cur, &ok ); |
1166 | if ( !ok ) | 1173 | if ( !ok ) |
1167 | dt = cur.addSecs( -62 ); | 1174 | dt = cur.addSecs( -62 ); |
1168 | } | 1175 | } |
1169 | else | 1176 | else |
1170 | dt = inR->dtStart(); | 1177 | dt = inR->dtStart(); |
1171 | if ( dt < cur || dt > end ) { | 1178 | if ( dt < cur || dt > end ) { |
1172 | remote->deleteIncidence( inR ); | 1179 | remote->deleteIncidence( inR ); |
1173 | ++delFut; | 1180 | ++delFut; |
1174 | } | 1181 | } |
1175 | inR = er.next(); | 1182 | inR = er.next(); |
1176 | } | 1183 | } |
1177 | } | 1184 | } |
1178 | bar.hide(); | 1185 | bar.hide(); |
1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1186 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1180 | eventLSync->setReadOnly( false ); | 1187 | eventLSync->setReadOnly( false ); |
1181 | eventLSync->setDtStart( mLastCalendarSync ); | 1188 | eventLSync->setDtStart( mLastCalendarSync ); |
1182 | eventRSync->setDtStart( mLastCalendarSync ); | 1189 | eventRSync->setDtStart( mLastCalendarSync ); |
1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1190 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1191 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1192 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1193 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1187 | eventLSync->setReadOnly( true ); | 1194 | eventLSync->setReadOnly( true ); |
1188 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1195 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1196 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1190 | remote->addEvent( eventRSync ); | 1197 | remote->addEvent( eventRSync ); |
1191 | else | 1198 | else |
1192 | delete eventRSync; | 1199 | delete eventRSync; |
1193 | QString mes; | 1200 | QString mes; |
1194 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1201 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1195 | QString delmess; | 1202 | QString delmess; |
1196 | if ( delFut ) { | 1203 | if ( delFut ) { |
1197 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1204 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1198 | mes += delmess; | 1205 | mes += delmess; |
1199 | } | 1206 | } |
1200 | mes = i18n("Local calendar changed!\n") +mes; | 1207 | mes = i18n("Local calendar changed!\n") +mes; |
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | 1208 | mCalendar->checkAlarmForIncidence( 0, true ); |
1202 | qDebug( mes ); | 1209 | qDebug( mes ); |
1203 | if ( mSyncManager->mShowSyncSummary ) { | 1210 | if ( mSyncManager->mShowSyncSummary ) { |
1204 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1211 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1205 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1212 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1206 | qDebug("cancelled "); | 1213 | qDebug("cancelled "); |
1207 | return false; | 1214 | return false; |
1208 | } | 1215 | } |
1209 | } | 1216 | } |
1210 | return syncOK; | 1217 | return syncOK; |
1211 | } | 1218 | } |
1212 | 1219 | ||
1213 | void CalendarView::setSyncDevice( QString s ) | 1220 | void CalendarView::setSyncDevice( QString s ) |
1214 | { | 1221 | { |
1215 | mCurrentSyncDevice= s; | 1222 | mCurrentSyncDevice= s; |
1216 | } | 1223 | } |
1217 | void CalendarView::setSyncName( QString s ) | 1224 | void CalendarView::setSyncName( QString s ) |
1218 | { | 1225 | { |
1219 | mCurrentSyncName= s; | 1226 | mCurrentSyncName= s; |
1220 | } | 1227 | } |
1221 | bool CalendarView::syncCalendar(QString filename, int mode) | 1228 | bool CalendarView::syncCalendar(QString filename, int mode) |
1222 | { | 1229 | { |
1223 | //qDebug("syncCalendar %s ", filename.latin1()); | 1230 | //qDebug("syncCalendar %s ", filename.latin1()); |
1224 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1231 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1225 | CalendarLocal* calendar = new CalendarLocal(); | 1232 | CalendarLocal* calendar = new CalendarLocal(); |
1226 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1233 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1227 | FileStorage* storage = new FileStorage( calendar ); | 1234 | FileStorage* storage = new FileStorage( calendar ); |
1228 | bool syncOK = false; | 1235 | bool syncOK = false; |
1229 | storage->setFileName( filename ); | 1236 | storage->setFileName( filename ); |
1230 | // qDebug("loading ... "); | 1237 | // qDebug("loading ... "); |
1231 | if ( storage->load() ) { | 1238 | if ( storage->load() ) { |
1232 | getEventViewerDialog()->setSyncMode( true ); | 1239 | getEventViewerDialog()->setSyncMode( true ); |
1233 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1240 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1234 | getEventViewerDialog()->setSyncMode( false ); | 1241 | getEventViewerDialog()->setSyncMode( false ); |
1235 | if ( syncOK ) { | 1242 | if ( syncOK ) { |
1236 | if ( mSyncManager->mWriteBackFile ) | 1243 | if ( mSyncManager->mWriteBackFile ) |
1237 | { | 1244 | { |
1238 | storage->setSaveFormat( new ICalFormat() ); | 1245 | storage->setSaveFormat( new ICalFormat() ); |
1239 | storage->save(); | 1246 | storage->save(); |
1240 | } | 1247 | } |
1241 | } | 1248 | } |
1242 | setModified( true ); | 1249 | setModified( true ); |
1243 | } | 1250 | } |
1244 | delete storage; | 1251 | delete storage; |
1245 | delete calendar; | 1252 | delete calendar; |
1246 | if ( syncOK ) | 1253 | if ( syncOK ) |
1247 | updateView(); | 1254 | updateView(); |
1248 | return syncOK; | 1255 | return syncOK; |
1249 | } | 1256 | } |
1250 | 1257 | ||
1251 | void CalendarView::syncExternal( int mode ) | 1258 | void CalendarView::syncExternal( int mode ) |
1252 | { | 1259 | { |
1253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1260 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1254 | 1261 | ||
1255 | qApp->processEvents(); | 1262 | qApp->processEvents(); |
1256 | CalendarLocal* calendar = new CalendarLocal(); | 1263 | CalendarLocal* calendar = new CalendarLocal(); |
1257 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1264 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1258 | bool syncOK = false; | 1265 | bool syncOK = false; |
1259 | bool loadSuccess = false; | 1266 | bool loadSuccess = false; |
1260 | PhoneFormat* phoneFormat = 0; | 1267 | PhoneFormat* phoneFormat = 0; |
1261 | emit tempDisableBR(true); | 1268 | emit tempDisableBR(true); |
1262 | #ifndef DESKTOP_VERSION | 1269 | #ifndef DESKTOP_VERSION |
1263 | SharpFormat* sharpFormat = 0; | 1270 | SharpFormat* sharpFormat = 0; |
1264 | if ( mode == 0 ) { // sharp | 1271 | if ( mode == 0 ) { // sharp |
1265 | sharpFormat = new SharpFormat () ; | 1272 | sharpFormat = new SharpFormat () ; |
1266 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1273 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1267 | 1274 | ||
1268 | } else | 1275 | } else |
1269 | #endif | 1276 | #endif |
1270 | if ( mode == 1 ) { // phone | 1277 | if ( mode == 1 ) { // phone |
1271 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1278 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1272 | mSyncManager->mPhoneDevice, | 1279 | mSyncManager->mPhoneDevice, |
1273 | mSyncManager->mPhoneConnection, | 1280 | mSyncManager->mPhoneConnection, |
1274 | mSyncManager->mPhoneModel); | 1281 | mSyncManager->mPhoneModel); |
1275 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1282 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1276 | 1283 | ||
1277 | } else { | 1284 | } else { |
1278 | emit tempDisableBR(false); | 1285 | emit tempDisableBR(false); |
1279 | return; | 1286 | return; |
1280 | } | 1287 | } |
1281 | if ( loadSuccess ) { | 1288 | if ( loadSuccess ) { |
1282 | getEventViewerDialog()->setSyncMode( true ); | 1289 | getEventViewerDialog()->setSyncMode( true ); |
1283 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1290 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1284 | getEventViewerDialog()->setSyncMode( false ); | 1291 | getEventViewerDialog()->setSyncMode( false ); |
1285 | qApp->processEvents(); | 1292 | qApp->processEvents(); |
1286 | if ( syncOK ) { | 1293 | if ( syncOK ) { |
1287 | if ( mSyncManager->mWriteBackFile ) | 1294 | if ( mSyncManager->mWriteBackFile ) |
1288 | { | 1295 | { |
1289 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1296 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1290 | Incidence* inc = iL.first(); | 1297 | Incidence* inc = iL.first(); |
1291 | if ( phoneFormat ) { | 1298 | if ( phoneFormat ) { |
1292 | while ( inc ) { | 1299 | while ( inc ) { |
1293 | inc->removeID(mCurrentSyncDevice); | 1300 | inc->removeID(mCurrentSyncDevice); |
1294 | inc = iL.next(); | 1301 | inc = iL.next(); |
1295 | } | 1302 | } |
1296 | } | 1303 | } |
1297 | #ifndef DESKTOP_VERSION | 1304 | #ifndef DESKTOP_VERSION |
1298 | if ( sharpFormat ) | 1305 | if ( sharpFormat ) |
1299 | sharpFormat->save(calendar); | 1306 | sharpFormat->save(calendar); |
1300 | #endif | 1307 | #endif |
1301 | if ( phoneFormat ) | 1308 | if ( phoneFormat ) |
1302 | phoneFormat->save(calendar); | 1309 | phoneFormat->save(calendar); |
1303 | iL = calendar->rawIncidences(); | 1310 | iL = calendar->rawIncidences(); |
1304 | inc = iL.first(); | 1311 | inc = iL.first(); |
1305 | Incidence* loc; | 1312 | Incidence* loc; |
1306 | while ( inc ) { | 1313 | while ( inc ) { |
1307 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1314 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1308 | loc = mCalendar->incidence(inc->uid() ); | 1315 | loc = mCalendar->incidence(inc->uid() ); |
1309 | if ( loc ) { | 1316 | if ( loc ) { |
1310 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1317 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1311 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1318 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1312 | } | 1319 | } |
1313 | } | 1320 | } |
1314 | inc = iL.next(); | 1321 | inc = iL.next(); |
1315 | } | 1322 | } |
1316 | Incidence* lse = getLastSyncEvent(); | 1323 | Incidence* lse = getLastSyncEvent(); |
1317 | if ( lse ) { | 1324 | if ( lse ) { |
1318 | lse->setReadOnly( false ); | 1325 | lse->setReadOnly( false ); |
1319 | lse->setDescription( "" ); | 1326 | lse->setDescription( "" ); |
1320 | lse->setReadOnly( true ); | 1327 | lse->setReadOnly( true ); |
1321 | } | 1328 | } |
1322 | } | 1329 | } |
1323 | } else { | 1330 | } else { |
1324 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1331 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1325 | } | 1332 | } |
1326 | setModified( true ); | 1333 | setModified( true ); |
1327 | } else { | 1334 | } else { |
1328 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1335 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1329 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1336 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1330 | question, i18n("Ok")) ; | 1337 | question, i18n("Ok")) ; |
1331 | 1338 | ||
1332 | } | 1339 | } |
1333 | delete calendar; | 1340 | delete calendar; |
1334 | updateView(); | 1341 | updateView(); |
1335 | emit tempDisableBR(false); | 1342 | emit tempDisableBR(false); |
1336 | return ;//syncOK; | 1343 | return ;//syncOK; |
1337 | 1344 | ||
1338 | } | 1345 | } |
1339 | 1346 | ||
1340 | bool CalendarView::importBday() | 1347 | bool CalendarView::importBday() |
1341 | { | 1348 | { |
1342 | #ifndef KORG_NOKABC | 1349 | #ifndef KORG_NOKABC |
1343 | 1350 | ||
1344 | #ifdef DESKTOP_VERSION | 1351 | #ifdef DESKTOP_VERSION |
1345 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1352 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1346 | KABC::AddressBook::Iterator it; | 1353 | KABC::AddressBook::Iterator it; |
1347 | int count = 0; | 1354 | int count = 0; |
1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1349 | ++count; | 1356 | ++count; |
1350 | } | 1357 | } |
1351 | QProgressBar bar(count,0 ); | 1358 | QProgressBar bar(count,0 ); |
1352 | int w = 300; | 1359 | int w = 300; |
1353 | if ( QApplication::desktop()->width() < 320 ) | 1360 | if ( QApplication::desktop()->width() < 320 ) |
1354 | w = 220; | 1361 | w = 220; |
1355 | int h = bar.sizeHint().height() ; | 1362 | int h = bar.sizeHint().height() ; |
1356 | int dw = QApplication::desktop()->width(); | 1363 | int dw = QApplication::desktop()->width(); |
1357 | int dh = QApplication::desktop()->height(); | 1364 | int dh = QApplication::desktop()->height(); |
1358 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1365 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1359 | bar.show(); | 1366 | bar.show(); |
1360 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1367 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1361 | qApp->processEvents(); | 1368 | qApp->processEvents(); |
1362 | count = 0; | 1369 | count = 0; |
1363 | int addCount = 0; | 1370 | int addCount = 0; |
1364 | KCal::Attendee* a = 0; | 1371 | KCal::Attendee* a = 0; |
1365 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1372 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1366 | if ( ! bar.isVisible() ) | 1373 | if ( ! bar.isVisible() ) |
1367 | return false; | 1374 | return false; |
1368 | bar.setProgress( count++ ); | 1375 | bar.setProgress( count++ ); |
1369 | qApp->processEvents(); | 1376 | qApp->processEvents(); |
1370 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1377 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1371 | if ( (*it).birthday().date().isValid() ){ | 1378 | if ( (*it).birthday().date().isValid() ){ |
1372 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1379 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1373 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1380 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1374 | ++addCount; | 1381 | ++addCount; |
1375 | } | 1382 | } |
1376 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1383 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1377 | if ( anni.isValid() ){ | 1384 | if ( anni.isValid() ){ |
1378 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1385 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1379 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1386 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1380 | ++addCount; | 1387 | ++addCount; |
1381 | } | 1388 | } |
1382 | } | 1389 | } |
1383 | updateView(); | 1390 | updateView(); |
1384 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1391 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1385 | #else //DESKTOP_VERSION | 1392 | #else //DESKTOP_VERSION |
1386 | 1393 | ||
1387 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1394 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1388 | // the result should now arrive through method insertBirthdays | 1395 | // the result should now arrive through method insertBirthdays |
1389 | 1396 | ||
1390 | #endif //DESKTOP_VERSION | 1397 | #endif //DESKTOP_VERSION |
1391 | 1398 | ||
1392 | #endif //KORG_NOKABC | 1399 | #endif //KORG_NOKABC |
1393 | 1400 | ||
1394 | 1401 | ||
1395 | return true; | 1402 | return true; |
1396 | } | 1403 | } |
1397 | 1404 | ||
1398 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1405 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1399 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1406 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1400 | const QStringList& anniversaryList, const QStringList& realNameList, | 1407 | const QStringList& anniversaryList, const QStringList& realNameList, |
1401 | const QStringList& emailList, const QStringList& assembledNameList, | 1408 | const QStringList& emailList, const QStringList& assembledNameList, |
1402 | const QStringList& uidList) | 1409 | const QStringList& uidList) |
1403 | { | 1410 | { |
1404 | qDebug("CalendarView::insertBirthdays"); | 1411 | qDebug("CalendarView::insertBirthdays"); |
1405 | if (uid == this->name()) | 1412 | if (uid == this->name()) |
1406 | { | 1413 | { |
1407 | int count = birthdayList.count(); | 1414 | int count = birthdayList.count(); |
1408 | int addCount = 0; | 1415 | int addCount = 0; |
1409 | KCal::Attendee* a = 0; | 1416 | KCal::Attendee* a = 0; |
1410 | 1417 | ||
1411 | qDebug("CalView 1 %i", count); | 1418 | qDebug("CalView 1 %i", count); |
1412 | 1419 | ||
1413 | QProgressBar bar(count,0 ); | 1420 | QProgressBar bar(count,0 ); |
1414 | int w = 300; | 1421 | int w = 300; |
1415 | if ( QApplication::desktop()->width() < 320 ) | 1422 | if ( QApplication::desktop()->width() < 320 ) |
1416 | w = 220; | 1423 | w = 220; |
1417 | int h = bar.sizeHint().height() ; | 1424 | int h = bar.sizeHint().height() ; |
1418 | int dw = QApplication::desktop()->width(); | 1425 | int dw = QApplication::desktop()->width(); |
1419 | int dh = QApplication::desktop()->height(); | 1426 | int dh = QApplication::desktop()->height(); |
1420 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1427 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1421 | bar.show(); | 1428 | bar.show(); |
1422 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1429 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1423 | qApp->processEvents(); | 1430 | qApp->processEvents(); |
1424 | 1431 | ||
1425 | QDate birthday; | 1432 | QDate birthday; |
1426 | QDate anniversary; | 1433 | QDate anniversary; |
1427 | QString realName; | 1434 | QString realName; |
1428 | QString email; | 1435 | QString email; |
1429 | QString assembledName; | 1436 | QString assembledName; |
1430 | QString uid; | 1437 | QString uid; |
1431 | bool ok = true; | 1438 | bool ok = true; |
1432 | for ( int i = 0; i < count; i++) | 1439 | for ( int i = 0; i < count; i++) |
1433 | { | 1440 | { |
1434 | if ( ! bar.isVisible() ) | 1441 | if ( ! bar.isVisible() ) |
1435 | return; | 1442 | return; |
1436 | bar.setProgress( i ); | 1443 | bar.setProgress( i ); |
1437 | qApp->processEvents(); | 1444 | qApp->processEvents(); |
1438 | 1445 | ||
1439 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1446 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1440 | if (!ok) { | 1447 | if (!ok) { |
1441 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1448 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1442 | } | 1449 | } |
1443 | 1450 | ||
1444 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1451 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1445 | if (!ok) { | 1452 | if (!ok) { |
1446 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1453 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1447 | } | 1454 | } |
1448 | realName = realNameList[i]; | 1455 | realName = realNameList[i]; |
1449 | email = emailList[i]; | 1456 | email = emailList[i]; |
1450 | assembledName = assembledNameList[i]; | 1457 | assembledName = assembledNameList[i]; |
1451 | uid = uidList[i]; | 1458 | uid = uidList[i]; |
1452 | //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() ); | 1459 | //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() ); |
1453 | 1460 | ||
1454 | if ( birthday.isValid() ){ | 1461 | if ( birthday.isValid() ){ |
1455 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1462 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1456 | KCal::Attendee::ReqParticipant,uid) ; | 1463 | KCal::Attendee::ReqParticipant,uid) ; |
1457 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1464 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1458 | ++addCount; | 1465 | ++addCount; |
1459 | } | 1466 | } |
1460 | 1467 | ||
1461 | if ( anniversary.isValid() ){ | 1468 | if ( anniversary.isValid() ){ |
1462 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1469 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1463 | KCal::Attendee::ReqParticipant,uid) ; | 1470 | KCal::Attendee::ReqParticipant,uid) ; |
1464 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1471 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1465 | ++addCount; | 1472 | ++addCount; |
1466 | } | 1473 | } |
1467 | } | 1474 | } |
1468 | 1475 | ||
1469 | updateView(); | 1476 | updateView(); |
1470 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1477 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1471 | 1478 | ||
1472 | } | 1479 | } |
1473 | 1480 | ||
1474 | } | 1481 | } |
1475 | 1482 | ||
1476 | 1483 | ||
1477 | 1484 | ||
1478 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1485 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1479 | { | 1486 | { |
1480 | //qDebug("addAnni "); | 1487 | //qDebug("addAnni "); |
1481 | Event * ev = new Event(); | 1488 | Event * ev = new Event(); |
1482 | if ( a ) { | 1489 | if ( a ) { |
1483 | ev->addAttendee( a ); | 1490 | ev->addAttendee( a ); |
1484 | } | 1491 | } |
1485 | QString kind; | 1492 | QString kind; |
1486 | if ( birthday ) | 1493 | if ( birthday ) |
1487 | kind = i18n( "Birthday" ); | 1494 | kind = i18n( "Birthday" ); |
1488 | else | 1495 | else |
1489 | kind = i18n( "Anniversary" ); | 1496 | kind = i18n( "Anniversary" ); |
1490 | ev->setSummary( name + " - " + kind ); | 1497 | ev->setSummary( name + " - " + kind ); |
1491 | ev->setOrganizer(a->email()); | 1498 | ev->setOrganizer(a->email()); |
1492 | ev->setCategories( kind ); | 1499 | ev->setCategories( kind ); |
1493 | ev->setDtStart( QDateTime(date) ); | 1500 | ev->setDtStart( QDateTime(date) ); |
1494 | ev->setDtEnd( QDateTime(date) ); | 1501 | ev->setDtEnd( QDateTime(date) ); |
1495 | ev->setFloats( true ); | 1502 | ev->setFloats( true ); |
1496 | Recurrence * rec = ev->recurrence(); | 1503 | Recurrence * rec = ev->recurrence(); |
1497 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1504 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1498 | rec->addYearlyNum( date.month() ); | 1505 | rec->addYearlyNum( date.month() ); |
1499 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1506 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1500 | delete ev; | 1507 | delete ev; |
1501 | return false; | 1508 | return false; |
1502 | } | 1509 | } |
1503 | return true; | 1510 | return true; |
1504 | 1511 | ||
1505 | } | 1512 | } |
1506 | bool CalendarView::importQtopia( const QString &categories, | 1513 | bool CalendarView::importQtopia( const QString &categories, |
1507 | const QString &datebook, | 1514 | const QString &datebook, |
1508 | const QString &todolist ) | 1515 | const QString &todolist ) |
1509 | { | 1516 | { |
1510 | 1517 | ||
1511 | QtopiaFormat qtopiaFormat; | 1518 | QtopiaFormat qtopiaFormat; |
1512 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1519 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1513 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1520 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1514 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1521 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1515 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1522 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1516 | 1523 | ||
1517 | updateView(); | 1524 | updateView(); |
1518 | return true; | 1525 | return true; |
1519 | 1526 | ||
1520 | #if 0 | 1527 | #if 0 |
1521 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1528 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1522 | mCurrentSyncDevice = "qtopia-XML"; | 1529 | mCurrentSyncDevice = "qtopia-XML"; |
1523 | if ( mSyncManager->mAskForPreferences ) | 1530 | if ( mSyncManager->mAskForPreferences ) |
1524 | edit_sync_options(); | 1531 | edit_sync_options(); |
1525 | qApp->processEvents(); | 1532 | qApp->processEvents(); |
1526 | CalendarLocal* calendar = new CalendarLocal(); | 1533 | CalendarLocal* calendar = new CalendarLocal(); |
1527 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1534 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1528 | bool syncOK = false; | 1535 | bool syncOK = false; |
1529 | QtopiaFormat qtopiaFormat; | 1536 | QtopiaFormat qtopiaFormat; |
1530 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1537 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1531 | bool loadOk = true; | 1538 | bool loadOk = true; |
1532 | if ( !categories.isEmpty() ) | 1539 | if ( !categories.isEmpty() ) |
1533 | loadOk = qtopiaFormat.load( calendar, categories ); | 1540 | loadOk = qtopiaFormat.load( calendar, categories ); |
1534 | if ( loadOk && !datebook.isEmpty() ) | 1541 | if ( loadOk && !datebook.isEmpty() ) |
1535 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1542 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1536 | if ( loadOk && !todolist.isEmpty() ) | 1543 | if ( loadOk && !todolist.isEmpty() ) |
1537 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1544 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1538 | 1545 | ||
1539 | if ( loadOk ) { | 1546 | if ( loadOk ) { |
1540 | getEventViewerDialog()->setSyncMode( true ); | 1547 | getEventViewerDialog()->setSyncMode( true ); |
1541 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1548 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1542 | getEventViewerDialog()->setSyncMode( false ); | 1549 | getEventViewerDialog()->setSyncMode( false ); |
1543 | qApp->processEvents(); | 1550 | qApp->processEvents(); |
1544 | if ( syncOK ) { | 1551 | if ( syncOK ) { |
1545 | if ( mSyncManager->mWriteBackFile ) | 1552 | if ( mSyncManager->mWriteBackFile ) |
1546 | { | 1553 | { |
1547 | // write back XML file | 1554 | // write back XML file |
1548 | 1555 | ||
1549 | } | 1556 | } |
1550 | setModified( true ); | 1557 | setModified( true ); |
1551 | } | 1558 | } |
1552 | } else { | 1559 | } else { |
1553 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1560 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1554 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1561 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1555 | question, i18n("Ok")) ; | 1562 | question, i18n("Ok")) ; |
1556 | } | 1563 | } |
1557 | delete calendar; | 1564 | delete calendar; |
1558 | updateView(); | 1565 | updateView(); |
1559 | return syncOK; | 1566 | return syncOK; |
1560 | 1567 | ||
1561 | 1568 | ||
1562 | #endif | 1569 | #endif |
1563 | 1570 | ||
1564 | } | 1571 | } |
1565 | 1572 | ||
1566 | void CalendarView::setSyncEventsReadOnly() | 1573 | void CalendarView::setSyncEventsReadOnly() |
1567 | { | 1574 | { |
1568 | Event * ev; | 1575 | Event * ev; |
1569 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1576 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1570 | ev = eL.first(); | 1577 | ev = eL.first(); |
1571 | while ( ev ) { | 1578 | while ( ev ) { |
1572 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1579 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1573 | ev->setReadOnly( true ); | 1580 | ev->setReadOnly( true ); |
1574 | ev = eL.next(); | 1581 | ev = eL.next(); |
1575 | } | 1582 | } |
1576 | } | 1583 | } |
1577 | bool CalendarView::openCalendar(QString filename, bool merge) | 1584 | bool CalendarView::openCalendar(QString filename, bool merge) |
1578 | { | 1585 | { |
1579 | 1586 | ||
1580 | if (filename.isEmpty()) { | 1587 | if (filename.isEmpty()) { |
1581 | return false; | 1588 | return false; |
1582 | } | 1589 | } |
1583 | 1590 | ||
1584 | if (!QFile::exists(filename)) { | 1591 | if (!QFile::exists(filename)) { |
1585 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1592 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1586 | return false; | 1593 | return false; |
1587 | } | 1594 | } |
1588 | 1595 | ||
1589 | globalFlagBlockAgenda = 1; | 1596 | globalFlagBlockAgenda = 1; |
1590 | if (!merge) mCalendar->close(); | 1597 | if (!merge) mCalendar->close(); |
1591 | 1598 | ||
1592 | mStorage->setFileName( filename ); | 1599 | mStorage->setFileName( filename ); |
1593 | 1600 | ||
1594 | if ( mStorage->load() ) { | 1601 | if ( mStorage->load() ) { |
1595 | if ( merge ) ;//setModified( true ); | 1602 | if ( merge ) ;//setModified( true ); |
1596 | else { | 1603 | else { |
1597 | //setModified( true ); | 1604 | //setModified( true ); |
1598 | mViewManager->setDocumentId( filename ); | 1605 | mViewManager->setDocumentId( filename ); |
1599 | mDialogManager->setDocumentId( filename ); | 1606 | mDialogManager->setDocumentId( filename ); |
1600 | mTodoList->setDocumentId( filename ); | 1607 | mTodoList->setDocumentId( filename ); |
1601 | } | 1608 | } |
1602 | globalFlagBlockAgenda = 2; | 1609 | globalFlagBlockAgenda = 2; |
1603 | // if ( getLastSyncEvent() ) | 1610 | // if ( getLastSyncEvent() ) |
1604 | // getLastSyncEvent()->setReadOnly( true ); | 1611 | // getLastSyncEvent()->setReadOnly( true ); |
1605 | mCalendar->reInitAlarmSettings(); | 1612 | mCalendar->reInitAlarmSettings(); |
1606 | setSyncEventsReadOnly(); | 1613 | setSyncEventsReadOnly(); |
1607 | updateUnmanagedViews(); | 1614 | updateUnmanagedViews(); |
1608 | updateView(); | 1615 | updateView(); |
1609 | if ( filename != MainWindow::defaultFileName() ) { | 1616 | if ( filename != MainWindow::defaultFileName() ) { |
1610 | saveCalendar( MainWindow::defaultFileName() ); | 1617 | saveCalendar( MainWindow::defaultFileName() ); |
1611 | } else { | 1618 | } else { |
1612 | QFileInfo finf ( MainWindow::defaultFileName()); | 1619 | QFileInfo finf ( MainWindow::defaultFileName()); |
1613 | if ( finf.exists() ) { | 1620 | if ( finf.exists() ) { |
1614 | setLoadedFileVersion( finf.lastModified () ); | 1621 | setLoadedFileVersion( finf.lastModified () ); |
1615 | } | 1622 | } |
1616 | } | 1623 | } |
1617 | return true; | 1624 | return true; |
1618 | } else { | 1625 | } else { |
1619 | // while failing to load, the calendar object could | 1626 | // while failing to load, the calendar object could |
1620 | // have become partially populated. Clear it out. | 1627 | // have become partially populated. Clear it out. |
1621 | if ( !merge ) { | 1628 | if ( !merge ) { |
1622 | mCalendar->close(); | 1629 | mCalendar->close(); |
1623 | mViewManager->setDocumentId( filename ); | 1630 | mViewManager->setDocumentId( filename ); |
1624 | mDialogManager->setDocumentId( filename ); | 1631 | mDialogManager->setDocumentId( filename ); |
1625 | mTodoList->setDocumentId( filename ); | 1632 | mTodoList->setDocumentId( filename ); |
1626 | } | 1633 | } |
1627 | 1634 | ||
1628 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1635 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1629 | 1636 | ||
1630 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1637 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1631 | globalFlagBlockAgenda = 2; | 1638 | globalFlagBlockAgenda = 2; |
1632 | mCalendar->reInitAlarmSettings(); | 1639 | mCalendar->reInitAlarmSettings(); |
1633 | setSyncEventsReadOnly(); | 1640 | setSyncEventsReadOnly(); |
1634 | updateUnmanagedViews(); | 1641 | updateUnmanagedViews(); |
1635 | updateView(); | 1642 | updateView(); |
1636 | } | 1643 | } |
1637 | return false; | 1644 | return false; |
1638 | } | 1645 | } |
1639 | void CalendarView::showOpenError() | 1646 | void CalendarView::showOpenError() |
1640 | { | 1647 | { |
1641 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1648 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1642 | } | 1649 | } |
1643 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1650 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1644 | { | 1651 | { |
1645 | loadedFileVersion = dt; | 1652 | loadedFileVersion = dt; |
1646 | } | 1653 | } |
1647 | bool CalendarView::checkFileChanged(QString fn) | 1654 | bool CalendarView::checkFileChanged(QString fn) |
1648 | { | 1655 | { |
1649 | QFileInfo finf ( fn ); | 1656 | QFileInfo finf ( fn ); |
1650 | if ( !finf.exists() ) | 1657 | if ( !finf.exists() ) |
1651 | return true; | 1658 | return true; |
1652 | QDateTime dt = finf.lastModified (); | 1659 | QDateTime dt = finf.lastModified (); |
1653 | if ( dt <= loadedFileVersion ) | 1660 | if ( dt <= loadedFileVersion ) |
1654 | return false; | 1661 | return false; |
1655 | return true; | 1662 | return true; |
1656 | 1663 | ||
1657 | } | 1664 | } |
1658 | void CalendarView::watchSavedFile() | 1665 | void CalendarView::watchSavedFile() |
1659 | { | 1666 | { |
1660 | QFileInfo finf ( MainWindow::defaultFileName()); | 1667 | QFileInfo finf ( MainWindow::defaultFileName()); |
1661 | if ( !finf.exists() ) | 1668 | if ( !finf.exists() ) |
1662 | return; | 1669 | return; |
1663 | QDateTime dt = finf.lastModified (); | 1670 | QDateTime dt = finf.lastModified (); |
1664 | if ( dt < loadedFileVersion ) { | 1671 | if ( dt < loadedFileVersion ) { |
1665 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1672 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1666 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1673 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1667 | return; | 1674 | return; |
1668 | } | 1675 | } |
1669 | loadedFileVersion = dt; | 1676 | loadedFileVersion = dt; |
1670 | } | 1677 | } |
1671 | 1678 | ||
1672 | bool CalendarView::checkFileVersion(QString fn) | 1679 | bool CalendarView::checkFileVersion(QString fn) |
1673 | { | 1680 | { |
1674 | QFileInfo finf ( fn ); | 1681 | QFileInfo finf ( fn ); |
1675 | if ( !finf.exists() ) | 1682 | if ( !finf.exists() ) |
1676 | return true; | 1683 | return true; |
1677 | QDateTime dt = finf.lastModified (); | 1684 | QDateTime dt = finf.lastModified (); |
1678 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1685 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1679 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1686 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1680 | if ( dt <= loadedFileVersion ) | 1687 | if ( dt <= loadedFileVersion ) |
1681 | return true; | 1688 | return true; |
1682 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1689 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1683 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1690 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1684 | i18n("Sync+save")); | 1691 | i18n("Sync+save")); |
1685 | 1692 | ||
1686 | if ( km == KMessageBox::Cancel ) | 1693 | if ( km == KMessageBox::Cancel ) |
1687 | return false; | 1694 | return false; |
1688 | if ( km == KMessageBox::Yes ) | 1695 | if ( km == KMessageBox::Yes ) |
1689 | return true; | 1696 | return true; |
1690 | 1697 | ||
1691 | setSyncDevice("deleteaftersync" ); | 1698 | setSyncDevice("deleteaftersync" ); |
1692 | mSyncManager->mAskForPreferences = true; | 1699 | mSyncManager->mAskForPreferences = true; |
1693 | mSyncManager->mSyncAlgoPrefs = 3; | 1700 | mSyncManager->mSyncAlgoPrefs = 3; |
1694 | mSyncManager->mWriteBackFile = false; | 1701 | mSyncManager->mWriteBackFile = false; |
1695 | mSyncManager->mWriteBackExistingOnly = false; | 1702 | mSyncManager->mWriteBackExistingOnly = false; |
1696 | mSyncManager->mShowSyncSummary = false; | 1703 | mSyncManager->mShowSyncSummary = false; |
1697 | syncCalendar( fn, 3 ); | 1704 | syncCalendar( fn, 3 ); |
1698 | Event * e = getLastSyncEvent(); | 1705 | Event * e = getLastSyncEvent(); |
1699 | mCalendar->deleteEvent ( e ); | 1706 | mCalendar->deleteEvent ( e ); |
1700 | updateView(); | 1707 | updateView(); |
1701 | return true; | 1708 | return true; |
1702 | } | 1709 | } |
1703 | 1710 | ||
1704 | bool CalendarView::saveCalendar( QString filename ) | 1711 | bool CalendarView::saveCalendar( QString filename ) |
1705 | { | 1712 | { |
1706 | 1713 | ||
1707 | // Store back all unsaved data into calendar object | 1714 | // Store back all unsaved data into calendar object |
1708 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1715 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1709 | if ( mViewManager->currentView() ) | 1716 | if ( mViewManager->currentView() ) |
1710 | mViewManager->currentView()->flushView(); | 1717 | mViewManager->currentView()->flushView(); |
1711 | 1718 | ||
1712 | 1719 | ||
1713 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1720 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1714 | mStorage->setSaveFormat( new ICalFormat() ); | 1721 | mStorage->setSaveFormat( new ICalFormat() ); |
1715 | mStorage->setFileName( filename ); | 1722 | mStorage->setFileName( filename ); |
1716 | bool success; | 1723 | bool success; |
1717 | success = mStorage->save(); | 1724 | success = mStorage->save(); |
1718 | if ( !success ) { | 1725 | if ( !success ) { |
1719 | return false; | 1726 | return false; |
1720 | } | 1727 | } |
1721 | if ( filename == MainWindow::defaultFileName() ) { | 1728 | if ( filename == MainWindow::defaultFileName() ) { |
1722 | setLoadedFileVersion( lfv ); | 1729 | setLoadedFileVersion( lfv ); |
1723 | watchSavedFile(); | 1730 | watchSavedFile(); |
1724 | } | 1731 | } |
1725 | return true; | 1732 | return true; |
1726 | } | 1733 | } |
1727 | 1734 | ||
1728 | void CalendarView::closeCalendar() | 1735 | void CalendarView::closeCalendar() |
1729 | { | 1736 | { |
1730 | 1737 | ||
1731 | // child windows no longer valid | 1738 | // child windows no longer valid |
1732 | emit closingDown(); | 1739 | emit closingDown(); |
1733 | 1740 | ||
1734 | mCalendar->close(); | 1741 | mCalendar->close(); |
1735 | setModified(false); | 1742 | setModified(false); |
1736 | updateView(); | 1743 | updateView(); |
1737 | } | 1744 | } |
1738 | 1745 | ||
1739 | void CalendarView::archiveCalendar() | 1746 | void CalendarView::archiveCalendar() |
1740 | { | 1747 | { |
1741 | mDialogManager->showArchiveDialog(); | 1748 | mDialogManager->showArchiveDialog(); |
1742 | } | 1749 | } |
1743 | 1750 | ||
1744 | 1751 | ||
1745 | void CalendarView::readSettings() | 1752 | void CalendarView::readSettings() |
1746 | { | 1753 | { |
1747 | 1754 | ||
1748 | 1755 | ||
1749 | // mViewManager->showAgendaView(); | 1756 | // mViewManager->showAgendaView(); |
1750 | QString str; | 1757 | QString str; |
1751 | //qDebug("CalendarView::readSettings() "); | 1758 | //qDebug("CalendarView::readSettings() "); |
1752 | // read settings from the KConfig, supplying reasonable | 1759 | // read settings from the KConfig, supplying reasonable |
1753 | // defaults where none are to be found | 1760 | // defaults where none are to be found |
1754 | KConfig *config = KOGlobals::config(); | 1761 | KConfig *config = KOGlobals::config(); |
1755 | #ifndef KORG_NOSPLITTER | 1762 | #ifndef KORG_NOSPLITTER |
1756 | config->setGroup("KOrganizer Geometry"); | 1763 | config->setGroup("KOrganizer Geometry"); |
1757 | 1764 | ||
1758 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1765 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1759 | if (sizes.count() != 2) { | 1766 | if (sizes.count() != 2) { |
1760 | sizes << mDateNavigator->minimumSizeHint().width(); | 1767 | sizes << mDateNavigator->minimumSizeHint().width(); |
1761 | sizes << 300; | 1768 | sizes << 300; |
1762 | } | 1769 | } |
1763 | mPanner->setSizes(sizes); | 1770 | mPanner->setSizes(sizes); |
1764 | 1771 | ||
1765 | sizes = config->readIntListEntry("Separator2"); | 1772 | sizes = config->readIntListEntry("Separator2"); |
1766 | if ( ( mResourceView && sizes.count() == 4 ) || | 1773 | if ( ( mResourceView && sizes.count() == 4 ) || |
1767 | ( !mResourceView && sizes.count() == 3 ) ) { | 1774 | ( !mResourceView && sizes.count() == 3 ) ) { |
1768 | mLeftSplitter->setSizes(sizes); | 1775 | mLeftSplitter->setSizes(sizes); |
1769 | } | 1776 | } |
1770 | #endif | 1777 | #endif |
1771 | globalFlagBlockAgenda = 1; | 1778 | globalFlagBlockAgenda = 1; |
1772 | mViewManager->showAgendaView(); | 1779 | mViewManager->showAgendaView(); |
1773 | //mViewManager->readSettings( config ); | 1780 | //mViewManager->readSettings( config ); |
1774 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1781 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1775 | readFilterSettings(config); | 1782 | readFilterSettings(config); |
1776 | config->setGroup( "Views" ); | 1783 | config->setGroup( "Views" ); |
1777 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1784 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1778 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1785 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1779 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1786 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1780 | else mNavigator->selectDates( dateCount ); | 1787 | else mNavigator->selectDates( dateCount ); |
1781 | // mViewManager->readSettings( config ); | 1788 | // mViewManager->readSettings( config ); |
1782 | updateConfig(); | 1789 | updateConfig(); |
1783 | globalFlagBlockAgenda = 2; | 1790 | globalFlagBlockAgenda = 2; |
1784 | mViewManager->readSettings( config ); | 1791 | mViewManager->readSettings( config ); |
1785 | #ifdef DESKTOP_VERSION | 1792 | #ifdef DESKTOP_VERSION |
1786 | config->setGroup("WidgetLayout"); | 1793 | config->setGroup("WidgetLayout"); |
1787 | QStringList list; | 1794 | QStringList list; |
1788 | list = config->readListEntry("MainLayout"); | 1795 | list = config->readListEntry("MainLayout"); |
1789 | int x,y,w,h; | 1796 | int x,y,w,h; |
1790 | if ( ! list.isEmpty() ) { | 1797 | if ( ! list.isEmpty() ) { |
1791 | x = list[0].toInt(); | 1798 | x = list[0].toInt(); |
1792 | y = list[1].toInt(); | 1799 | y = list[1].toInt(); |
1793 | w = list[2].toInt(); | 1800 | w = list[2].toInt(); |
1794 | h = list[3].toInt(); | 1801 | h = list[3].toInt(); |
1795 | topLevelWidget()->setGeometry(x,y,w,h); | 1802 | topLevelWidget()->setGeometry(x,y,w,h); |
1796 | 1803 | ||
1797 | } else { | 1804 | } else { |
1798 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1805 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1799 | } | 1806 | } |
1800 | list = config->readListEntry("EditEventLayout"); | 1807 | list = config->readListEntry("EditEventLayout"); |
1801 | if ( ! list.isEmpty() ) { | 1808 | if ( ! list.isEmpty() ) { |
1802 | x = list[0].toInt(); | 1809 | x = list[0].toInt(); |
1803 | y = list[1].toInt(); | 1810 | y = list[1].toInt(); |
1804 | w = list[2].toInt(); | 1811 | w = list[2].toInt(); |
1805 | h = list[3].toInt(); | 1812 | h = list[3].toInt(); |
1806 | mEventEditor->setGeometry(x,y,w,h); | 1813 | mEventEditor->setGeometry(x,y,w,h); |
1807 | 1814 | ||
1808 | } | 1815 | } |
1809 | list = config->readListEntry("EditTodoLayout"); | 1816 | list = config->readListEntry("EditTodoLayout"); |
1810 | if ( ! list.isEmpty() ) { | 1817 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1818 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1819 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1820 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1821 | h = list[3].toInt(); |
1815 | mTodoEditor->setGeometry(x,y,w,h); | 1822 | mTodoEditor->setGeometry(x,y,w,h); |
1816 | 1823 | ||
1817 | } | 1824 | } |
1818 | list = config->readListEntry("ViewerLayout"); | 1825 | list = config->readListEntry("ViewerLayout"); |
1819 | if ( ! list.isEmpty() ) { | 1826 | if ( ! list.isEmpty() ) { |
1820 | x = list[0].toInt(); | 1827 | x = list[0].toInt(); |
1821 | y = list[1].toInt(); | 1828 | y = list[1].toInt(); |
1822 | w = list[2].toInt(); | 1829 | w = list[2].toInt(); |
1823 | h = list[3].toInt(); | 1830 | h = list[3].toInt(); |
1824 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1831 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1825 | } | 1832 | } |
1826 | #endif | 1833 | #endif |
1827 | 1834 | ||
1828 | } | 1835 | } |
1829 | 1836 | ||
1830 | 1837 | ||
1831 | void CalendarView::writeSettings() | 1838 | void CalendarView::writeSettings() |
1832 | { | 1839 | { |
1833 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1840 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1834 | 1841 | ||
1835 | KConfig *config = KOGlobals::config(); | 1842 | KConfig *config = KOGlobals::config(); |
1836 | 1843 | ||
1837 | #ifndef KORG_NOSPLITTER | 1844 | #ifndef KORG_NOSPLITTER |
1838 | config->setGroup("KOrganizer Geometry"); | 1845 | config->setGroup("KOrganizer Geometry"); |
1839 | 1846 | ||
1840 | QValueList<int> list = mPanner->sizes(); | 1847 | QValueList<int> list = mPanner->sizes(); |
1841 | config->writeEntry("Separator1",list); | 1848 | config->writeEntry("Separator1",list); |
1842 | 1849 | ||
1843 | list = mLeftSplitter->sizes(); | 1850 | list = mLeftSplitter->sizes(); |
1844 | config->writeEntry("Separator2",list); | 1851 | config->writeEntry("Separator2",list); |
1845 | #endif | 1852 | #endif |
1846 | 1853 | ||
1847 | mViewManager->writeSettings( config ); | 1854 | mViewManager->writeSettings( config ); |
1848 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1855 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1849 | mDialogManager->writeSettings( config ); | 1856 | mDialogManager->writeSettings( config ); |
1850 | //KOPrefs::instance()->usrWriteConfig(); | 1857 | //KOPrefs::instance()->usrWriteConfig(); |
1851 | KOPrefs::instance()->writeConfig(); | 1858 | KOPrefs::instance()->writeConfig(); |
1852 | 1859 | ||
1853 | writeFilterSettings(config); | 1860 | writeFilterSettings(config); |
1854 | 1861 | ||
1855 | config->setGroup( "Views" ); | 1862 | config->setGroup( "Views" ); |
1856 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1863 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1857 | 1864 | ||
1858 | #ifdef DESKTOP_VERSION | 1865 | #ifdef DESKTOP_VERSION |
1859 | config->setGroup("WidgetLayout"); | 1866 | config->setGroup("WidgetLayout"); |
1860 | QStringList list ;//= config->readListEntry("MainLayout"); | 1867 | QStringList list ;//= config->readListEntry("MainLayout"); |
1861 | int x,y,w,h; | 1868 | int x,y,w,h; |
1862 | QWidget* wid; | 1869 | QWidget* wid; |
1863 | wid = topLevelWidget(); | 1870 | wid = topLevelWidget(); |
1864 | x = wid->geometry().x(); | 1871 | x = wid->geometry().x(); |
1865 | y = wid->geometry().y(); | 1872 | y = wid->geometry().y(); |
1866 | w = wid->width(); | 1873 | w = wid->width(); |
1867 | h = wid->height(); | 1874 | h = wid->height(); |
1868 | list.clear(); | 1875 | list.clear(); |
1869 | list << QString::number( x ); | 1876 | list << QString::number( x ); |
1870 | list << QString::number( y ); | 1877 | list << QString::number( y ); |
1871 | list << QString::number( w ); | 1878 | list << QString::number( w ); |
1872 | list << QString::number( h ); | 1879 | list << QString::number( h ); |
1873 | config->writeEntry("MainLayout",list ); | 1880 | config->writeEntry("MainLayout",list ); |
1874 | 1881 | ||
1875 | wid = mEventEditor; | 1882 | wid = mEventEditor; |
1876 | x = wid->geometry().x(); | 1883 | x = wid->geometry().x(); |
1877 | y = wid->geometry().y(); | 1884 | y = wid->geometry().y(); |
1878 | w = wid->width(); | 1885 | w = wid->width(); |
1879 | h = wid->height(); | 1886 | h = wid->height(); |
1880 | list.clear(); | 1887 | list.clear(); |
1881 | list << QString::number( x ); | 1888 | list << QString::number( x ); |
1882 | list << QString::number( y ); | 1889 | list << QString::number( y ); |
1883 | list << QString::number( w ); | 1890 | list << QString::number( w ); |
1884 | list << QString::number( h ); | 1891 | list << QString::number( h ); |
1885 | config->writeEntry("EditEventLayout",list ); | 1892 | config->writeEntry("EditEventLayout",list ); |
1886 | 1893 | ||
1887 | wid = mTodoEditor; | 1894 | wid = mTodoEditor; |
1888 | x = wid->geometry().x(); | 1895 | x = wid->geometry().x(); |
1889 | y = wid->geometry().y(); | 1896 | y = wid->geometry().y(); |
1890 | w = wid->width(); | 1897 | w = wid->width(); |
1891 | h = wid->height(); | 1898 | h = wid->height(); |
1892 | list.clear(); | 1899 | list.clear(); |
1893 | list << QString::number( x ); | 1900 | list << QString::number( x ); |
1894 | list << QString::number( y ); | 1901 | list << QString::number( y ); |
1895 | list << QString::number( w ); | 1902 | list << QString::number( w ); |
1896 | list << QString::number( h ); | 1903 | list << QString::number( h ); |
1897 | config->writeEntry("EditTodoLayout",list ); | 1904 | config->writeEntry("EditTodoLayout",list ); |
1898 | wid = getEventViewerDialog(); | 1905 | wid = getEventViewerDialog(); |
1899 | x = wid->geometry().x(); | 1906 | x = wid->geometry().x(); |
1900 | y = wid->geometry().y(); | 1907 | y = wid->geometry().y(); |
1901 | w = wid->width(); | 1908 | w = wid->width(); |
1902 | h = wid->height(); | 1909 | h = wid->height(); |
1903 | list.clear(); | 1910 | list.clear(); |
1904 | list << QString::number( x ); | 1911 | list << QString::number( x ); |
1905 | list << QString::number( y ); | 1912 | list << QString::number( y ); |
1906 | list << QString::number( w ); | 1913 | list << QString::number( w ); |
1907 | list << QString::number( h ); | 1914 | list << QString::number( h ); |
1908 | config->writeEntry("ViewerLayout",list ); | 1915 | config->writeEntry("ViewerLayout",list ); |
1909 | wid = mDialogManager->getSearchDialog(); | 1916 | wid = mDialogManager->getSearchDialog(); |
1910 | if ( wid ) { | 1917 | if ( wid ) { |
1911 | x = wid->geometry().x(); | 1918 | x = wid->geometry().x(); |
1912 | y = wid->geometry().y(); | 1919 | y = wid->geometry().y(); |
1913 | w = wid->width(); | 1920 | w = wid->width(); |
1914 | h = wid->height(); | 1921 | h = wid->height(); |
1915 | list.clear(); | 1922 | list.clear(); |
1916 | list << QString::number( x ); | 1923 | list << QString::number( x ); |
1917 | list << QString::number( y ); | 1924 | list << QString::number( y ); |
1918 | list << QString::number( w ); | 1925 | list << QString::number( w ); |
1919 | list << QString::number( h ); | 1926 | list << QString::number( h ); |
1920 | config->writeEntry("SearchLayout",list ); | 1927 | config->writeEntry("SearchLayout",list ); |
1921 | } | 1928 | } |
1922 | #endif | 1929 | #endif |
1923 | 1930 | ||
1924 | 1931 | ||
1925 | config->sync(); | 1932 | config->sync(); |
1926 | } | 1933 | } |
1927 | 1934 | ||
1928 | void CalendarView::readFilterSettings(KConfig *config) | 1935 | void CalendarView::readFilterSettings(KConfig *config) |
1929 | { | 1936 | { |
1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1937 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1931 | 1938 | ||
1932 | mFilters.clear(); | 1939 | mFilters.clear(); |
1933 | 1940 | ||
1934 | config->setGroup("General"); | 1941 | config->setGroup("General"); |
1935 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1942 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1936 | 1943 | ||
1937 | QStringList::ConstIterator it = filterList.begin(); | 1944 | QStringList::ConstIterator it = filterList.begin(); |
1938 | QStringList::ConstIterator end = filterList.end(); | 1945 | QStringList::ConstIterator end = filterList.end(); |
1939 | while(it != end) { | 1946 | while(it != end) { |
1940 | // kdDebug() << " filter: " << (*it) << endl; | 1947 | // kdDebug() << " filter: " << (*it) << endl; |
1941 | 1948 | ||
1942 | CalFilter *filter; | 1949 | CalFilter *filter; |
1943 | filter = new CalFilter(*it); | 1950 | filter = new CalFilter(*it); |
1944 | config->setGroup("Filter_" + (*it)); | 1951 | config->setGroup("Filter_" + (*it)); |
1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1952 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1953 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1947 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1954 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1948 | mFilters.append(filter); | 1955 | mFilters.append(filter); |
1949 | 1956 | ||
1950 | ++it; | 1957 | ++it; |
1951 | } | 1958 | } |
1952 | 1959 | ||
1953 | if (mFilters.count() == 0) { | 1960 | if (mFilters.count() == 0) { |
1954 | CalFilter *filter = new CalFilter(i18n("Default")); | 1961 | CalFilter *filter = new CalFilter(i18n("Default")); |
1955 | mFilters.append(filter); | 1962 | mFilters.append(filter); |
1956 | } | 1963 | } |
1957 | mFilterView->updateFilters(); | 1964 | mFilterView->updateFilters(); |
1958 | config->setGroup("FilterView"); | 1965 | config->setGroup("FilterView"); |
1959 | 1966 | ||
1960 | mFilterView->blockSignals(true); | 1967 | mFilterView->blockSignals(true); |
1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1968 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1969 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1963 | mFilterView->blockSignals(false); | 1970 | mFilterView->blockSignals(false); |
1964 | // We do it manually to avoid it being done twice by the above calls | 1971 | // We do it manually to avoid it being done twice by the above calls |
1965 | updateFilter(); | 1972 | updateFilter(); |
1966 | } | 1973 | } |
1967 | 1974 | ||
1968 | void CalendarView::writeFilterSettings(KConfig *config) | 1975 | void CalendarView::writeFilterSettings(KConfig *config) |
1969 | { | 1976 | { |
1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1977 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1971 | 1978 | ||
1972 | QStringList filterList; | 1979 | QStringList filterList; |
1973 | 1980 | ||
1974 | CalFilter *filter = mFilters.first(); | 1981 | CalFilter *filter = mFilters.first(); |
1975 | while(filter) { | 1982 | while(filter) { |
1976 | // kdDebug() << " fn: " << filter->name() << endl; | 1983 | // kdDebug() << " fn: " << filter->name() << endl; |
1977 | filterList << filter->name(); | 1984 | filterList << filter->name(); |
1978 | config->setGroup("Filter_" + filter->name()); | 1985 | config->setGroup("Filter_" + filter->name()); |
1979 | config->writeEntry("Criteria",filter->criteria()); | 1986 | config->writeEntry("Criteria",filter->criteria()); |
1980 | config->writeEntry("CategoryList",filter->categoryList()); | 1987 | config->writeEntry("CategoryList",filter->categoryList()); |
1981 | filter = mFilters.next(); | 1988 | filter = mFilters.next(); |
1982 | } | 1989 | } |
1983 | config->setGroup("General"); | 1990 | config->setGroup("General"); |
1984 | config->writeEntry("CalendarFilters",filterList); | 1991 | config->writeEntry("CalendarFilters",filterList); |
1985 | 1992 | ||
1986 | config->setGroup("FilterView"); | 1993 | config->setGroup("FilterView"); |
1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1994 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1995 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1989 | } | 1996 | } |
1990 | 1997 | ||
1991 | 1998 | ||
1992 | void CalendarView::goToday() | 1999 | void CalendarView::goToday() |
1993 | { | 2000 | { |
1994 | if ( mViewManager->currentView()->isMonthView() ) | 2001 | if ( mViewManager->currentView()->isMonthView() ) |
1995 | mNavigator->selectTodayMonth(); | 2002 | mNavigator->selectTodayMonth(); |
1996 | else | 2003 | else |
1997 | mNavigator->selectToday(); | 2004 | mNavigator->selectToday(); |
1998 | } | 2005 | } |
1999 | 2006 | ||
2000 | void CalendarView::goNext() | 2007 | void CalendarView::goNext() |
2001 | { | 2008 | { |
2002 | mNavigator->selectNext(); | 2009 | mNavigator->selectNext(); |
2003 | } | 2010 | } |
2004 | 2011 | ||
2005 | void CalendarView::goPrevious() | 2012 | void CalendarView::goPrevious() |
2006 | { | 2013 | { |
2007 | mNavigator->selectPrevious(); | 2014 | mNavigator->selectPrevious(); |
2008 | } | 2015 | } |
2009 | void CalendarView::goNextMonth() | 2016 | void CalendarView::goNextMonth() |
2010 | { | 2017 | { |
2011 | mNavigator->selectNextMonth(); | 2018 | mNavigator->selectNextMonth(); |
2012 | } | 2019 | } |
2013 | 2020 | ||
2014 | void CalendarView::goPreviousMonth() | 2021 | void CalendarView::goPreviousMonth() |
2015 | { | 2022 | { |
2016 | mNavigator->selectPreviousMonth(); | 2023 | mNavigator->selectPreviousMonth(); |
2017 | } | 2024 | } |
2018 | void CalendarView::writeLocale() | 2025 | void CalendarView::writeLocale() |
2019 | { | 2026 | { |
2020 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2027 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2021 | #if 0 | 2028 | #if 0 |
2022 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2029 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2023 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2030 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2024 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2031 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2025 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2032 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2026 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2033 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2027 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2034 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2028 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2035 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2029 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2036 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2030 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2037 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2031 | KOPrefs::instance()->mDaylightsavingStart, | 2038 | KOPrefs::instance()->mDaylightsavingStart, |
2032 | KOPrefs::instance()->mDaylightsavingEnd ); | 2039 | KOPrefs::instance()->mDaylightsavingEnd ); |
2033 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2040 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2034 | #endif | 2041 | #endif |
2035 | } | 2042 | } |
2036 | void CalendarView::updateConfig() | 2043 | void CalendarView::updateConfig() |
2037 | { | 2044 | { |
2038 | writeLocale(); | 2045 | writeLocale(); |
2039 | if ( KOPrefs::instance()->mUseAppColors ) | 2046 | if ( KOPrefs::instance()->mUseAppColors ) |
2040 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2047 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2041 | emit configChanged(); | 2048 | emit configChanged(); |
2042 | mTodoList->updateConfig(); | 2049 | mTodoList->updateConfig(); |
2043 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2050 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2044 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2051 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2045 | // To make the "fill window" configurations work | 2052 | // To make the "fill window" configurations work |
2046 | //mViewManager->raiseCurrentView(); | 2053 | //mViewManager->raiseCurrentView(); |
2047 | } | 2054 | } |
2048 | 2055 | ||
2049 | 2056 | ||
2050 | void CalendarView::eventChanged(Event *event) | 2057 | void CalendarView::eventChanged(Event *event) |
2051 | { | 2058 | { |
2052 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2059 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2053 | //updateUnmanagedViews(); | 2060 | //updateUnmanagedViews(); |
2054 | } | 2061 | } |
2055 | 2062 | ||
2056 | void CalendarView::eventAdded(Event *event) | 2063 | void CalendarView::eventAdded(Event *event) |
2057 | { | 2064 | { |
2058 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2065 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2059 | } | 2066 | } |
2060 | 2067 | ||
2061 | void CalendarView::eventToBeDeleted(Event *) | 2068 | void CalendarView::eventToBeDeleted(Event *) |
2062 | { | 2069 | { |
2063 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2070 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2064 | } | 2071 | } |
2065 | 2072 | ||
2066 | void CalendarView::eventDeleted() | 2073 | void CalendarView::eventDeleted() |
2067 | { | 2074 | { |
2068 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2075 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2069 | } | 2076 | } |
2070 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2077 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2071 | { | 2078 | { |
2072 | changeIncidenceDisplay((Incidence *)which, action); | 2079 | changeIncidenceDisplay((Incidence *)which, action); |
2073 | mDateNavigator->updateView(); //LR | 2080 | mDateNavigator->updateView(); //LR |
2074 | //mDialogManager->updateSearchDialog(); | 2081 | //mDialogManager->updateSearchDialog(); |
2075 | 2082 | ||
2076 | if (which) { | 2083 | if (which) { |
2077 | mViewManager->updateWNview(); | 2084 | mViewManager->updateWNview(); |
2078 | //mTodoList->updateView(); | 2085 | //mTodoList->updateView(); |
2079 | } | 2086 | } |
2080 | 2087 | ||
2081 | } | 2088 | } |
2082 | 2089 | ||
2083 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2090 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2084 | { | 2091 | { |
2085 | updateUnmanagedViews(); | 2092 | updateUnmanagedViews(); |
2086 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2093 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2087 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2094 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2088 | mCalendar->checkAlarmForIncidence( 0, true ); | 2095 | mCalendar->checkAlarmForIncidence( 0, true ); |
2089 | if ( mEventViewerDialog ) | 2096 | if ( mEventViewerDialog ) |
2090 | mEventViewerDialog->hide(); | 2097 | mEventViewerDialog->hide(); |
2091 | } | 2098 | } |
2092 | else | 2099 | else |
2093 | mCalendar->checkAlarmForIncidence( which , false ); | 2100 | mCalendar->checkAlarmForIncidence( which , false ); |
2094 | } | 2101 | } |
2095 | 2102 | ||
2096 | // most of the changeEventDisplays() right now just call the view's | 2103 | // most of the changeEventDisplays() right now just call the view's |
2097 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2104 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2098 | void CalendarView::changeEventDisplay(Event *which, int action) | 2105 | void CalendarView::changeEventDisplay(Event *which, int action) |
2099 | { | 2106 | { |
2100 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2107 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2101 | changeIncidenceDisplay((Incidence *)which, action); | 2108 | changeIncidenceDisplay((Incidence *)which, action); |
2102 | mDateNavigator->updateView(); | 2109 | mDateNavigator->updateView(); |
2103 | //mDialogManager->updateSearchDialog(); | 2110 | //mDialogManager->updateSearchDialog(); |
2104 | 2111 | ||
2105 | if (which) { | 2112 | if (which) { |
2106 | // If there is an event view visible update the display | 2113 | // If there is an event view visible update the display |
2107 | mViewManager->currentView()->changeEventDisplay(which,action); | 2114 | mViewManager->currentView()->changeEventDisplay(which,action); |
2108 | // TODO: check, if update needed | 2115 | // TODO: check, if update needed |
2109 | // if (which->getTodoStatus()) { | 2116 | // if (which->getTodoStatus()) { |
2110 | mTodoList->updateView(); | 2117 | mTodoList->updateView(); |
2111 | // } | 2118 | // } |
2112 | } else { | 2119 | } else { |
2113 | mViewManager->currentView()->updateView(); | 2120 | mViewManager->currentView()->updateView(); |
2114 | } | 2121 | } |
2115 | } | 2122 | } |
2116 | 2123 | ||
2117 | 2124 | ||
2118 | void CalendarView::updateTodoViews() | 2125 | void CalendarView::updateTodoViews() |
2119 | { | 2126 | { |
2120 | 2127 | ||
2121 | mTodoList->updateView(); | 2128 | mTodoList->updateView(); |
2122 | mViewManager->currentView()->updateView(); | 2129 | mViewManager->currentView()->updateView(); |
2123 | 2130 | ||
2124 | } | 2131 | } |
2125 | 2132 | ||
2126 | 2133 | ||
2127 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2134 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2128 | { | 2135 | { |
2129 | mTodoList->updateView(); | 2136 | mTodoList->updateView(); |
2130 | mViewManager->updateView(start, end); | 2137 | mViewManager->updateView(start, end); |
2131 | //mDateNavigator->updateView(); | 2138 | //mDateNavigator->updateView(); |
2132 | } | 2139 | } |
2133 | 2140 | ||
2134 | void CalendarView::updateView() | 2141 | void CalendarView::updateView() |
2135 | { | 2142 | { |
2136 | DateList tmpList = mNavigator->selectedDates(); | 2143 | DateList tmpList = mNavigator->selectedDates(); |
2137 | 2144 | ||
2138 | // We assume that the navigator only selects consecutive days. | 2145 | // We assume that the navigator only selects consecutive days. |
2139 | updateView( tmpList.first(), tmpList.last() ); | 2146 | updateView( tmpList.first(), tmpList.last() ); |
2140 | } | 2147 | } |
2141 | 2148 | ||
2142 | void CalendarView::updateUnmanagedViews() | 2149 | void CalendarView::updateUnmanagedViews() |
2143 | { | 2150 | { |
2144 | mDateNavigator->updateDayMatrix(); | 2151 | mDateNavigator->updateDayMatrix(); |
2145 | } | 2152 | } |
2146 | 2153 | ||
2147 | int CalendarView::msgItemDelete() | 2154 | int CalendarView::msgItemDelete() |
2148 | { | 2155 | { |
2149 | return KMessageBox::warningContinueCancel(this, | 2156 | return KMessageBox::warningContinueCancel(this, |
2150 | i18n("This item will be\npermanently deleted."), | 2157 | i18n("This item will be\npermanently deleted."), |
2151 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2158 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2152 | } | 2159 | } |
2153 | 2160 | ||
2154 | 2161 | ||
2155 | void CalendarView::edit_cut() | 2162 | void CalendarView::edit_cut() |
2156 | { | 2163 | { |
2157 | Event *anEvent=0; | 2164 | Event *anEvent=0; |
2158 | 2165 | ||
2159 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2166 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2160 | 2167 | ||
2161 | if (mViewManager->currentView()->isEventView()) { | 2168 | if (mViewManager->currentView()->isEventView()) { |
2162 | if ( incidence && incidence->type() == "Event" ) { | 2169 | if ( incidence && incidence->type() == "Event" ) { |
2163 | anEvent = static_cast<Event *>(incidence); | 2170 | anEvent = static_cast<Event *>(incidence); |
2164 | } | 2171 | } |
2165 | } | 2172 | } |
2166 | 2173 | ||
2167 | if (!anEvent) { | 2174 | if (!anEvent) { |
2168 | KNotifyClient::beep(); | 2175 | KNotifyClient::beep(); |
2169 | return; | 2176 | return; |
2170 | } | 2177 | } |
2171 | DndFactory factory( mCalendar ); | 2178 | DndFactory factory( mCalendar ); |
2172 | factory.cutEvent(anEvent); | 2179 | factory.cutEvent(anEvent); |
2173 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2180 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2174 | } | 2181 | } |
2175 | 2182 | ||
2176 | void CalendarView::edit_copy() | 2183 | void CalendarView::edit_copy() |
2177 | { | 2184 | { |
2178 | Event *anEvent=0; | 2185 | Event *anEvent=0; |
2179 | 2186 | ||
2180 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2181 | 2188 | ||
2182 | if (mViewManager->currentView()->isEventView()) { | 2189 | if (mViewManager->currentView()->isEventView()) { |
2183 | if ( incidence && incidence->type() == "Event" ) { | 2190 | if ( incidence && incidence->type() == "Event" ) { |
2184 | anEvent = static_cast<Event *>(incidence); | 2191 | anEvent = static_cast<Event *>(incidence); |
2185 | } | 2192 | } |
2186 | } | 2193 | } |
2187 | 2194 | ||
2188 | if (!anEvent) { | 2195 | if (!anEvent) { |
2189 | KNotifyClient::beep(); | 2196 | KNotifyClient::beep(); |
2190 | return; | 2197 | return; |
2191 | } | 2198 | } |
2192 | DndFactory factory( mCalendar ); | 2199 | DndFactory factory( mCalendar ); |
2193 | factory.copyEvent(anEvent); | 2200 | factory.copyEvent(anEvent); |
2194 | } | 2201 | } |
2195 | 2202 | ||
2196 | void CalendarView::edit_paste() | 2203 | void CalendarView::edit_paste() |
2197 | { | 2204 | { |
2198 | QDate date = mNavigator->selectedDates().first(); | 2205 | QDate date = mNavigator->selectedDates().first(); |
2199 | 2206 | ||
2200 | DndFactory factory( mCalendar ); | 2207 | DndFactory factory( mCalendar ); |
2201 | Event *pastedEvent = factory.pasteEvent( date ); | 2208 | Event *pastedEvent = factory.pasteEvent( date ); |
2202 | 2209 | ||
2203 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2210 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2204 | } | 2211 | } |
2205 | 2212 | ||
2206 | void CalendarView::edit_options() | 2213 | void CalendarView::edit_options() |
2207 | { | 2214 | { |
2208 | mDialogManager->showOptionsDialog(); | 2215 | mDialogManager->showOptionsDialog(); |
2209 | //writeSettings(); | 2216 | //writeSettings(); |
2210 | } | 2217 | } |
2211 | 2218 | ||
2219 | |||
2212 | void CalendarView::slotSelectPickerDate( QDate d) | 2220 | void CalendarView::slotSelectPickerDate( QDate d) |
2213 | { | 2221 | { |
2214 | mDateFrame->hide(); | 2222 | mDateFrame->hide(); |
2215 | if ( mDatePickerMode == 1 ) { | 2223 | if ( mDatePickerMode == 1 ) { |
2216 | mNavigator->slotDaySelect( d ); | 2224 | mNavigator->slotDaySelect( d ); |
2217 | } else if ( mDatePickerMode == 2 ) { | 2225 | } else if ( mDatePickerMode == 2 ) { |
2218 | if ( mMoveIncidence->type() == "Todo" ) { | 2226 | if ( mMoveIncidence->type() == "Todo" ) { |
2219 | Todo * to = (Todo *) mMoveIncidence; | 2227 | Todo * to = (Todo *) mMoveIncidence; |
2220 | QTime tim; | 2228 | QTime tim; |
2221 | if ( to->hasDueDate() ) | 2229 | if ( to->hasDueDate() ) |
2222 | tim = to->dtDue().time(); | 2230 | tim = to->dtDue().time(); |
2223 | else { | 2231 | else { |
2224 | tim = QTime ( 0,0,0 ); | 2232 | tim = QTime ( 0,0,0 ); |
2225 | to->setFloats( true ); | 2233 | to->setFloats( true ); |
2226 | to->setHasDueDate( true ); | 2234 | to->setHasDueDate( true ); |
2227 | } | 2235 | } |
2228 | QDateTime dt ( d,tim ); | 2236 | QDateTime dt ( d,tim ); |
2229 | to->setDtDue( dt ); | 2237 | to->setDtDue( dt ); |
2230 | todoChanged( to ); | 2238 | todoChanged( to ); |
2231 | } else { | 2239 | } else { |
2240 | if ( mMoveIncidence->doesRecur() ) { | ||
2241 | #if 0 | ||
2242 | // PENDING implement this | ||
2243 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | ||
2244 | mCalendar()->addIncidence( newInc ); | ||
2245 | if ( mMoveIncidence->type() == "Todo" ) | ||
2246 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | ||
2247 | else | ||
2248 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | ||
2249 | mMoveIncidence = newInc; | ||
2250 | |||
2251 | #endif | ||
2252 | } | ||
2232 | QTime tim = mMoveIncidence->dtStart().time(); | 2253 | QTime tim = mMoveIncidence->dtStart().time(); |
2233 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2254 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2234 | QDateTime dt ( d,tim ); | 2255 | QDateTime dt ( d,tim ); |
2235 | mMoveIncidence->setDtStart( dt ); | 2256 | mMoveIncidence->setDtStart( dt ); |
2236 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2257 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2237 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2258 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2238 | } | 2259 | } |
2239 | 2260 | ||
2240 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2261 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2241 | } | 2262 | } |
2242 | } | 2263 | } |
2243 | 2264 | ||
2244 | void CalendarView::removeCategories() | 2265 | void CalendarView::removeCategories() |
2245 | { | 2266 | { |
2246 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2267 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2247 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2268 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2248 | QStringList catIncList; | 2269 | QStringList catIncList; |
2249 | QStringList newCatList; | 2270 | QStringList newCatList; |
2250 | Incidence* inc = incList.first(); | 2271 | Incidence* inc = incList.first(); |
2251 | int i; | 2272 | int i; |
2252 | int count = 0; | 2273 | int count = 0; |
2253 | while ( inc ) { | 2274 | while ( inc ) { |
2254 | newCatList.clear(); | 2275 | newCatList.clear(); |
2255 | catIncList = inc->categories() ; | 2276 | catIncList = inc->categories() ; |
2256 | for( i = 0; i< catIncList.count(); ++i ) { | 2277 | for( i = 0; i< catIncList.count(); ++i ) { |
2257 | if ( catList.contains (catIncList[i])) | 2278 | if ( catList.contains (catIncList[i])) |
2258 | newCatList.append( catIncList[i] ); | 2279 | newCatList.append( catIncList[i] ); |
2259 | } | 2280 | } |
2260 | newCatList.sort(); | 2281 | newCatList.sort(); |
2261 | inc->setCategories( newCatList.join(",") ); | 2282 | inc->setCategories( newCatList.join(",") ); |
2262 | inc = incList.next(); | 2283 | inc = incList.next(); |
2263 | } | 2284 | } |
2264 | } | 2285 | } |
2265 | 2286 | ||
2266 | int CalendarView::addCategories() | 2287 | int CalendarView::addCategories() |
2267 | { | 2288 | { |
2268 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2289 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2269 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2290 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2270 | QStringList catIncList; | 2291 | QStringList catIncList; |
2271 | Incidence* inc = incList.first(); | 2292 | Incidence* inc = incList.first(); |
2272 | int i; | 2293 | int i; |
2273 | int count = 0; | 2294 | int count = 0; |
2274 | while ( inc ) { | 2295 | while ( inc ) { |
2275 | catIncList = inc->categories() ; | 2296 | catIncList = inc->categories() ; |
2276 | for( i = 0; i< catIncList.count(); ++i ) { | 2297 | for( i = 0; i< catIncList.count(); ++i ) { |
2277 | if ( !catList.contains (catIncList[i])) { | 2298 | if ( !catList.contains (catIncList[i])) { |
2278 | catList.append( catIncList[i] ); | 2299 | catList.append( catIncList[i] ); |
2279 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2300 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2280 | ++count; | 2301 | ++count; |
2281 | } | 2302 | } |
2282 | } | 2303 | } |
2283 | inc = incList.next(); | 2304 | inc = incList.next(); |
2284 | } | 2305 | } |
2285 | catList.sort(); | 2306 | catList.sort(); |
2286 | KOPrefs::instance()->mCustomCategories = catList; | 2307 | KOPrefs::instance()->mCustomCategories = catList; |
2287 | return count; | 2308 | return count; |
2288 | } | 2309 | } |
2289 | 2310 | ||
2290 | void CalendarView::manageCategories() | 2311 | void CalendarView::manageCategories() |
2291 | { | 2312 | { |
2292 | KOCatPrefs* cp = new KOCatPrefs(); | 2313 | KOCatPrefs* cp = new KOCatPrefs(); |
2293 | cp->show(); | 2314 | cp->show(); |
2294 | int w =cp->sizeHint().width() ; | 2315 | int w =cp->sizeHint().width() ; |
2295 | int h = cp->sizeHint().height() ; | 2316 | int h = cp->sizeHint().height() ; |
2296 | int dw = QApplication::desktop()->width(); | 2317 | int dw = QApplication::desktop()->width(); |
2297 | int dh = QApplication::desktop()->height(); | 2318 | int dh = QApplication::desktop()->height(); |
2298 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2319 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2299 | if ( !cp->exec() ) { | 2320 | if ( !cp->exec() ) { |
2300 | delete cp; | 2321 | delete cp; |
2301 | return; | 2322 | return; |
2302 | } | 2323 | } |
2303 | int count = 0; | 2324 | int count = 0; |
2304 | if ( cp->addCat() ) { | 2325 | if ( cp->addCat() ) { |
2305 | count = addCategories(); | 2326 | count = addCategories(); |
2306 | if ( count ) { | 2327 | if ( count ) { |
2307 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2328 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2308 | writeSettings(); | 2329 | writeSettings(); |
2309 | } else | 2330 | } else |
2310 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2331 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2311 | } else { | 2332 | } else { |
2312 | removeCategories(); | 2333 | removeCategories(); |
2313 | updateView(); | 2334 | updateView(); |
2314 | } | 2335 | } |
2315 | delete cp; | 2336 | delete cp; |
2316 | } | 2337 | } |
2317 | 2338 | ||
2318 | void CalendarView::beamIncidence(Incidence * Inc) | 2339 | void CalendarView::beamIncidence(Incidence * Inc) |
2319 | { | 2340 | { |
2320 | QPtrList<Incidence> delSel ; | 2341 | QPtrList<Incidence> delSel ; |
2321 | delSel.append(Inc); | 2342 | delSel.append(Inc); |
2322 | beamIncidenceList( delSel ); | 2343 | beamIncidenceList( delSel ); |
2323 | } | 2344 | } |
2324 | void CalendarView::beamCalendar() | 2345 | void CalendarView::beamCalendar() |
2325 | { | 2346 | { |
2326 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2347 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2327 | //qDebug("beamCalendar() "); | 2348 | //qDebug("beamCalendar() "); |
2328 | beamIncidenceList( delSel ); | 2349 | beamIncidenceList( delSel ); |
2329 | } | 2350 | } |
2330 | void CalendarView::beamFilteredCalendar() | 2351 | void CalendarView::beamFilteredCalendar() |
2331 | { | 2352 | { |
2332 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2353 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2333 | //qDebug("beamFilteredCalendar() "); | 2354 | //qDebug("beamFilteredCalendar() "); |
2334 | beamIncidenceList( delSel ); | 2355 | beamIncidenceList( delSel ); |
2335 | } | 2356 | } |
2336 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2357 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2337 | { | 2358 | { |
2338 | if ( beamDialog->exec () == QDialog::Rejected ) | 2359 | if ( beamDialog->exec () == QDialog::Rejected ) |
2339 | return; | 2360 | return; |
2340 | #ifdef DESKTOP_VERSION | 2361 | #ifdef DESKTOP_VERSION |
2341 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2362 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2342 | #else | 2363 | #else |
2343 | QString fn = "/tmp/kopibeamfile"; | 2364 | QString fn = "/tmp/kopibeamfile"; |
2344 | #endif | 2365 | #endif |
2345 | QString mes; | 2366 | QString mes; |
2346 | bool createbup = true; | 2367 | bool createbup = true; |
2347 | if ( createbup ) { | 2368 | if ( createbup ) { |
2348 | QString description = "\n"; | 2369 | QString description = "\n"; |
2349 | CalendarLocal* cal = new CalendarLocal(); | 2370 | CalendarLocal* cal = new CalendarLocal(); |
2350 | if ( beamDialog->beamLocal() ) | 2371 | if ( beamDialog->beamLocal() ) |
2351 | cal->setLocalTime(); | 2372 | cal->setLocalTime(); |
2352 | else | 2373 | else |
2353 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2374 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2354 | Incidence *incidence = delSel.first(); | 2375 | Incidence *incidence = delSel.first(); |
2355 | bool addText = false; | 2376 | bool addText = false; |
2356 | if ( delSel.count() < 10 ) | 2377 | if ( delSel.count() < 10 ) |
2357 | addText = true; | 2378 | addText = true; |
2358 | else { | 2379 | else { |
2359 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2380 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2360 | } | 2381 | } |
2361 | while ( incidence ) { | 2382 | while ( incidence ) { |
2362 | Incidence *in = incidence->clone(); | 2383 | Incidence *in = incidence->clone(); |
2363 | if ( ! in->summary().isEmpty() ) { | 2384 | if ( ! in->summary().isEmpty() ) { |
2364 | in->setDescription(""); | 2385 | in->setDescription(""); |
2365 | } else { | 2386 | } else { |
2366 | in->setSummary( in->description().left(20)); | 2387 | in->setSummary( in->description().left(20)); |
2367 | in->setDescription(""); | 2388 | in->setDescription(""); |
2368 | } | 2389 | } |
2369 | if ( addText ) | 2390 | if ( addText ) |
2370 | description += in->summary() + "\n"; | 2391 | description += in->summary() + "\n"; |
2371 | cal->addIncidence( in ); | 2392 | cal->addIncidence( in ); |
2372 | incidence = delSel.next(); | 2393 | incidence = delSel.next(); |
2373 | } | 2394 | } |
2374 | if ( beamDialog->beamVcal() ) { | 2395 | if ( beamDialog->beamVcal() ) { |
2375 | fn += ".vcs"; | 2396 | fn += ".vcs"; |
2376 | FileStorage storage( cal, fn, new VCalFormat ); | 2397 | FileStorage storage( cal, fn, new VCalFormat ); |
2377 | storage.save(); | 2398 | storage.save(); |
2378 | } else { | 2399 | } else { |
2379 | fn += ".ics"; | 2400 | fn += ".ics"; |
2380 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2401 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2381 | storage.save(); | 2402 | storage.save(); |
2382 | } | 2403 | } |
2383 | delete cal; | 2404 | delete cal; |
2384 | mes = i18n("KO/Pi: Ready for beaming"); | 2405 | mes = i18n("KO/Pi: Ready for beaming"); |
2385 | topLevelWidget()->setCaption(mes); | 2406 | topLevelWidget()->setCaption(mes); |
2386 | KApplication::convert2latin1( fn ); | 2407 | KApplication::convert2latin1( fn ); |
2387 | #ifndef DESKTOP_VERSION | 2408 | #ifndef DESKTOP_VERSION |
2388 | Ir *ir = new Ir( this ); | 2409 | Ir *ir = new Ir( this ); |
2389 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2410 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2390 | ir->send( fn, description, "text/x-vCalendar" ); | 2411 | ir->send( fn, description, "text/x-vCalendar" ); |
2391 | #endif | 2412 | #endif |
2392 | } | 2413 | } |
2393 | } | 2414 | } |
2394 | void CalendarView::beamDone( Ir *ir ) | 2415 | void CalendarView::beamDone( Ir *ir ) |
2395 | { | 2416 | { |
2396 | #ifndef DESKTOP_VERSION | 2417 | #ifndef DESKTOP_VERSION |
2397 | delete ir; | 2418 | delete ir; |
2398 | #endif | 2419 | #endif |
2399 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2420 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2400 | topLevelWidget()->raise(); | 2421 | topLevelWidget()->raise(); |
2401 | } | 2422 | } |
2402 | 2423 | ||
2403 | void CalendarView::moveIncidence(Incidence * inc ) | 2424 | void CalendarView::moveIncidence(Incidence * inc ) |
2404 | { | 2425 | { |
2405 | if ( !inc ) return; | 2426 | if ( !inc ) return; |
2406 | // qDebug("showDatePickerForIncidence( ) "); | 2427 | // qDebug("showDatePickerForIncidence( ) "); |
2407 | if ( mDateFrame->isVisible() ) | 2428 | if ( mDateFrame->isVisible() ) |
2408 | mDateFrame->hide(); | 2429 | mDateFrame->hide(); |
2409 | else { | 2430 | else { |
2410 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2431 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2411 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2432 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2412 | int dw = QApplication::desktop()->width(); | 2433 | int dw = QApplication::desktop()->width(); |
2413 | int dh = QApplication::desktop()->height(); | 2434 | int dh = QApplication::desktop()->height(); |
2414 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2435 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2415 | mDateFrame->show(); | 2436 | mDateFrame->show(); |
2416 | } | 2437 | } |
2417 | mDatePickerMode = 2; | 2438 | mDatePickerMode = 2; |
2418 | mMoveIncidence = inc ; | 2439 | mMoveIncidence = inc ; |
2419 | QDate da; | 2440 | QDate da; |
2420 | if ( mMoveIncidence->type() == "Todo" ) { | 2441 | if ( mMoveIncidence->type() == "Todo" ) { |
2421 | Todo * to = (Todo *) mMoveIncidence; | 2442 | Todo * to = (Todo *) mMoveIncidence; |
2422 | if ( to->hasDueDate() ) | 2443 | if ( to->hasDueDate() ) |
2423 | da = to->dtDue().date(); | 2444 | da = to->dtDue().date(); |
2424 | else | 2445 | else |
2425 | da = QDate::currentDate(); | 2446 | da = QDate::currentDate(); |
2426 | } else { | 2447 | } else { |
2427 | da = mMoveIncidence->dtStart().date(); | 2448 | da = mMoveIncidence->dtStart().date(); |
2428 | } | 2449 | } |
2450 | //PENDING set date for recurring incidence to date of recurrence | ||
2451 | //mMoveIncidenceOldDate; | ||
2429 | mDatePicker->setDate( da ); | 2452 | mDatePicker->setDate( da ); |
2430 | } | 2453 | } |
2431 | void CalendarView::showDatePicker( ) | 2454 | void CalendarView::showDatePicker( ) |
2432 | { | 2455 | { |
2433 | //qDebug("CalendarView::showDatePicker( ) "); | 2456 | //qDebug("CalendarView::showDatePicker( ) "); |
2434 | if ( mDateFrame->isVisible() ) | 2457 | if ( mDateFrame->isVisible() ) |
2435 | mDateFrame->hide(); | 2458 | mDateFrame->hide(); |
2436 | else { | 2459 | else { |
2437 | int w =mDatePicker->sizeHint().width() ; | 2460 | int w =mDatePicker->sizeHint().width() ; |
2438 | int h = mDatePicker->sizeHint().height() ; | 2461 | int h = mDatePicker->sizeHint().height() ; |
2439 | int dw = QApplication::desktop()->width(); | 2462 | int dw = QApplication::desktop()->width(); |
2440 | int dh = QApplication::desktop()->height(); | 2463 | int dh = QApplication::desktop()->height(); |
2441 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2464 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2442 | mDateFrame->show(); | 2465 | mDateFrame->show(); |
2443 | } | 2466 | } |
2444 | mDatePickerMode = 1; | 2467 | mDatePickerMode = 1; |
2445 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2468 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2446 | } | 2469 | } |
2447 | 2470 | ||
2448 | void CalendarView::showEventEditor() | 2471 | void CalendarView::showEventEditor() |
2449 | { | 2472 | { |
2450 | #ifdef DESKTOP_VERSION | 2473 | #ifdef DESKTOP_VERSION |
2451 | mEventEditor->show(); | 2474 | mEventEditor->show(); |
2452 | #else | 2475 | #else |
2453 | if ( mEventEditor->width() != QApplication::desktop()->width() ) { | 2476 | if ( mEventEditor->width() != QApplication::desktop()->width() ) { |
2454 | qDebug("CalendarView: recreate mEventEditor "); | 2477 | qDebug("CalendarView: recreate mEventEditor "); |
2455 | delete mEventEditor; | 2478 | delete mEventEditor; |
2456 | mEventEditor = mDialogManager->getEventEditor(); | 2479 | mEventEditor = mDialogManager->getEventEditor(); |
2457 | } | 2480 | } |
2458 | mEventEditor->showMaximized(); | 2481 | mEventEditor->showMaximized(); |
2459 | #endif | 2482 | #endif |
2460 | } | 2483 | } |
2461 | void CalendarView::showTodoEditor() | 2484 | void CalendarView::showTodoEditor() |
2462 | { | 2485 | { |
2463 | #ifdef DESKTOP_VERSION | 2486 | #ifdef DESKTOP_VERSION |
2464 | mTodoEditor->show(); | 2487 | mTodoEditor->show(); |
2465 | #else | 2488 | #else |
2466 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) { | 2489 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) { |
2467 | qDebug("CalendarView: recreate mTodoEditor "); | 2490 | qDebug("CalendarView: recreate mTodoEditor "); |
2468 | delete mTodoEditor; | 2491 | delete mTodoEditor; |
2469 | mTodoEditor = mDialogManager->getTodoEditor(); | 2492 | mTodoEditor = mDialogManager->getTodoEditor(); |
2470 | } | 2493 | } |
2471 | mTodoEditor->showMaximized(); | 2494 | mTodoEditor->showMaximized(); |
2472 | #endif | 2495 | #endif |
2473 | } | 2496 | } |
2474 | 2497 | ||
2475 | void CalendarView::cloneIncidence() | 2498 | void CalendarView::cloneIncidence() |
2476 | { | 2499 | { |
2477 | Incidence *incidence = currentSelection(); | 2500 | Incidence *incidence = currentSelection(); |
2478 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2501 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2479 | if ( incidence ) { | 2502 | if ( incidence ) { |
2480 | cloneIncidence(incidence); | 2503 | cloneIncidence(incidence); |
2481 | } | 2504 | } |
2482 | } | 2505 | } |
2483 | void CalendarView::moveIncidence() | 2506 | void CalendarView::moveIncidence() |
2484 | { | 2507 | { |
2485 | Incidence *incidence = currentSelection(); | 2508 | Incidence *incidence = currentSelection(); |
2486 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2509 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2487 | if ( incidence ) { | 2510 | if ( incidence ) { |
2488 | moveIncidence(incidence); | 2511 | moveIncidence(incidence); |
2489 | } | 2512 | } |
2490 | } | 2513 | } |
2491 | void CalendarView::beamIncidence() | 2514 | void CalendarView::beamIncidence() |
2492 | { | 2515 | { |
2493 | Incidence *incidence = currentSelection(); | 2516 | Incidence *incidence = currentSelection(); |
2494 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2517 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2495 | if ( incidence ) { | 2518 | if ( incidence ) { |
2496 | beamIncidence(incidence); | 2519 | beamIncidence(incidence); |
2497 | } | 2520 | } |
2498 | } | 2521 | } |
2499 | void CalendarView::toggleCancelIncidence() | 2522 | void CalendarView::toggleCancelIncidence() |
2500 | { | 2523 | { |
2501 | Incidence *incidence = currentSelection(); | 2524 | Incidence *incidence = currentSelection(); |
2502 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2503 | if ( incidence ) { | 2526 | if ( incidence ) { |
2504 | cancelIncidence(incidence); | 2527 | cancelIncidence(incidence); |
2505 | } | 2528 | } |
2506 | } | 2529 | } |
2507 | 2530 | ||
2508 | 2531 | ||
2509 | void CalendarView::cancelIncidence(Incidence * inc ) | 2532 | void CalendarView::cancelIncidence(Incidence * inc ) |
2510 | { | 2533 | { |
2511 | inc->setCancelled( ! inc->cancelled() ); | 2534 | inc->setCancelled( ! inc->cancelled() ); |
2512 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2535 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2513 | updateView(); | 2536 | updateView(); |
2514 | } | 2537 | } |
2515 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2538 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2516 | { | 2539 | { |
2517 | Incidence * newInc = orgInc->clone(); | 2540 | Incidence * newInc = orgInc->clone(); |
2518 | newInc->recreate(); | 2541 | newInc->recreate(); |
2519 | 2542 | ||
2520 | if ( newInc->type() == "Todo" ) { | 2543 | if ( newInc->type() == "Todo" ) { |
2521 | Todo* t = (Todo*) newInc; | 2544 | Todo* t = (Todo*) newInc; |
2522 | mTodoEditor->editTodo( t ); | 2545 | mTodoEditor->editTodo( t ); |
2523 | showTodoEditor(); | 2546 | showTodoEditor(); |
2524 | if ( mTodoEditor->exec() ) { | 2547 | if ( mTodoEditor->exec() ) { |
2525 | mCalendar->addTodo( t ); | 2548 | mCalendar->addTodo( t ); |
2526 | updateView(); | 2549 | updateView(); |
2527 | } else { | 2550 | } else { |
2528 | delete t; | 2551 | delete t; |
2529 | } | 2552 | } |
2530 | } | 2553 | } |
2531 | else { | 2554 | else { |
2532 | Event* e = (Event*) newInc; | 2555 | Event* e = (Event*) newInc; |
2533 | mEventEditor->editEvent( e ); | 2556 | mEventEditor->editEvent( e ); |
2534 | showEventEditor(); | 2557 | showEventEditor(); |
2535 | if ( mEventEditor->exec() ) { | 2558 | if ( mEventEditor->exec() ) { |
2536 | mCalendar->addEvent( e ); | 2559 | mCalendar->addEvent( e ); |
2537 | updateView(); | 2560 | updateView(); |
2538 | } else { | 2561 | } else { |
2539 | delete e; | 2562 | delete e; |
2540 | } | 2563 | } |
2541 | } | 2564 | } |
2542 | } | 2565 | } |
2543 | 2566 | ||
2544 | void CalendarView::newEvent() | 2567 | void CalendarView::newEvent() |
2545 | { | 2568 | { |
2546 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2569 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2547 | KOAgendaView *aView = mViewManager->agendaView(); | 2570 | KOAgendaView *aView = mViewManager->agendaView(); |
2548 | if (aView) { | 2571 | if (aView) { |
2549 | if (aView->selectionStart().isValid()) { | 2572 | if (aView->selectionStart().isValid()) { |
2550 | if (aView->selectedIsAllDay()) { | 2573 | if (aView->selectedIsAllDay()) { |
2551 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2574 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2552 | } else { | 2575 | } else { |
2553 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2576 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2554 | } | 2577 | } |
2555 | return; | 2578 | return; |
2556 | } | 2579 | } |
2557 | } | 2580 | } |
2558 | 2581 | ||
2559 | QDate date = mNavigator->selectedDates().first(); | 2582 | QDate date = mNavigator->selectedDates().first(); |
2560 | QDateTime current = QDateTime::currentDateTime(); | 2583 | QDateTime current = QDateTime::currentDateTime(); |
2561 | if ( date <= current.date() ) { | 2584 | if ( date <= current.date() ) { |
2562 | int hour = current.time().hour() +1; | 2585 | int hour = current.time().hour() +1; |
2563 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2586 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2564 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2587 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2565 | } else | 2588 | } else |
2566 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2589 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2567 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2590 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2568 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2591 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2569 | } | 2592 | } |
2570 | 2593 | ||
2571 | void CalendarView::newEvent(QDateTime fh) | 2594 | void CalendarView::newEvent(QDateTime fh) |
2572 | { | 2595 | { |
2573 | newEvent(fh, | 2596 | newEvent(fh, |
2574 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2597 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2575 | } | 2598 | } |
2576 | 2599 | ||
2577 | void CalendarView::newEvent(QDate dt) | 2600 | void CalendarView::newEvent(QDate dt) |
2578 | { | 2601 | { |
2579 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2602 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2580 | QDateTime(dt, QTime(0,0,0)), true); | 2603 | QDateTime(dt, QTime(0,0,0)), true); |
2581 | } | 2604 | } |
2582 | 2605 | ||
2583 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2606 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2584 | { | 2607 | { |
2585 | 2608 | ||
2586 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2609 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2587 | if ( mFilterView->filtersEnabled() ) { | 2610 | if ( mFilterView->filtersEnabled() ) { |
2588 | CalFilter *filter = mFilterView->selectedFilter(); | 2611 | CalFilter *filter = mFilterView->selectedFilter(); |
2589 | if (filter && filter->showCategories()) { | 2612 | if (filter && filter->showCategories()) { |
2590 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2613 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2591 | } | 2614 | } |
2592 | if ( filter ) | 2615 | if ( filter ) |
2593 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2616 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2594 | } | 2617 | } |
2595 | showEventEditor(); | 2618 | showEventEditor(); |
2596 | } | 2619 | } |
2597 | void CalendarView::todoAdded(Todo * t) | 2620 | void CalendarView::todoAdded(Todo * t) |
2598 | { | 2621 | { |
2599 | 2622 | ||
2600 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2623 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2601 | updateTodoViews(); | 2624 | updateTodoViews(); |
2602 | } | 2625 | } |
2603 | void CalendarView::todoChanged(Todo * t) | 2626 | void CalendarView::todoChanged(Todo * t) |
2604 | { | 2627 | { |
2605 | emit todoModified( t, 4 ); | 2628 | emit todoModified( t, 4 ); |
2606 | // updateTodoViews(); | 2629 | // updateTodoViews(); |
2607 | } | 2630 | } |
2608 | void CalendarView::todoToBeDeleted(Todo *) | 2631 | void CalendarView::todoToBeDeleted(Todo *) |
2609 | { | 2632 | { |
2610 | //qDebug("todoToBeDeleted(Todo *) "); | 2633 | //qDebug("todoToBeDeleted(Todo *) "); |
2611 | updateTodoViews(); | 2634 | updateTodoViews(); |
2612 | } | 2635 | } |
2613 | void CalendarView::todoDeleted() | 2636 | void CalendarView::todoDeleted() |
2614 | { | 2637 | { |
2615 | //qDebug(" todoDeleted()"); | 2638 | //qDebug(" todoDeleted()"); |
2616 | updateTodoViews(); | 2639 | updateTodoViews(); |
2617 | } | 2640 | } |
2618 | 2641 | ||
2619 | 2642 | ||
2620 | 2643 | ||
2621 | void CalendarView::newTodo() | 2644 | void CalendarView::newTodo() |
2622 | { | 2645 | { |
2623 | 2646 | ||
2624 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2647 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2625 | if ( mFilterView->filtersEnabled() ) { | 2648 | if ( mFilterView->filtersEnabled() ) { |
2626 | CalFilter *filter = mFilterView->selectedFilter(); | 2649 | CalFilter *filter = mFilterView->selectedFilter(); |
2627 | if (filter && filter->showCategories()) { | 2650 | if (filter && filter->showCategories()) { |
2628 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2651 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2629 | } | 2652 | } |
2630 | if ( filter ) | 2653 | if ( filter ) |
2631 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2654 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2632 | } | 2655 | } |
2633 | showTodoEditor(); | 2656 | showTodoEditor(); |
2634 | } | 2657 | } |
2635 | 2658 | ||
2636 | void CalendarView::newSubTodo() | 2659 | void CalendarView::newSubTodo() |
2637 | { | 2660 | { |
2638 | Todo *todo = selectedTodo(); | 2661 | Todo *todo = selectedTodo(); |
2639 | if ( todo ) newSubTodo( todo ); | 2662 | if ( todo ) newSubTodo( todo ); |
2640 | } | 2663 | } |
2641 | 2664 | ||
2642 | void CalendarView::newSubTodo(Todo *parentEvent) | 2665 | void CalendarView::newSubTodo(Todo *parentEvent) |
2643 | { | 2666 | { |
2644 | 2667 | ||
2645 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2668 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2646 | showTodoEditor(); | 2669 | showTodoEditor(); |
2647 | } | 2670 | } |
2648 | 2671 | ||
2649 | void CalendarView::newFloatingEvent() | 2672 | void CalendarView::newFloatingEvent() |
2650 | { | 2673 | { |
2651 | DateList tmpList = mNavigator->selectedDates(); | 2674 | DateList tmpList = mNavigator->selectedDates(); |
2652 | QDate date = tmpList.first(); | 2675 | QDate date = tmpList.first(); |
2653 | 2676 | ||
2654 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2677 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2655 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2678 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2656 | } | 2679 | } |
2657 | 2680 | ||
2658 | 2681 | ||
2659 | void CalendarView::editEvent( Event *event ) | 2682 | void CalendarView::editEvent( Event *event ) |
2660 | { | 2683 | { |
2661 | 2684 | ||
2662 | if ( !event ) return; | 2685 | if ( !event ) return; |
2663 | if ( event->isReadOnly() ) { | 2686 | if ( event->isReadOnly() ) { |
2664 | showEvent( event ); | 2687 | showEvent( event ); |
2665 | return; | 2688 | return; |
2666 | } | 2689 | } |
2667 | mEventEditor->editEvent( event , mFlagEditDescription); | 2690 | mEventEditor->editEvent( event , mFlagEditDescription); |
2668 | showEventEditor(); | 2691 | showEventEditor(); |
2669 | } | 2692 | } |
2670 | void CalendarView::editJournal( Journal *jour ) | 2693 | void CalendarView::editJournal( Journal *jour ) |
2671 | { | 2694 | { |
2672 | if ( !jour ) return; | 2695 | if ( !jour ) return; |
2673 | mDialogManager->hideSearchDialog(); | 2696 | mDialogManager->hideSearchDialog(); |
2674 | mViewManager->showJournalView(); | 2697 | mViewManager->showJournalView(); |
2675 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2698 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2676 | } | 2699 | } |
2677 | void CalendarView::editTodo( Todo *todo ) | 2700 | void CalendarView::editTodo( Todo *todo ) |
2678 | { | 2701 | { |
2679 | if ( !todo ) return; | 2702 | if ( !todo ) return; |
2680 | 2703 | ||
2681 | if ( todo->isReadOnly() ) { | 2704 | if ( todo->isReadOnly() ) { |
2682 | showTodo( todo ); | 2705 | showTodo( todo ); |
2683 | return; | 2706 | return; |
2684 | } | 2707 | } |
2685 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2708 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2686 | showTodoEditor(); | 2709 | showTodoEditor(); |
2687 | 2710 | ||
2688 | } | 2711 | } |
2689 | 2712 | ||
2690 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2713 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2691 | { | 2714 | { |
2692 | if ( !mEventViewerDialog ) { | 2715 | if ( !mEventViewerDialog ) { |
2693 | mEventViewerDialog = new KOEventViewerDialog(this); | 2716 | mEventViewerDialog = new KOEventViewerDialog(this); |
2694 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2717 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2695 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2718 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2696 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2719 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2697 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2720 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2698 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2721 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2699 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2722 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2700 | mEventViewerDialog->resize( 640, 480 ); | 2723 | mEventViewerDialog->resize( 640, 480 ); |
2701 | 2724 | ||
2702 | } | 2725 | } |
2703 | return mEventViewerDialog; | 2726 | return mEventViewerDialog; |
2704 | } | 2727 | } |
2705 | void CalendarView::showEvent(Event *event) | 2728 | void CalendarView::showEvent(Event *event) |
2706 | { | 2729 | { |
2707 | getEventViewerDialog()->setEvent(event); | 2730 | getEventViewerDialog()->setEvent(event); |
2708 | getEventViewerDialog()->showMe(); | 2731 | getEventViewerDialog()->showMe(); |
2709 | } | 2732 | } |
2710 | 2733 | ||
2711 | void CalendarView::showTodo(Todo *event) | 2734 | void CalendarView::showTodo(Todo *event) |
2712 | { | 2735 | { |
2713 | getEventViewerDialog()->setTodo(event); | 2736 | getEventViewerDialog()->setTodo(event); |
2714 | getEventViewerDialog()->showMe(); | 2737 | getEventViewerDialog()->showMe(); |
2715 | } | 2738 | } |
2716 | void CalendarView::showJournal( Journal *jour ) | 2739 | void CalendarView::showJournal( Journal *jour ) |
2717 | { | 2740 | { |
2718 | getEventViewerDialog()->setJournal(jour); | 2741 | getEventViewerDialog()->setJournal(jour); |
2719 | getEventViewerDialog()->showMe(); | 2742 | getEventViewerDialog()->showMe(); |
2720 | 2743 | ||
2721 | } | 2744 | } |
2722 | // void CalendarView::todoModified (Todo *event, int changed) | 2745 | // void CalendarView::todoModified (Todo *event, int changed) |
2723 | // { | 2746 | // { |
2724 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2747 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2725 | // // kdDebug() << "Todo modified and open" << endl; | 2748 | // // kdDebug() << "Todo modified and open" << endl; |
2726 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2749 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2727 | // // temp->modified (changed); | 2750 | // // temp->modified (changed); |
2728 | 2751 | ||
2729 | // // } | 2752 | // // } |
2730 | 2753 | ||
2731 | // mViewManager->updateView(); | 2754 | // mViewManager->updateView(); |
2732 | // } | 2755 | // } |
2733 | 2756 | ||
2734 | void CalendarView::appointment_show() | 2757 | void CalendarView::appointment_show() |
2735 | { | 2758 | { |
2736 | Event *anEvent = 0; | 2759 | Event *anEvent = 0; |
2737 | 2760 | ||
2738 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2761 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2739 | 2762 | ||
2740 | if (mViewManager->currentView()->isEventView()) { | 2763 | if (mViewManager->currentView()->isEventView()) { |
2741 | if ( incidence && incidence->type() == "Event" ) { | 2764 | if ( incidence && incidence->type() == "Event" ) { |
2742 | anEvent = static_cast<Event *>(incidence); | 2765 | anEvent = static_cast<Event *>(incidence); |
2743 | } | 2766 | } |
2744 | } | 2767 | } |
2745 | 2768 | ||
2746 | if (!anEvent) { | 2769 | if (!anEvent) { |
2747 | KNotifyClient::beep(); | 2770 | KNotifyClient::beep(); |
2748 | return; | 2771 | return; |
2749 | } | 2772 | } |
2750 | 2773 | ||
2751 | showEvent(anEvent); | 2774 | showEvent(anEvent); |
2752 | } | 2775 | } |
2753 | 2776 | ||
2754 | void CalendarView::appointment_edit() | 2777 | void CalendarView::appointment_edit() |
2755 | { | 2778 | { |
2756 | Event *anEvent = 0; | 2779 | Event *anEvent = 0; |
2757 | 2780 | ||
2758 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2781 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2759 | 2782 | ||
2760 | if (mViewManager->currentView()->isEventView()) { | 2783 | if (mViewManager->currentView()->isEventView()) { |
2761 | if ( incidence && incidence->type() == "Event" ) { | 2784 | if ( incidence && incidence->type() == "Event" ) { |
2762 | anEvent = static_cast<Event *>(incidence); | 2785 | anEvent = static_cast<Event *>(incidence); |
2763 | } | 2786 | } |
2764 | } | 2787 | } |
2765 | 2788 | ||
2766 | if (!anEvent) { | 2789 | if (!anEvent) { |
2767 | KNotifyClient::beep(); | 2790 | KNotifyClient::beep(); |
2768 | return; | 2791 | return; |
2769 | } | 2792 | } |
2770 | 2793 | ||
2771 | editEvent(anEvent); | 2794 | editEvent(anEvent); |
2772 | } | 2795 | } |
2773 | 2796 | ||
2774 | void CalendarView::appointment_delete() | 2797 | void CalendarView::appointment_delete() |
2775 | { | 2798 | { |
2776 | Event *anEvent = 0; | 2799 | Event *anEvent = 0; |
2777 | 2800 | ||
2778 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2801 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2779 | 2802 | ||
2780 | if (mViewManager->currentView()->isEventView()) { | 2803 | if (mViewManager->currentView()->isEventView()) { |
2781 | if ( incidence && incidence->type() == "Event" ) { | 2804 | if ( incidence && incidence->type() == "Event" ) { |
2782 | anEvent = static_cast<Event *>(incidence); | 2805 | anEvent = static_cast<Event *>(incidence); |
2783 | } | 2806 | } |
2784 | } | 2807 | } |
2785 | 2808 | ||
2786 | if (!anEvent) { | 2809 | if (!anEvent) { |
2787 | KNotifyClient::beep(); | 2810 | KNotifyClient::beep(); |
2788 | return; | 2811 | return; |
2789 | } | 2812 | } |
2790 | 2813 | ||
2791 | deleteEvent(anEvent); | 2814 | deleteEvent(anEvent); |
2792 | } | 2815 | } |
2793 | 2816 | ||
2794 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2817 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2795 | { | 2818 | { |
2796 | if (!sub) return; | 2819 | if (!sub) return; |
2797 | if (!parent) return; | 2820 | if (!parent) return; |
2798 | if ( sub->relatedTo() ) | 2821 | if ( sub->relatedTo() ) |
2799 | sub->relatedTo()->removeRelation(sub); | 2822 | sub->relatedTo()->removeRelation(sub); |
2800 | sub->setRelatedTo(parent); | 2823 | sub->setRelatedTo(parent); |
2801 | sub->setRelatedToUid(parent->uid()); | 2824 | sub->setRelatedToUid(parent->uid()); |
2802 | parent->addRelation(sub); | 2825 | parent->addRelation(sub); |
2803 | sub->updated(); | 2826 | sub->updated(); |
2804 | parent->updated(); | 2827 | parent->updated(); |
2805 | setModified(true); | 2828 | setModified(true); |
2806 | updateView(); | 2829 | updateView(); |
2807 | } | 2830 | } |
2808 | void CalendarView::todo_unsub(Todo *anTodo ) | 2831 | void CalendarView::todo_unsub(Todo *anTodo ) |
2809 | { | 2832 | { |
2810 | // Todo *anTodo = selectedTodo(); | 2833 | // Todo *anTodo = selectedTodo(); |
2811 | if (!anTodo) return; | 2834 | if (!anTodo) return; |
2812 | if (!anTodo->relatedTo()) return; | 2835 | if (!anTodo->relatedTo()) return; |
2813 | anTodo->relatedTo()->removeRelation(anTodo); | 2836 | anTodo->relatedTo()->removeRelation(anTodo); |
2814 | anTodo->setRelatedTo(0); | 2837 | anTodo->setRelatedTo(0); |
2815 | anTodo->updated(); | 2838 | anTodo->updated(); |
2816 | anTodo->setRelatedToUid(""); | 2839 | anTodo->setRelatedToUid(""); |
2817 | setModified(true); | 2840 | setModified(true); |
2818 | updateView(); | 2841 | updateView(); |
2819 | } | 2842 | } |
2820 | 2843 | ||
2821 | void CalendarView::deleteTodo(Todo *todo) | 2844 | void CalendarView::deleteTodo(Todo *todo) |
2822 | { | 2845 | { |
2823 | if (!todo) { | 2846 | if (!todo) { |
2824 | KNotifyClient::beep(); | 2847 | KNotifyClient::beep(); |
2825 | return; | 2848 | return; |
2826 | } | 2849 | } |
2827 | if (KOPrefs::instance()->mConfirm) { | 2850 | if (KOPrefs::instance()->mConfirm) { |
2828 | switch (msgItemDelete()) { | 2851 | switch (msgItemDelete()) { |
2829 | case KMessageBox::Continue: // OK | 2852 | case KMessageBox::Continue: // OK |
2830 | if (!todo->relations().isEmpty()) { | 2853 | if (!todo->relations().isEmpty()) { |
2831 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2854 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2832 | i18n("Delete To-Do")); | 2855 | i18n("Delete To-Do")); |
2833 | } else { | 2856 | } else { |
2834 | checkExternalId( todo ); | 2857 | checkExternalId( todo ); |
2835 | calendar()->deleteTodo(todo); | 2858 | calendar()->deleteTodo(todo); |
2836 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2859 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2837 | updateView(); | 2860 | updateView(); |
2838 | } | 2861 | } |
2839 | break; | 2862 | break; |
2840 | } // switch | 2863 | } // switch |
2841 | } else { | 2864 | } else { |
2842 | if (!todo->relations().isEmpty()) { | 2865 | if (!todo->relations().isEmpty()) { |
2843 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2866 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2844 | i18n("Delete To-Do")); | 2867 | i18n("Delete To-Do")); |
2845 | } else { | 2868 | } else { |
2846 | checkExternalId( todo ); | 2869 | checkExternalId( todo ); |
2847 | mCalendar->deleteTodo(todo); | 2870 | mCalendar->deleteTodo(todo); |
2848 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2871 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2849 | updateView(); | 2872 | updateView(); |
2850 | } | 2873 | } |
2851 | } | 2874 | } |
2852 | emit updateSearchDialog(); | 2875 | emit updateSearchDialog(); |
2853 | } | 2876 | } |
2854 | void CalendarView::deleteJournal(Journal *jour) | 2877 | void CalendarView::deleteJournal(Journal *jour) |
2855 | { | 2878 | { |
2856 | if (!jour) { | 2879 | if (!jour) { |
2857 | KNotifyClient::beep(); | 2880 | KNotifyClient::beep(); |
2858 | return; | 2881 | return; |
2859 | } | 2882 | } |
2860 | if (KOPrefs::instance()->mConfirm) { | 2883 | if (KOPrefs::instance()->mConfirm) { |
2861 | switch (msgItemDelete()) { | 2884 | switch (msgItemDelete()) { |
2862 | case KMessageBox::Continue: // OK | 2885 | case KMessageBox::Continue: // OK |
2863 | calendar()->deleteJournal(jour); | 2886 | calendar()->deleteJournal(jour); |
2864 | updateView(); | 2887 | updateView(); |
2865 | break; | 2888 | break; |
2866 | } // switch | 2889 | } // switch |
2867 | } else { | 2890 | } else { |
2868 | calendar()->deleteJournal(jour);; | 2891 | calendar()->deleteJournal(jour);; |
2869 | updateView(); | 2892 | updateView(); |
2870 | } | 2893 | } |
2871 | emit updateSearchDialog(); | 2894 | emit updateSearchDialog(); |
2872 | } | 2895 | } |
2873 | 2896 | ||
2874 | void CalendarView::deleteEvent(Event *anEvent) | 2897 | void CalendarView::deleteEvent(Event *anEvent) |
2875 | { | 2898 | { |
2876 | if (!anEvent) { | 2899 | if (!anEvent) { |
2877 | KNotifyClient::beep(); | 2900 | KNotifyClient::beep(); |
2878 | return; | 2901 | return; |
2879 | } | 2902 | } |
2880 | 2903 | ||
2881 | if (anEvent->recurrence()->doesRecur()) { | 2904 | if (anEvent->recurrence()->doesRecur()) { |
2882 | QDate itemDate = mViewManager->currentSelectionDate(); | 2905 | QDate itemDate = mViewManager->currentSelectionDate(); |
2883 | int km; | 2906 | int km; |
2884 | if (!itemDate.isValid()) { | 2907 | if (!itemDate.isValid()) { |
2885 | //kdDebug() << "Date Not Valid" << endl; | 2908 | //kdDebug() << "Date Not Valid" << endl; |
2886 | if (KOPrefs::instance()->mConfirm) { | 2909 | if (KOPrefs::instance()->mConfirm) { |
2887 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2910 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2888 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2911 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2889 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2912 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2890 | if ( km == KMessageBox::Continue ) | 2913 | if ( km == KMessageBox::Continue ) |
2891 | km = KMessageBox::No; // No = all below | 2914 | km = KMessageBox::No; // No = all below |
2892 | } else | 2915 | } else |
2893 | km = KMessageBox::No; | 2916 | km = KMessageBox::No; |
2894 | } else { | 2917 | } else { |
2895 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2918 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2896 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2919 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2897 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2920 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2898 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2921 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2899 | i18n("All")); | 2922 | i18n("All")); |
2900 | } | 2923 | } |
2901 | switch(km) { | 2924 | switch(km) { |
2902 | 2925 | ||
2903 | case KMessageBox::No: // Continue // all | 2926 | case KMessageBox::No: // Continue // all |
2904 | //qDebug("KMessageBox::No "); | 2927 | //qDebug("KMessageBox::No "); |
2905 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2928 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2906 | schedule(Scheduler::Cancel,anEvent); | 2929 | schedule(Scheduler::Cancel,anEvent); |
2907 | 2930 | ||
2908 | checkExternalId( anEvent); | 2931 | checkExternalId( anEvent); |
2909 | mCalendar->deleteEvent(anEvent); | 2932 | mCalendar->deleteEvent(anEvent); |
2910 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2933 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2911 | break; | 2934 | break; |
2912 | 2935 | ||
2913 | // Disabled because it does not work | 2936 | // Disabled because it does not work |
2914 | //#if 0 | 2937 | //#if 0 |
2915 | case KMessageBox::Yes: // just this one | 2938 | case KMessageBox::Yes: // just this one |
2916 | //QDate qd = mNavigator->selectedDates().first(); | 2939 | //QDate qd = mNavigator->selectedDates().first(); |
2917 | //if (!qd.isValid()) { | 2940 | //if (!qd.isValid()) { |
2918 | // kdDebug() << "no date selected, or invalid date" << endl; | 2941 | // kdDebug() << "no date selected, or invalid date" << endl; |
2919 | // KNotifyClient::beep(); | 2942 | // KNotifyClient::beep(); |
2920 | // return; | 2943 | // return; |
2921 | //} | 2944 | //} |
2922 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2945 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2923 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2946 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2924 | anEvent->addExDate(itemDate); | 2947 | anEvent->addExDate(itemDate); |
2925 | int duration = anEvent->recurrence()->duration(); | 2948 | int duration = anEvent->recurrence()->duration(); |
2926 | if ( duration > 0 ) { | 2949 | if ( duration > 0 ) { |
2927 | anEvent->recurrence()->setDuration( duration - 1 ); | 2950 | anEvent->recurrence()->setDuration( duration - 1 ); |
2928 | } | 2951 | } |
2929 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2952 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2930 | } | 2953 | } |
2931 | break; | 2954 | break; |
2932 | //#endif | 2955 | //#endif |
2933 | } // switch | 2956 | } // switch |
2934 | } else { | 2957 | } else { |
2935 | if (KOPrefs::instance()->mConfirm) { | 2958 | if (KOPrefs::instance()->mConfirm) { |
2936 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2959 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2937 | i18n("\nAre you sure you want\nto delete this event?"), | 2960 | i18n("\nAre you sure you want\nto delete this event?"), |
2938 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2961 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2939 | case KMessageBox::Continue: // OK | 2962 | case KMessageBox::Continue: // OK |
2940 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2963 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2941 | schedule(Scheduler::Cancel,anEvent); | 2964 | schedule(Scheduler::Cancel,anEvent); |
2942 | checkExternalId( anEvent); | 2965 | checkExternalId( anEvent); |
2943 | mCalendar->deleteEvent(anEvent); | 2966 | mCalendar->deleteEvent(anEvent); |
2944 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2967 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2945 | break; | 2968 | break; |
2946 | } // switch | 2969 | } // switch |
2947 | } else { | 2970 | } else { |
2948 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2971 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2949 | schedule(Scheduler::Cancel,anEvent); | 2972 | schedule(Scheduler::Cancel,anEvent); |
2950 | checkExternalId( anEvent); | 2973 | checkExternalId( anEvent); |
2951 | mCalendar->deleteEvent(anEvent); | 2974 | mCalendar->deleteEvent(anEvent); |
2952 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2975 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2953 | } | 2976 | } |
2954 | } // if-else | 2977 | } // if-else |
2955 | emit updateSearchDialog(); | 2978 | emit updateSearchDialog(); |
2956 | } | 2979 | } |
2957 | 2980 | ||
2958 | bool CalendarView::deleteEvent(const QString &uid) | 2981 | bool CalendarView::deleteEvent(const QString &uid) |
2959 | { | 2982 | { |
2960 | Event *ev = mCalendar->event(uid); | 2983 | Event *ev = mCalendar->event(uid); |
2961 | if (ev) { | 2984 | if (ev) { |
2962 | deleteEvent(ev); | 2985 | deleteEvent(ev); |
2963 | return true; | 2986 | return true; |
2964 | } else { | 2987 | } else { |
2965 | return false; | 2988 | return false; |
2966 | } | 2989 | } |
2967 | } | 2990 | } |
2968 | 2991 | ||
2969 | /*****************************************************************************/ | 2992 | /*****************************************************************************/ |
2970 | 2993 | ||
2971 | void CalendarView::action_mail() | 2994 | void CalendarView::action_mail() |
2972 | { | 2995 | { |
2973 | #ifndef KORG_NOMAIL | 2996 | #ifndef KORG_NOMAIL |
2974 | KOMailClient mailClient; | 2997 | KOMailClient mailClient; |
2975 | 2998 | ||
2976 | Incidence *incidence = currentSelection(); | 2999 | Incidence *incidence = currentSelection(); |
2977 | 3000 | ||
2978 | if (!incidence) { | 3001 | if (!incidence) { |
2979 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3002 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2980 | return; | 3003 | return; |
2981 | } | 3004 | } |
2982 | if(incidence->attendeeCount() == 0 ) { | 3005 | if(incidence->attendeeCount() == 0 ) { |
2983 | KMessageBox::sorry(this, | 3006 | KMessageBox::sorry(this, |
2984 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3007 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2985 | return; | 3008 | return; |
2986 | } | 3009 | } |
2987 | 3010 | ||
2988 | CalendarLocal cal_tmp; | 3011 | CalendarLocal cal_tmp; |
2989 | Event *event = 0; | 3012 | Event *event = 0; |
2990 | Event *ev = 0; | 3013 | Event *ev = 0; |
2991 | if ( incidence && incidence->type() == "Event" ) { | 3014 | if ( incidence && incidence->type() == "Event" ) { |
2992 | event = static_cast<Event *>(incidence); | 3015 | event = static_cast<Event *>(incidence); |
2993 | ev = new Event(*event); | 3016 | ev = new Event(*event); |
2994 | cal_tmp.addEvent(ev); | 3017 | cal_tmp.addEvent(ev); |
2995 | } | 3018 | } |
2996 | ICalFormat mForm(); | 3019 | ICalFormat mForm(); |
2997 | QString attachment = mForm.toString( &cal_tmp ); | 3020 | QString attachment = mForm.toString( &cal_tmp ); |
2998 | if (ev) delete(ev); | 3021 | if (ev) delete(ev); |
2999 | 3022 | ||
3000 | mailClient.mailAttendees(currentSelection(), attachment); | 3023 | mailClient.mailAttendees(currentSelection(), attachment); |
3001 | 3024 | ||
3002 | #endif | 3025 | #endif |
3003 | 3026 | ||
3004 | #if 0 | 3027 | #if 0 |
3005 | Event *anEvent = 0; | 3028 | Event *anEvent = 0; |
3006 | if (mViewManager->currentView()->isEventView()) { | 3029 | if (mViewManager->currentView()->isEventView()) { |
3007 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3030 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3008 | } | 3031 | } |
3009 | 3032 | ||
3010 | if (!anEvent) { | 3033 | if (!anEvent) { |
3011 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3034 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3012 | return; | 3035 | return; |
3013 | } | 3036 | } |
3014 | if(anEvent->attendeeCount() == 0 ) { | 3037 | if(anEvent->attendeeCount() == 0 ) { |
3015 | KMessageBox::sorry(this, | 3038 | KMessageBox::sorry(this, |
3016 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3039 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3017 | return; | 3040 | return; |
3018 | } | 3041 | } |
3019 | 3042 | ||
3020 | mailobject.emailEvent(anEvent); | 3043 | mailobject.emailEvent(anEvent); |
3021 | #endif | 3044 | #endif |
3022 | } | 3045 | } |
3023 | 3046 | ||
3024 | 3047 | ||
3025 | void CalendarView::schedule_publish(Incidence *incidence) | 3048 | void CalendarView::schedule_publish(Incidence *incidence) |
3026 | { | 3049 | { |
3027 | Event *event = 0; | 3050 | Event *event = 0; |
3028 | Todo *todo = 0; | 3051 | Todo *todo = 0; |
3029 | 3052 | ||
3030 | if (incidence == 0) { | 3053 | if (incidence == 0) { |
3031 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3054 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3032 | if (incidence == 0) { | 3055 | if (incidence == 0) { |
3033 | incidence = mTodoList->selectedIncidences().first(); | 3056 | incidence = mTodoList->selectedIncidences().first(); |
3034 | } | 3057 | } |
3035 | } | 3058 | } |
3036 | if ( incidence && incidence->type() == "Event" ) { | 3059 | if ( incidence && incidence->type() == "Event" ) { |
3037 | event = static_cast<Event *>(incidence); | 3060 | event = static_cast<Event *>(incidence); |
3038 | } else { | 3061 | } else { |
3039 | if ( incidence && incidence->type() == "Todo" ) { | 3062 | if ( incidence && incidence->type() == "Todo" ) { |
3040 | todo = static_cast<Todo *>(incidence); | 3063 | todo = static_cast<Todo *>(incidence); |
3041 | } | 3064 | } |
3042 | } | 3065 | } |
3043 | 3066 | ||
3044 | if (!event && !todo) { | 3067 | if (!event && !todo) { |
3045 | KMessageBox::sorry(this,i18n("No event selected.")); | 3068 | KMessageBox::sorry(this,i18n("No event selected.")); |
3046 | return; | 3069 | return; |
3047 | } | 3070 | } |
3048 | 3071 | ||
3049 | PublishDialog *publishdlg = new PublishDialog(); | 3072 | PublishDialog *publishdlg = new PublishDialog(); |
3050 | if (incidence->attendeeCount()>0) { | 3073 | if (incidence->attendeeCount()>0) { |
3051 | QPtrList<Attendee> attendees = incidence->attendees(); | 3074 | QPtrList<Attendee> attendees = incidence->attendees(); |
3052 | attendees.first(); | 3075 | attendees.first(); |
3053 | while ( attendees.current()!=0 ) { | 3076 | while ( attendees.current()!=0 ) { |
3054 | publishdlg->addAttendee(attendees.current()); | 3077 | publishdlg->addAttendee(attendees.current()); |
3055 | attendees.next(); | 3078 | attendees.next(); |
3056 | } | 3079 | } |
3057 | } | 3080 | } |
3058 | bool send = true; | 3081 | bool send = true; |
3059 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3082 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3060 | if ( publishdlg->exec() != QDialog::Accepted ) | 3083 | if ( publishdlg->exec() != QDialog::Accepted ) |
3061 | send = false; | 3084 | send = false; |
3062 | } | 3085 | } |
3063 | if ( send ) { | 3086 | if ( send ) { |
3064 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3087 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3065 | if ( event ) { | 3088 | if ( event ) { |
3066 | Event *ev = new Event(*event); | 3089 | Event *ev = new Event(*event); |
3067 | ev->registerObserver(0); | 3090 | ev->registerObserver(0); |
3068 | ev->clearAttendees(); | 3091 | ev->clearAttendees(); |
3069 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3092 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3070 | delete(ev); | 3093 | delete(ev); |
3071 | } | 3094 | } |
3072 | } else { | 3095 | } else { |
3073 | if ( todo ) { | 3096 | if ( todo ) { |
3074 | Todo *ev = new Todo(*todo); | 3097 | Todo *ev = new Todo(*todo); |
3075 | ev->registerObserver(0); | 3098 | ev->registerObserver(0); |
3076 | ev->clearAttendees(); | 3099 | ev->clearAttendees(); |
3077 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3100 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3078 | delete(ev); | 3101 | delete(ev); |
3079 | } | 3102 | } |
3080 | } | 3103 | } |
3081 | } | 3104 | } |
3082 | } | 3105 | } |
3083 | delete publishdlg; | 3106 | delete publishdlg; |
3084 | } | 3107 | } |
3085 | 3108 | ||
3086 | void CalendarView::schedule_request(Incidence *incidence) | 3109 | void CalendarView::schedule_request(Incidence *incidence) |
3087 | { | 3110 | { |
3088 | schedule(Scheduler::Request,incidence); | 3111 | schedule(Scheduler::Request,incidence); |
3089 | } | 3112 | } |
3090 | 3113 | ||
3091 | void CalendarView::schedule_refresh(Incidence *incidence) | 3114 | void CalendarView::schedule_refresh(Incidence *incidence) |
3092 | { | 3115 | { |
3093 | schedule(Scheduler::Refresh,incidence); | 3116 | schedule(Scheduler::Refresh,incidence); |
3094 | } | 3117 | } |
3095 | 3118 | ||
3096 | void CalendarView::schedule_cancel(Incidence *incidence) | 3119 | void CalendarView::schedule_cancel(Incidence *incidence) |
3097 | { | 3120 | { |
3098 | schedule(Scheduler::Cancel,incidence); | 3121 | schedule(Scheduler::Cancel,incidence); |
3099 | } | 3122 | } |
3100 | 3123 | ||
3101 | void CalendarView::schedule_add(Incidence *incidence) | 3124 | void CalendarView::schedule_add(Incidence *incidence) |
3102 | { | 3125 | { |
3103 | schedule(Scheduler::Add,incidence); | 3126 | schedule(Scheduler::Add,incidence); |
3104 | } | 3127 | } |
3105 | 3128 | ||
3106 | void CalendarView::schedule_reply(Incidence *incidence) | 3129 | void CalendarView::schedule_reply(Incidence *incidence) |
3107 | { | 3130 | { |
3108 | schedule(Scheduler::Reply,incidence); | 3131 | schedule(Scheduler::Reply,incidence); |
3109 | } | 3132 | } |
3110 | 3133 | ||
3111 | void CalendarView::schedule_counter(Incidence *incidence) | 3134 | void CalendarView::schedule_counter(Incidence *incidence) |
3112 | { | 3135 | { |
3113 | schedule(Scheduler::Counter,incidence); | 3136 | schedule(Scheduler::Counter,incidence); |
3114 | } | 3137 | } |
3115 | 3138 | ||
3116 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3139 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3117 | { | 3140 | { |
3118 | schedule(Scheduler::Declinecounter,incidence); | 3141 | schedule(Scheduler::Declinecounter,incidence); |
3119 | } | 3142 | } |
3120 | 3143 | ||
3121 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3144 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3122 | { | 3145 | { |
3123 | QDateTime start = QDateTime::currentDateTime(); | 3146 | QDateTime start = QDateTime::currentDateTime(); |
3124 | QDateTime end = start.addDays(daysToPublish); | 3147 | QDateTime end = start.addDays(daysToPublish); |
3125 | 3148 | ||
3126 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3149 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3127 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3150 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3128 | 3151 | ||
3129 | 3152 | ||
3130 | PublishDialog *publishdlg = new PublishDialog(); | 3153 | PublishDialog *publishdlg = new PublishDialog(); |
3131 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3154 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3132 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3155 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3133 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3156 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3134 | delete(freebusy); | 3157 | delete(freebusy); |
3135 | } | 3158 | } |
3136 | } | 3159 | } |
3137 | delete publishdlg; | 3160 | delete publishdlg; |
3138 | } | 3161 | } |
3139 | 3162 | ||
3140 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3163 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3141 | { | 3164 | { |
3142 | Event *event = 0; | 3165 | Event *event = 0; |
3143 | Todo *todo = 0; | 3166 | Todo *todo = 0; |
3144 | 3167 | ||
3145 | if (incidence == 0) { | 3168 | if (incidence == 0) { |
3146 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3169 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3147 | if (incidence == 0) { | 3170 | if (incidence == 0) { |
3148 | incidence = mTodoList->selectedIncidences().first(); | 3171 | incidence = mTodoList->selectedIncidences().first(); |
3149 | } | 3172 | } |
3150 | } | 3173 | } |
3151 | if ( incidence && incidence->type() == "Event" ) { | 3174 | if ( incidence && incidence->type() == "Event" ) { |
3152 | event = static_cast<Event *>(incidence); | 3175 | event = static_cast<Event *>(incidence); |
3153 | } | 3176 | } |
3154 | if ( incidence && incidence->type() == "Todo" ) { | 3177 | if ( incidence && incidence->type() == "Todo" ) { |
3155 | todo = static_cast<Todo *>(incidence); | 3178 | todo = static_cast<Todo *>(incidence); |
3156 | } | 3179 | } |
3157 | 3180 | ||
3158 | if (!event && !todo) { | 3181 | if (!event && !todo) { |
3159 | KMessageBox::sorry(this,i18n("No event selected.")); | 3182 | KMessageBox::sorry(this,i18n("No event selected.")); |
3160 | return; | 3183 | return; |
3161 | } | 3184 | } |
3162 | 3185 | ||
3163 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3186 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3164 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3187 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3165 | return; | 3188 | return; |
3166 | } | 3189 | } |
3167 | 3190 | ||
3168 | Event *ev = 0; | 3191 | Event *ev = 0; |
3169 | if (event) ev = new Event(*event); | 3192 | if (event) ev = new Event(*event); |
3170 | Todo *to = 0; | 3193 | Todo *to = 0; |
3171 | if (todo) to = new Todo(*todo); | 3194 | if (todo) to = new Todo(*todo); |
3172 | 3195 | ||
3173 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3196 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3174 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3197 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3175 | if (!me) { | 3198 | if (!me) { |
3176 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3199 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3177 | return; | 3200 | return; |
3178 | } | 3201 | } |
3179 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3202 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3180 | StatusDialog *statdlg = new StatusDialog(this); | 3203 | StatusDialog *statdlg = new StatusDialog(this); |
3181 | if (!statdlg->exec()==QDialog::Accepted) return; | 3204 | if (!statdlg->exec()==QDialog::Accepted) return; |
3182 | me->setStatus( statdlg->status() ); | 3205 | me->setStatus( statdlg->status() ); |
3183 | delete(statdlg); | 3206 | delete(statdlg); |
3184 | } | 3207 | } |
3185 | Attendee *menew = new Attendee(*me); | 3208 | Attendee *menew = new Attendee(*me); |
3186 | if (ev) { | 3209 | if (ev) { |
3187 | ev->clearAttendees(); | 3210 | ev->clearAttendees(); |
3188 | ev->addAttendee(menew,false); | 3211 | ev->addAttendee(menew,false); |
3189 | } else { | 3212 | } else { |
3190 | if (to) { | 3213 | if (to) { |
3191 | todo->clearAttendees(); | 3214 | todo->clearAttendees(); |
3192 | todo->addAttendee(menew,false); | 3215 | todo->addAttendee(menew,false); |
3193 | } | 3216 | } |
3194 | } | 3217 | } |
3195 | } | 3218 | } |
3196 | 3219 | ||
3197 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3220 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3198 | if (ev) { | 3221 | if (ev) { |
3199 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3222 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3200 | } else { | 3223 | } else { |
3201 | if (to) { | 3224 | if (to) { |
3202 | if ( !dlg->addMessage(to,method) ) delete(to); | 3225 | if ( !dlg->addMessage(to,method) ) delete(to); |
3203 | } | 3226 | } |
3204 | } | 3227 | } |
3205 | } | 3228 | } |
3206 | 3229 | ||
3207 | void CalendarView::openAddressbook() | 3230 | void CalendarView::openAddressbook() |
3208 | { | 3231 | { |
3209 | KRun::runCommand("kaddressbook"); | 3232 | KRun::runCommand("kaddressbook"); |
3210 | } | 3233 | } |
3211 | 3234 | ||
3212 | void CalendarView::setModified(bool modified) | 3235 | void CalendarView::setModified(bool modified) |
3213 | { | 3236 | { |
3214 | if ( modified ) | 3237 | if ( modified ) |
3215 | emit signalmodified(); | 3238 | emit signalmodified(); |
3216 | if (mModified != modified) { | 3239 | if (mModified != modified) { |
3217 | mModified = modified; | 3240 | mModified = modified; |
3218 | emit modifiedChanged(mModified); | 3241 | emit modifiedChanged(mModified); |
3219 | } | 3242 | } |
3220 | } | 3243 | } |
3221 | 3244 | ||
3222 | bool CalendarView::isReadOnly() | 3245 | bool CalendarView::isReadOnly() |
3223 | { | 3246 | { |
3224 | return mReadOnly; | 3247 | return mReadOnly; |
3225 | } | 3248 | } |
3226 | 3249 | ||
3227 | void CalendarView::setReadOnly(bool readOnly) | 3250 | void CalendarView::setReadOnly(bool readOnly) |
3228 | { | 3251 | { |
3229 | if (mReadOnly != readOnly) { | 3252 | if (mReadOnly != readOnly) { |
3230 | mReadOnly = readOnly; | 3253 | mReadOnly = readOnly; |
3231 | emit readOnlyChanged(mReadOnly); | 3254 | emit readOnlyChanged(mReadOnly); |
3232 | } | 3255 | } |
3233 | } | 3256 | } |
3234 | 3257 | ||
3235 | bool CalendarView::isModified() | 3258 | bool CalendarView::isModified() |
3236 | { | 3259 | { |
3237 | return mModified; | 3260 | return mModified; |
3238 | } | 3261 | } |
3239 | 3262 | ||
3240 | void CalendarView::printSetup() | 3263 | void CalendarView::printSetup() |
3241 | { | 3264 | { |
3242 | #ifndef KORG_NOPRINTER | 3265 | #ifndef KORG_NOPRINTER |
3243 | createPrinter(); | 3266 | createPrinter(); |
3244 | 3267 | ||
3245 | mCalPrinter->setupPrinter(); | 3268 | mCalPrinter->setupPrinter(); |
3246 | #endif | 3269 | #endif |
3247 | } | 3270 | } |
3248 | 3271 | ||
3249 | void CalendarView::print() | 3272 | void CalendarView::print() |
3250 | { | 3273 | { |
3251 | #ifndef KORG_NOPRINTER | 3274 | #ifndef KORG_NOPRINTER |
3252 | createPrinter(); | 3275 | createPrinter(); |
3253 | 3276 | ||
3254 | DateList tmpDateList = mNavigator->selectedDates(); | 3277 | DateList tmpDateList = mNavigator->selectedDates(); |
3255 | mCalPrinter->print(CalPrinter::Month, | 3278 | mCalPrinter->print(CalPrinter::Month, |
3256 | tmpDateList.first(), tmpDateList.last()); | 3279 | tmpDateList.first(), tmpDateList.last()); |
3257 | #endif | 3280 | #endif |
3258 | } | 3281 | } |
3259 | 3282 | ||
3260 | void CalendarView::printPreview() | 3283 | void CalendarView::printPreview() |
3261 | { | 3284 | { |
3262 | #ifndef KORG_NOPRINTER | 3285 | #ifndef KORG_NOPRINTER |
3263 | kdDebug() << "CalendarView::printPreview()" << endl; | 3286 | kdDebug() << "CalendarView::printPreview()" << endl; |
3264 | 3287 | ||
3265 | createPrinter(); | 3288 | createPrinter(); |
3266 | 3289 | ||
3267 | DateList tmpDateList = mNavigator->selectedDates(); | 3290 | DateList tmpDateList = mNavigator->selectedDates(); |
3268 | 3291 | ||
3269 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3292 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3270 | tmpDateList.last()); | 3293 | tmpDateList.last()); |
3271 | #endif | 3294 | #endif |
3272 | } | 3295 | } |
3273 | 3296 | ||
3274 | void CalendarView::exportICalendar() | 3297 | void CalendarView::exportICalendar() |
3275 | { | 3298 | { |
3276 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3299 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3277 | 3300 | ||
3278 | // Force correct extension | 3301 | // Force correct extension |
3279 | if (filename.right(4) != ".ics") filename += ".ics"; | 3302 | if (filename.right(4) != ".ics") filename += ".ics"; |
3280 | 3303 | ||
3281 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3304 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3282 | storage.save(); | 3305 | storage.save(); |
3283 | } | 3306 | } |
3284 | 3307 | ||
3285 | bool CalendarView::exportVCalendar( QString filename ) | 3308 | bool CalendarView::exportVCalendar( QString filename ) |
3286 | { | 3309 | { |
3287 | if (mCalendar->journals().count() > 0) { | 3310 | if (mCalendar->journals().count() > 0) { |
3288 | int result = KMessageBox::warningContinueCancel(this, | 3311 | int result = KMessageBox::warningContinueCancel(this, |
3289 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3312 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3290 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3313 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3291 | true); | 3314 | true); |
3292 | if (result != KMessageBox::Continue) return false; | 3315 | if (result != KMessageBox::Continue) return false; |
3293 | } | 3316 | } |
3294 | 3317 | ||
3295 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3318 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3296 | 3319 | ||
3297 | // Force correct extension | 3320 | // Force correct extension |
3298 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3321 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3299 | 3322 | ||
3300 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3323 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3301 | return storage.save(); | 3324 | return storage.save(); |
3302 | 3325 | ||
3303 | } | 3326 | } |
3304 | 3327 | ||
3305 | void CalendarView::eventUpdated(Incidence *) | 3328 | void CalendarView::eventUpdated(Incidence *) |
3306 | { | 3329 | { |
3307 | setModified(); | 3330 | setModified(); |
3308 | // Don't call updateView here. The code, which has caused the update of the | 3331 | // Don't call updateView here. The code, which has caused the update of the |
3309 | // event is responsible for updating the view. | 3332 | // event is responsible for updating the view. |
3310 | // updateView(); | 3333 | // updateView(); |
3311 | } | 3334 | } |
3312 | 3335 | ||
3313 | void CalendarView::adaptNavigationUnits() | 3336 | void CalendarView::adaptNavigationUnits() |
3314 | { | 3337 | { |
3315 | if (mViewManager->currentView()->isEventView()) { | 3338 | if (mViewManager->currentView()->isEventView()) { |
3316 | int days = mViewManager->currentView()->currentDateCount(); | 3339 | int days = mViewManager->currentView()->currentDateCount(); |
3317 | if (days == 1) { | 3340 | if (days == 1) { |
3318 | emit changeNavStringPrev(i18n("&Previous Day")); | 3341 | emit changeNavStringPrev(i18n("&Previous Day")); |
3319 | emit changeNavStringNext(i18n("&Next Day")); | 3342 | emit changeNavStringNext(i18n("&Next Day")); |
3320 | } else { | 3343 | } else { |
3321 | emit changeNavStringPrev(i18n("&Previous Week")); | 3344 | emit changeNavStringPrev(i18n("&Previous Week")); |
3322 | emit changeNavStringNext(i18n("&Next Week")); | 3345 | emit changeNavStringNext(i18n("&Next Week")); |
3323 | } | 3346 | } |
3324 | } | 3347 | } |
3325 | } | 3348 | } |
3326 | 3349 | ||
3327 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3350 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3328 | { | 3351 | { |
3329 | if ( incidence ) mTodoList->clearSelection(); | 3352 | if ( incidence ) mTodoList->clearSelection(); |
3330 | processIncidenceSelection( incidence ); | 3353 | processIncidenceSelection( incidence ); |
3331 | } | 3354 | } |
3332 | 3355 | ||
3333 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3356 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3334 | { | 3357 | { |
3335 | if ( incidence && mViewManager->currentView() ) { | 3358 | if ( incidence && mViewManager->currentView() ) { |
3336 | mViewManager->currentView()->clearSelection(); | 3359 | mViewManager->currentView()->clearSelection(); |
3337 | } | 3360 | } |
3338 | processIncidenceSelection( incidence ); | 3361 | processIncidenceSelection( incidence ); |
3339 | } | 3362 | } |
3340 | 3363 | ||
3341 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3364 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3342 | { | 3365 | { |
3343 | if ( incidence == mSelectedIncidence ) return; | 3366 | if ( incidence == mSelectedIncidence ) return; |
3344 | 3367 | ||
3345 | mSelectedIncidence = incidence; | 3368 | mSelectedIncidence = incidence; |
3346 | 3369 | ||
3347 | emit incidenceSelected( mSelectedIncidence ); | 3370 | emit incidenceSelected( mSelectedIncidence ); |
3348 | 3371 | ||
3349 | if ( incidence && incidence->type() == "Event" ) { | 3372 | if ( incidence && incidence->type() == "Event" ) { |
3350 | Event *event = static_cast<Event *>( incidence ); | 3373 | Event *event = static_cast<Event *>( incidence ); |
3351 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3374 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3352 | emit organizerEventsSelected( true ); | 3375 | emit organizerEventsSelected( true ); |
3353 | } else { | 3376 | } else { |
3354 | emit organizerEventsSelected(false); | 3377 | emit organizerEventsSelected(false); |
3355 | } | 3378 | } |
3356 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3379 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3357 | KOPrefs::instance()->email() ) ) { | 3380 | KOPrefs::instance()->email() ) ) { |
3358 | emit groupEventsSelected( true ); | 3381 | emit groupEventsSelected( true ); |
3359 | } else { | 3382 | } else { |
3360 | emit groupEventsSelected(false); | 3383 | emit groupEventsSelected(false); |
3361 | } | 3384 | } |
3362 | return; | 3385 | return; |
3363 | } else { | 3386 | } else { |
3364 | if ( incidence && incidence->type() == "Todo" ) { | 3387 | if ( incidence && incidence->type() == "Todo" ) { |
3365 | emit todoSelected( true ); | 3388 | emit todoSelected( true ); |
3366 | Todo *event = static_cast<Todo *>( incidence ); | 3389 | Todo *event = static_cast<Todo *>( incidence ); |
3367 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3390 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3368 | emit organizerEventsSelected( true ); | 3391 | emit organizerEventsSelected( true ); |
3369 | } else { | 3392 | } else { |
3370 | emit organizerEventsSelected(false); | 3393 | emit organizerEventsSelected(false); |
3371 | } | 3394 | } |
3372 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3395 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3373 | KOPrefs::instance()->email() ) ) { | 3396 | KOPrefs::instance()->email() ) ) { |
3374 | emit groupEventsSelected( true ); | 3397 | emit groupEventsSelected( true ); |
3375 | } else { | 3398 | } else { |
3376 | emit groupEventsSelected(false); | 3399 | emit groupEventsSelected(false); |
3377 | } | 3400 | } |
3378 | return; | 3401 | return; |
3379 | } else { | 3402 | } else { |
3380 | emit todoSelected( false ); | 3403 | emit todoSelected( false ); |
3381 | emit organizerEventsSelected(false); | 3404 | emit organizerEventsSelected(false); |
3382 | emit groupEventsSelected(false); | 3405 | emit groupEventsSelected(false); |
3383 | } | 3406 | } |
3384 | return; | 3407 | return; |
3385 | } | 3408 | } |
3386 | 3409 | ||
3387 | /* if ( incidence && incidence->type() == "Todo" ) { | 3410 | /* if ( incidence && incidence->type() == "Todo" ) { |
3388 | emit todoSelected( true ); | 3411 | emit todoSelected( true ); |
3389 | } else { | 3412 | } else { |
3390 | emit todoSelected( false ); | 3413 | emit todoSelected( false ); |
3391 | }*/ | 3414 | }*/ |
3392 | } | 3415 | } |
3393 | 3416 | ||
3394 | 3417 | ||
3395 | void CalendarView::checkClipboard() | 3418 | void CalendarView::checkClipboard() |
3396 | { | 3419 | { |
3397 | #ifndef KORG_NODND | 3420 | #ifndef KORG_NODND |
3398 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3421 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3399 | emit pasteEnabled(true); | 3422 | emit pasteEnabled(true); |
3400 | } else { | 3423 | } else { |
3401 | emit pasteEnabled(false); | 3424 | emit pasteEnabled(false); |
3402 | } | 3425 | } |
3403 | #endif | 3426 | #endif |
3404 | } | 3427 | } |
3405 | 3428 | ||
3406 | void CalendarView::showDates(const DateList &selectedDates) | 3429 | void CalendarView::showDates(const DateList &selectedDates) |
3407 | { | 3430 | { |
3408 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3431 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3409 | 3432 | ||
3410 | if ( mViewManager->currentView() ) { | 3433 | if ( mViewManager->currentView() ) { |
3411 | updateView( selectedDates.first(), selectedDates.last() ); | 3434 | updateView( selectedDates.first(), selectedDates.last() ); |
3412 | } else { | 3435 | } else { |
3413 | mViewManager->showAgendaView(); | 3436 | mViewManager->showAgendaView(); |
3414 | } | 3437 | } |
3415 | 3438 | ||
3416 | QString selDates; | 3439 | QString selDates; |
3417 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3440 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3418 | if (selectedDates.first() < selectedDates.last() ) | 3441 | if (selectedDates.first() < selectedDates.last() ) |
3419 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3442 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3420 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3443 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3421 | 3444 | ||
3422 | } | 3445 | } |
3423 | 3446 | ||
3424 | QPtrList<CalFilter> CalendarView::filters() | 3447 | QPtrList<CalFilter> CalendarView::filters() |
3425 | { | 3448 | { |
3426 | return mFilters; | 3449 | return mFilters; |
3427 | 3450 | ||
3428 | } | 3451 | } |
3429 | void CalendarView::editFilters() | 3452 | void CalendarView::editFilters() |
3430 | { | 3453 | { |
3431 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3454 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3432 | 3455 | ||
3433 | CalFilter *filter = mFilters.first(); | 3456 | CalFilter *filter = mFilters.first(); |
3434 | while(filter) { | 3457 | while(filter) { |
3435 | kdDebug() << " Filter: " << filter->name() << endl; | 3458 | kdDebug() << " Filter: " << filter->name() << endl; |
3436 | filter = mFilters.next(); | 3459 | filter = mFilters.next(); |
3437 | } | 3460 | } |
3438 | 3461 | ||
3439 | mDialogManager->showFilterEditDialog(&mFilters); | 3462 | mDialogManager->showFilterEditDialog(&mFilters); |
3440 | } | 3463 | } |
3441 | void CalendarView::toggleFilter() | 3464 | void CalendarView::toggleFilter() |
3442 | { | 3465 | { |
3443 | showFilter(! mFilterView->isVisible()); | 3466 | showFilter(! mFilterView->isVisible()); |
3444 | } | 3467 | } |
3445 | 3468 | ||
3446 | KOFilterView *CalendarView::filterView() | 3469 | KOFilterView *CalendarView::filterView() |
3447 | { | 3470 | { |
3448 | return mFilterView; | 3471 | return mFilterView; |
3449 | } | 3472 | } |
3450 | void CalendarView::selectFilter( int fil ) | 3473 | void CalendarView::selectFilter( int fil ) |
3451 | { | 3474 | { |
3452 | mFilterView->setSelectedFilter( fil ); | 3475 | mFilterView->setSelectedFilter( fil ); |
3453 | } | 3476 | } |
3454 | void CalendarView::showFilter(bool visible) | 3477 | void CalendarView::showFilter(bool visible) |
3455 | { | 3478 | { |
3456 | if (visible) mFilterView->show(); | 3479 | if (visible) mFilterView->show(); |
3457 | else mFilterView->hide(); | 3480 | else mFilterView->hide(); |
3458 | } | 3481 | } |
3459 | void CalendarView::toggleFilerEnabled( ) | 3482 | void CalendarView::toggleFilerEnabled( ) |
3460 | { | 3483 | { |
3461 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3484 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3462 | if ( !mFilterView->filtersEnabled() ) | 3485 | if ( !mFilterView->filtersEnabled() ) |
3463 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3486 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3464 | 3487 | ||
3465 | } | 3488 | } |
3466 | void CalendarView::updateFilter() | 3489 | void CalendarView::updateFilter() |
3467 | { | 3490 | { |
3468 | CalFilter *filter = mFilterView->selectedFilter(); | 3491 | CalFilter *filter = mFilterView->selectedFilter(); |
3469 | if (filter) { | 3492 | if (filter) { |
3470 | if (mFilterView->filtersEnabled()) { | 3493 | if (mFilterView->filtersEnabled()) { |
3471 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3494 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3472 | filter->setEnabled(true); | 3495 | filter->setEnabled(true); |
3473 | } | 3496 | } |
3474 | else filter->setEnabled(false); | 3497 | else filter->setEnabled(false); |
3475 | mCalendar->setFilter(filter); | 3498 | mCalendar->setFilter(filter); |
3476 | updateView(); | 3499 | updateView(); |
3477 | } | 3500 | } |
3478 | } | 3501 | } |
3479 | 3502 | ||
3480 | void CalendarView::filterEdited() | 3503 | void CalendarView::filterEdited() |
3481 | { | 3504 | { |
3482 | mFilterView->updateFilters(); | 3505 | mFilterView->updateFilters(); |
3483 | updateFilter(); | 3506 | updateFilter(); |
3484 | writeSettings(); | 3507 | writeSettings(); |
3485 | } | 3508 | } |
3486 | 3509 | ||
3487 | 3510 | ||
3488 | void CalendarView::takeOverEvent() | 3511 | void CalendarView::takeOverEvent() |
3489 | { | 3512 | { |
3490 | Incidence *incidence = currentSelection(); | 3513 | Incidence *incidence = currentSelection(); |
3491 | 3514 | ||
3492 | if (!incidence) return; | 3515 | if (!incidence) return; |
3493 | 3516 | ||
3494 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3517 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3495 | incidence->recreate(); | 3518 | incidence->recreate(); |
3496 | incidence->setReadOnly(false); | 3519 | incidence->setReadOnly(false); |
3497 | 3520 | ||
3498 | updateView(); | 3521 | updateView(); |
3499 | } | 3522 | } |
3500 | 3523 | ||
3501 | void CalendarView::takeOverCalendar() | 3524 | void CalendarView::takeOverCalendar() |
3502 | { | 3525 | { |
3503 | // TODO: Create Calendar::allIncidences() function and use it here | 3526 | // TODO: Create Calendar::allIncidences() function and use it here |
3504 | 3527 | ||
3505 | QPtrList<Event> events = mCalendar->events(); | 3528 | QPtrList<Event> events = mCalendar->events(); |
3506 | for(uint i=0; i<events.count(); ++i) { | 3529 | for(uint i=0; i<events.count(); ++i) { |
3507 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3530 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3508 | events.at(i)->recreate(); | 3531 | events.at(i)->recreate(); |
3509 | events.at(i)->setReadOnly(false); | 3532 | events.at(i)->setReadOnly(false); |
3510 | } | 3533 | } |
3511 | 3534 | ||
3512 | QPtrList<Todo> todos = mCalendar->todos(); | 3535 | QPtrList<Todo> todos = mCalendar->todos(); |
3513 | for(uint i=0; i<todos.count(); ++i) { | 3536 | for(uint i=0; i<todos.count(); ++i) { |
3514 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3537 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3515 | todos.at(i)->recreate(); | 3538 | todos.at(i)->recreate(); |
3516 | todos.at(i)->setReadOnly(false); | 3539 | todos.at(i)->setReadOnly(false); |
3517 | } | 3540 | } |
3518 | 3541 | ||
3519 | QPtrList<Journal> journals = mCalendar->journals(); | 3542 | QPtrList<Journal> journals = mCalendar->journals(); |
3520 | for(uint i=0; i<journals.count(); ++i) { | 3543 | for(uint i=0; i<journals.count(); ++i) { |
3521 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3544 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3522 | journals.at(i)->recreate(); | 3545 | journals.at(i)->recreate(); |
3523 | journals.at(i)->setReadOnly(false); | 3546 | journals.at(i)->setReadOnly(false); |
3524 | } | 3547 | } |
3525 | 3548 | ||
3526 | updateView(); | 3549 | updateView(); |
3527 | } | 3550 | } |
3528 | 3551 | ||
3529 | void CalendarView::showIntro() | 3552 | void CalendarView::showIntro() |
3530 | { | 3553 | { |
3531 | kdDebug() << "To be implemented." << endl; | 3554 | kdDebug() << "To be implemented." << endl; |
3532 | } | 3555 | } |
3533 | 3556 | ||
3534 | QWidgetStack *CalendarView::viewStack() | 3557 | QWidgetStack *CalendarView::viewStack() |
3535 | { | 3558 | { |
3536 | return mRightFrame; | 3559 | return mRightFrame; |
3537 | } | 3560 | } |
3538 | 3561 | ||
3539 | QWidget *CalendarView::leftFrame() | 3562 | QWidget *CalendarView::leftFrame() |
3540 | { | 3563 | { |
3541 | return mLeftFrame; | 3564 | return mLeftFrame; |
3542 | } | 3565 | } |
3543 | 3566 | ||
3544 | DateNavigator *CalendarView::dateNavigator() | 3567 | DateNavigator *CalendarView::dateNavigator() |
3545 | { | 3568 | { |
3546 | return mNavigator; | 3569 | return mNavigator; |
3547 | } | 3570 | } |
3548 | 3571 | ||
3549 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3572 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3550 | { | 3573 | { |
3551 | return mDateNavigator; | 3574 | return mDateNavigator; |
3552 | } | 3575 | } |
3553 | void CalendarView::toggleDateNavigatorWidget() | 3576 | void CalendarView::toggleDateNavigatorWidget() |
3554 | { | 3577 | { |
3555 | if (mDateNavigator->isVisible()) | 3578 | if (mDateNavigator->isVisible()) |
3556 | mDateNavigator->hide(); | 3579 | mDateNavigator->hide(); |
3557 | else | 3580 | else |
3558 | mDateNavigator->show(); | 3581 | mDateNavigator->show(); |
3559 | } | 3582 | } |
3560 | void CalendarView::addView(KOrg::BaseView *view) | 3583 | void CalendarView::addView(KOrg::BaseView *view) |
3561 | { | 3584 | { |
3562 | mViewManager->addView(view); | 3585 | mViewManager->addView(view); |
3563 | } | 3586 | } |
3564 | 3587 | ||
3565 | void CalendarView::showView(KOrg::BaseView *view) | 3588 | void CalendarView::showView(KOrg::BaseView *view) |
3566 | { | 3589 | { |
3567 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3590 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3568 | } | 3591 | } |
3569 | 3592 | ||
3570 | Incidence *CalendarView::currentSelection() | 3593 | Incidence *CalendarView::currentSelection() |
3571 | { | 3594 | { |
3572 | return mViewManager->currentSelection(); | 3595 | return mViewManager->currentSelection(); |
3573 | } | 3596 | } |
3574 | void CalendarView::toggleAllDaySize() | 3597 | void CalendarView::toggleAllDaySize() |
3575 | { | 3598 | { |
3576 | /* | 3599 | /* |
3577 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3600 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3578 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3601 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3579 | else | 3602 | else |
3580 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3603 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3581 | */ | 3604 | */ |
3582 | viewManager()->agendaView()->toggleAllDay(); | 3605 | viewManager()->agendaView()->toggleAllDay(); |
3583 | } | 3606 | } |
3584 | void CalendarView::toggleExpand() | 3607 | void CalendarView::toggleExpand() |
3585 | { | 3608 | { |
3586 | // if ( mLeftFrame->isHidden() ) { | 3609 | // if ( mLeftFrame->isHidden() ) { |
3587 | // mLeftFrame->show(); | 3610 | // mLeftFrame->show(); |
3588 | // emit calendarViewExpanded( false ); | 3611 | // emit calendarViewExpanded( false ); |
3589 | // } else { | 3612 | // } else { |
3590 | // mLeftFrame->hide(); | 3613 | // mLeftFrame->hide(); |
3591 | // emit calendarViewExpanded( true ); | 3614 | // emit calendarViewExpanded( true ); |
3592 | // } | 3615 | // } |
3593 | 3616 | ||
3594 | globalFlagBlockAgenda = 1; | 3617 | globalFlagBlockAgenda = 1; |
3595 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3618 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3596 | globalFlagBlockAgenda = 5; | 3619 | globalFlagBlockAgenda = 5; |
3597 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3620 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3598 | //mViewManager->showView( 0, true ); | 3621 | //mViewManager->showView( 0, true ); |
3599 | } | 3622 | } |
3600 | 3623 | ||
3601 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3624 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3602 | { | 3625 | { |
3603 | setModified( modified ); | 3626 | setModified( modified ); |
3604 | } | 3627 | } |
3605 | 3628 | ||
3606 | Todo *CalendarView::selectedTodo() | 3629 | Todo *CalendarView::selectedTodo() |
3607 | { | 3630 | { |
3608 | Incidence *incidence = currentSelection(); | 3631 | Incidence *incidence = currentSelection(); |
3609 | if ( incidence && incidence->type() == "Todo" ) { | 3632 | if ( incidence && incidence->type() == "Todo" ) { |
3610 | return static_cast<Todo *>( incidence ); | 3633 | return static_cast<Todo *>( incidence ); |
3611 | } | 3634 | } |
3612 | 3635 | ||
3613 | incidence = mTodoList->selectedIncidences().first(); | 3636 | incidence = mTodoList->selectedIncidences().first(); |
3614 | if ( incidence && incidence->type() == "Todo" ) { | 3637 | if ( incidence && incidence->type() == "Todo" ) { |
3615 | return static_cast<Todo *>( incidence ); | 3638 | return static_cast<Todo *>( incidence ); |
3616 | } | 3639 | } |
3617 | 3640 | ||
3618 | return 0; | 3641 | return 0; |
3619 | } | 3642 | } |
3620 | 3643 | ||
3621 | void CalendarView::dialogClosing(Incidence *in) | 3644 | void CalendarView::dialogClosing(Incidence *in) |
3622 | { | 3645 | { |
3623 | // mDialogList.remove(in); | 3646 | // mDialogList.remove(in); |
3624 | } | 3647 | } |
3625 | 3648 | ||
3626 | void CalendarView::showIncidence() | 3649 | void CalendarView::showIncidence() |
3627 | { | 3650 | { |
3628 | Incidence *incidence = currentSelection(); | 3651 | Incidence *incidence = currentSelection(); |
3629 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3630 | if ( incidence ) { | 3653 | if ( incidence ) { |
3631 | ShowIncidenceVisitor v; | 3654 | ShowIncidenceVisitor v; |
3632 | v.act( incidence, this ); | 3655 | v.act( incidence, this ); |
3633 | } | 3656 | } |
3634 | } | 3657 | } |
3635 | void CalendarView::editIncidenceDescription() | 3658 | void CalendarView::editIncidenceDescription() |
3636 | { | 3659 | { |
3637 | mFlagEditDescription = true; | 3660 | mFlagEditDescription = true; |
3638 | editIncidence(); | 3661 | editIncidence(); |
3639 | mFlagEditDescription = false; | 3662 | mFlagEditDescription = false; |
3640 | } | 3663 | } |
3641 | void CalendarView::editIncidence() | 3664 | void CalendarView::editIncidence() |
3642 | { | 3665 | { |
3643 | // qDebug("editIncidence() "); | 3666 | // qDebug("editIncidence() "); |
3644 | Incidence *incidence = currentSelection(); | 3667 | Incidence *incidence = currentSelection(); |
3645 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3668 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3646 | if ( incidence ) { | 3669 | if ( incidence ) { |
3647 | EditIncidenceVisitor v; | 3670 | EditIncidenceVisitor v; |
3648 | v.act( incidence, this ); | 3671 | v.act( incidence, this ); |
3649 | } | 3672 | } |
3650 | } | 3673 | } |
3651 | 3674 | ||
3652 | void CalendarView::deleteIncidence() | 3675 | void CalendarView::deleteIncidence() |
3653 | { | 3676 | { |
3654 | Incidence *incidence = currentSelection(); | 3677 | Incidence *incidence = currentSelection(); |
3655 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3678 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3656 | if ( incidence ) { | 3679 | if ( incidence ) { |
3657 | deleteIncidence(incidence); | 3680 | deleteIncidence(incidence); |
3658 | } | 3681 | } |
3659 | } | 3682 | } |
3660 | 3683 | ||
3661 | void CalendarView::showIncidence(Incidence *incidence) | 3684 | void CalendarView::showIncidence(Incidence *incidence) |
3662 | { | 3685 | { |
3663 | if ( incidence ) { | 3686 | if ( incidence ) { |
3664 | ShowIncidenceVisitor v; | 3687 | ShowIncidenceVisitor v; |
3665 | v.act( incidence, this ); | 3688 | v.act( incidence, this ); |
3666 | } | 3689 | } |
3667 | } | 3690 | } |
3668 | 3691 | ||
3669 | void CalendarView::editIncidence(Incidence *incidence) | 3692 | void CalendarView::editIncidence(Incidence *incidence) |
3670 | { | 3693 | { |
3671 | if ( incidence ) { | 3694 | if ( incidence ) { |
3672 | 3695 | ||
3673 | EditIncidenceVisitor v; | 3696 | EditIncidenceVisitor v; |
3674 | v.act( incidence, this ); | 3697 | v.act( incidence, this ); |
3675 | 3698 | ||
3676 | } | 3699 | } |
3677 | } | 3700 | } |
3678 | 3701 | ||
3679 | void CalendarView::deleteIncidence(Incidence *incidence) | 3702 | void CalendarView::deleteIncidence(Incidence *incidence) |
3680 | { | 3703 | { |
3681 | //qDebug(" CalendarView::deleteIncidence "); | 3704 | //qDebug(" CalendarView::deleteIncidence "); |
3682 | if ( incidence ) { | 3705 | if ( incidence ) { |
3683 | DeleteIncidenceVisitor v; | 3706 | DeleteIncidenceVisitor v; |
3684 | v.act( incidence, this ); | 3707 | v.act( incidence, this ); |
3685 | } | 3708 | } |
3686 | } | 3709 | } |
3687 | 3710 | ||
3688 | 3711 | ||
3689 | void CalendarView::lookForOutgoingMessages() | 3712 | void CalendarView::lookForOutgoingMessages() |
3690 | { | 3713 | { |
3691 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3714 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3692 | ogd->loadMessages(); | 3715 | ogd->loadMessages(); |
3693 | } | 3716 | } |
3694 | 3717 | ||
3695 | void CalendarView::lookForIncomingMessages() | 3718 | void CalendarView::lookForIncomingMessages() |
3696 | { | 3719 | { |
3697 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3720 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3698 | icd->retrieve(); | 3721 | icd->retrieve(); |
3699 | } | 3722 | } |
3700 | 3723 | ||
3701 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3724 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3702 | { | 3725 | { |
3703 | bool deleteTodo = true; | 3726 | bool deleteTodo = true; |
3704 | QPtrList<Incidence> subTodos; | 3727 | QPtrList<Incidence> subTodos; |
3705 | Incidence *aTodo; | 3728 | Incidence *aTodo; |
3706 | subTodos = t->relations(); | 3729 | subTodos = t->relations(); |
3707 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3730 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3708 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3731 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3709 | deleteTodo = false; | 3732 | deleteTodo = false; |
3710 | } | 3733 | } |
3711 | if ( deleteTodo ) { | 3734 | if ( deleteTodo ) { |
3712 | if ( t->isCompleted() ) { | 3735 | if ( t->isCompleted() ) { |
3713 | checkExternalId( t ); | 3736 | checkExternalId( t ); |
3714 | mCalendar->deleteTodo( t ); | 3737 | mCalendar->deleteTodo( t ); |
3715 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3738 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3716 | } | 3739 | } |
3717 | else | 3740 | else |
3718 | deleteTodo = false; | 3741 | deleteTodo = false; |
3719 | } | 3742 | } |
3720 | return deleteTodo; | 3743 | return deleteTodo; |
3721 | 3744 | ||
3722 | } | 3745 | } |
3723 | void CalendarView::purgeCompleted() | 3746 | void CalendarView::purgeCompleted() |
3724 | { | 3747 | { |
3725 | int result = KMessageBox::warningContinueCancel(this, | 3748 | int result = KMessageBox::warningContinueCancel(this, |
3726 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3749 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3727 | 3750 | ||
3728 | if (result == KMessageBox::Continue) { | 3751 | if (result == KMessageBox::Continue) { |
3729 | 3752 | ||
3730 | QPtrList<Todo> todoCal; | 3753 | QPtrList<Todo> todoCal; |
3731 | QPtrList<Todo> rootTodos; | 3754 | QPtrList<Todo> rootTodos; |
3732 | //QPtrList<Incidence> rel; | 3755 | //QPtrList<Incidence> rel; |
3733 | Todo *aTodo;//, *rTodo; | 3756 | Todo *aTodo;//, *rTodo; |
3734 | Incidence *rIncidence; | 3757 | Incidence *rIncidence; |
3735 | bool childDelete = false; | 3758 | bool childDelete = false; |
3736 | bool deletedOne = true; | 3759 | bool deletedOne = true; |
3737 | todoCal = calendar()->todos(); | 3760 | todoCal = calendar()->todos(); |
3738 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3761 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3739 | if ( !aTodo->relatedTo() ) | 3762 | if ( !aTodo->relatedTo() ) |
3740 | rootTodos.append( aTodo ); | 3763 | rootTodos.append( aTodo ); |
3741 | } | 3764 | } |
3742 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3765 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3743 | removeCompletedSubTodos( aTodo ); | 3766 | removeCompletedSubTodos( aTodo ); |
3744 | } | 3767 | } |
3745 | 3768 | ||
3746 | updateView(); | 3769 | updateView(); |
3747 | } | 3770 | } |
3748 | } | 3771 | } |
3749 | 3772 | ||
3750 | void CalendarView::slotCalendarChanged() | 3773 | void CalendarView::slotCalendarChanged() |
3751 | { | 3774 | { |
3752 | ; | 3775 | ; |
3753 | } | 3776 | } |
3754 | 3777 | ||
3755 | NavigatorBar *CalendarView::navigatorBar() | 3778 | NavigatorBar *CalendarView::navigatorBar() |
3756 | { | 3779 | { |
3757 | return mNavigatorBar; | 3780 | return mNavigatorBar; |
3758 | } | 3781 | } |
3759 | 3782 | ||
3760 | 3783 | ||
3761 | 3784 | ||
3762 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3785 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3763 | { | 3786 | { |
3764 | //qDebug(" alendarView::keyPressEvent "); | 3787 | //qDebug(" alendarView::keyPressEvent "); |
3765 | e->ignore(); | 3788 | e->ignore(); |
3766 | } | 3789 | } |
3767 | 3790 | ||
3768 | 3791 | ||
3769 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3792 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3770 | { | 3793 | { |
3771 | // mSyncManager = manager; | 3794 | // mSyncManager = manager; |
3772 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3795 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3773 | qDebug("SyncKDE request detected!"); | 3796 | qDebug("SyncKDE request detected!"); |
3774 | } | 3797 | } |
3775 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3798 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3776 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3799 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3777 | return syncCalendar( filename, mode ); | 3800 | return syncCalendar( filename, mode ); |
3778 | } | 3801 | } |
3779 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3802 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3780 | { | 3803 | { |
3781 | //mSyncManager = manager; | 3804 | //mSyncManager = manager; |
3782 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3805 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3783 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3806 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3784 | if ( resource == "sharp" ) | 3807 | if ( resource == "sharp" ) |
3785 | syncExternal( 0 ); | 3808 | syncExternal( 0 ); |
3786 | if ( resource == "phone" ) | 3809 | if ( resource == "phone" ) |
3787 | syncExternal( 1 ); | 3810 | syncExternal( 1 ); |
3788 | // pending setmodified | 3811 | // pending setmodified |
3789 | return true; | 3812 | return true; |
3790 | } | 3813 | } |
3791 | void CalendarView::setSyncManager(KSyncManager* manager) | 3814 | void CalendarView::setSyncManager(KSyncManager* manager) |
3792 | { | 3815 | { |
3793 | mSyncManager = manager; | 3816 | mSyncManager = manager; |
3794 | } | 3817 | } |
3795 | 3818 | ||
3796 | void CalendarView::removeSyncInfo( QString syncProfile) | 3819 | void CalendarView::removeSyncInfo( QString syncProfile) |
3797 | { | 3820 | { |
3798 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3821 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3799 | mCalendar->removeSyncInfo( syncProfile ); | 3822 | mCalendar->removeSyncInfo( syncProfile ); |
3800 | 3823 | ||
3801 | } | 3824 | } |
3825 | |||
3826 | void CalendarView::undo_delete() | ||
3827 | { | ||
3828 | //qDebug("undo_delete() "); | ||
3829 | Incidence* undo = mCalendar->undoIncidence(); | ||
3830 | if ( !undo ) { | ||
3831 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | ||
3832 | i18n("KO/Pi")); | ||
3833 | return; | ||
3834 | } | ||
3835 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | ||
3836 | i18n("\nAre you sure you want\nto restore this?"), | ||
3837 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | ||
3838 | mCalendar->undoDeleteIncidence(); | ||
3839 | updateView(); | ||
3840 | } | ||
3841 | } | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 437a51c..646973d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,605 +1,608 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class NavigatorBar; | 60 | class NavigatorBar; |
61 | class KOEventEditor; | 61 | class KOEventEditor; |
62 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
63 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
64 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | class AlarmDialog; | 66 | class AlarmDialog; |
67 | class KCal::Attendee; | 67 | class KCal::Attendee; |
68 | 68 | ||
69 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
70 | 70 | ||
71 | using namespace KCal; | 71 | using namespace KCal; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
75 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
76 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
77 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
78 | 78 | ||
79 | @short main calendar view widget | 79 | @short main calendar view widget |
80 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
81 | */ | 81 | */ |
82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | /** | 86 | /** |
87 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
88 | 88 | ||
89 | @param calendar calendar document | 89 | @param calendar calendar document |
90 | @param parent parent window | 90 | @param parent parent window |
91 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
92 | */ | 92 | */ |
93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
96 | const char *name = 0 ); | 96 | const char *name = 0 ); |
97 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
98 | 98 | ||
99 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
100 | 100 | ||
101 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
102 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
103 | 103 | ||
104 | QDate startDate(); | 104 | QDate startDate(); |
105 | QDate endDate(); | 105 | QDate endDate(); |
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showOpenError(); | 177 | void showOpenError(); |
178 | void watchSavedFile(); | 178 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 179 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 180 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 184 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 185 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 186 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 187 | void updateConfig(); |
188 | 188 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 190 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 191 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 192 | const QStringList& uidList); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 195 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 196 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 197 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 198 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 199 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 200 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Save calendar data to file. Return true if calendar could be | 203 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 204 | successfully saved. |
205 | */ | 205 | */ |
206 | bool saveCalendar(QString filename); | 206 | bool saveCalendar(QString filename); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 209 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 210 | calendar. |
211 | */ | 211 | */ |
212 | void closeCalendar(); | 212 | void closeCalendar(); |
213 | 213 | ||
214 | /** Archive old events of calendar */ | 214 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 215 | void archiveCalendar(); |
216 | 216 | ||
217 | void showIncidence(); | 217 | void showIncidence(); |
218 | void editIncidence(); | 218 | void editIncidence(); |
219 | void editIncidenceDescription(); | 219 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 220 | void deleteIncidence(); |
221 | void cloneIncidence(); | 221 | void cloneIncidence(); |
222 | void moveIncidence(); | 222 | void moveIncidence(); |
223 | void beamIncidence(); | 223 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 224 | void toggleCancelIncidence(); |
225 | 225 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 226 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 227 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 228 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
229 | void newEvent(QDateTime fh); | 229 | void newEvent(QDateTime fh); |
230 | void newEvent(QDate dt); | 230 | void newEvent(QDate dt); |
231 | /** create new event without having a date hint. Takes current date as | 231 | /** create new event without having a date hint. Takes current date as |
232 | default hint. */ | 232 | default hint. */ |
233 | void newEvent(); | 233 | void newEvent(); |
234 | void newFloatingEvent(); | 234 | void newFloatingEvent(); |
235 | 235 | ||
236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
237 | void showIncidence(Incidence *); | 237 | void showIncidence(Incidence *); |
238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
239 | void editIncidence(Incidence *); | 239 | void editIncidence(Incidence *); |
240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
241 | void deleteIncidence(Incidence *); | 241 | void deleteIncidence(Incidence *); |
242 | void cloneIncidence(Incidence *); | 242 | void cloneIncidence(Incidence *); |
243 | void cancelIncidence(Incidence *); | 243 | void cancelIncidence(Incidence *); |
244 | /** Create an editor for the supplied event. */ | 244 | /** Create an editor for the supplied event. */ |
245 | void editEvent(Event *); | 245 | void editEvent(Event *); |
246 | /** Delete the supplied event. */ | 246 | /** Delete the supplied event. */ |
247 | void deleteEvent(Event *); | 247 | void deleteEvent(Event *); |
248 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 248 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
249 | found. */ | 249 | found. */ |
250 | bool deleteEvent(const QString &uid); | 250 | bool deleteEvent(const QString &uid); |
251 | /** Create a read-only viewer dialog for the supplied event. */ | 251 | /** Create a read-only viewer dialog for the supplied event. */ |
252 | void showEvent(Event *); | 252 | void showEvent(Event *); |
253 | 253 | ||
254 | void editJournal(Journal *); | 254 | void editJournal(Journal *); |
255 | void showJournal(Journal *); | 255 | void showJournal(Journal *); |
256 | void deleteJournal(Journal *); | 256 | void deleteJournal(Journal *); |
257 | /** Create an editor dialog for a todo */ | 257 | /** Create an editor dialog for a todo */ |
258 | void editTodo(Todo *); | 258 | void editTodo(Todo *); |
259 | /** Create a read-only viewer dialog for the supplied todo */ | 259 | /** Create a read-only viewer dialog for the supplied todo */ |
260 | void showTodo(Todo *); | 260 | void showTodo(Todo *); |
261 | /** create new todo */ | 261 | /** create new todo */ |
262 | void newTodo(); | 262 | void newTodo(); |
263 | /** create new todo with a parent todo */ | 263 | /** create new todo with a parent todo */ |
264 | void newSubTodo(); | 264 | void newSubTodo(); |
265 | /** create new todo with a parent todo */ | 265 | /** create new todo with a parent todo */ |
266 | void newSubTodo(Todo *); | 266 | void newSubTodo(Todo *); |
267 | /** Delete todo */ | 267 | /** Delete todo */ |
268 | void deleteTodo(Todo *); | 268 | void deleteTodo(Todo *); |
269 | 269 | ||
270 | 270 | ||
271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
272 | * emitted as result. */ | 272 | * emitted as result. */ |
273 | void checkClipboard(); | 273 | void checkClipboard(); |
274 | 274 | ||
275 | /** using the KConfig associated with the kapp variable, read in the | 275 | /** using the KConfig associated with the kapp variable, read in the |
276 | * settings from the config file. | 276 | * settings from the config file. |
277 | */ | 277 | */ |
278 | void readSettings(); | 278 | void readSettings(); |
279 | 279 | ||
280 | /** write current state to config file. */ | 280 | /** write current state to config file. */ |
281 | void writeSettings(); | 281 | void writeSettings(); |
282 | 282 | ||
283 | /** read settings for calendar filters */ | 283 | /** read settings for calendar filters */ |
284 | void readFilterSettings(KConfig *config); | 284 | void readFilterSettings(KConfig *config); |
285 | 285 | ||
286 | /** write settings for calendar filters */ | 286 | /** write settings for calendar filters */ |
287 | void writeFilterSettings(KConfig *config); | 287 | void writeFilterSettings(KConfig *config); |
288 | 288 | ||
289 | /** passes on the message that an event has changed to the currently | 289 | /** passes on the message that an event has changed to the currently |
290 | * activated view so that it can make appropriate display changes. */ | 290 | * activated view so that it can make appropriate display changes. */ |
291 | void changeEventDisplay(Event *, int); | 291 | void changeEventDisplay(Event *, int); |
292 | void changeIncidenceDisplay(Incidence *, int); | 292 | void changeIncidenceDisplay(Incidence *, int); |
293 | void changeTodoDisplay(Todo *, int); | 293 | void changeTodoDisplay(Todo *, int); |
294 | 294 | ||
295 | void eventAdded(Event *); | 295 | void eventAdded(Event *); |
296 | void eventChanged(Event *); | 296 | void eventChanged(Event *); |
297 | void eventToBeDeleted(Event *); | 297 | void eventToBeDeleted(Event *); |
298 | void eventDeleted(); | 298 | void eventDeleted(); |
299 | 299 | ||
300 | void todoAdded(Todo *); | 300 | void todoAdded(Todo *); |
301 | void todoChanged(Todo *); | 301 | void todoChanged(Todo *); |
302 | void todoToBeDeleted(Todo *); | 302 | void todoToBeDeleted(Todo *); |
303 | void todoDeleted(); | 303 | void todoDeleted(); |
304 | 304 | ||
305 | void updateView(const QDate &start, const QDate &end); | 305 | void updateView(const QDate &start, const QDate &end); |
306 | void updateView(); | 306 | void updateView(); |
307 | 307 | ||
308 | /** Full update of visible todo views */ | 308 | /** Full update of visible todo views */ |
309 | void updateTodoViews(); | 309 | void updateTodoViews(); |
310 | 310 | ||
311 | void updateUnmanagedViews(); | 311 | void updateUnmanagedViews(); |
312 | 312 | ||
313 | /** cut the current appointment to the clipboard */ | 313 | /** cut the current appointment to the clipboard */ |
314 | void edit_cut(); | 314 | void edit_cut(); |
315 | 315 | ||
316 | /** copy the current appointment(s) to the clipboard */ | 316 | /** copy the current appointment(s) to the clipboard */ |
317 | void edit_copy(); | 317 | void edit_copy(); |
318 | 318 | ||
319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
320 | void edit_paste(); | 320 | void edit_paste(); |
321 | 321 | ||
322 | /** edit viewing and configuration options. */ | 322 | /** edit viewing and configuration options. */ |
323 | void edit_options(); | 323 | void edit_options(); |
324 | /** | 324 | /** |
325 | Functions for printing, previewing a print, and setting up printing | 325 | Functions for printing, previewing a print, and setting up printing |
326 | parameters. | 326 | parameters. |
327 | */ | 327 | */ |
328 | void print(); | 328 | void print(); |
329 | void printSetup(); | 329 | void printSetup(); |
330 | void printPreview(); | 330 | void printPreview(); |
331 | 331 | ||
332 | /** Export as iCalendar file */ | 332 | /** Export as iCalendar file */ |
333 | void exportICalendar(); | 333 | void exportICalendar(); |
334 | 334 | ||
335 | /** Export as vCalendar file */ | 335 | /** Export as vCalendar file */ |
336 | bool exportVCalendar( QString fn); | 336 | bool exportVCalendar( QString fn); |
337 | 337 | ||
338 | /** pop up a dialog to show an existing appointment. */ | 338 | /** pop up a dialog to show an existing appointment. */ |
339 | void appointment_show(); | 339 | void appointment_show(); |
340 | /** | 340 | /** |
341 | * pop up an Appointment Dialog to edit an existing appointment.Get | 341 | * pop up an Appointment Dialog to edit an existing appointment.Get |
342 | * information on the appointment from the list of unique IDs that is | 342 | * information on the appointment from the list of unique IDs that is |
343 | * currently in the View, called currIds. | 343 | * currently in the View, called currIds. |
344 | */ | 344 | */ |
345 | void appointment_edit(); | 345 | void appointment_edit(); |
346 | /** | 346 | /** |
347 | * pop up dialog confirming deletion of currently selected event in the | 347 | * pop up dialog confirming deletion of currently selected event in the |
348 | * View. | 348 | * View. |
349 | */ | 349 | */ |
350 | void appointment_delete(); | 350 | void appointment_delete(); |
351 | 351 | ||
352 | /** mails the currently selected event to a particular user as a vCalendar | 352 | /** mails the currently selected event to a particular user as a vCalendar |
353 | attachment. */ | 353 | attachment. */ |
354 | void action_mail(); | 354 | void action_mail(); |
355 | 355 | ||
356 | /* frees a subtodo from it's relation */ | 356 | /* frees a subtodo from it's relation */ |
357 | void todo_unsub( Todo * ); | 357 | void todo_unsub( Todo * ); |
358 | void todo_resub( Todo * parent, Todo * sub ); | 358 | void todo_resub( Todo * parent, Todo * sub ); |
359 | 359 | ||
360 | /** Take ownership of selected event. */ | 360 | /** Take ownership of selected event. */ |
361 | void takeOverEvent(); | 361 | void takeOverEvent(); |
362 | 362 | ||
363 | /** Take ownership of all events in calendar. */ | 363 | /** Take ownership of all events in calendar. */ |
364 | void takeOverCalendar(); | 364 | void takeOverCalendar(); |
365 | 365 | ||
366 | /** query whether or not the calendar is "dirty". */ | 366 | /** query whether or not the calendar is "dirty". */ |
367 | bool isModified(); | 367 | bool isModified(); |
368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
369 | void setModified(bool modified=true); | 369 | void setModified(bool modified=true); |
370 | 370 | ||
371 | /** query if the calendar is read-only. */ | 371 | /** query if the calendar is read-only. */ |
372 | bool isReadOnly(); | 372 | bool isReadOnly(); |
373 | /** set state of calendar to read-only */ | 373 | /** set state of calendar to read-only */ |
374 | void setReadOnly(bool readOnly=true); | 374 | void setReadOnly(bool readOnly=true); |
375 | 375 | ||
376 | void eventUpdated(Incidence *); | 376 | void eventUpdated(Incidence *); |
377 | 377 | ||
378 | /* iTIP scheduling actions */ | 378 | /* iTIP scheduling actions */ |
379 | void schedule_publish(Incidence *incidence = 0); | 379 | void schedule_publish(Incidence *incidence = 0); |
380 | void schedule_request(Incidence *incidence = 0); | 380 | void schedule_request(Incidence *incidence = 0); |
381 | void schedule_refresh(Incidence *incidence = 0); | 381 | void schedule_refresh(Incidence *incidence = 0); |
382 | void schedule_cancel(Incidence *incidence = 0); | 382 | void schedule_cancel(Incidence *incidence = 0); |
383 | void schedule_add(Incidence *incidence = 0); | 383 | void schedule_add(Incidence *incidence = 0); |
384 | void schedule_reply(Incidence *incidence = 0); | 384 | void schedule_reply(Incidence *incidence = 0); |
385 | void schedule_counter(Incidence *incidence = 0); | 385 | void schedule_counter(Incidence *incidence = 0); |
386 | void schedule_declinecounter(Incidence *incidence = 0); | 386 | void schedule_declinecounter(Incidence *incidence = 0); |
387 | void schedule_publish_freebusy(int daysToPublish = 30); | 387 | void schedule_publish_freebusy(int daysToPublish = 30); |
388 | 388 | ||
389 | void openAddressbook(); | 389 | void openAddressbook(); |
390 | 390 | ||
391 | void editFilters(); | 391 | void editFilters(); |
392 | void toggleFilerEnabled(); | 392 | void toggleFilerEnabled(); |
393 | QPtrList<CalFilter> filters(); | 393 | QPtrList<CalFilter> filters(); |
394 | void toggleFilter(); | 394 | void toggleFilter(); |
395 | void showFilter(bool visible); | 395 | void showFilter(bool visible); |
396 | void updateFilter(); | 396 | void updateFilter(); |
397 | void filterEdited(); | 397 | void filterEdited(); |
398 | void selectFilter( int ); | 398 | void selectFilter( int ); |
399 | KOFilterView *filterView(); | 399 | KOFilterView *filterView(); |
400 | 400 | ||
401 | void showIntro(); | 401 | void showIntro(); |
402 | 402 | ||
403 | /** Move the curdatepient view date to today */ | 403 | /** Move the curdatepient view date to today */ |
404 | void goToday(); | 404 | void goToday(); |
405 | 405 | ||
406 | /** Move to the next date(s) in the current view */ | 406 | /** Move to the next date(s) in the current view */ |
407 | void goNext(); | 407 | void goNext(); |
408 | 408 | ||
409 | /** Move to the previous date(s) in the current view */ | 409 | /** Move to the previous date(s) in the current view */ |
410 | void goPrevious(); | 410 | void goPrevious(); |
411 | /** Move to the next date(s) in the current view */ | 411 | /** Move to the next date(s) in the current view */ |
412 | void goNextMonth(); | 412 | void goNextMonth(); |
413 | 413 | ||
414 | /** Move to the previous date(s) in the current view */ | 414 | /** Move to the previous date(s) in the current view */ |
415 | void goPreviousMonth(); | 415 | void goPreviousMonth(); |
416 | 416 | ||
417 | void toggleExpand(); | 417 | void toggleExpand(); |
418 | void toggleDateNavigatorWidget(); | 418 | void toggleDateNavigatorWidget(); |
419 | void toggleAllDaySize(); | 419 | void toggleAllDaySize(); |
420 | void dialogClosing(Incidence *); | 420 | void dialogClosing(Incidence *); |
421 | 421 | ||
422 | /** Look for new messages in the inbox */ | 422 | /** Look for new messages in the inbox */ |
423 | void lookForIncomingMessages(); | 423 | void lookForIncomingMessages(); |
424 | /** Look for new messages in the outbox */ | 424 | /** Look for new messages in the outbox */ |
425 | void lookForOutgoingMessages(); | 425 | void lookForOutgoingMessages(); |
426 | 426 | ||
427 | void processMainViewSelection( Incidence * ); | 427 | void processMainViewSelection( Incidence * ); |
428 | void processTodoListSelection( Incidence * ); | 428 | void processTodoListSelection( Incidence * ); |
429 | 429 | ||
430 | void processIncidenceSelection( Incidence * ); | 430 | void processIncidenceSelection( Incidence * ); |
431 | 431 | ||
432 | void purgeCompleted(); | 432 | void purgeCompleted(); |
433 | bool removeCompletedSubTodos( Todo* ); | 433 | bool removeCompletedSubTodos( Todo* ); |
434 | void slotCalendarChanged(); | 434 | void slotCalendarChanged(); |
435 | bool importBday(); | 435 | bool importBday(); |
436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
437 | bool importQtopia( const QString &categoriesFile, | 437 | bool importQtopia( const QString &categoriesFile, |
438 | const QString &datebookFile, | 438 | const QString &datebookFile, |
439 | const QString &tasklistFile ); | 439 | const QString &tasklistFile ); |
440 | void syncExternal( int mode ); | 440 | void syncExternal( int mode ); |
441 | void slotSelectPickerDate( QDate ) ; | 441 | void slotSelectPickerDate( QDate ) ; |
442 | void showDatePicker( ) ; | 442 | void showDatePicker( ) ; |
443 | void moveIncidence(Incidence *) ; | 443 | void moveIncidence(Incidence *) ; |
444 | void beamIncidence(Incidence *) ; | 444 | void beamIncidence(Incidence *) ; |
445 | void beamCalendar() ; | 445 | void beamCalendar() ; |
446 | void beamFilteredCalendar() ; | 446 | void beamFilteredCalendar() ; |
447 | void beamIncidenceList(QPtrList<Incidence>) ; | 447 | void beamIncidenceList(QPtrList<Incidence>) ; |
448 | void manageCategories(); | 448 | void manageCategories(); |
449 | int addCategories(); | 449 | int addCategories(); |
450 | void removeCategories(); | 450 | void removeCategories(); |
451 | void setSyncDevice( QString ); | 451 | void setSyncDevice( QString ); |
452 | void setSyncName( QString ); | 452 | void setSyncName( QString ); |
453 | void showDay( QDate ); | ||
454 | void undo_delete(); | ||
453 | protected slots: | 455 | protected slots: |
454 | void timerAlarm(); | 456 | void timerAlarm(); |
455 | void suspendAlarm(); | 457 | void suspendAlarm(); |
456 | void beamDone( Ir *ir ); | 458 | void beamDone( Ir *ir ); |
457 | /** Select a view or adapt the current view to display the specified dates. */ | 459 | /** Select a view or adapt the current view to display the specified dates. */ |
458 | void showDates( const KCal::DateList & ); | 460 | void showDates( const KCal::DateList & ); |
459 | void selectWeekNum ( int ); | 461 | void selectWeekNum ( int ); |
460 | 462 | ||
461 | public: | 463 | public: |
462 | // show a standard warning | 464 | // show a standard warning |
463 | // returns KMsgBox::yesNoCancel() | 465 | // returns KMsgBox::yesNoCancel() |
464 | int msgCalModified(); | 466 | int msgCalModified(); |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 467 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | 468 | ||
467 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 469 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
468 | virtual void removeSyncInfo( QString syncProfile); | 470 | virtual void removeSyncInfo( QString syncProfile); |
469 | void setSyncManager(KSyncManager* manager); | 471 | void setSyncManager(KSyncManager* manager); |
470 | void setLoadedFileVersion(QDateTime); | 472 | void setLoadedFileVersion(QDateTime); |
471 | bool checkFileVersion(QString fn); | 473 | bool checkFileVersion(QString fn); |
472 | bool checkFileChanged(QString fn); | 474 | bool checkFileChanged(QString fn); |
473 | Event* getLastSyncEvent(); | 475 | Event* getLastSyncEvent(); |
474 | /** Adapt navigation units correpsonding to step size of navigation of the | 476 | /** Adapt navigation units correpsonding to step size of navigation of the |
475 | * current view. | 477 | * current view. |
476 | */ | 478 | */ |
477 | void adaptNavigationUnits(); | 479 | void adaptNavigationUnits(); |
478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 480 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 481 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
480 | //Attendee* getYourAttendee(Event *event); | 482 | //Attendee* getYourAttendee(Event *event); |
481 | protected: | 483 | protected: |
482 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 484 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
483 | 485 | ||
484 | // returns KMsgBox::OKCandel() | 486 | // returns KMsgBox::OKCandel() |
485 | int msgItemDelete(); | 487 | int msgItemDelete(); |
486 | void showEventEditor(); | 488 | void showEventEditor(); |
487 | void showTodoEditor(); | 489 | void showTodoEditor(); |
488 | void writeLocale(); | 490 | void writeLocale(); |
489 | Todo *selectedTodo(); | 491 | Todo *selectedTodo(); |
490 | 492 | ||
491 | private: | 493 | private: |
492 | KSyncManager* mSyncManager; | 494 | KSyncManager* mSyncManager; |
493 | AlarmDialog * mAlarmDialog; | 495 | AlarmDialog * mAlarmDialog; |
494 | QString mAlarmNotification; | 496 | QString mAlarmNotification; |
495 | QString mSuspendAlarmNotification; | 497 | QString mSuspendAlarmNotification; |
496 | QTimer* mSuspendTimer; | 498 | QTimer* mSuspendTimer; |
497 | QTimer* mAlarmTimer; | 499 | QTimer* mAlarmTimer; |
498 | QTimer* mRecheckAlarmTimer; | 500 | QTimer* mRecheckAlarmTimer; |
499 | void computeAlarm( QString ); | 501 | void computeAlarm( QString ); |
500 | void startAlarm( QString, QString ); | 502 | void startAlarm( QString, QString ); |
501 | void setSyncEventsReadOnly(); | 503 | void setSyncEventsReadOnly(); |
502 | 504 | ||
503 | QDateTime loadedFileVersion; | 505 | QDateTime loadedFileVersion; |
504 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 506 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
505 | void checkExternalId( Incidence * inc ); | 507 | void checkExternalId( Incidence * inc ); |
506 | int mGlobalSyncMode; | 508 | int mGlobalSyncMode; |
507 | QString mCurrentSyncDevice; | 509 | QString mCurrentSyncDevice; |
508 | QString mCurrentSyncName; | 510 | QString mCurrentSyncName; |
509 | KOBeamPrefs* beamDialog; | 511 | KOBeamPrefs* beamDialog; |
510 | void init(); | 512 | void init(); |
511 | int mDatePickerMode; | 513 | int mDatePickerMode; |
512 | bool mFlagEditDescription; | 514 | bool mFlagEditDescription; |
513 | QDateTime mLastCalendarSync; | 515 | QDateTime mLastCalendarSync; |
514 | void createPrinter(); | 516 | void createPrinter(); |
515 | 517 | ||
516 | void calendarModified( bool, Calendar * ); | 518 | void calendarModified( bool, Calendar * ); |
517 | 519 | ||
518 | CalPrinter *mCalPrinter; | 520 | CalPrinter *mCalPrinter; |
519 | 521 | ||
520 | QSplitter *mPanner; | 522 | QSplitter *mPanner; |
521 | QSplitter *mLeftSplitter; | 523 | QSplitter *mLeftSplitter; |
522 | QWidget *mLeftFrame; | 524 | QWidget *mLeftFrame; |
523 | QWidgetStack *mRightFrame; | 525 | QWidgetStack *mRightFrame; |
524 | 526 | ||
525 | KDatePicker* mDatePicker; | 527 | KDatePicker* mDatePicker; |
526 | QVBox* mDateFrame; | 528 | QVBox* mDateFrame; |
527 | NavigatorBar *mNavigatorBar; | 529 | NavigatorBar *mNavigatorBar; |
528 | 530 | ||
529 | KDateNavigator *mDateNavigator; // widget showing small month view. | 531 | KDateNavigator *mDateNavigator; // widget showing small month view. |
530 | 532 | ||
531 | KOFilterView *mFilterView; | 533 | KOFilterView *mFilterView; |
532 | 534 | ||
533 | ResourceView *mResourceView; | 535 | ResourceView *mResourceView; |
534 | 536 | ||
535 | // calendar object for this viewing instance | 537 | // calendar object for this viewing instance |
536 | Calendar *mCalendar; | 538 | Calendar *mCalendar; |
537 | 539 | ||
538 | CalendarResourceManager *mResourceManager; | 540 | CalendarResourceManager *mResourceManager; |
539 | 541 | ||
540 | FileStorage *mStorage; | 542 | FileStorage *mStorage; |
541 | 543 | ||
542 | DateNavigator *mNavigator; | 544 | DateNavigator *mNavigator; |
543 | 545 | ||
544 | KOViewManager *mViewManager; | 546 | KOViewManager *mViewManager; |
545 | KODialogManager *mDialogManager; | 547 | KODialogManager *mDialogManager; |
546 | 548 | ||
547 | // Calendar filters | 549 | // Calendar filters |
548 | QPtrList<CalFilter> mFilters; | 550 | QPtrList<CalFilter> mFilters; |
549 | 551 | ||
550 | // various housekeeping variables. | 552 | // various housekeeping variables. |
551 | bool mModified; // flag indicating if calendar is modified | 553 | bool mModified; // flag indicating if calendar is modified |
552 | bool mReadOnly; // flag indicating if calendar is read-only | 554 | bool mReadOnly; // flag indicating if calendar is read-only |
553 | QDate mSaveSingleDate; | 555 | QDate mSaveSingleDate; |
554 | 556 | ||
555 | Incidence *mSelectedIncidence; | 557 | Incidence *mSelectedIncidence; |
556 | Incidence *mMoveIncidence; | 558 | Incidence *mMoveIncidence; |
559 | QDate mMoveIncidenceOldDate; | ||
557 | KOTodoView *mTodoList; | 560 | KOTodoView *mTodoList; |
558 | KOEventEditor * mEventEditor; | 561 | KOEventEditor * mEventEditor; |
559 | KOTodoEditor * mTodoEditor; | 562 | KOTodoEditor * mTodoEditor; |
560 | KOEventViewerDialog * mEventViewerDialog; | 563 | KOEventViewerDialog * mEventViewerDialog; |
561 | void keyPressEvent ( QKeyEvent *e) ; | 564 | void keyPressEvent ( QKeyEvent *e) ; |
562 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 565 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
563 | }; | 566 | }; |
564 | 567 | ||
565 | 568 | ||
566 | class CalendarViewVisitor : public Incidence::Visitor | 569 | class CalendarViewVisitor : public Incidence::Visitor |
567 | { | 570 | { |
568 | public: | 571 | public: |
569 | CalendarViewVisitor() : mView( 0 ) {} | 572 | CalendarViewVisitor() : mView( 0 ) {} |
570 | 573 | ||
571 | bool act( Incidence *incidence, CalendarView *view ) | 574 | bool act( Incidence *incidence, CalendarView *view ) |
572 | { | 575 | { |
573 | mView = view; | 576 | mView = view; |
574 | return incidence->accept( *this ); | 577 | return incidence->accept( *this ); |
575 | } | 578 | } |
576 | 579 | ||
577 | protected: | 580 | protected: |
578 | CalendarView *mView; | 581 | CalendarView *mView; |
579 | }; | 582 | }; |
580 | 583 | ||
581 | class ShowIncidenceVisitor : public CalendarViewVisitor | 584 | class ShowIncidenceVisitor : public CalendarViewVisitor |
582 | { | 585 | { |
583 | protected: | 586 | protected: |
584 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 587 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
585 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 588 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
586 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 589 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
587 | }; | 590 | }; |
588 | 591 | ||
589 | class EditIncidenceVisitor : public CalendarViewVisitor | 592 | class EditIncidenceVisitor : public CalendarViewVisitor |
590 | { | 593 | { |
591 | protected: | 594 | protected: |
592 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 595 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
593 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 596 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
594 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 597 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
595 | }; | 598 | }; |
596 | 599 | ||
597 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 600 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
598 | { | 601 | { |
599 | protected: | 602 | protected: |
600 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 603 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
601 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 604 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
602 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 605 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
603 | }; | 606 | }; |
604 | 607 | ||
605 | #endif | 608 | #endif |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index f027343..46184ac 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,720 +1,722 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
60 | const char *name,WFlags) : | 60 | const char *name,WFlags) : |
61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
62 | { | 62 | { |
63 | #ifndef DESKTOP_VERSION | 63 | #ifndef DESKTOP_VERSION |
64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
65 | #endif | 65 | #endif |
66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
67 | setWFlags ( wflags); | 67 | setWFlags ( wflags); |
68 | mAllDay = allday; | 68 | mAllDay = allday; |
69 | init ( incidence, qd ); | 69 | init ( incidence, qd ); |
70 | setMouseTracking(true); | 70 | setMouseTracking(true); |
71 | //setAcceptDrops(true); | 71 | //setAcceptDrops(true); |
72 | xPaintCoord = -1; | 72 | xPaintCoord = -1; |
73 | yPaintCoord = -1; | 73 | yPaintCoord = -1; |
74 | } | 74 | } |
75 | 75 | ||
76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
77 | { | 77 | { |
78 | mIncidence = incidence; | 78 | mIncidence = incidence; |
79 | mDate = qd; | 79 | mDate = qd; |
80 | mFirstMultiItem = 0; | 80 | mFirstMultiItem = 0; |
81 | mNextMultiItem = 0; | 81 | mNextMultiItem = 0; |
82 | mLastMultiItem = 0; | 82 | mLastMultiItem = 0; |
83 | computeText(); | 83 | computeText(); |
84 | 84 | ||
85 | if ( (incidence->type() == "Todo") && | 85 | if ( (incidence->type() == "Todo") && |
86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
90 | else | 90 | else |
91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
92 | } | 92 | } |
93 | else { | 93 | else { |
94 | QStringList categories = mIncidence->categories(); | 94 | QStringList categories = mIncidence->categories(); |
95 | QString cat = categories.first(); | 95 | QString cat = categories.first(); |
96 | if (cat.isEmpty()) { | 96 | if (cat.isEmpty()) { |
97 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 97 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
98 | } else { | 98 | } else { |
99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 102 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
103 | mBackgroundColor.dark(),mBackgroundColor.light(), | 103 | mBackgroundColor.dark(),mBackgroundColor.light(), |
104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
105 | setBackgroundColor( mBackgroundColor ); | 105 | setBackgroundColor( mBackgroundColor ); |
106 | 106 | ||
107 | setCellXY(0,0,1); | 107 | setCellXY(0,0,1); |
108 | setCellXWidth(0); | 108 | setCellXWidth(0); |
109 | setSubCell(0); | 109 | setSubCell(0); |
110 | setSubCells(1); | 110 | setSubCells(1); |
111 | setMultiItem(0,0,0); | 111 | setMultiItem(0,0,0); |
112 | startMove(); | 112 | startMove(); |
113 | mSelected = true; | 113 | mSelected = true; |
114 | select(false); | 114 | select(false); |
115 | QString tipText = mIncidence->summary(); | 115 | QString tipText = mIncidence->summary(); |
116 | // QToolTip::add(this,tipText); | 116 | // QToolTip::add(this,tipText); |
117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
118 | if ( !mIncidence->doesFloat() ) | 118 | if ( !mIncidence->doesFloat() ) |
119 | if ( mIncidence->type() == "Event" ) { | 119 | if ( mIncidence->type() == "Event" ) { |
120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
123 | } | 123 | } |
124 | else { | 124 | else { |
125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | else if ( mIncidence->type() == "Todo" ) { | 129 | else if ( mIncidence->type() == "Todo" ) { |
130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); | 130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); |
131 | } | 131 | } |
132 | 132 | ||
133 | if (!mIncidence->location().isEmpty()) { | 133 | if (!mIncidence->location().isEmpty()) { |
134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
135 | } | 135 | } |
136 | QToolTip::add(this,tipText,toolTipGroup(),""); | 136 | QToolTip::add(this,tipText,toolTipGroup(),""); |
137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
138 | mFontPixelSize = fontinf.height();; | 138 | mFontPixelSize = fontinf.height();; |
139 | hide(); | 139 | hide(); |
140 | xPaintCoord = -1; | 140 | xPaintCoord = -1; |
141 | yPaintCoord = -1; | 141 | yPaintCoord = -1; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | KOAgendaItem::~KOAgendaItem() | 145 | KOAgendaItem::~KOAgendaItem() |
146 | { | 146 | { |
147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | void KOAgendaItem::recreateIncidence() | 151 | void KOAgendaItem::recreateIncidence() |
152 | { | 152 | { |
153 | #if 0 | ||
153 | Incidence* newInc = mIncidence->clone(); | 154 | Incidence* newInc = mIncidence->clone(); |
154 | newInc->recreate(); | 155 | newInc->recreate(); |
155 | if ( mIncidence->doesRecur() ) { | 156 | if ( mIncidence->doesRecur() ) { |
156 | mIncidence->addExDate( mDate ); | 157 | mIncidence->addExDate( mDate ); |
157 | newInc->recurrence()->unsetRecurs(); | 158 | newInc->recurrence()->unsetRecurs(); |
158 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 159 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
159 | QTime tim = mIncidence->dtStart().time(); | 160 | QTime tim = mIncidence->dtStart().time(); |
160 | newInc->setDtStart( QDateTime(mDate, tim) ); | 161 | newInc->setDtStart( QDateTime(mDate, tim) ); |
161 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 162 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
162 | } | 163 | } |
163 | mIncidence = newInc; | 164 | #endif |
165 | mIncidence = mIncidence->recreateCloneException( mDate ); | ||
164 | } | 166 | } |
165 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 167 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
166 | { | 168 | { |
167 | int size = AGENDA_ICON_SIZE; | 169 | int size = AGENDA_ICON_SIZE; |
168 | 170 | ||
169 | int yOff = 0; | 171 | int yOff = 0; |
170 | int xOff = 0; | 172 | int xOff = 0; |
171 | int x = pos().x() +3; | 173 | int x = pos().x() +3; |
172 | int y; | 174 | int y; |
173 | if ( mAllDay ) | 175 | if ( mAllDay ) |
174 | y = pos().y()+3; | 176 | y = pos().y()+3; |
175 | else | 177 | else |
176 | y = mCellYTop * ( height() / cellHeight() ) +3; | 178 | y = mCellYTop * ( height() / cellHeight() ) +3; |
177 | if (mIncidence->cancelled()) { | 179 | if (mIncidence->cancelled()) { |
178 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 180 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
179 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 181 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
180 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 182 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
181 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 183 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
182 | if ( horLayout ) | 184 | if ( horLayout ) |
183 | ++xOff; | 185 | ++xOff; |
184 | else | 186 | else |
185 | ++yOff; | 187 | ++yOff; |
186 | } | 188 | } |
187 | if (mIncidence->isAlarmEnabled()) { | 189 | if (mIncidence->isAlarmEnabled()) { |
188 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 190 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
189 | if ( horLayout ) | 191 | if ( horLayout ) |
190 | ++xOff; | 192 | ++xOff; |
191 | else | 193 | else |
192 | ++yOff; | 194 | ++yOff; |
193 | } | 195 | } |
194 | if (mIncidence->recurrence()->doesRecur()) { | 196 | if (mIncidence->recurrence()->doesRecur()) { |
195 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 197 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
196 | if ( horLayout ) | 198 | if ( horLayout ) |
197 | ++xOff; | 199 | ++xOff; |
198 | else | 200 | else |
199 | ++yOff; | 201 | ++yOff; |
200 | } | 202 | } |
201 | if (mIncidence->description().length() > 0) { | 203 | if (mIncidence->description().length() > 0) { |
202 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 204 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
203 | if ( horLayout ) | 205 | if ( horLayout ) |
204 | ++xOff; | 206 | ++xOff; |
205 | else | 207 | else |
206 | ++yOff; | 208 | ++yOff; |
207 | } | 209 | } |
208 | if (mIncidence->isReadOnly()) { | 210 | if (mIncidence->isReadOnly()) { |
209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 211 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
210 | if ( horLayout ) | 212 | if ( horLayout ) |
211 | ++xOff; | 213 | ++xOff; |
212 | else | 214 | else |
213 | ++yOff; | 215 | ++yOff; |
214 | } | 216 | } |
215 | 217 | ||
216 | if (mIncidence->attendeeCount()>0) { | 218 | if (mIncidence->attendeeCount()>0) { |
217 | 219 | ||
218 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 220 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
219 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
220 | if ( horLayout ) | 222 | if ( horLayout ) |
221 | ++xOff; | 223 | ++xOff; |
222 | else | 224 | else |
223 | ++yOff; | 225 | ++yOff; |
224 | } else { | 226 | } else { |
225 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 227 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
226 | if (me!=0) { | 228 | if (me!=0) { |
227 | 229 | ||
228 | 230 | ||
229 | } else { | 231 | } else { |
230 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 232 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
231 | if ( horLayout ) | 233 | if ( horLayout ) |
232 | ++xOff; | 234 | ++xOff; |
233 | else | 235 | else |
234 | ++yOff; | 236 | ++yOff; |
235 | 237 | ||
236 | } | 238 | } |
237 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 239 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
238 | if ( horLayout ) | 240 | if ( horLayout ) |
239 | ++xOff; | 241 | ++xOff; |
240 | else | 242 | else |
241 | ++yOff; | 243 | ++yOff; |
242 | 244 | ||
243 | } | 245 | } |
244 | 246 | ||
245 | } | 247 | } |
246 | return ( yOff || xOff ); | 248 | return ( yOff || xOff ); |
247 | } | 249 | } |
248 | 250 | ||
249 | 251 | ||
250 | void KOAgendaItem::select(bool selected) | 252 | void KOAgendaItem::select(bool selected) |
251 | { | 253 | { |
252 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 254 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
253 | if (mSelected == selected) return; | 255 | if (mSelected == selected) return; |
254 | mSelected = selected; | 256 | mSelected = selected; |
255 | if ( ! isVisible() ) | 257 | if ( ! isVisible() ) |
256 | return; | 258 | return; |
257 | if ( firstMultiItem() ) | 259 | if ( firstMultiItem() ) |
258 | firstMultiItem()->select( selected ); | 260 | firstMultiItem()->select( selected ); |
259 | if ( !firstMultiItem() && nextMultiItem() ) { | 261 | if ( !firstMultiItem() && nextMultiItem() ) { |
260 | KOAgendaItem * placeItem = nextMultiItem(); | 262 | KOAgendaItem * placeItem = nextMultiItem(); |
261 | while ( placeItem ) { | 263 | while ( placeItem ) { |
262 | placeItem->select( selected ); | 264 | placeItem->select( selected ); |
263 | placeItem = placeItem->nextMultiItem(); | 265 | placeItem = placeItem->nextMultiItem(); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | globalFlagBlockAgendaItemUpdate = 0; | 268 | globalFlagBlockAgendaItemUpdate = 0; |
267 | paintMe( selected ); | 269 | paintMe( selected ); |
268 | globalFlagBlockAgendaItemUpdate = 1; | 270 | globalFlagBlockAgendaItemUpdate = 1; |
269 | repaint( false ); | 271 | repaint( false ); |
270 | } | 272 | } |
271 | 273 | ||
272 | 274 | ||
273 | /* | 275 | /* |
274 | The eventFilter has to filter the mouse events of the agenda item childs. The | 276 | The eventFilter has to filter the mouse events of the agenda item childs. The |
275 | events are fed into the event handling method of KOAgendaItem. This allows the | 277 | events are fed into the event handling method of KOAgendaItem. This allows the |
276 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 278 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
277 | */ | 279 | */ |
278 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 280 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
279 | { | 281 | { |
280 | if (e->type() == QEvent::MouseButtonPress || | 282 | if (e->type() == QEvent::MouseButtonPress || |
281 | e->type() == QEvent::MouseButtonDblClick || | 283 | e->type() == QEvent::MouseButtonDblClick || |
282 | e->type() == QEvent::MouseButtonRelease || | 284 | e->type() == QEvent::MouseButtonRelease || |
283 | e->type() == QEvent::MouseMove) { | 285 | e->type() == QEvent::MouseMove) { |
284 | QMouseEvent *me = (QMouseEvent *)e; | 286 | QMouseEvent *me = (QMouseEvent *)e; |
285 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 287 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
286 | mapToGlobal(me->pos())); | 288 | mapToGlobal(me->pos())); |
287 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 289 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
288 | return event(&returnEvent); | 290 | return event(&returnEvent); |
289 | } else { | 291 | } else { |
290 | return false; | 292 | return false; |
291 | } | 293 | } |
292 | } | 294 | } |
293 | void KOAgendaItem::repaintMe( ) | 295 | void KOAgendaItem::repaintMe( ) |
294 | { | 296 | { |
295 | paintMe ( mSelected ); | 297 | paintMe ( mSelected ); |
296 | } | 298 | } |
297 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 299 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
298 | { | 300 | { |
299 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 301 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
300 | return; | 302 | return; |
301 | QPainter pa; | 303 | QPainter pa; |
302 | 304 | ||
303 | if ( mSelected ) { | 305 | if ( mSelected ) { |
304 | pa.begin( paintPixSel() ); | 306 | pa.begin( paintPixSel() ); |
305 | } else { | 307 | } else { |
306 | if ( mAllDay ) | 308 | if ( mAllDay ) |
307 | pa.begin( paintPixAllday() ); | 309 | pa.begin( paintPixAllday() ); |
308 | else | 310 | else |
309 | pa.begin( paintPix() ); | 311 | pa.begin( paintPix() ); |
310 | } | 312 | } |
311 | int x, yy, w, h; | 313 | int x, yy, w, h; |
312 | float nfh; | 314 | float nfh; |
313 | x = pos().x(); w = width(); h = height (); | 315 | x = pos().x(); w = width(); h = height (); |
314 | if ( mAllDay ) | 316 | if ( mAllDay ) |
315 | yy = y(); | 317 | yy = y(); |
316 | else | 318 | else |
317 | yy = mCellYTop * ( height() / cellHeight() ); | 319 | yy = mCellYTop * ( height() / cellHeight() ); |
318 | xPaintCoord= x; | 320 | xPaintCoord= x; |
319 | yPaintCoord = yy; | 321 | yPaintCoord = yy; |
320 | wPaintCoord = width(); | 322 | wPaintCoord = width(); |
321 | hPaintCoord = height(); | 323 | hPaintCoord = height(); |
322 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 324 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
323 | if ( paint == 0 ) | 325 | if ( paint == 0 ) |
324 | paint = &pa; | 326 | paint = &pa; |
325 | bool horLayout = ( w < h ); | 327 | bool horLayout = ( w < h ); |
326 | int maxhei = mFontPixelSize+4; | 328 | int maxhei = mFontPixelSize+4; |
327 | if ( horLayout ) | 329 | if ( horLayout ) |
328 | maxhei += AGENDA_ICON_SIZE -4; | 330 | maxhei += AGENDA_ICON_SIZE -4; |
329 | bool small = ( h < maxhei ); | 331 | bool small = ( h < maxhei ); |
330 | if ( ! small ) | 332 | if ( ! small ) |
331 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 333 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
332 | else { | 334 | else { |
333 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 335 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
334 | f.setBold( false ); | 336 | f.setBold( false ); |
335 | int fh = f.pointSize(); | 337 | int fh = f.pointSize(); |
336 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 338 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
337 | if ( nfh < 6 ) | 339 | if ( nfh < 6 ) |
338 | nfh = 6; | 340 | nfh = 6; |
339 | f.setPointSize( nfh ); | 341 | f.setPointSize( nfh ); |
340 | paint->setFont(f); | 342 | paint->setFont(f); |
341 | } | 343 | } |
342 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 344 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
343 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 345 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
344 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 346 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
345 | if ( mIncidence->type() == "Todo" ) { | 347 | if ( mIncidence->type() == "Todo" ) { |
346 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 348 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
347 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 349 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
348 | int yyy = yy+3; | 350 | int yyy = yy+3; |
349 | if ( tempTodo->isCompleted() ) | 351 | if ( tempTodo->isCompleted() ) |
350 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 352 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
351 | else { | 353 | else { |
352 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 354 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
353 | 355 | ||
354 | } | 356 | } |
355 | } | 357 | } |
356 | bool addIcon = false; | 358 | bool addIcon = false; |
357 | if ( ! small || w > 3 * h || h > 3* w ) | 359 | if ( ! small || w > 3 * h || h > 3* w ) |
358 | addIcon = updateIcons( paint, horLayout ); | 360 | addIcon = updateIcons( paint, horLayout ); |
359 | 361 | ||
360 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 362 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
361 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 363 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
362 | if ( ! small ) { | 364 | if ( ! small ) { |
363 | x += 3; yy += 3;w -= 6; h-= 5; | 365 | x += 3; yy += 3;w -= 6; h-= 5; |
364 | } else { | 366 | } else { |
365 | x += 2; yy += 1;w -= 4; h-= 4; | 367 | x += 2; yy += 1;w -= 4; h-= 4; |
366 | if ( nfh < 6.01 ) { | 368 | if ( nfh < 6.01 ) { |
367 | yy -= 2; | 369 | yy -= 2; |
368 | h += 4; | 370 | h += 4; |
369 | } | 371 | } |
370 | else | 372 | else |
371 | if ( nfh < h -2 ) | 373 | if ( nfh < h -2 ) |
372 | ++yy; | 374 | ++yy; |
373 | } | 375 | } |
374 | int align; | 376 | int align; |
375 | #ifndef DESKTOP_VERSION | 377 | #ifndef DESKTOP_VERSION |
376 | align = ( AlignLeft|WordBreak|AlignTop); | 378 | align = ( AlignLeft|WordBreak|AlignTop); |
377 | #else | 379 | #else |
378 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 380 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
379 | #endif | 381 | #endif |
380 | if ( addIcon ) { | 382 | if ( addIcon ) { |
381 | if ( ! horLayout ) { | 383 | if ( ! horLayout ) { |
382 | x += AGENDA_ICON_SIZE+3; | 384 | x += AGENDA_ICON_SIZE+3; |
383 | w -= (AGENDA_ICON_SIZE+3); | 385 | w -= (AGENDA_ICON_SIZE+3); |
384 | } | 386 | } |
385 | else { | 387 | else { |
386 | yy+= AGENDA_ICON_SIZE+2; | 388 | yy+= AGENDA_ICON_SIZE+2; |
387 | h -=(AGENDA_ICON_SIZE+3); | 389 | h -=(AGENDA_ICON_SIZE+3); |
388 | } | 390 | } |
389 | } | 391 | } |
390 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 392 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
391 | if ( colsum < 250 ) | 393 | if ( colsum < 250 ) |
392 | paint->setPen ( white); | 394 | paint->setPen ( white); |
393 | if ( x < 0 ) { | 395 | if ( x < 0 ) { |
394 | w = w+x-3; | 396 | w = w+x-3; |
395 | x = 3; | 397 | x = 3; |
396 | if ( w > parentWidget()->width() ){ | 398 | if ( w > parentWidget()->width() ){ |
397 | w = parentWidget()->width() - 6; | 399 | w = parentWidget()->width() - 6; |
398 | #ifndef DESKTOP_VERSION | 400 | #ifndef DESKTOP_VERSION |
399 | align = ( AlignCenter|WordBreak); | 401 | align = ( AlignCenter|WordBreak); |
400 | #else | 402 | #else |
401 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 403 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
402 | #endif | 404 | #endif |
403 | 405 | ||
404 | } | 406 | } |
405 | } | 407 | } |
406 | QRect dr; | 408 | QRect dr; |
407 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 409 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
408 | if ( mIncidence->cancelled() ){ | 410 | if ( mIncidence->cancelled() ){ |
409 | if ( ! small ) { | 411 | if ( ! small ) { |
410 | QFontMetrics fm ( paint->font() ); | 412 | QFontMetrics fm ( paint->font() ); |
411 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 413 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
412 | } | 414 | } |
413 | 415 | ||
414 | } | 416 | } |
415 | pa.end(); | 417 | pa.end(); |
416 | 418 | ||
417 | } | 419 | } |
418 | void KOAgendaItem::resizePixmap( int w , int h ) | 420 | void KOAgendaItem::resizePixmap( int w , int h ) |
419 | { | 421 | { |
420 | paintPix()->resize( w, h ); | 422 | paintPix()->resize( w, h ); |
421 | paintPixSel()->resize( w, h ); | 423 | paintPixSel()->resize( w, h ); |
422 | 424 | ||
423 | } | 425 | } |
424 | QPixmap * KOAgendaItem::paintPix() | 426 | QPixmap * KOAgendaItem::paintPix() |
425 | { | 427 | { |
426 | static QPixmap* mPaintPix = 0; | 428 | static QPixmap* mPaintPix = 0; |
427 | if ( ! mPaintPix ) | 429 | if ( ! mPaintPix ) |
428 | mPaintPix = new QPixmap(); | 430 | mPaintPix = new QPixmap(); |
429 | return mPaintPix ; | 431 | return mPaintPix ; |
430 | } | 432 | } |
431 | QPixmap * KOAgendaItem::paintPixAllday() | 433 | QPixmap * KOAgendaItem::paintPixAllday() |
432 | { | 434 | { |
433 | static QPixmap* mPaintPixA = 0; | 435 | static QPixmap* mPaintPixA = 0; |
434 | if ( ! mPaintPixA ) | 436 | if ( ! mPaintPixA ) |
435 | mPaintPixA = new QPixmap(); | 437 | mPaintPixA = new QPixmap(); |
436 | return mPaintPixA ; | 438 | return mPaintPixA ; |
437 | } | 439 | } |
438 | QPixmap * KOAgendaItem::paintPixSel() | 440 | QPixmap * KOAgendaItem::paintPixSel() |
439 | { | 441 | { |
440 | static QPixmap* mPaintPixSel = 0; | 442 | static QPixmap* mPaintPixSel = 0; |
441 | if ( ! mPaintPixSel ) | 443 | if ( ! mPaintPixSel ) |
442 | mPaintPixSel = new QPixmap(); | 444 | mPaintPixSel = new QPixmap(); |
443 | return mPaintPixSel ; | 445 | return mPaintPixSel ; |
444 | } | 446 | } |
445 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 447 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
446 | { | 448 | { |
447 | 449 | ||
448 | if ( globalFlagBlockAgendaItemPaint ) | 450 | if ( globalFlagBlockAgendaItemPaint ) |
449 | return; | 451 | return; |
450 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 452 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
451 | return; | 453 | return; |
452 | int yy; | 454 | int yy; |
453 | if ( mAllDay ) | 455 | if ( mAllDay ) |
454 | yy = y(); | 456 | yy = y(); |
455 | else | 457 | else |
456 | yy = mCellYTop * ( height() / cellHeight() ); | 458 | yy = mCellYTop * ( height() / cellHeight() ); |
457 | int xx = x(); | 459 | int xx = x(); |
458 | if ( xPaintCoord != xx || yPaintCoord != yy || | 460 | if ( xPaintCoord != xx || yPaintCoord != yy || |
459 | wPaintCoord != width() || hPaintCoord != height()) { | 461 | wPaintCoord != width() || hPaintCoord != height()) { |
460 | xPaintCoord= xx; | 462 | xPaintCoord= xx; |
461 | yPaintCoord = yy; | 463 | yPaintCoord = yy; |
462 | wPaintCoord = width(); | 464 | wPaintCoord = width(); |
463 | hPaintCoord = height(); | 465 | hPaintCoord = height(); |
464 | globalFlagBlockAgendaItemUpdate = 0; | 466 | globalFlagBlockAgendaItemUpdate = 0; |
465 | paintMe( mSelected ); | 467 | paintMe( mSelected ); |
466 | //qDebug("calling paintMe "); | 468 | //qDebug("calling paintMe "); |
467 | globalFlagBlockAgendaItemUpdate = 1; | 469 | globalFlagBlockAgendaItemUpdate = 1; |
468 | } | 470 | } |
469 | int rx, ry, rw, rh; | 471 | int rx, ry, rw, rh; |
470 | rx = e->rect().x(); | 472 | rx = e->rect().x(); |
471 | ry = e->rect().y(); | 473 | ry = e->rect().y(); |
472 | rw = e->rect().width(); | 474 | rw = e->rect().width(); |
473 | rh = e->rect().height(); | 475 | rh = e->rect().height(); |
474 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 476 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
475 | 477 | ||
476 | QPixmap* paintFrom ; | 478 | QPixmap* paintFrom ; |
477 | if ( mSelected ) { | 479 | if ( mSelected ) { |
478 | paintFrom = paintPixSel(); | 480 | paintFrom = paintPixSel(); |
479 | } else { | 481 | } else { |
480 | if ( mAllDay ) | 482 | if ( mAllDay ) |
481 | paintFrom = paintPixAllday(); | 483 | paintFrom = paintPixAllday(); |
482 | else | 484 | else |
483 | paintFrom = paintPix(); | 485 | paintFrom = paintPix(); |
484 | } | 486 | } |
485 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 487 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
486 | } | 488 | } |
487 | void KOAgendaItem::computeText() | 489 | void KOAgendaItem::computeText() |
488 | { | 490 | { |
489 | mDisplayedText = mIncidence->summary(); | 491 | mDisplayedText = mIncidence->summary(); |
490 | if ( (mIncidence->type() == "Todo") ) { | 492 | if ( (mIncidence->type() == "Todo") ) { |
491 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 493 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
492 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
493 | else if ( !(mIncidence->doesFloat())) | 495 | else if ( !(mIncidence->doesFloat())) |
494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 496 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
495 | 497 | ||
496 | 498 | ||
497 | 499 | ||
498 | } else { | 500 | } else { |
499 | if ( !(mIncidence->doesFloat())) | 501 | if ( !(mIncidence->doesFloat())) |
500 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 502 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
501 | 503 | ||
502 | if ( mAllDay ) { | 504 | if ( mAllDay ) { |
503 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 505 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
504 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 506 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
505 | } | 507 | } |
506 | } | 508 | } |
507 | 509 | ||
508 | } | 510 | } |
509 | 511 | ||
510 | if ( !mIncidence->location().isEmpty() ) { | 512 | if ( !mIncidence->location().isEmpty() ) { |
511 | if ( mAllDay ) | 513 | if ( mAllDay ) |
512 | mDisplayedText += " ("; | 514 | mDisplayedText += " ("; |
513 | else | 515 | else |
514 | mDisplayedText += "\n("; | 516 | mDisplayedText += "\n("; |
515 | mDisplayedText += mIncidence->location() +")"; | 517 | mDisplayedText += mIncidence->location() +")"; |
516 | } | 518 | } |
517 | } | 519 | } |
518 | void KOAgendaItem::updateItem() | 520 | void KOAgendaItem::updateItem() |
519 | { | 521 | { |
520 | computeText(); | 522 | computeText(); |
521 | 523 | ||
522 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 524 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
523 | paintMe( mSelected ); | 525 | paintMe( mSelected ); |
524 | repaint( false); | 526 | repaint( false); |
525 | } | 527 | } |
526 | 528 | ||
527 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 529 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
528 | { | 530 | { |
529 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 531 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
530 | paintMe( mSelected ); | 532 | paintMe( mSelected ); |
531 | repaint( false ); | 533 | repaint( false ); |
532 | } | 534 | } |
533 | 535 | ||
534 | /* | 536 | /* |
535 | Return height of item in units of agenda cells | 537 | Return height of item in units of agenda cells |
536 | */ | 538 | */ |
537 | int KOAgendaItem::cellHeight() | 539 | int KOAgendaItem::cellHeight() |
538 | { | 540 | { |
539 | int ret = mCellYBottom - mCellYTop + 1; | 541 | int ret = mCellYBottom - mCellYTop + 1; |
540 | if ( ret <= 0 ) { | 542 | if ( ret <= 0 ) { |
541 | ret = 1; | 543 | ret = 1; |
542 | mCellYBottom = 0; | 544 | mCellYBottom = 0; |
543 | mCellYTop = 0; | 545 | mCellYTop = 0; |
544 | } | 546 | } |
545 | return ret; | 547 | return ret; |
546 | } | 548 | } |
547 | 549 | ||
548 | /* | 550 | /* |
549 | Return height of item in units of agenda cells | 551 | Return height of item in units of agenda cells |
550 | */ | 552 | */ |
551 | int KOAgendaItem::cellWidth() | 553 | int KOAgendaItem::cellWidth() |
552 | { | 554 | { |
553 | return mCellXWidth - mCellX + 1; | 555 | return mCellXWidth - mCellX + 1; |
554 | } | 556 | } |
555 | 557 | ||
556 | void KOAgendaItem::setItemDate(QDate qd) | 558 | void KOAgendaItem::setItemDate(QDate qd) |
557 | { | 559 | { |
558 | mDate = qd; | 560 | mDate = qd; |
559 | } | 561 | } |
560 | 562 | ||
561 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 563 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
562 | { | 564 | { |
563 | mCellX = X; | 565 | mCellX = X; |
564 | mCellYTop = YTop; | 566 | mCellYTop = YTop; |
565 | mCellYBottom = YBottom; | 567 | mCellYBottom = YBottom; |
566 | } | 568 | } |
567 | 569 | ||
568 | void KOAgendaItem::setCellXWidth(int xwidth) | 570 | void KOAgendaItem::setCellXWidth(int xwidth) |
569 | { | 571 | { |
570 | mCellXWidth = xwidth; | 572 | mCellXWidth = xwidth; |
571 | } | 573 | } |
572 | 574 | ||
573 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 575 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
574 | { | 576 | { |
575 | mCellX = XLeft; | 577 | mCellX = XLeft; |
576 | mCellXWidth = XRight; | 578 | mCellXWidth = XRight; |
577 | } | 579 | } |
578 | 580 | ||
579 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 581 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
580 | { | 582 | { |
581 | mCellYTop = YTop; | 583 | mCellYTop = YTop; |
582 | mCellYBottom = YBottom; | 584 | mCellYBottom = YBottom; |
583 | } | 585 | } |
584 | 586 | ||
585 | void KOAgendaItem::setSubCell(int subCell) | 587 | void KOAgendaItem::setSubCell(int subCell) |
586 | { | 588 | { |
587 | mSubCell = subCell; | 589 | mSubCell = subCell; |
588 | } | 590 | } |
589 | 591 | ||
590 | void KOAgendaItem::setSubCells(int subCells) | 592 | void KOAgendaItem::setSubCells(int subCells) |
591 | { | 593 | { |
592 | mSubCells = subCells; | 594 | mSubCells = subCells; |
593 | } | 595 | } |
594 | 596 | ||
595 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 597 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
596 | KOAgendaItem *last) | 598 | KOAgendaItem *last) |
597 | { | 599 | { |
598 | mFirstMultiItem = first; | 600 | mFirstMultiItem = first; |
599 | mNextMultiItem = next; | 601 | mNextMultiItem = next; |
600 | mLastMultiItem = last; | 602 | mLastMultiItem = last; |
601 | } | 603 | } |
602 | 604 | ||
603 | void KOAgendaItem::startMove() | 605 | void KOAgendaItem::startMove() |
604 | { | 606 | { |
605 | mStartCellX = mCellX; | 607 | mStartCellX = mCellX; |
606 | mStartCellXWidth = mCellXWidth; | 608 | mStartCellXWidth = mCellXWidth; |
607 | mStartCellYTop = mCellYTop; | 609 | mStartCellYTop = mCellYTop; |
608 | mStartCellYBottom = mCellYBottom; | 610 | mStartCellYBottom = mCellYBottom; |
609 | } | 611 | } |
610 | 612 | ||
611 | void KOAgendaItem::resetMove() | 613 | void KOAgendaItem::resetMove() |
612 | { | 614 | { |
613 | mCellX = mStartCellX; | 615 | mCellX = mStartCellX; |
614 | mCellXWidth = mStartCellXWidth; | 616 | mCellXWidth = mStartCellXWidth; |
615 | mCellYTop = mStartCellYTop; | 617 | mCellYTop = mStartCellYTop; |
616 | mCellYBottom = mStartCellYBottom; | 618 | mCellYBottom = mStartCellYBottom; |
617 | } | 619 | } |
618 | 620 | ||
619 | void KOAgendaItem::moveRelative(int dx, int dy) | 621 | void KOAgendaItem::moveRelative(int dx, int dy) |
620 | { | 622 | { |
621 | int newX = cellX() + dx; | 623 | int newX = cellX() + dx; |
622 | int newXWidth = cellXWidth() + dx; | 624 | int newXWidth = cellXWidth() + dx; |
623 | int newYTop = cellYTop() + dy; | 625 | int newYTop = cellYTop() + dy; |
624 | int newYBottom = cellYBottom() + dy; | 626 | int newYBottom = cellYBottom() + dy; |
625 | setCellXY(newX,newYTop,newYBottom); | 627 | setCellXY(newX,newYTop,newYBottom); |
626 | setCellXWidth(newXWidth); | 628 | setCellXWidth(newXWidth); |
627 | } | 629 | } |
628 | 630 | ||
629 | void KOAgendaItem::expandTop(int dy) | 631 | void KOAgendaItem::expandTop(int dy) |
630 | { | 632 | { |
631 | int newYTop = cellYTop() + dy; | 633 | int newYTop = cellYTop() + dy; |
632 | int newYBottom = cellYBottom(); | 634 | int newYBottom = cellYBottom(); |
633 | if (newYTop > newYBottom) newYTop = newYBottom; | 635 | if (newYTop > newYBottom) newYTop = newYBottom; |
634 | setCellY(newYTop, newYBottom); | 636 | setCellY(newYTop, newYBottom); |
635 | } | 637 | } |
636 | 638 | ||
637 | void KOAgendaItem::expandBottom(int dy) | 639 | void KOAgendaItem::expandBottom(int dy) |
638 | { | 640 | { |
639 | int newYTop = cellYTop(); | 641 | int newYTop = cellYTop(); |
640 | int newYBottom = cellYBottom() + dy; | 642 | int newYBottom = cellYBottom() + dy; |
641 | if (newYBottom < newYTop) newYBottom = newYTop; | 643 | if (newYBottom < newYTop) newYBottom = newYTop; |
642 | setCellY(newYTop, newYBottom); | 644 | setCellY(newYTop, newYBottom); |
643 | } | 645 | } |
644 | 646 | ||
645 | void KOAgendaItem::expandLeft(int dx) | 647 | void KOAgendaItem::expandLeft(int dx) |
646 | { | 648 | { |
647 | int newX = cellX() + dx; | 649 | int newX = cellX() + dx; |
648 | int newXWidth = cellXWidth(); | 650 | int newXWidth = cellXWidth(); |
649 | if (newX > newXWidth) newX = newXWidth; | 651 | if (newX > newXWidth) newX = newXWidth; |
650 | setCellX(newX,newXWidth); | 652 | setCellX(newX,newXWidth); |
651 | } | 653 | } |
652 | 654 | ||
653 | void KOAgendaItem::expandRight(int dx) | 655 | void KOAgendaItem::expandRight(int dx) |
654 | { | 656 | { |
655 | int newX = cellX(); | 657 | int newX = cellX(); |
656 | int newXWidth = cellXWidth() + dx; | 658 | int newXWidth = cellXWidth() + dx; |
657 | if (newXWidth < newX) newXWidth = newX; | 659 | if (newXWidth < newX) newXWidth = newX; |
658 | setCellX(newX,newXWidth); | 660 | setCellX(newX,newXWidth); |
659 | } | 661 | } |
660 | 662 | ||
661 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 663 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
662 | { | 664 | { |
663 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 665 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
664 | return mToolTipGroup; | 666 | return mToolTipGroup; |
665 | } | 667 | } |
666 | 668 | ||
667 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 669 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
668 | { | 670 | { |
669 | #ifndef KORG_NODND | 671 | #ifndef KORG_NODND |
670 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 672 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
671 | !QTextDrag::canDecode( e ) ) { | 673 | !QTextDrag::canDecode( e ) ) { |
672 | e->ignore(); | 674 | e->ignore(); |
673 | return; | 675 | return; |
674 | } | 676 | } |
675 | e->accept(); | 677 | e->accept(); |
676 | #endif | 678 | #endif |
677 | } | 679 | } |
678 | 680 | ||
679 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 681 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
680 | { | 682 | { |
681 | #ifndef KORG_NODND | 683 | #ifndef KORG_NODND |
682 | QString text; | 684 | QString text; |
683 | if(QTextDrag::decode(e,text)) | 685 | if(QTextDrag::decode(e,text)) |
684 | { | 686 | { |
685 | kdDebug() << "Dropped : " << text << endl; | 687 | kdDebug() << "Dropped : " << text << endl; |
686 | QStringList emails = QStringList::split(",",text); | 688 | QStringList emails = QStringList::split(",",text); |
687 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 689 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
688 | kdDebug() << " Email: " << (*it) << endl; | 690 | kdDebug() << " Email: " << (*it) << endl; |
689 | int pos = (*it).find("<"); | 691 | int pos = (*it).find("<"); |
690 | QString name = (*it).left(pos); | 692 | QString name = (*it).left(pos); |
691 | QString email = (*it).mid(pos); | 693 | QString email = (*it).mid(pos); |
692 | if (!email.isEmpty()) { | 694 | if (!email.isEmpty()) { |
693 | mIncidence->addAttendee(new Attendee(name,email)); | 695 | mIncidence->addAttendee(new Attendee(name,email)); |
694 | } | 696 | } |
695 | } | 697 | } |
696 | } | 698 | } |
697 | #endif | 699 | #endif |
698 | } | 700 | } |
699 | 701 | ||
700 | 702 | ||
701 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 703 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
702 | { | 704 | { |
703 | return mConflictItems; | 705 | return mConflictItems; |
704 | } | 706 | } |
705 | 707 | ||
706 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 708 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
707 | { | 709 | { |
708 | mConflictItems = ci; | 710 | mConflictItems = ci; |
709 | KOAgendaItem *item; | 711 | KOAgendaItem *item; |
710 | for ( item=mConflictItems.first(); item != 0; | 712 | for ( item=mConflictItems.first(); item != 0; |
711 | item=mConflictItems.next() ) { | 713 | item=mConflictItems.next() ) { |
712 | item->addConflictItem(this); | 714 | item->addConflictItem(this); |
713 | } | 715 | } |
714 | } | 716 | } |
715 | 717 | ||
716 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 718 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
717 | { | 719 | { |
718 | if (mConflictItems.find(ci)<0) | 720 | if (mConflictItems.find(ci)<0) |
719 | mConflictItems.append(ci); | 721 | mConflictItems.append(ci); |
720 | } | 722 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 7d1e82f..08232e2 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1056 +1,1062 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | 57 | ||
58 | class KNOWhatsThis :public QWhatsThis | 58 | class KNOWhatsThis :public QWhatsThis |
59 | { | 59 | { |
60 | public: | 60 | public: |
61 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 61 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | virtual QString text( const QPoint& p) | 64 | virtual QString text( const QPoint& p) |
65 | { | 65 | { |
66 | return _wid->getWhatsThisText(p) ; | 66 | return _wid->getWhatsThisText(p) ; |
67 | }; | 67 | }; |
68 | private: | 68 | private: |
69 | KNoScrollListBox* _wid; | 69 | KNoScrollListBox* _wid; |
70 | 70 | ||
71 | }; | 71 | }; |
72 | 72 | ||
73 | 73 | ||
74 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 74 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
75 | : QListBox(parent, name) | 75 | : QListBox(parent, name) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KNOWhatsThis(this); | 80 | new KNOWhatsThis(this); |
81 | } | 81 | } |
82 | 82 | ||
83 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 83 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
84 | { | 84 | { |
85 | QListBoxItem* item = itemAt ( p ); | 85 | QListBoxItem* item = itemAt ( p ); |
86 | if ( ! item ) { | 86 | if ( ! item ) { |
87 | return i18n("Click in the cell or\non the date label\nto add an event!"); | 87 | return i18n("Click in the cell or\non the date label\nto add an event!"); |
88 | } | 88 | } |
89 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 89 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
90 | } | 90 | } |
91 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 91 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
92 | { | 92 | { |
93 | 93 | ||
94 | switch(e->key()) { | 94 | switch(e->key()) { |
95 | case Key_Right: | 95 | case Key_Right: |
96 | // if ( e->state() == Qt::ControlButton ) | 96 | // if ( e->state() == Qt::ControlButton ) |
97 | { | 97 | { |
98 | e->ignore(); | 98 | e->ignore(); |
99 | return; | 99 | return; |
100 | } | 100 | } |
101 | scrollBy(4,0); | 101 | scrollBy(4,0); |
102 | break; | 102 | break; |
103 | case Key_Left: | 103 | case Key_Left: |
104 | // if ( e->state() == Qt::ControlButton ) | 104 | // if ( e->state() == Qt::ControlButton ) |
105 | { | 105 | { |
106 | e->ignore(); | 106 | e->ignore(); |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | scrollBy(-4,0); | 109 | scrollBy(-4,0); |
110 | break; | 110 | break; |
111 | case Key_Up: | 111 | case Key_Up: |
112 | if(!count()) break; | 112 | if(!count()) break; |
113 | setCurrentItem((currentItem()+count()-1)%count()); | 113 | setCurrentItem((currentItem()+count()-1)%count()); |
114 | if(!itemVisible(currentItem())) { | 114 | if(!itemVisible(currentItem())) { |
115 | if((unsigned int) currentItem() == (count()-1)) { | 115 | if((unsigned int) currentItem() == (count()-1)) { |
116 | setTopItem(currentItem()-numItemsVisible()+1); | 116 | setTopItem(currentItem()-numItemsVisible()+1); |
117 | } else { | 117 | } else { |
118 | setTopItem(topItem()-1); | 118 | setTopItem(topItem()-1); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | break; | 121 | break; |
122 | case Key_Down: | 122 | case Key_Down: |
123 | if(!count()) break; | 123 | if(!count()) break; |
124 | setCurrentItem((currentItem()+1)%count()); | 124 | setCurrentItem((currentItem()+1)%count()); |
125 | if(!itemVisible(currentItem())) { | 125 | if(!itemVisible(currentItem())) { |
126 | if(currentItem() == 0) { | 126 | if(currentItem() == 0) { |
127 | setTopItem(0); | 127 | setTopItem(0); |
128 | } else { | 128 | } else { |
129 | setTopItem(topItem()+1); | 129 | setTopItem(topItem()+1); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | break; | 132 | break; |
133 | case Key_Shift: | 133 | case Key_Shift: |
134 | emit shiftDown(); | 134 | emit shiftDown(); |
135 | break; | 135 | break; |
136 | default: | 136 | default: |
137 | e->ignore(); | 137 | e->ignore(); |
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 142 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
143 | { | 143 | { |
144 | switch(e->key()) { | 144 | switch(e->key()) { |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftUp(); | 146 | emit shiftUp(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 153 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
154 | { | 154 | { |
155 | QListBox::mousePressEvent(e); | 155 | QListBox::mousePressEvent(e); |
156 | 156 | ||
157 | if(e->button() == RightButton) { | 157 | if(e->button() == RightButton) { |
158 | emit rightClick(); | 158 | emit rightClick(); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 162 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
163 | : QListBoxItem() | 163 | : QListBoxItem() |
164 | { | 164 | { |
165 | setText( s ); | 165 | setText( s ); |
166 | 166 | ||
167 | mIncidence = incidence; | 167 | mIncidence = incidence; |
168 | mDate = qd; | 168 | mDate = qd; |
169 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 169 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
170 | mRecur = false; | 170 | mRecur = false; |
171 | mAlarm = false; | 171 | mAlarm = false; |
172 | mReply = false; | 172 | mReply = false; |
173 | mInfo = false; | 173 | mInfo = false; |
174 | } | 174 | } |
175 | 175 | ||
176 | void MonthViewItem::paint(QPainter *p) | 176 | void MonthViewItem::paint(QPainter *p) |
177 | { | 177 | { |
178 | #if QT_VERSION >= 0x030000 | 178 | #if QT_VERSION >= 0x030000 |
179 | bool sel = isSelected(); | 179 | bool sel = isSelected(); |
180 | #else | 180 | #else |
181 | bool sel = selected(); | 181 | bool sel = selected(); |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | 184 | ||
185 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 185 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
186 | { | 186 | { |
187 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 187 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
188 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 188 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
189 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 189 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
190 | } | 190 | } |
191 | int x = 1; | 191 | int x = 1; |
192 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 192 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
193 | int size = PIXMAP_SIZE; | 193 | int size = PIXMAP_SIZE; |
194 | if ( QApplication::desktop()->width() < 300 ) | 194 | if ( QApplication::desktop()->width() < 300 ) |
195 | size = 3; | 195 | size = 3; |
196 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 196 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
197 | if ( mInfo ) { | 197 | if ( mInfo ) { |
198 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 198 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
199 | x += size + 1; | 199 | x += size + 1; |
200 | } | 200 | } |
201 | if ( mRecur ) { | 201 | if ( mRecur ) { |
202 | p->fillRect ( x, y,size,size, Qt::blue ); | 202 | p->fillRect ( x, y,size,size, Qt::blue ); |
203 | x += size + 1; | 203 | x += size + 1; |
204 | } | 204 | } |
205 | if ( mAlarm ) { | 205 | if ( mAlarm ) { |
206 | p->fillRect ( x, y,size,size, Qt::red ); | 206 | p->fillRect ( x, y,size,size, Qt::red ); |
207 | x += size + 1; | 207 | x += size + 1; |
208 | } | 208 | } |
209 | if ( mReply ) { | 209 | if ( mReply ) { |
210 | p->fillRect ( x, y,size,size, Qt::yellow ); | 210 | p->fillRect ( x, y,size,size, Qt::yellow ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | QFontMetrics fm = p->fontMetrics(); | 214 | QFontMetrics fm = p->fontMetrics(); |
215 | int yPos; | 215 | int yPos; |
216 | int pmheight = size; | 216 | int pmheight = size; |
217 | if( pmheight < fm.height() ) | 217 | if( pmheight < fm.height() ) |
218 | yPos = fm.ascent() + fm.leading()/2; | 218 | yPos = fm.ascent() + fm.leading()/2; |
219 | else | 219 | else |
220 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 220 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
221 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 221 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
222 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 222 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
223 | p->drawText( x, yPos, text() ); | 223 | p->drawText( x, yPos, text() ); |
224 | if ( mIncidence->cancelled() ) { | 224 | if ( mIncidence->cancelled() ) { |
225 | int wid = fm.width( text() ); | 225 | int wid = fm.width( text() ); |
226 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 226 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
227 | } | 227 | } |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | int MonthViewItem::height(const QListBox *lb) const | 231 | int MonthViewItem::height(const QListBox *lb) const |
232 | { | 232 | { |
233 | return lb->fontMetrics().lineSpacing()+1; | 233 | return lb->fontMetrics().lineSpacing()+1; |
234 | } | 234 | } |
235 | 235 | ||
236 | int MonthViewItem::width(const QListBox *lb) const | 236 | int MonthViewItem::width(const QListBox *lb) const |
237 | { | 237 | { |
238 | int size = PIXMAP_SIZE; | 238 | int size = PIXMAP_SIZE; |
239 | if ( QApplication::desktop()->width() < 300 ) | 239 | if ( QApplication::desktop()->width() < 300 ) |
240 | size = 3; | 240 | size = 3; |
241 | int x = 1; | 241 | int x = 1; |
242 | if ( mInfo ) { | 242 | if ( mInfo ) { |
243 | x += size + 1; | 243 | x += size + 1; |
244 | } | 244 | } |
245 | if( mRecur ) { | 245 | if( mRecur ) { |
246 | x += size+1; | 246 | x += size+1; |
247 | } | 247 | } |
248 | if( mAlarm ) { | 248 | if( mAlarm ) { |
249 | x += size+1; | 249 | x += size+1; |
250 | } | 250 | } |
251 | if( mReply ) { | 251 | if( mReply ) { |
252 | x += size+1; | 252 | x += size+1; |
253 | } | 253 | } |
254 | 254 | ||
255 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 255 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 259 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
260 | : QWidget( parent ), | 260 | : QWidget( parent ), |
261 | mMonthView( parent ) | 261 | mMonthView( parent ) |
262 | { | 262 | { |
263 | 263 | ||
264 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 264 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
265 | 265 | ||
266 | // mLabel = new QLabel( this );QPushButton | 266 | // mLabel = new QLabel( this );QPushButton |
267 | mLabel = new QPushButton( this ); | 267 | mLabel = new QPushButton( this ); |
268 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 268 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
269 | //mLabel->setLineWidth( 1 ); | 269 | //mLabel->setLineWidth( 1 ); |
270 | //mLabel->setAlignment( AlignCenter ); | 270 | //mLabel->setAlignment( AlignCenter ); |
271 | mLabel->setFlat( true ); | 271 | mLabel->setFlat( true ); |
272 | mItemList = new KNoScrollListBox( this ); | 272 | mItemList = new KNoScrollListBox( this ); |
273 | mItemList->setMinimumSize( 10, 10 ); | 273 | mItemList->setMinimumSize( 10, 10 ); |
274 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 274 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
275 | mItemList->setLineWidth( 1 ); | 275 | mItemList->setLineWidth( 1 ); |
276 | topLayout->addWidget( mItemList ); | 276 | topLayout->addWidget( mItemList ); |
277 | mLabel->raise(); | 277 | mLabel->raise(); |
278 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 278 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
279 | mStandardPalette = palette(); | 279 | mStandardPalette = palette(); |
280 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 280 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
281 | 281 | ||
282 | enableScrollBars( false ); | 282 | enableScrollBars( false ); |
283 | updateConfig(); | 283 | updateConfig(); |
284 | connect( mLabel, SIGNAL( clicked( )), | 284 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
285 | SLOT( newEvent() )); | 285 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
286 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 286 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
287 | SLOT( defaultAction( QListBoxItem * ) ) ); | 287 | SLOT( defaultAction( QListBoxItem * ) ) ); |
288 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 288 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
289 | const QPoint &) ), | 289 | const QPoint &) ), |
290 | SLOT( contextMenu( QListBoxItem * ) ) ); | 290 | SLOT( contextMenu( QListBoxItem * ) ) ); |
291 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 291 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
292 | SLOT( selection( QListBoxItem * ) ) ); | 292 | SLOT( selection( QListBoxItem * ) ) ); |
293 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 293 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
294 | SLOT( cellClicked( QListBoxItem * ) ) ); | 294 | SLOT( cellClicked( QListBoxItem * ) ) ); |
295 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 295 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
296 | SLOT( selection( QListBoxItem * ) ) ); | 296 | SLOT( selection( QListBoxItem * ) ) ); |
297 | } | 297 | } |
298 | 298 | ||
299 | void MonthViewCell::setDate( const QDate &date ) | 299 | void MonthViewCell::setDate( const QDate &date ) |
300 | { | 300 | { |
301 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 301 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
302 | 302 | ||
303 | mDate = date; | 303 | mDate = date; |
304 | 304 | ||
305 | QString text; | 305 | QString text; |
306 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 306 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
307 | if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 307 | if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
308 | text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; | 308 | text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; |
309 | mLabel->resize( mLabelBigSize ); | 309 | mLabel->resize( mLabelBigSize ); |
310 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 310 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
311 | } else { | 311 | } else { |
312 | mLabel->resize( mLabelSize ); | 312 | mLabel->resize( mLabelSize ); |
313 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 313 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
314 | } | 314 | } |
315 | mLabel->setText( text ); | 315 | mLabel->setText( text ); |
316 | 316 | ||
317 | //resizeEvent( 0 ); | 317 | //resizeEvent( 0 ); |
318 | } | 318 | } |
319 | 319 | ||
320 | QDate MonthViewCell::date() const | 320 | QDate MonthViewCell::date() const |
321 | { | 321 | { |
322 | return mDate; | 322 | return mDate; |
323 | } | 323 | } |
324 | 324 | ||
325 | void MonthViewCell::setPrimary( bool primary ) | 325 | void MonthViewCell::setPrimary( bool primary ) |
326 | { | 326 | { |
327 | mPrimary = primary; | 327 | mPrimary = primary; |
328 | //setMyPalette(); | 328 | //setMyPalette(); |
329 | } | 329 | } |
330 | void MonthViewCell::setMyPalette() | 330 | void MonthViewCell::setMyPalette() |
331 | { | 331 | { |
332 | 332 | ||
333 | if ( mHoliday) { | 333 | if ( mHoliday) { |
334 | setPalette( mHolidayPalette ); | 334 | setPalette( mHolidayPalette ); |
335 | } else { | 335 | } else { |
336 | if ( mPrimary ) { | 336 | if ( mPrimary ) { |
337 | setPalette( mPrimaryPalette ); | 337 | setPalette( mPrimaryPalette ); |
338 | } else { | 338 | } else { |
339 | setPalette( mNonPrimaryPalette ); | 339 | setPalette( mNonPrimaryPalette ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | QPalette pal = palette(); | 342 | QPalette pal = palette(); |
343 | 343 | ||
344 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 344 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
345 | } | 345 | } |
346 | QPalette MonthViewCell::getPalette () | 346 | QPalette MonthViewCell::getPalette () |
347 | { | 347 | { |
348 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 348 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
349 | return mStandardPalette; | 349 | return mStandardPalette; |
350 | if ( mHoliday) { | 350 | if ( mHoliday) { |
351 | return mHolidayPalette ; | 351 | return mHolidayPalette ; |
352 | } else { | 352 | } else { |
353 | if ( mPrimary ) { | 353 | if ( mPrimary ) { |
354 | return mPrimaryPalette ; | 354 | return mPrimaryPalette ; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | return mNonPrimaryPalette; | 357 | return mNonPrimaryPalette; |
358 | } | 358 | } |
359 | bool MonthViewCell::isPrimary() const | 359 | bool MonthViewCell::isPrimary() const |
360 | { | 360 | { |
361 | return mPrimary; | 361 | return mPrimary; |
362 | } | 362 | } |
363 | 363 | ||
364 | void MonthViewCell::setHoliday( bool holiday ) | 364 | void MonthViewCell::setHoliday( bool holiday ) |
365 | { | 365 | { |
366 | mHoliday = holiday; | 366 | mHoliday = holiday; |
367 | //setMyPalette(); | 367 | //setMyPalette(); |
368 | } | 368 | } |
369 | 369 | ||
370 | void MonthViewCell::setHoliday( const QString &holiday ) | 370 | void MonthViewCell::setHoliday( const QString &holiday ) |
371 | { | 371 | { |
372 | mHolidayString = holiday; | 372 | mHolidayString = holiday; |
373 | 373 | ||
374 | if ( !holiday.isEmpty() ) { | 374 | if ( !holiday.isEmpty() ) { |
375 | setHoliday( true ); | 375 | setHoliday( true ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 378 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
379 | { | 379 | { |
380 | 380 | ||
381 | e->ignore(); | 381 | e->ignore(); |
382 | 382 | ||
383 | } | 383 | } |
384 | void MonthViewCell::updateCell() | 384 | void MonthViewCell::updateCell() |
385 | { | 385 | { |
386 | 386 | ||
387 | setPrimary( mDate.month()%2 ); | 387 | setPrimary( mDate.month()%2 ); |
388 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 388 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
389 | if ( mDate == QDate::currentDate() ) { | 389 | if ( mDate == QDate::currentDate() ) { |
390 | mItemList->setLineWidth( 3 ); | 390 | mItemList->setLineWidth( 3 ); |
391 | } else { | 391 | } else { |
392 | mItemList->setLineWidth( 1 ); | 392 | mItemList->setLineWidth( 1 ); |
393 | } | 393 | } |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | //qApp->processEvents(); | 395 | //qApp->processEvents(); |
396 | if ( !mHolidayString.isEmpty() ) { | 396 | if ( !mHolidayString.isEmpty() ) { |
397 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 397 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
398 | item->setPalette( mHolidayPalette ); | 398 | item->setPalette( mHolidayPalette ); |
399 | mItemList->insertItem( item ); | 399 | mItemList->insertItem( item ); |
400 | } | 400 | } |
401 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 401 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
402 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 402 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
403 | Event *event; | 403 | Event *event; |
404 | for( event = events.first(); event; event = events.next() ) { | 404 | for( event = events.first(); event; event = events.next() ) { |
405 | if ( event->categories().contains("Holiday") || | 405 | if ( event->categories().contains("Holiday") || |
406 | event->categories().contains(i18n("Holiday"))) { | 406 | event->categories().contains(i18n("Holiday"))) { |
407 | setHoliday( true ); | 407 | setHoliday( true ); |
408 | if ( mDate.dayOfWeek() == 7 ) | 408 | if ( mDate.dayOfWeek() == 7 ) |
409 | mItemList->setLineWidth( 3 ); | 409 | mItemList->setLineWidth( 3 ); |
410 | } | 410 | } |
411 | QString text; | 411 | QString text; |
412 | if (event->isMultiDay()) { | 412 | if (event->isMultiDay()) { |
413 | QString prefix = "<->"; | 413 | QString prefix = "<->"; |
414 | if ( event->doesRecur() ) { | 414 | if ( event->doesRecur() ) { |
415 | if ( event->recursOn( mDate) ) | 415 | if ( event->recursOn( mDate) ) |
416 | prefix ="->" ; | 416 | prefix ="->" ; |
417 | else { | 417 | else { |
418 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 418 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
419 | if ( event->recursOn( mDate.addDays( -days)) ) | 419 | if ( event->recursOn( mDate.addDays( -days)) ) |
420 | prefix ="<-" ; | 420 | prefix ="<-" ; |
421 | } | 421 | } |
422 | 422 | ||
423 | } else { | 423 | } else { |
424 | if (mDate == event->dtStart().date()) { | 424 | if (mDate == event->dtStart().date()) { |
425 | prefix ="->" ; | 425 | prefix ="->" ; |
426 | } else if (mDate == event->dtEnd().date()) { | 426 | } else if (mDate == event->dtEnd().date()) { |
427 | prefix ="<-" ; | 427 | prefix ="<-" ; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | text = prefix + event->summary(); | 430 | text = prefix + event->summary(); |
431 | } else { | 431 | } else { |
432 | if (event->doesFloat()) | 432 | if (event->doesFloat()) |
433 | text = event->summary(); | 433 | text = event->summary(); |
434 | else { | 434 | else { |
435 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 435 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
436 | text += " " + event->summary(); | 436 | text += " " + event->summary(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 440 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
441 | QPalette pal; | 441 | QPalette pal; |
442 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 442 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
443 | QStringList categories = event->categories(); | 443 | QStringList categories = event->categories(); |
444 | QString cat = categories.first(); | 444 | QString cat = categories.first(); |
445 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 445 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
446 | pal = getPalette(); | 446 | pal = getPalette(); |
447 | if (cat.isEmpty()) { | 447 | if (cat.isEmpty()) { |
448 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 448 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
449 | } else { | 449 | } else { |
450 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 450 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
451 | } | 451 | } |
452 | 452 | ||
453 | } else { | 453 | } else { |
454 | if (cat.isEmpty()) { | 454 | if (cat.isEmpty()) { |
455 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 455 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
456 | } else { | 456 | } else { |
457 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 457 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | pal = mStandardPalette ; | 462 | pal = mStandardPalette ; |
463 | } | 463 | } |
464 | item->setPalette( pal ); | 464 | item->setPalette( pal ); |
465 | item->setRecur( event->recurrence()->doesRecur() ); | 465 | item->setRecur( event->recurrence()->doesRecur() ); |
466 | item->setAlarm( event->isAlarmEnabled() ); | 466 | item->setAlarm( event->isAlarmEnabled() ); |
467 | item->setMoreInfo( event->description().length() > 0 ); | 467 | item->setMoreInfo( event->description().length() > 0 ); |
468 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 468 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
469 | KOPrefs::instance()->email()); | 469 | KOPrefs::instance()->email()); |
470 | if ( me != 0 ) { | 470 | if ( me != 0 ) { |
471 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 471 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
472 | item->setReply(true); | 472 | item->setReply(true); |
473 | else | 473 | else |
474 | item->setReply(false); | 474 | item->setReply(false); |
475 | } else | 475 | } else |
476 | item->setReply(false); | 476 | item->setReply(false); |
477 | bool insert = true; | 477 | bool insert = true; |
478 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 478 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
479 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 479 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
480 | insert = false; | 480 | insert = false; |
481 | else | 481 | else |
482 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 482 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
483 | insert = false; | 483 | insert = false; |
484 | 484 | ||
485 | } | 485 | } |
486 | if ( insert ) | 486 | if ( insert ) |
487 | mItemList->insertItem( item ); | 487 | mItemList->insertItem( item ); |
488 | } | 488 | } |
489 | 489 | ||
490 | // insert due todos | 490 | // insert due todos |
491 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 491 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
492 | Todo *todo; | 492 | Todo *todo; |
493 | for(todo = todos.first(); todo; todo = todos.next()) { | 493 | for(todo = todos.first(); todo; todo = todos.next()) { |
494 | QString text; | 494 | QString text; |
495 | if (todo->hasDueDate()) { | 495 | if (todo->hasDueDate()) { |
496 | if (!todo->doesFloat()) { | 496 | if (!todo->doesFloat()) { |
497 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 497 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
498 | text += " "; | 498 | text += " "; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | text += i18n("To-Do: %1").arg(todo->summary()); | 501 | text += i18n("To-Do: %1").arg(todo->summary()); |
502 | 502 | ||
503 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 503 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
504 | //item->setPalette( mStandardPalette ); | 504 | //item->setPalette( mStandardPalette ); |
505 | QPalette pal; | 505 | QPalette pal; |
506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
507 | QStringList categories = todo->categories(); | 507 | QStringList categories = todo->categories(); |
508 | QString cat = categories.first(); | 508 | QString cat = categories.first(); |
509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
510 | pal = getPalette(); | 510 | pal = getPalette(); |
511 | if (cat.isEmpty()) { | 511 | if (cat.isEmpty()) { |
512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
513 | } else { | 513 | } else { |
514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
515 | } | 515 | } |
516 | 516 | ||
517 | } else { | 517 | } else { |
518 | if (cat.isEmpty()) { | 518 | if (cat.isEmpty()) { |
519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
520 | } else { | 520 | } else { |
521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | } else { | 525 | } else { |
526 | pal = mStandardPalette ; | 526 | pal = mStandardPalette ; |
527 | } | 527 | } |
528 | item->setPalette( pal ); | 528 | item->setPalette( pal ); |
529 | mItemList->insertItem( item ); | 529 | mItemList->insertItem( item ); |
530 | } | 530 | } |
531 | //setMyPalette(); | 531 | //setMyPalette(); |
532 | setMyPalette(); | 532 | setMyPalette(); |
533 | resizeEvent( 0 ); | 533 | resizeEvent( 0 ); |
534 | // if ( isVisible()) | 534 | // if ( isVisible()) |
535 | // qApp->processEvents(); | 535 | // qApp->processEvents(); |
536 | } | 536 | } |
537 | 537 | ||
538 | void MonthViewCell::updateConfig() | 538 | void MonthViewCell::updateConfig() |
539 | { | 539 | { |
540 | 540 | ||
541 | setFont( KOPrefs::instance()->mMonthViewFont ); | 541 | setFont( KOPrefs::instance()->mMonthViewFont ); |
542 | 542 | ||
543 | QFontMetrics fm( font() ); | 543 | QFontMetrics fm( font() ); |
544 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 544 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
545 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 545 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
546 | mHolidayPalette = mStandardPalette; | 546 | mHolidayPalette = mStandardPalette; |
547 | mPrimaryPalette = mStandardPalette; | 547 | mPrimaryPalette = mStandardPalette; |
548 | mNonPrimaryPalette = mStandardPalette; | 548 | mNonPrimaryPalette = mStandardPalette; |
549 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 549 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
550 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 550 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
551 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 551 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
552 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 552 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
553 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 553 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
554 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 554 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
555 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 555 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
556 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 556 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
557 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 557 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
558 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 558 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
559 | } | 559 | } |
560 | updateCell(); | 560 | updateCell(); |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::enableScrollBars( bool enabled ) | 563 | void MonthViewCell::enableScrollBars( bool enabled ) |
564 | { | 564 | { |
565 | if ( enabled ) { | 565 | if ( enabled ) { |
566 | mItemList->setVScrollBarMode(QScrollView::Auto); | 566 | mItemList->setVScrollBarMode(QScrollView::Auto); |
567 | mItemList->setHScrollBarMode(QScrollView::Auto); | 567 | mItemList->setHScrollBarMode(QScrollView::Auto); |
568 | } else { | 568 | } else { |
569 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 569 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
570 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 570 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
571 | } | 571 | } |
572 | } | 572 | } |
573 | 573 | ||
574 | Incidence *MonthViewCell::selectedIncidence() | 574 | Incidence *MonthViewCell::selectedIncidence() |
575 | { | 575 | { |
576 | int index = mItemList->currentItem(); | 576 | int index = mItemList->currentItem(); |
577 | if ( index < 0 ) return 0; | 577 | if ( index < 0 ) return 0; |
578 | 578 | ||
579 | MonthViewItem *item = | 579 | MonthViewItem *item = |
580 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 580 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
581 | 581 | ||
582 | if ( !item ) return 0; | 582 | if ( !item ) return 0; |
583 | 583 | ||
584 | return item->incidence(); | 584 | return item->incidence(); |
585 | } | 585 | } |
586 | 586 | ||
587 | QDate MonthViewCell::selectedIncidenceDate() | 587 | QDate MonthViewCell::selectedIncidenceDate() |
588 | { | 588 | { |
589 | QDate qd; | 589 | QDate qd; |
590 | int index = mItemList->currentItem(); | 590 | int index = mItemList->currentItem(); |
591 | if ( index < 0 ) return qd; | 591 | if ( index < 0 ) return qd; |
592 | 592 | ||
593 | MonthViewItem *item = | 593 | MonthViewItem *item = |
594 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 594 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
595 | 595 | ||
596 | if ( !item ) return qd; | 596 | if ( !item ) return qd; |
597 | 597 | ||
598 | return item->incidenceDate(); | 598 | return item->incidenceDate(); |
599 | } | 599 | } |
600 | 600 | ||
601 | void MonthViewCell::deselect() | 601 | void MonthViewCell::deselect() |
602 | { | 602 | { |
603 | mItemList->clearSelection(); | 603 | mItemList->clearSelection(); |
604 | enableScrollBars( false ); | 604 | enableScrollBars( false ); |
605 | // updateCell(); | 605 | // updateCell(); |
606 | } | 606 | } |
607 | void MonthViewCell::select() | 607 | void MonthViewCell::select() |
608 | { | 608 | { |
609 | ;// updateCell(); | 609 | ;// updateCell(); |
610 | } | 610 | } |
611 | 611 | ||
612 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 612 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
613 | { | 613 | { |
614 | int size = height() - mLabel->height(); | 614 | int size = height() - mLabel->height(); |
615 | if ( size > 0 ) | 615 | if ( size > 0 ) |
616 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 616 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
617 | size = width() - mLabel->width(); | 617 | size = width() - mLabel->width(); |
618 | if ( size > 0 ) | 618 | if ( size > 0 ) |
619 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 619 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
620 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 620 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
621 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 621 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
622 | } | 622 | } |
623 | 623 | ||
624 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 624 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
625 | { | 625 | { |
626 | if ( !item ) return; | 626 | if ( !item ) return; |
627 | 627 | ||
628 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 628 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
629 | Incidence *incidence = eventItem->incidence(); | 629 | Incidence *incidence = eventItem->incidence(); |
630 | if ( incidence ) mMonthView->defaultAction( incidence ); | 630 | if ( incidence ) mMonthView->defaultAction( incidence ); |
631 | } | 631 | } |
632 | void MonthViewCell::showDay() | ||
633 | { | ||
634 | emit showDaySignal( date() ); | ||
635 | } | ||
632 | void MonthViewCell::newEvent() | 636 | void MonthViewCell::newEvent() |
633 | { | 637 | { |
634 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 638 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
635 | emit newEventSignal( dt ); | 639 | emit newEventSignal( dt ); |
636 | } | 640 | } |
637 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 641 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
638 | { | 642 | { |
639 | static QListBoxItem * lastClicked = 0; | 643 | static QListBoxItem * lastClicked = 0; |
640 | if ( item == 0 ) { | 644 | if ( item == 0 ) { |
641 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 645 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
642 | emit newEventSignal( dt ); | 646 | emit newEventSignal( dt ); |
643 | return; | 647 | return; |
644 | } | 648 | } |
645 | /* | 649 | /* |
646 | if ( lastClicked ) | 650 | if ( lastClicked ) |
647 | if ( ! item ) { | 651 | if ( ! item ) { |
648 | if ( lastClicked->listBox() != item->listBox() ) | 652 | if ( lastClicked->listBox() != item->listBox() ) |
649 | lastClicked->listBox()->clearSelection(); | 653 | lastClicked->listBox()->clearSelection(); |
650 | } | 654 | } |
651 | */ | 655 | */ |
652 | 656 | ||
653 | mMonthView->setSelectedCell( this ); | 657 | mMonthView->setSelectedCell( this ); |
654 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 658 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); |
655 | select(); | 659 | select(); |
656 | } | 660 | } |
657 | 661 | ||
658 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 662 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
659 | { | 663 | { |
660 | if ( !item ) return; | 664 | if ( !item ) return; |
661 | 665 | ||
662 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 666 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
663 | Incidence *incidence = eventItem->incidence(); | 667 | Incidence *incidence = eventItem->incidence(); |
664 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 668 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
665 | } | 669 | } |
666 | 670 | ||
667 | void MonthViewCell::selection( QListBoxItem *item ) | 671 | void MonthViewCell::selection( QListBoxItem *item ) |
668 | { | 672 | { |
669 | if ( !item ) return; | 673 | if ( !item ) return; |
670 | 674 | ||
671 | mMonthView->setSelectedCell( this ); | 675 | mMonthView->setSelectedCell( this ); |
672 | } | 676 | } |
673 | 677 | ||
674 | 678 | ||
675 | // ******************************************************************************* | 679 | // ******************************************************************************* |
676 | // ******************************************************************************* | 680 | // ******************************************************************************* |
677 | // ******************************************************************************* | 681 | // ******************************************************************************* |
678 | 682 | ||
679 | 683 | ||
680 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 684 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
681 | : KOEventView( calendar, parent, name ), | 685 | : KOEventView( calendar, parent, name ), |
682 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 686 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
683 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 687 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
684 | { | 688 | { |
685 | mCells.setAutoDelete( true ); | 689 | mCells.setAutoDelete( true ); |
686 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 690 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
687 | // mDayLayout = new QGridLayout( this ); | 691 | // mDayLayout = new QGridLayout( this ); |
688 | // create the day of the week labels (Sun, Mon, etc) and add them to | 692 | // create the day of the week labels (Sun, Mon, etc) and add them to |
689 | // the layout. | 693 | // the layout. |
690 | mDayLabels.resize( mDaysPerWeek ); | 694 | mDayLabels.resize( mDaysPerWeek ); |
691 | QFont bfont = font(); | 695 | QFont bfont = font(); |
692 | if ( QApplication::desktop()->width() < 650 ) { | 696 | if ( QApplication::desktop()->width() < 650 ) { |
693 | bfont.setPointSize( bfont.pointSize() - 2 ); | 697 | bfont.setPointSize( bfont.pointSize() - 2 ); |
694 | } | 698 | } |
695 | bfont.setBold( true ); | 699 | bfont.setBold( true ); |
696 | int i; | 700 | int i; |
697 | 701 | ||
698 | for( i = 0; i < mDaysPerWeek; i++ ) { | 702 | for( i = 0; i < mDaysPerWeek; i++ ) { |
699 | QLabel *label = new QLabel( this ); | 703 | QLabel *label = new QLabel( this ); |
700 | label->setFont(bfont); | 704 | label->setFont(bfont); |
701 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 705 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
702 | label->setLineWidth(1); | 706 | label->setLineWidth(1); |
703 | label->setAlignment(AlignCenter); | 707 | label->setAlignment(AlignCenter); |
704 | mDayLabels.insert( i, label ); | 708 | mDayLabels.insert( i, label ); |
705 | } | 709 | } |
706 | 710 | ||
707 | bfont.setBold( false ); | 711 | bfont.setBold( false ); |
708 | mWeekLabels.resize( mNumWeeks+1 ); | 712 | mWeekLabels.resize( mNumWeeks+1 ); |
709 | for( i = 0; i < mNumWeeks+1; i++ ) { | 713 | for( i = 0; i < mNumWeeks+1; i++ ) { |
710 | KOWeekButton *label = new KOWeekButton( this ); | 714 | KOWeekButton *label = new KOWeekButton( this ); |
711 | label->setFont(bfont); | 715 | label->setFont(bfont); |
712 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 716 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
713 | label->setFlat(true); | 717 | label->setFlat(true); |
714 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 718 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
715 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 719 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
716 | //label->setLineWidth(1); | 720 | //label->setLineWidth(1); |
717 | //label->setAlignment(AlignCenter); | 721 | //label->setAlignment(AlignCenter); |
718 | mWeekLabels.insert( i, label ); | 722 | mWeekLabels.insert( i, label ); |
719 | } | 723 | } |
720 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 724 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
721 | int row, col; | 725 | int row, col; |
722 | mCells.resize( mNumCells ); | 726 | mCells.resize( mNumCells ); |
723 | for( row = 0; row < mNumWeeks; ++row ) { | 727 | for( row = 0; row < mNumWeeks; ++row ) { |
724 | for( col = 0; col < mDaysPerWeek; ++col ) { | 728 | for( col = 0; col < mDaysPerWeek; ++col ) { |
725 | MonthViewCell *cell = new MonthViewCell( this ); | 729 | MonthViewCell *cell = new MonthViewCell( this ); |
726 | mCells.insert( row * mDaysPerWeek + col, cell ); | 730 | mCells.insert( row * mDaysPerWeek + col, cell ); |
727 | 731 | ||
728 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 732 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
729 | SLOT( defaultAction( Incidence * ) ) ); | 733 | SLOT( defaultAction( Incidence * ) ) ); |
730 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 734 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
731 | SIGNAL( newEventSignal( QDateTime ) ) ); | 735 | SIGNAL( newEventSignal( QDateTime ) ) ); |
736 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | ||
737 | SIGNAL( showDaySignal( QDate ) ) ); | ||
732 | } | 738 | } |
733 | } | 739 | } |
734 | 740 | ||
735 | mContextMenu = eventPopup(); | 741 | mContextMenu = eventPopup(); |
736 | // updateConfig(); //useless here | 742 | // updateConfig(); //useless here |
737 | 743 | ||
738 | emit incidenceSelected( 0 ); | 744 | emit incidenceSelected( 0 ); |
739 | } | 745 | } |
740 | 746 | ||
741 | KOMonthView::~KOMonthView() | 747 | KOMonthView::~KOMonthView() |
742 | { | 748 | { |
743 | delete mContextMenu; | 749 | delete mContextMenu; |
744 | } | 750 | } |
745 | 751 | ||
746 | int KOMonthView::maxDatesHint() | 752 | int KOMonthView::maxDatesHint() |
747 | { | 753 | { |
748 | return mNumCells; | 754 | return mNumCells; |
749 | } | 755 | } |
750 | 756 | ||
751 | int KOMonthView::currentDateCount() | 757 | int KOMonthView::currentDateCount() |
752 | { | 758 | { |
753 | return mNumCells; | 759 | return mNumCells; |
754 | } | 760 | } |
755 | 761 | ||
756 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 762 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
757 | { | 763 | { |
758 | QPtrList<Incidence> selected; | 764 | QPtrList<Incidence> selected; |
759 | 765 | ||
760 | if ( mSelectedCell ) { | 766 | if ( mSelectedCell ) { |
761 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 767 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
762 | if ( incidence ) selected.append( incidence ); | 768 | if ( incidence ) selected.append( incidence ); |
763 | } | 769 | } |
764 | 770 | ||
765 | return selected; | 771 | return selected; |
766 | } | 772 | } |
767 | 773 | ||
768 | DateList KOMonthView::selectedDates() | 774 | DateList KOMonthView::selectedDates() |
769 | { | 775 | { |
770 | DateList selected; | 776 | DateList selected; |
771 | 777 | ||
772 | if ( mSelectedCell ) { | 778 | if ( mSelectedCell ) { |
773 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 779 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
774 | if ( qd.isValid() ) selected.append( qd ); | 780 | if ( qd.isValid() ) selected.append( qd ); |
775 | } | 781 | } |
776 | 782 | ||
777 | return selected; | 783 | return selected; |
778 | } | 784 | } |
779 | 785 | ||
780 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 786 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
781 | const QDate &td) | 787 | const QDate &td) |
782 | { | 788 | { |
783 | #ifndef KORG_NOPRINTER | 789 | #ifndef KORG_NOPRINTER |
784 | calPrinter->preview(CalPrinter::Month, fd, td); | 790 | calPrinter->preview(CalPrinter::Month, fd, td); |
785 | #endif | 791 | #endif |
786 | } | 792 | } |
787 | 793 | ||
788 | void KOMonthView::updateConfig() | 794 | void KOMonthView::updateConfig() |
789 | { | 795 | { |
790 | 796 | ||
791 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 797 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
792 | 798 | ||
793 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 799 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
794 | mWidthLongDayLabel = 0; | 800 | mWidthLongDayLabel = 0; |
795 | 801 | ||
796 | for (int i = 0; i < 7; i++) { | 802 | for (int i = 0; i < 7; i++) { |
797 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 803 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
798 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 804 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
799 | } | 805 | } |
800 | bool temp = mShowSatSunComp ; | 806 | bool temp = mShowSatSunComp ; |
801 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 807 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
802 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 808 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
803 | computeLayout(); | 809 | computeLayout(); |
804 | updateDayLabels(); | 810 | updateDayLabels(); |
805 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 811 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
806 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 812 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
807 | //resizeEvent( 0 ); | 813 | //resizeEvent( 0 ); |
808 | for (uint i = 0; i < mCells.count(); ++i) { | 814 | for (uint i = 0; i < mCells.count(); ++i) { |
809 | mCells[i]->updateConfig(); | 815 | mCells[i]->updateConfig(); |
810 | } | 816 | } |
811 | } | 817 | } |
812 | 818 | ||
813 | void KOMonthView::updateDayLabels() | 819 | void KOMonthView::updateDayLabels() |
814 | { | 820 | { |
815 | 821 | ||
816 | for (int i = 0; i < 7; i++) { | 822 | for (int i = 0; i < 7; i++) { |
817 | if (mWeekStartsMonday) { | 823 | if (mWeekStartsMonday) { |
818 | bool show = mShortDayLabels; | 824 | bool show = mShortDayLabels; |
819 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 825 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
820 | show = true; | 826 | show = true; |
821 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 827 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
822 | } else { | 828 | } else { |
823 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 829 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
824 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 830 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
825 | 831 | ||
826 | } | 832 | } |
827 | } | 833 | } |
828 | } | 834 | } |
829 | 835 | ||
830 | void KOMonthView::showDates(const QDate &start, const QDate &) | 836 | void KOMonthView::showDates(const QDate &start, const QDate &) |
831 | { | 837 | { |
832 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 838 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
833 | 839 | ||
834 | 840 | ||
835 | mStartDate = start; | 841 | mStartDate = start; |
836 | 842 | ||
837 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 843 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
838 | 844 | ||
839 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 845 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
840 | mStartDate = mStartDate.addDays( -1 ); | 846 | mStartDate = mStartDate.addDays( -1 ); |
841 | } | 847 | } |
842 | 848 | ||
843 | bool primary = false; | 849 | bool primary = false; |
844 | uint i; | 850 | uint i; |
845 | for( i = 0; i < mCells.size(); ++i ) { | 851 | for( i = 0; i < mCells.size(); ++i ) { |
846 | QDate date = mStartDate.addDays( i ); | 852 | QDate date = mStartDate.addDays( i ); |
847 | mCells[i]->setDate( date ); | 853 | mCells[i]->setDate( date ); |
848 | 854 | ||
849 | #ifndef KORG_NOPLUGINS | 855 | #ifndef KORG_NOPLUGINS |
850 | // add holiday, if present | 856 | // add holiday, if present |
851 | QString hstring(KOCore::self()->holiday(date)); | 857 | QString hstring(KOCore::self()->holiday(date)); |
852 | mCells[i]->setHoliday( hstring ); | 858 | mCells[i]->setHoliday( hstring ); |
853 | #endif | 859 | #endif |
854 | 860 | ||
855 | } | 861 | } |
856 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 862 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
857 | for( i = 0; i < 6; ++i ) { | 863 | for( i = 0; i < 6; ++i ) { |
858 | int wno; | 864 | int wno; |
859 | // remember, according to ISO 8601, the first week of the year is the | 865 | // remember, according to ISO 8601, the first week of the year is the |
860 | // first week that contains a thursday. Thus we must subtract off 4, | 866 | // first week that contains a thursday. Thus we must subtract off 4, |
861 | // not just 1. | 867 | // not just 1. |
862 | int dayOfYear = date.dayOfYear(); | 868 | int dayOfYear = date.dayOfYear(); |
863 | if (dayOfYear % 7 != 0) | 869 | if (dayOfYear % 7 != 0) |
864 | wno = dayOfYear / 7 + 1; | 870 | wno = dayOfYear / 7 + 1; |
865 | else | 871 | else |
866 | wno =dayOfYear / 7; | 872 | wno =dayOfYear / 7; |
867 | mWeekLabels[i]->setWeekNum( wno ); | 873 | mWeekLabels[i]->setWeekNum( wno ); |
868 | date = date.addDays( 7 ); | 874 | date = date.addDays( 7 ); |
869 | } | 875 | } |
870 | updateView(); | 876 | updateView(); |
871 | } | 877 | } |
872 | 878 | ||
873 | void KOMonthView::showEvents(QPtrList<Event>) | 879 | void KOMonthView::showEvents(QPtrList<Event>) |
874 | { | 880 | { |
875 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 881 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
876 | } | 882 | } |
877 | 883 | ||
878 | void KOMonthView::changeEventDisplay(Event *, int) | 884 | void KOMonthView::changeEventDisplay(Event *, int) |
879 | { | 885 | { |
880 | // this should be re-written to be much more efficient, but this | 886 | // this should be re-written to be much more efficient, but this |
881 | // quick-and-dirty-hack gets the job done for right now. | 887 | // quick-and-dirty-hack gets the job done for right now. |
882 | updateView(); | 888 | updateView(); |
883 | } | 889 | } |
884 | 890 | ||
885 | void KOMonthView::updateView() | 891 | void KOMonthView::updateView() |
886 | { | 892 | { |
887 | 893 | ||
888 | uint i; | 894 | uint i; |
889 | for( i = 0; i < mCells.count(); ++i ) { | 895 | for( i = 0; i < mCells.count(); ++i ) { |
890 | mCells[i]->updateCell(); | 896 | mCells[i]->updateCell(); |
891 | } | 897 | } |
892 | //qDebug("KOMonthView::updateView() "); | 898 | //qDebug("KOMonthView::updateView() "); |
893 | processSelectionChange(); | 899 | processSelectionChange(); |
894 | } | 900 | } |
895 | 901 | ||
896 | void KOMonthView::resizeEvent(QResizeEvent * e) | 902 | void KOMonthView::resizeEvent(QResizeEvent * e) |
897 | { | 903 | { |
898 | computeLayout(); | 904 | computeLayout(); |
899 | } | 905 | } |
900 | void KOMonthView::computeLayout() | 906 | void KOMonthView::computeLayout() |
901 | { | 907 | { |
902 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 908 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
903 | // note this only changes the text if the requested size crosses the | 909 | // note this only changes the text if the requested size crosses the |
904 | // threshold between big enough to support the full name and not big | 910 | // threshold between big enough to support the full name and not big |
905 | // enough. | 911 | // enough. |
906 | 912 | ||
907 | int daysToShow = 7; | 913 | int daysToShow = 7; |
908 | bool combinedSatSun = false; | 914 | bool combinedSatSun = false; |
909 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 915 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
910 | daysToShow = 6; | 916 | daysToShow = 6; |
911 | combinedSatSun = true; | 917 | combinedSatSun = true; |
912 | } | 918 | } |
913 | int tWid = topLevelWidget()->size().width(); | 919 | int tWid = topLevelWidget()->size().width(); |
914 | int tHei = topLevelWidget()->size().height(); | 920 | int tHei = topLevelWidget()->size().height(); |
915 | 921 | ||
916 | int wid = size().width();//e | 922 | int wid = size().width();//e |
917 | int hei = size().height()-1; | 923 | int hei = size().height()-1; |
918 | 924 | ||
919 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 925 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
920 | return; | 926 | return; |
921 | 927 | ||
922 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 928 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
923 | int weeklabelwid = fm.width( "888" ); | 929 | int weeklabelwid = fm.width( "888" ); |
924 | wid -= weeklabelwid; | 930 | wid -= weeklabelwid; |
925 | 931 | ||
926 | int colWid = wid / daysToShow; | 932 | int colWid = wid / daysToShow; |
927 | int lastCol = wid - ( colWid*6 ); | 933 | int lastCol = wid - ( colWid*6 ); |
928 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 934 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
929 | int cellHei = (hei - dayLabelHei) /6; | 935 | int cellHei = (hei - dayLabelHei) /6; |
930 | int colModulo = wid % daysToShow; | 936 | int colModulo = wid % daysToShow; |
931 | int rowModulo = (hei- dayLabelHei) % 6; | 937 | int rowModulo = (hei- dayLabelHei) % 6; |
932 | //qDebug("rowmod %d ", rowModulo); | 938 | //qDebug("rowmod %d ", rowModulo); |
933 | int i; | 939 | int i; |
934 | int x,y,w,h; | 940 | int x,y,w,h; |
935 | x= 0; | 941 | x= 0; |
936 | y= 0; | 942 | y= 0; |
937 | w = colWid; | 943 | w = colWid; |
938 | h = dayLabelHei ; | 944 | h = dayLabelHei ; |
939 | for ( i = 0; i < 7; i++) { | 945 | for ( i = 0; i < 7; i++) { |
940 | if ( i == daysToShow-colModulo ) | 946 | if ( i == daysToShow-colModulo ) |
941 | ++w; | 947 | ++w; |
942 | if ( combinedSatSun ) { | 948 | if ( combinedSatSun ) { |
943 | if ( i >= daysToShow-1 ) { | 949 | if ( i >= daysToShow-1 ) { |
944 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 950 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
945 | x -= w/2 ; | 951 | x -= w/2 ; |
946 | } | 952 | } |
947 | else | 953 | else |
948 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 954 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
949 | } else | 955 | } else |
950 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 956 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
951 | x += w; | 957 | x += w; |
952 | } | 958 | } |
953 | x= 0; | 959 | x= 0; |
954 | y= dayLabelHei; | 960 | y= dayLabelHei; |
955 | w = colWid; | 961 | w = colWid; |
956 | h = cellHei ; | 962 | h = cellHei ; |
957 | for ( i = 0; i < mCells.count(); ++i) { | 963 | for ( i = 0; i < mCells.count(); ++i) { |
958 | 964 | ||
959 | w = colWid; | 965 | w = colWid; |
960 | if ( ((i) % 7) >= 7-colModulo ) { | 966 | if ( ((i) % 7) >= 7-colModulo ) { |
961 | ++w; | 967 | ++w; |
962 | } | 968 | } |
963 | if ( i == (6-rowModulo)*7) | 969 | if ( i == (6-rowModulo)*7) |
964 | ++h; | 970 | ++h; |
965 | if ( combinedSatSun ) { | 971 | if ( combinedSatSun ) { |
966 | if ( (i)%7 >= daysToShow-1 ) { | 972 | if ( (i)%7 >= daysToShow-1 ) { |
967 | if ( (i)%7 == daysToShow-1 ) { | 973 | if ( (i)%7 == daysToShow-1 ) { |
968 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 974 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
969 | x -= w ;y += h/2; | 975 | x -= w ;y += h/2; |
970 | } else { | 976 | } else { |
971 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 977 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
972 | y -= h/2; | 978 | y -= h/2; |
973 | } | 979 | } |
974 | } else | 980 | } else |
975 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 981 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
976 | 982 | ||
977 | } | 983 | } |
978 | else | 984 | else |
979 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 985 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
980 | x += w; | 986 | x += w; |
981 | if ( x + w/2 > wid ) { | 987 | if ( x + w/2 > wid ) { |
982 | x = 0; | 988 | x = 0; |
983 | y += h; | 989 | y += h; |
984 | } | 990 | } |
985 | } | 991 | } |
986 | y= dayLabelHei; | 992 | y= dayLabelHei; |
987 | h = cellHei ; | 993 | h = cellHei ; |
988 | for ( i = 0; i < 6; i++) { | 994 | for ( i = 0; i < 6; i++) { |
989 | if ( i == (6-rowModulo)) | 995 | if ( i == (6-rowModulo)) |
990 | ++h; | 996 | ++h; |
991 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 997 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
992 | y += h; | 998 | y += h; |
993 | } | 999 | } |
994 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1000 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
995 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1001 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
996 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1002 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
997 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1003 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
998 | updateDayLabels(); | 1004 | updateDayLabels(); |
999 | } | 1005 | } |
1000 | 1006 | ||
1001 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1007 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1002 | { | 1008 | { |
1003 | mContextMenu->showIncidencePopup(incidence); | 1009 | mContextMenu->showIncidencePopup(incidence); |
1004 | /* | 1010 | /* |
1005 | if( incidence && incidence->type() == "Event" ) { | 1011 | if( incidence && incidence->type() == "Event" ) { |
1006 | Event *event = static_cast<Event *>(incidence); | 1012 | Event *event = static_cast<Event *>(incidence); |
1007 | mContextMenu->showEventPopup(event); | 1013 | mContextMenu->showEventPopup(event); |
1008 | } else { | 1014 | } else { |
1009 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1015 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1010 | } | 1016 | } |
1011 | */ | 1017 | */ |
1012 | } | 1018 | } |
1013 | MonthViewCell * KOMonthView::selectedCell( ) | 1019 | MonthViewCell * KOMonthView::selectedCell( ) |
1014 | { | 1020 | { |
1015 | return mSelectedCell; | 1021 | return mSelectedCell; |
1016 | } | 1022 | } |
1017 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1023 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1018 | { | 1024 | { |
1019 | // qDebug("KOMonthView::setSelectedCell "); | 1025 | // qDebug("KOMonthView::setSelectedCell "); |
1020 | if ( mSelectedCell && mSelectedCell != cell ) { | 1026 | if ( mSelectedCell && mSelectedCell != cell ) { |
1021 | MonthViewCell * mvc = mSelectedCell; | 1027 | MonthViewCell * mvc = mSelectedCell; |
1022 | mSelectedCell = cell; | 1028 | mSelectedCell = cell; |
1023 | mvc->deselect(); | 1029 | mvc->deselect(); |
1024 | } else | 1030 | } else |
1025 | mSelectedCell = cell; | 1031 | mSelectedCell = cell; |
1026 | // if ( mSelectedCell ) | 1032 | // if ( mSelectedCell ) |
1027 | // mSelectedCell->select(); | 1033 | // mSelectedCell->select(); |
1028 | if ( !mSelectedCell ) | 1034 | if ( !mSelectedCell ) |
1029 | emit incidenceSelected( 0 ); | 1035 | emit incidenceSelected( 0 ); |
1030 | else | 1036 | else |
1031 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1037 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1032 | } | 1038 | } |
1033 | 1039 | ||
1034 | void KOMonthView::processSelectionChange() | 1040 | void KOMonthView::processSelectionChange() |
1035 | { | 1041 | { |
1036 | QPtrList<Incidence> incidences = selectedIncidences(); | 1042 | QPtrList<Incidence> incidences = selectedIncidences(); |
1037 | if (incidences.count() > 0) { | 1043 | if (incidences.count() > 0) { |
1038 | emit incidenceSelected( incidences.first() ); | 1044 | emit incidenceSelected( incidences.first() ); |
1039 | } else { | 1045 | } else { |
1040 | emit incidenceSelected( 0 ); | 1046 | emit incidenceSelected( 0 ); |
1041 | } | 1047 | } |
1042 | } | 1048 | } |
1043 | 1049 | ||
1044 | void KOMonthView::clearSelection() | 1050 | void KOMonthView::clearSelection() |
1045 | { | 1051 | { |
1046 | if ( mSelectedCell ) { | 1052 | if ( mSelectedCell ) { |
1047 | mSelectedCell->deselect(); | 1053 | mSelectedCell->deselect(); |
1048 | mSelectedCell = 0; | 1054 | mSelectedCell = 0; |
1049 | } | 1055 | } |
1050 | } | 1056 | } |
1051 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1057 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1052 | { | 1058 | { |
1053 | 1059 | ||
1054 | e->ignore(); | 1060 | e->ignore(); |
1055 | 1061 | ||
1056 | } | 1062 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e94952f..5124057 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,253 +1,256 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qintdict.h> | 29 | #include <qintdict.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qptrvector.h> | 32 | #include <qptrvector.h> |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | #include <libkcal/event.h> | 35 | #include <libkcal/event.h> |
36 | 36 | ||
37 | #include "koeventview.h" | 37 | #include "koeventview.h" |
38 | 38 | ||
39 | class KOWeekButton : public QPushButton | 39 | class KOWeekButton : public QPushButton |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 43 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
44 | QPushButton( parent, name) | 44 | QPushButton( parent, name) |
45 | { | 45 | { |
46 | connect( this, SIGNAL( clicked() ), | 46 | connect( this, SIGNAL( clicked() ), |
47 | SLOT( bottonClicked() )); | 47 | SLOT( bottonClicked() )); |
48 | mNumber = -1; | 48 | mNumber = -1; |
49 | } | 49 | } |
50 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 50 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
51 | signals: | 51 | signals: |
52 | void selectWeekNum ( int ); | 52 | void selectWeekNum ( int ); |
53 | private: | 53 | private: |
54 | int mNumber; | 54 | int mNumber; |
55 | private slots : | 55 | private slots : |
56 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 56 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class KNoScrollListBox: public QListBox | 59 | class KNoScrollListBox: public QListBox |
60 | { | 60 | { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | public: | 62 | public: |
63 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 63 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
64 | ~KNoScrollListBox() {} | 64 | ~KNoScrollListBox() {} |
65 | QString getWhatsThisText(QPoint p) ; | 65 | QString getWhatsThisText(QPoint p) ; |
66 | 66 | ||
67 | signals: | 67 | signals: |
68 | void shiftDown(); | 68 | void shiftDown(); |
69 | void shiftUp(); | 69 | void shiftUp(); |
70 | void rightClick(); | 70 | void rightClick(); |
71 | 71 | ||
72 | protected slots: | 72 | protected slots: |
73 | void keyPressEvent(QKeyEvent *); | 73 | void keyPressEvent(QKeyEvent *); |
74 | void keyReleaseEvent(QKeyEvent *); | 74 | void keyReleaseEvent(QKeyEvent *); |
75 | void mousePressEvent(QMouseEvent *); | 75 | void mousePressEvent(QMouseEvent *); |
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | class MonthViewItem: public QListBoxItem | 79 | class MonthViewItem: public QListBoxItem |
80 | { | 80 | { |
81 | public: | 81 | public: |
82 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 82 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
83 | 83 | ||
84 | void setRecur(bool on) { mRecur = on; } | 84 | void setRecur(bool on) { mRecur = on; } |
85 | void setAlarm(bool on) { mAlarm = on; } | 85 | void setAlarm(bool on) { mAlarm = on; } |
86 | void setReply(bool on) { mReply = on; } | 86 | void setReply(bool on) { mReply = on; } |
87 | void setMoreInfo(bool on) { mInfo = on; } | 87 | void setMoreInfo(bool on) { mInfo = on; } |
88 | 88 | ||
89 | 89 | ||
90 | void setPalette(const QPalette &p) { mPalette = p; } | 90 | void setPalette(const QPalette &p) { mPalette = p; } |
91 | QPalette palette() const { return mPalette; } | 91 | QPalette palette() const { return mPalette; } |
92 | 92 | ||
93 | Incidence *incidence() const { return mIncidence; } | 93 | Incidence *incidence() const { return mIncidence; } |
94 | QDate incidenceDate() { return mDate; } | 94 | QDate incidenceDate() { return mDate; } |
95 | 95 | ||
96 | protected: | 96 | protected: |
97 | virtual void paint(QPainter *); | 97 | virtual void paint(QPainter *); |
98 | virtual int height(const QListBox *) const; | 98 | virtual int height(const QListBox *) const; |
99 | virtual int width(const QListBox *) const; | 99 | virtual int width(const QListBox *) const; |
100 | 100 | ||
101 | private: | 101 | private: |
102 | bool mRecur; | 102 | bool mRecur; |
103 | bool mAlarm; | 103 | bool mAlarm; |
104 | bool mReply; | 104 | bool mReply; |
105 | bool mInfo; | 105 | bool mInfo; |
106 | 106 | ||
107 | QPalette mPalette; | 107 | QPalette mPalette; |
108 | QDate mDate; | 108 | QDate mDate; |
109 | 109 | ||
110 | Incidence *mIncidence; | 110 | Incidence *mIncidence; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | 113 | ||
114 | class KOMonthView; | 114 | class KOMonthView; |
115 | 115 | ||
116 | class MonthViewCell : public QWidget | 116 | class MonthViewCell : public QWidget |
117 | { | 117 | { |
118 | Q_OBJECT | 118 | Q_OBJECT |
119 | public: | 119 | public: |
120 | MonthViewCell( KOMonthView * ); | 120 | MonthViewCell( KOMonthView * ); |
121 | 121 | ||
122 | void setDate( const QDate & ); | 122 | void setDate( const QDate & ); |
123 | QDate date() const; | 123 | QDate date() const; |
124 | 124 | ||
125 | void setPrimary( bool ); | 125 | void setPrimary( bool ); |
126 | bool isPrimary() const; | 126 | bool isPrimary() const; |
127 | 127 | ||
128 | void setHoliday( bool ); | 128 | void setHoliday( bool ); |
129 | void setHoliday( const QString & ); | 129 | void setHoliday( const QString & ); |
130 | 130 | ||
131 | void updateCell(); | 131 | void updateCell(); |
132 | 132 | ||
133 | void updateConfig(); | 133 | void updateConfig(); |
134 | 134 | ||
135 | void enableScrollBars( bool ); | 135 | void enableScrollBars( bool ); |
136 | 136 | ||
137 | Incidence *selectedIncidence(); | 137 | Incidence *selectedIncidence(); |
138 | QDate selectedIncidenceDate(); | 138 | QDate selectedIncidenceDate(); |
139 | 139 | ||
140 | void deselect(); | 140 | void deselect(); |
141 | void select(); | 141 | void select(); |
142 | 142 | ||
143 | signals: | 143 | signals: |
144 | void defaultAction( Incidence * ); | 144 | void defaultAction( Incidence * ); |
145 | void newEventSignal( QDateTime ); | 145 | void newEventSignal( QDateTime ); |
146 | void showDaySignal( QDate ); | ||
146 | 147 | ||
147 | protected: | 148 | protected: |
148 | void resizeEvent( QResizeEvent * ); | 149 | void resizeEvent( QResizeEvent * ); |
149 | 150 | ||
150 | protected slots: | 151 | protected slots: |
151 | void defaultAction( QListBoxItem * ); | 152 | void defaultAction( QListBoxItem * ); |
152 | void contextMenu( QListBoxItem * ); | 153 | void contextMenu( QListBoxItem * ); |
153 | void selection( QListBoxItem * ); | 154 | void selection( QListBoxItem * ); |
154 | void cellClicked( QListBoxItem * ); | 155 | void cellClicked( QListBoxItem * ); |
155 | void newEvent(); | 156 | void newEvent(); |
157 | void showDay(); | ||
156 | 158 | ||
157 | private: | 159 | private: |
158 | KOMonthView *mMonthView; | 160 | KOMonthView *mMonthView; |
159 | 161 | ||
160 | QDate mDate; | 162 | QDate mDate; |
161 | bool mPrimary; | 163 | bool mPrimary; |
162 | bool mHoliday; | 164 | bool mHoliday; |
163 | QString mHolidayString; | 165 | QString mHolidayString; |
164 | 166 | ||
165 | //QLabel *mLabel; | 167 | //QLabel *mLabel; |
166 | QPushButton *mLabel; | 168 | QPushButton *mLabel; |
167 | QListBox *mItemList; | 169 | QListBox *mItemList; |
168 | 170 | ||
169 | QSize mLabelSize; | 171 | QSize mLabelSize; |
170 | QSize mLabelBigSize; | 172 | QSize mLabelBigSize; |
171 | QPalette mHolidayPalette; | 173 | QPalette mHolidayPalette; |
172 | QPalette mStandardPalette; | 174 | QPalette mStandardPalette; |
173 | QPalette mPrimaryPalette; | 175 | QPalette mPrimaryPalette; |
174 | QPalette mNonPrimaryPalette; | 176 | QPalette mNonPrimaryPalette; |
175 | void setMyPalette(); | 177 | void setMyPalette(); |
176 | QPalette getPalette (); | 178 | QPalette getPalette (); |
177 | void keyPressEvent ( QKeyEvent * ) ; | 179 | void keyPressEvent ( QKeyEvent * ) ; |
178 | 180 | ||
179 | }; | 181 | }; |
180 | 182 | ||
181 | 183 | ||
182 | class KOMonthView: public KOEventView | 184 | class KOMonthView: public KOEventView |
183 | { | 185 | { |
184 | Q_OBJECT | 186 | Q_OBJECT |
185 | public: | 187 | public: |
186 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 188 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
187 | ~KOMonthView(); | 189 | ~KOMonthView(); |
188 | 190 | ||
189 | /** Returns maximum number of days supported by the komonthview */ | 191 | /** Returns maximum number of days supported by the komonthview */ |
190 | virtual int maxDatesHint(); | 192 | virtual int maxDatesHint(); |
191 | 193 | ||
192 | /** Returns number of currently shown dates. */ | 194 | /** Returns number of currently shown dates. */ |
193 | virtual int currentDateCount(); | 195 | virtual int currentDateCount(); |
194 | 196 | ||
195 | /** returns the currently selected events */ | 197 | /** returns the currently selected events */ |
196 | virtual QPtrList<Incidence> selectedIncidences(); | 198 | virtual QPtrList<Incidence> selectedIncidences(); |
197 | 199 | ||
198 | /** returns dates of the currently selected events */ | 200 | /** returns dates of the currently selected events */ |
199 | virtual DateList selectedDates(); | 201 | virtual DateList selectedDates(); |
200 | 202 | ||
201 | virtual void printPreview(CalPrinter *calPrinter, | 203 | virtual void printPreview(CalPrinter *calPrinter, |
202 | const QDate &, const QDate &); | 204 | const QDate &, const QDate &); |
203 | bool isMonthView() { return true; } | 205 | bool isMonthView() { return true; } |
204 | 206 | ||
205 | MonthViewCell * selectedCell(); | 207 | MonthViewCell * selectedCell(); |
206 | public slots: | 208 | public slots: |
207 | virtual void updateView(); | 209 | virtual void updateView(); |
208 | virtual void updateConfig(); | 210 | virtual void updateConfig(); |
209 | virtual void showDates(const QDate &start, const QDate &end); | 211 | virtual void showDates(const QDate &start, const QDate &end); |
210 | virtual void showEvents(QPtrList<Event> eventList); | 212 | virtual void showEvents(QPtrList<Event> eventList); |
211 | 213 | ||
212 | void changeEventDisplay(Event *, int); | 214 | void changeEventDisplay(Event *, int); |
213 | 215 | ||
214 | void clearSelection(); | 216 | void clearSelection(); |
215 | 217 | ||
216 | void showContextMenu( Incidence * ); | 218 | void showContextMenu( Incidence * ); |
217 | 219 | ||
218 | void setSelectedCell( MonthViewCell * ); | 220 | void setSelectedCell( MonthViewCell * ); |
219 | 221 | ||
220 | protected slots: | 222 | protected slots: |
221 | void processSelectionChange(); | 223 | void processSelectionChange(); |
222 | signals: | 224 | signals: |
223 | void selectWeekNum ( int ); | 225 | void selectWeekNum ( int ); |
226 | void showDaySignal( QDate ); | ||
224 | protected: | 227 | protected: |
225 | void resizeEvent(QResizeEvent *); | 228 | void resizeEvent(QResizeEvent *); |
226 | void viewChanged(); | 229 | void viewChanged(); |
227 | void updateDayLabels(); | 230 | void updateDayLabels(); |
228 | 231 | ||
229 | private: | 232 | private: |
230 | int mDaysPerWeek; | 233 | int mDaysPerWeek; |
231 | int mNumWeeks; | 234 | int mNumWeeks; |
232 | int mNumCells; | 235 | int mNumCells; |
233 | bool mWeekStartsMonday; | 236 | bool mWeekStartsMonday; |
234 | bool mShowSatSunComp; | 237 | bool mShowSatSunComp; |
235 | void computeLayout(); | 238 | void computeLayout(); |
236 | 239 | ||
237 | QPtrVector<MonthViewCell> mCells; | 240 | QPtrVector<MonthViewCell> mCells; |
238 | QPtrVector<QLabel> mDayLabels; | 241 | QPtrVector<QLabel> mDayLabels; |
239 | QPtrVector<KOWeekButton> mWeekLabels; | 242 | QPtrVector<KOWeekButton> mWeekLabels; |
240 | 243 | ||
241 | bool mShortDayLabels; | 244 | bool mShortDayLabels; |
242 | int mWidthLongDayLabel; | 245 | int mWidthLongDayLabel; |
243 | 246 | ||
244 | QDate mStartDate; | 247 | QDate mStartDate; |
245 | 248 | ||
246 | MonthViewCell *mSelectedCell; | 249 | MonthViewCell *mSelectedCell; |
247 | 250 | ||
248 | KOEventPopupMenu *mContextMenu; | 251 | KOEventPopupMenu *mContextMenu; |
249 | void keyPressEvent ( QKeyEvent * ) ; | 252 | void keyPressEvent ( QKeyEvent * ) ; |
250 | 253 | ||
251 | }; | 254 | }; |
252 | 255 | ||
253 | #endif | 256 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 391f98c..6e151f9 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,577 +1,580 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | ||
35 | #include "calendarview.h" | 36 | #include "calendarview.h" |
36 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
37 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
38 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
39 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
40 | #include "komonthview.h" | 41 | #include "komonthview.h" |
41 | #include "kolistview.h" | 42 | #include "kolistview.h" |
42 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
43 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
44 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
45 | #include "koprefs.h" | 46 | #include "koprefs.h" |
46 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
47 | 48 | ||
48 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
49 | //extern bool externFlagMonthviewBlockPainting; | 50 | //extern bool externFlagMonthviewBlockPainting; |
50 | 51 | ||
51 | //bool globalFlagBlockPainting = false; | 52 | //bool globalFlagBlockPainting = false; |
52 | int globalFlagBlockAgenda = 0; | 53 | int globalFlagBlockAgenda = 0; |
53 | int globalFlagBlockLabel = 0; | 54 | int globalFlagBlockLabel = 0; |
54 | int globalFlagBlockAgendaItemPaint = 1; | 55 | int globalFlagBlockAgendaItemPaint = 1; |
55 | int globalFlagBlockAgendaItemUpdate = 1; | 56 | int globalFlagBlockAgendaItemUpdate = 1; |
56 | 57 | ||
57 | 58 | ||
58 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 59 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
59 | QObject(), mMainView( mainView ) | 60 | QObject(), mMainView( mainView ) |
60 | { | 61 | { |
61 | mCurrentView = 0; | 62 | mCurrentView = 0; |
62 | 63 | ||
63 | mWhatsNextView = 0; | 64 | mWhatsNextView = 0; |
64 | mTodoView = 0; | 65 | mTodoView = 0; |
65 | mAgendaView = 0; | 66 | mAgendaView = 0; |
66 | mMonthView = 0; | 67 | mMonthView = 0; |
67 | mListView = 0; | 68 | mListView = 0; |
68 | mJournalView = 0; | 69 | mJournalView = 0; |
69 | mTimeSpanView = 0; | 70 | mTimeSpanView = 0; |
70 | mCurrentAgendaView = 0 ; | 71 | mCurrentAgendaView = 0 ; |
71 | mFlagShowNextxDays = false; | 72 | mFlagShowNextxDays = false; |
72 | } | 73 | } |
73 | 74 | ||
74 | KOViewManager::~KOViewManager() | 75 | KOViewManager::~KOViewManager() |
75 | { | 76 | { |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | KOrg::BaseView *KOViewManager::currentView() | 80 | KOrg::BaseView *KOViewManager::currentView() |
80 | { | 81 | { |
81 | return mCurrentView; | 82 | return mCurrentView; |
82 | } | 83 | } |
83 | 84 | ||
84 | void KOViewManager::readSettings(KConfig *config) | 85 | void KOViewManager::readSettings(KConfig *config) |
85 | { | 86 | { |
86 | config->setGroup("General"); | 87 | config->setGroup("General"); |
87 | QString view = config->readEntry("Current View"); | 88 | QString view = config->readEntry("Current View"); |
88 | if (view == "WhatsNext") showWhatsNextView(); | 89 | if (view == "WhatsNext") showWhatsNextView(); |
89 | else if (view == "Month") showMonthView(); | 90 | else if (view == "Month") showMonthView(); |
90 | else if (view == "List") showListView(); | 91 | else if (view == "List") showListView(); |
91 | else if (view == "Journal") showJournalView(); | 92 | else if (view == "Journal") showJournalView(); |
92 | else if (view == "TimeSpan") showTimeSpanView(); | 93 | else if (view == "TimeSpan") showTimeSpanView(); |
93 | else if (view == "Todo") showTodoView(); | 94 | else if (view == "Todo") showTodoView(); |
94 | else { | 95 | else { |
95 | showAgendaView(); | 96 | showAgendaView(); |
96 | } | 97 | } |
97 | } | 98 | } |
98 | 99 | ||
99 | void KOViewManager::writeSettings(KConfig *config) | 100 | void KOViewManager::writeSettings(KConfig *config) |
100 | { | 101 | { |
101 | config->setGroup("General"); | 102 | config->setGroup("General"); |
102 | 103 | ||
103 | QString view; | 104 | QString view; |
104 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 105 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
105 | else if (mCurrentView == mMonthView) view = "Month"; | 106 | else if (mCurrentView == mMonthView) view = "Month"; |
106 | else if (mCurrentView == mListView) view = "List"; | 107 | else if (mCurrentView == mListView) view = "List"; |
107 | else if (mCurrentView == mJournalView) view = "Journal"; | 108 | else if (mCurrentView == mJournalView) view = "Journal"; |
108 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 109 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
109 | else if (mCurrentView == mTodoView) view = "Todo"; | 110 | else if (mCurrentView == mTodoView) view = "Todo"; |
110 | else view = "Agenda"; | 111 | else view = "Agenda"; |
111 | 112 | ||
112 | config->writeEntry("Current View",view); | 113 | config->writeEntry("Current View",view); |
113 | 114 | ||
114 | if (mAgendaView) { | 115 | if (mAgendaView) { |
115 | mAgendaView->writeSettings(config); | 116 | mAgendaView->writeSettings(config); |
116 | } | 117 | } |
117 | if (mTimeSpanView) { | 118 | if (mTimeSpanView) { |
118 | mTimeSpanView->writeSettings(config); | 119 | mTimeSpanView->writeSettings(config); |
119 | } | 120 | } |
120 | if (mListView) { | 121 | if (mListView) { |
121 | mListView->writeSettings(config); | 122 | mListView->writeSettings(config); |
122 | } | 123 | } |
123 | if (mTodoView) { | 124 | if (mTodoView) { |
124 | mTodoView->saveLayout(config,"Todo View"); | 125 | mTodoView->saveLayout(config,"Todo View"); |
125 | } | 126 | } |
126 | } | 127 | } |
127 | 128 | ||
128 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 129 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
129 | { | 130 | { |
130 | 131 | ||
131 | //mFlagShowNextxDays = false; | 132 | //mFlagShowNextxDays = false; |
132 | //if(view == mCurrentView) return; | 133 | //if(view == mCurrentView) return; |
133 | if ( view == 0 ) { | 134 | if ( view == 0 ) { |
134 | view = mCurrentView; | 135 | view = mCurrentView; |
135 | if ( view == 0 ) | 136 | if ( view == 0 ) |
136 | return; | 137 | return; |
137 | } | 138 | } |
138 | bool full = fullScreen; | 139 | bool full = fullScreen; |
139 | if(view == mCurrentView && view != mWhatsNextView ) { | 140 | if(view == mCurrentView && view != mWhatsNextView ) { |
140 | if ( mCurrentAgendaView < 0 ) | 141 | if ( mCurrentAgendaView < 0 ) |
141 | return; | 142 | return; |
142 | full = mMainView->leftFrame()->isVisible(); | 143 | full = mMainView->leftFrame()->isVisible(); |
143 | } else { | 144 | } else { |
144 | mCurrentView = view; | 145 | mCurrentView = view; |
145 | 146 | ||
146 | // bool full = fullScreen; | 147 | // bool full = fullScreen; |
147 | bool isFull = !mMainView->leftFrame()->isVisible(); | 148 | bool isFull = !mMainView->leftFrame()->isVisible(); |
148 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 149 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
149 | full = true; | 150 | full = true; |
150 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 151 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
151 | full = false; | 152 | full = false; |
152 | } | 153 | } |
153 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 154 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
154 | raiseCurrentView( full ); | 155 | raiseCurrentView( full ); |
155 | mMainView->processIncidenceSelection( 0 ); | 156 | mMainView->processIncidenceSelection( 0 ); |
156 | mMainView->updateView(); | 157 | mMainView->updateView(); |
157 | mMainView->adaptNavigationUnits(); | 158 | mMainView->adaptNavigationUnits(); |
158 | } | 159 | } |
159 | 160 | ||
160 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 161 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
161 | { | 162 | { |
162 | //qDebug("raiseCurrentView "); | 163 | //qDebug("raiseCurrentView "); |
163 | mCurrentAgendaView = 0; | 164 | mCurrentAgendaView = 0; |
164 | int wid = mMainView->width() ; | 165 | int wid = mMainView->width() ; |
165 | int hei = mMainView->height(); | 166 | int hei = mMainView->height(); |
166 | if ( mCurrentView == mMonthView ) { | 167 | if ( mCurrentView == mMonthView ) { |
167 | mMainView->navigatorBar()->show(); | 168 | mMainView->navigatorBar()->show(); |
168 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 169 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
169 | //mMainView->navigatorBar()->hide(); | 170 | //mMainView->navigatorBar()->hide(); |
170 | } else { | 171 | } else { |
171 | mMainView->navigatorBar()->hide(); | 172 | mMainView->navigatorBar()->hide(); |
172 | } | 173 | } |
173 | if ( fullScreen ) { | 174 | if ( fullScreen ) { |
174 | mMainView->leftFrame()->hide(); | 175 | mMainView->leftFrame()->hide(); |
175 | } else { | 176 | } else { |
176 | mMainView->leftFrame()->show(); | 177 | mMainView->leftFrame()->show(); |
177 | if ( KOPrefs::instance()->mVerticalScreen ) | 178 | if ( KOPrefs::instance()->mVerticalScreen ) |
178 | hei -= mMainView->leftFrame()->height(); | 179 | hei -= mMainView->leftFrame()->height(); |
179 | else | 180 | else |
180 | wid -= mMainView->leftFrame()->width(); | 181 | wid -= mMainView->leftFrame()->width(); |
181 | } | 182 | } |
182 | 183 | ||
183 | if ( globalFlagBlockAgenda == 5 ) { | 184 | if ( globalFlagBlockAgenda == 5 ) { |
184 | globalFlagBlockAgenda = 4; | 185 | globalFlagBlockAgenda = 4; |
185 | globalFlagBlockAgendaItemPaint = 1; | 186 | globalFlagBlockAgendaItemPaint = 1; |
186 | } | 187 | } |
187 | mMainView->viewStack()->raiseWidget(mCurrentView); | 188 | mMainView->viewStack()->raiseWidget(mCurrentView); |
188 | if ( globalFlagBlockAgenda == 4 ) { | 189 | if ( globalFlagBlockAgenda == 4 ) { |
189 | if ( mCurrentView == mAgendaView ) { | 190 | if ( mCurrentView == mAgendaView ) { |
190 | //globalFlagBlockAgenda =1 ; | 191 | //globalFlagBlockAgenda =1 ; |
191 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 192 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
192 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 193 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
193 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 194 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
194 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 195 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
195 | qApp->processEvents(); | 196 | qApp->processEvents(); |
196 | //qDebug("qApp->processEvents() "); | 197 | //qDebug("qApp->processEvents() "); |
197 | globalFlagBlockAgenda = 0; | 198 | globalFlagBlockAgenda = 0; |
198 | mAgendaView->repaintAgenda(); | 199 | mAgendaView->repaintAgenda(); |
199 | 200 | ||
200 | } | 201 | } |
201 | globalFlagBlockAgenda = 0; | 202 | globalFlagBlockAgenda = 0; |
202 | } | 203 | } |
203 | //qDebug("raiseCurrentView ende "); | 204 | //qDebug("raiseCurrentView ende "); |
204 | } | 205 | } |
205 | 206 | ||
206 | void KOViewManager::updateView() | 207 | void KOViewManager::updateView() |
207 | { | 208 | { |
208 | // qDebug("KOViewManager::updateView() "); | 209 | // qDebug("KOViewManager::updateView() "); |
209 | // if we are updating mTodoView, we get endless recursion | 210 | // if we are updating mTodoView, we get endless recursion |
210 | if ( mTodoView == mCurrentView ) | 211 | if ( mTodoView == mCurrentView ) |
211 | return; | 212 | return; |
212 | if ( mCurrentView ) mCurrentView->updateView(); | 213 | if ( mCurrentView ) mCurrentView->updateView(); |
213 | 214 | ||
214 | } | 215 | } |
215 | 216 | ||
216 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 217 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
217 | { | 218 | { |
218 | // kdDebug() << "KOViewManager::updateView()" << endl; | 219 | // kdDebug() << "KOViewManager::updateView()" << endl; |
219 | 220 | ||
220 | if (mCurrentView) mCurrentView->showDates(start, end); | 221 | if (mCurrentView) mCurrentView->showDates(start, end); |
221 | 222 | ||
222 | if (mTodoView) mTodoView->updateView(); | 223 | if (mTodoView) mTodoView->updateView(); |
223 | } | 224 | } |
224 | 225 | ||
225 | 226 | ||
226 | void KOViewManager::updateWNview() | 227 | void KOViewManager::updateWNview() |
227 | { | 228 | { |
228 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 229 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
229 | mWhatsNextView->updateView(); | 230 | mWhatsNextView->updateView(); |
230 | 231 | ||
231 | } | 232 | } |
232 | void KOViewManager::showWhatsNextView() | 233 | void KOViewManager::showWhatsNextView() |
233 | { | 234 | { |
234 | if (!mWhatsNextView) { | 235 | if (!mWhatsNextView) { |
235 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 236 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
236 | "KOViewManager::WhatsNextView"); | 237 | "KOViewManager::WhatsNextView"); |
237 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 238 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
238 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 239 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
239 | addView(mWhatsNextView); | 240 | addView(mWhatsNextView); |
240 | } | 241 | } |
241 | globalFlagBlockAgenda = 1; | 242 | globalFlagBlockAgenda = 1; |
242 | showView(mWhatsNextView, true ); | 243 | showView(mWhatsNextView, true ); |
243 | //mWhatsNextView->updateView(); | 244 | //mWhatsNextView->updateView(); |
244 | 245 | ||
245 | } | 246 | } |
246 | 247 | ||
247 | void KOViewManager::showListView() | 248 | void KOViewManager::showListView() |
248 | { | 249 | { |
249 | if (!mListView) { | 250 | if (!mListView) { |
250 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 251 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
251 | addView(mListView); | 252 | addView(mListView); |
252 | 253 | ||
253 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 254 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
254 | mMainView, SLOT(showIncidence(Incidence *))); | 255 | mMainView, SLOT(showIncidence(Incidence *))); |
255 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 256 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
256 | mMainView, SLOT(editIncidence(Incidence *))); | 257 | mMainView, SLOT(editIncidence(Incidence *))); |
257 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 258 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
258 | mMainView, SLOT(deleteIncidence(Incidence *))); | 259 | mMainView, SLOT(deleteIncidence(Incidence *))); |
259 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 260 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
260 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 261 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
261 | connect( mListView, SIGNAL( signalNewEvent() ), | 262 | connect( mListView, SIGNAL( signalNewEvent() ), |
262 | mMainView, SLOT( newEvent() ) ); | 263 | mMainView, SLOT( newEvent() ) ); |
263 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 264 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
264 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 265 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
265 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 266 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
266 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 267 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
267 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 268 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
268 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 269 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
269 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 270 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
270 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 271 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
271 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 272 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
272 | } | 273 | } |
273 | // bool temp = mFlagShowNextxDays; | 274 | // bool temp = mFlagShowNextxDays; |
274 | //globalFlagBlockPainting = true; | 275 | //globalFlagBlockPainting = true; |
275 | globalFlagBlockAgenda = 1; | 276 | globalFlagBlockAgenda = 1; |
276 | if ( KOPrefs::instance()->mListViewMonthTimespan ) | 277 | if ( KOPrefs::instance()->mListViewMonthTimespan ) |
277 | mMainView->dateNavigator()->selectMonth(); | 278 | mMainView->dateNavigator()->selectMonth(); |
278 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 279 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
279 | //mFlagShowNextxDays = temp; | 280 | //mFlagShowNextxDays = temp; |
280 | } | 281 | } |
281 | 282 | ||
282 | void KOViewManager::showAgendaView( bool fullScreen ) | 283 | void KOViewManager::showAgendaView( bool fullScreen ) |
283 | { | 284 | { |
284 | 285 | ||
285 | mMainView->dialogManager()->hideSearchDialog(); | 286 | mMainView->dialogManager()->hideSearchDialog(); |
286 | // qDebug("KOViewManager::showAgendaView "); | 287 | // qDebug("KOViewManager::showAgendaView "); |
287 | bool full; | 288 | bool full; |
288 | full = fullScreen; | 289 | full = fullScreen; |
289 | if (!mAgendaView) { | 290 | if (!mAgendaView) { |
290 | full = false; | 291 | full = false; |
291 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 292 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
292 | addView(mAgendaView); | 293 | addView(mAgendaView); |
293 | #ifndef DESKTOP_VERSION | 294 | #ifndef DESKTOP_VERSION |
294 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 295 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
295 | #endif | 296 | #endif |
296 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 297 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
297 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 298 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
298 | 299 | ||
299 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 300 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
300 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 301 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
301 | mMainView, SLOT(newEvent(QDateTime))); | 302 | mMainView, SLOT(newEvent(QDateTime))); |
302 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 303 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
303 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 304 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
304 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 305 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
305 | mMainView, SLOT(newEvent(QDate))); | 306 | mMainView, SLOT(newEvent(QDate))); |
306 | 307 | ||
307 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 308 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
308 | mMainView, SLOT(editIncidence(Incidence *))); | 309 | mMainView, SLOT(editIncidence(Incidence *))); |
309 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 310 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
310 | mMainView, SLOT(showIncidence(Incidence *))); | 311 | mMainView, SLOT(showIncidence(Incidence *))); |
311 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 312 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
312 | mMainView, SLOT(deleteIncidence(Incidence *))); | 313 | mMainView, SLOT(deleteIncidence(Incidence *))); |
313 | 314 | ||
314 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 315 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 316 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
316 | 317 | ||
317 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 318 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
318 | mMainView, SLOT( toggleExpand() ) ); | 319 | mMainView, SLOT( toggleExpand() ) ); |
319 | 320 | ||
320 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 321 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
321 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 322 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
322 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 323 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
323 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 324 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
324 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 325 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
325 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 326 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
326 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 327 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
327 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 328 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
328 | SLOT( updateTodo( Todo *, int ) ) ); | 329 | SLOT( updateTodo( Todo *, int ) ) ); |
329 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 330 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
330 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 331 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
331 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 332 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
332 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 333 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
333 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 334 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
334 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 335 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
335 | mAgendaView->readSettings(); | 336 | mAgendaView->readSettings(); |
336 | mAgendaView->updateConfig(); | 337 | mAgendaView->updateConfig(); |
337 | } | 338 | } |
338 | 339 | ||
339 | showView( mAgendaView, full); | 340 | showView( mAgendaView, full); |
340 | 341 | ||
341 | } | 342 | } |
342 | 343 | ||
343 | void KOViewManager::showDayView() | 344 | void KOViewManager::showDayView() |
344 | { | 345 | { |
345 | mFlagShowNextxDays = false; | 346 | mFlagShowNextxDays = false; |
346 | globalFlagBlockLabel = 1; | 347 | globalFlagBlockLabel = 1; |
347 | globalFlagBlockAgenda = 1; | 348 | globalFlagBlockAgenda = 1; |
348 | if ( mCurrentAgendaView != 1 ) | 349 | if ( mCurrentAgendaView != 1 ) |
349 | mCurrentAgendaView = -1; | 350 | mCurrentAgendaView = -1; |
350 | showAgendaView(); | 351 | showAgendaView(); |
351 | qApp->processEvents(); | 352 | qApp->processEvents(); |
352 | globalFlagBlockAgenda = 2; | 353 | globalFlagBlockAgenda = 2; |
353 | globalFlagBlockLabel = 0; | 354 | globalFlagBlockLabel = 0; |
354 | mMainView->dateNavigator()->selectDates( 1 ); | 355 | mMainView->dateNavigator()->selectDates( 1 ); |
355 | mCurrentAgendaView = 1 ; | 356 | mCurrentAgendaView = 1 ; |
356 | 357 | ||
357 | } | 358 | } |
358 | 359 | ||
359 | void KOViewManager::showWorkWeekView() | 360 | void KOViewManager::showWorkWeekView() |
360 | { | 361 | { |
361 | mFlagShowNextxDays = false; | 362 | mFlagShowNextxDays = false; |
362 | globalFlagBlockAgenda = 1; | 363 | globalFlagBlockAgenda = 1; |
363 | globalFlagBlockLabel = 1; | 364 | globalFlagBlockLabel = 1; |
364 | if ( mCurrentAgendaView != 5 ) | 365 | if ( mCurrentAgendaView != 5 ) |
365 | mCurrentAgendaView = -1; | 366 | mCurrentAgendaView = -1; |
366 | showAgendaView(); | 367 | showAgendaView(); |
367 | qApp->processEvents(); | 368 | qApp->processEvents(); |
368 | globalFlagBlockAgenda = 2; | 369 | globalFlagBlockAgenda = 2; |
369 | globalFlagBlockLabel = 0; | 370 | globalFlagBlockLabel = 0; |
370 | mMainView->dateNavigator()->selectWorkWeek(); | 371 | mMainView->dateNavigator()->selectWorkWeek(); |
371 | mCurrentAgendaView = 5 ; | 372 | mCurrentAgendaView = 5 ; |
372 | 373 | ||
373 | } | 374 | } |
374 | 375 | ||
375 | void KOViewManager::showWeekView() | 376 | void KOViewManager::showWeekView() |
376 | { | 377 | { |
377 | /* | 378 | /* |
378 | globalFlagBlockAgenda = 2; | 379 | globalFlagBlockAgenda = 2; |
379 | qDebug("4globalFlagBlockAgenda = 2; "); | 380 | qDebug("4globalFlagBlockAgenda = 2; "); |
380 | //globalFlagBlockPainting = true; | 381 | //globalFlagBlockPainting = true; |
381 | mMainView->dateNavigator()->selectWeek(); | 382 | mMainView->dateNavigator()->selectWeek(); |
382 | showAgendaView(); | 383 | showAgendaView(); |
383 | */ | 384 | */ |
384 | 385 | ||
385 | 386 | ||
386 | mFlagShowNextxDays = false; | 387 | mFlagShowNextxDays = false; |
387 | globalFlagBlockAgenda = 1; | 388 | globalFlagBlockAgenda = 1; |
388 | globalFlagBlockLabel = 1; | 389 | globalFlagBlockLabel = 1; |
389 | if ( mCurrentAgendaView != 7 ) | 390 | if ( mCurrentAgendaView != 7 ) |
390 | mCurrentAgendaView = -1; | 391 | mCurrentAgendaView = -1; |
391 | showAgendaView(); | 392 | showAgendaView(); |
392 | qApp->processEvents(); | 393 | qApp->processEvents(); |
393 | globalFlagBlockAgenda = 2; | 394 | globalFlagBlockAgenda = 2; |
394 | globalFlagBlockLabel = 0; | 395 | globalFlagBlockLabel = 0; |
395 | mMainView->dateNavigator()->selectWeek(); | 396 | mMainView->dateNavigator()->selectWeek(); |
396 | mCurrentAgendaView = 7 ; | 397 | mCurrentAgendaView = 7 ; |
397 | } | 398 | } |
398 | 399 | ||
399 | void KOViewManager::showNextXView() | 400 | void KOViewManager::showNextXView() |
400 | { | 401 | { |
401 | 402 | ||
402 | globalFlagBlockAgenda = 1; | 403 | globalFlagBlockAgenda = 1; |
403 | if ( mCurrentAgendaView != 3 ) | 404 | if ( mCurrentAgendaView != 3 ) |
404 | mCurrentAgendaView = -1; | 405 | mCurrentAgendaView = -1; |
405 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 406 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
406 | globalFlagBlockAgenda = 2; | 407 | globalFlagBlockAgenda = 2; |
407 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 408 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
408 | KOPrefs::instance()->mNextXDays ); | 409 | KOPrefs::instance()->mNextXDays ); |
409 | mFlagShowNextxDays = true; | 410 | mFlagShowNextxDays = true; |
410 | mCurrentAgendaView = 3 ; | 411 | mCurrentAgendaView = 3 ; |
411 | } | 412 | } |
412 | bool KOViewManager::showsNextDays() | 413 | bool KOViewManager::showsNextDays() |
413 | { | 414 | { |
414 | return mFlagShowNextxDays; | 415 | return mFlagShowNextxDays; |
415 | } | 416 | } |
416 | void KOViewManager::showMonthView() | 417 | void KOViewManager::showMonthView() |
417 | { | 418 | { |
418 | if (!mMonthView) { | 419 | if (!mMonthView) { |
419 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 420 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
420 | 421 | ||
421 | addView(mMonthView); | 422 | addView(mMonthView); |
422 | // mMonthView->show(); | 423 | // mMonthView->show(); |
423 | // SIGNALS/SLOTS FOR MONTH VIEW | 424 | // SIGNALS/SLOTS FOR MONTH VIEW |
424 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 425 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
425 | mMainView, SLOT(newEvent(QDateTime))); | 426 | mMainView, SLOT(newEvent(QDateTime))); |
426 | 427 | ||
427 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 428 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
428 | mMainView, SLOT(showIncidence(Incidence *))); | 429 | mMainView, SLOT(showIncidence(Incidence *))); |
429 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 430 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
430 | mMainView, SLOT(editIncidence(Incidence *))); | 431 | mMainView, SLOT(editIncidence(Incidence *))); |
431 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 432 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
432 | mMainView, SLOT(deleteIncidence(Incidence *))); | 433 | mMainView, SLOT(deleteIncidence(Incidence *))); |
433 | 434 | ||
434 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 435 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
435 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 436 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
436 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 437 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
437 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 438 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
438 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 439 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
439 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 440 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
440 | 441 | ||
441 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 442 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
442 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 443 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
443 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 444 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
444 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 445 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
445 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 446 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
446 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 447 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
448 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | ||
449 | mMainView, SLOT ( showDay( QDate ) ) ); | ||
447 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 450 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
448 | mMonthView->updateConfig(); | 451 | mMonthView->updateConfig(); |
449 | } | 452 | } |
450 | 453 | ||
451 | globalFlagBlockAgenda = 1; | 454 | globalFlagBlockAgenda = 1; |
452 | //mFlagShowNextxDays = false; | 455 | //mFlagShowNextxDays = false; |
453 | // if(mMonthView == mCurrentView) return; | 456 | // if(mMonthView == mCurrentView) return; |
454 | mMainView->dateNavigator()->selectMonth(); | 457 | mMainView->dateNavigator()->selectMonth(); |
455 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 458 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
456 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 459 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
457 | 460 | ||
458 | showView(mMonthView, true ); | 461 | showView(mMonthView, true ); |
459 | 462 | ||
460 | } | 463 | } |
461 | 464 | ||
462 | void KOViewManager::showTodoView() | 465 | void KOViewManager::showTodoView() |
463 | { | 466 | { |
464 | //mFlagShowNextxDays = false; | 467 | //mFlagShowNextxDays = false; |
465 | if ( !mTodoView ) { | 468 | if ( !mTodoView ) { |
466 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 469 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
467 | "KOViewManager::TodoView" ); | 470 | "KOViewManager::TodoView" ); |
468 | 471 | ||
469 | addView( mTodoView ); | 472 | addView( mTodoView ); |
470 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 473 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
471 | 474 | ||
472 | // SIGNALS/SLOTS FOR TODO VIEW | 475 | // SIGNALS/SLOTS FOR TODO VIEW |
473 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 476 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
474 | mMainView, SLOT( newTodo() ) ); | 477 | mMainView, SLOT( newTodo() ) ); |
475 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 478 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
476 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 479 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
477 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 480 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
478 | mMainView, SLOT( showTodo( Todo * ) ) ); | 481 | mMainView, SLOT( showTodo( Todo * ) ) ); |
479 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 482 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
480 | mMainView, SLOT( editTodo( Todo * ) ) ); | 483 | mMainView, SLOT( editTodo( Todo * ) ) ); |
481 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 484 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
482 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 485 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
483 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 486 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
484 | mMainView, SLOT( purgeCompleted() ) ); | 487 | mMainView, SLOT( purgeCompleted() ) ); |
485 | 488 | ||
486 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 489 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
487 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 490 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
488 | 491 | ||
489 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 492 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
490 | SLOT( updateConfig() ) ); | 493 | SLOT( updateConfig() ) ); |
491 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 494 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
492 | SLOT( updateTodo( Todo *, int ) ) ); | 495 | SLOT( updateTodo( Todo *, int ) ) ); |
493 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 496 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
494 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 497 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
495 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 498 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
496 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 499 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
497 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 500 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
498 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 501 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
499 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 502 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
500 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 503 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
501 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 504 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
502 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 505 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
503 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 506 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
504 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 507 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
505 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 508 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
506 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 509 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
507 | KConfig *config = KOGlobals::config(); | 510 | KConfig *config = KOGlobals::config(); |
508 | mTodoView->restoreLayout(config,"Todo View"); | 511 | mTodoView->restoreLayout(config,"Todo View"); |
509 | } | 512 | } |
510 | 513 | ||
511 | globalFlagBlockAgenda = 1; | 514 | globalFlagBlockAgenda = 1; |
512 | showView( mTodoView, true ); | 515 | showView( mTodoView, true ); |
513 | 516 | ||
514 | } | 517 | } |
515 | 518 | ||
516 | void KOViewManager::showJournalView() | 519 | void KOViewManager::showJournalView() |
517 | { | 520 | { |
518 | //mFlagShowNextxDays = false; | 521 | //mFlagShowNextxDays = false; |
519 | if (!mJournalView) { | 522 | if (!mJournalView) { |
520 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 523 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
521 | "KOViewManager::JournalView"); | 524 | "KOViewManager::JournalView"); |
522 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 525 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
523 | SLOT( updateConfig() ) ); | 526 | SLOT( updateConfig() ) ); |
524 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 527 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
525 | addView(mJournalView); | 528 | addView(mJournalView); |
526 | } | 529 | } |
527 | 530 | ||
528 | showView(mJournalView); | 531 | showView(mJournalView); |
529 | } | 532 | } |
530 | 533 | ||
531 | void KOViewManager::showTimeSpanView() | 534 | void KOViewManager::showTimeSpanView() |
532 | { | 535 | { |
533 | //mFlagShowNextxDays = false; | 536 | //mFlagShowNextxDays = false; |
534 | if (!mTimeSpanView) { | 537 | if (!mTimeSpanView) { |
535 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 538 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
536 | "KOViewManager::TimeSpanView"); | 539 | "KOViewManager::TimeSpanView"); |
537 | addView(mTimeSpanView); | 540 | addView(mTimeSpanView); |
538 | 541 | ||
539 | mTimeSpanView->readSettings(); | 542 | mTimeSpanView->readSettings(); |
540 | } | 543 | } |
541 | 544 | ||
542 | showView(mTimeSpanView); | 545 | showView(mTimeSpanView); |
543 | } | 546 | } |
544 | 547 | ||
545 | Incidence *KOViewManager::currentSelection() | 548 | Incidence *KOViewManager::currentSelection() |
546 | { | 549 | { |
547 | if (!mCurrentView) return 0; | 550 | if (!mCurrentView) return 0; |
548 | if ( mCurrentView == mListView ) { | 551 | if ( mCurrentView == mListView ) { |
549 | if ( mListView->currentItem() ) | 552 | if ( mListView->currentItem() ) |
550 | return mListView->currentItem(); | 553 | return mListView->currentItem(); |
551 | } | 554 | } |
552 | return mCurrentView->selectedIncidences().first(); | 555 | return mCurrentView->selectedIncidences().first(); |
553 | } | 556 | } |
554 | 557 | ||
555 | QDate KOViewManager::currentSelectionDate() | 558 | QDate KOViewManager::currentSelectionDate() |
556 | { | 559 | { |
557 | QDate qd; | 560 | QDate qd; |
558 | if (mCurrentView) { | 561 | if (mCurrentView) { |
559 | DateList qvl = mCurrentView->selectedDates(); | 562 | DateList qvl = mCurrentView->selectedDates(); |
560 | if (!qvl.isEmpty()) qd = qvl.first(); | 563 | if (!qvl.isEmpty()) qd = qvl.first(); |
561 | } | 564 | } |
562 | return qd; | 565 | return qd; |
563 | } | 566 | } |
564 | 567 | ||
565 | void KOViewManager::addView(KOrg::BaseView *view) | 568 | void KOViewManager::addView(KOrg::BaseView *view) |
566 | { | 569 | { |
567 | #if QT_VERSION >= 300 | 570 | #if QT_VERSION >= 300 |
568 | mMainView->viewStack()->addWidget( view ); | 571 | mMainView->viewStack()->addWidget( view ); |
569 | #else | 572 | #else |
570 | mMainView->viewStack()->addWidget( view, 1 ); | 573 | mMainView->viewStack()->addWidget( view, 1 ); |
571 | #endif | 574 | #endif |
572 | } | 575 | } |
573 | 576 | ||
574 | void KOViewManager::setDocumentId( const QString &id ) | 577 | void KOViewManager::setDocumentId( const QString &id ) |
575 | { | 578 | { |
576 | if (mTodoView) mTodoView->setDocumentId( id ); | 579 | if (mTodoView) mTodoView->setDocumentId( id ); |
577 | } | 580 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 46ae6a0..a652c05 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1910 +1,1917 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | qApp->processEvents(); | 116 | qApp->processEvents(); |
117 | int dw = QApplication::desktop()->width(); | 117 | int dw = QApplication::desktop()->width(); |
118 | int dh = QApplication::desktop()->height(); | 118 | int dh = QApplication::desktop()->height(); |
119 | move( (dw-width())/2, (dh - height() )/2 ); | 119 | move( (dw-width())/2, (dh - height() )/2 ); |
120 | } | 120 | } |
121 | 121 | ||
122 | public: | 122 | public: |
123 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 123 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
124 | QCheckBox* mWriteBackFuture; | 124 | QCheckBox* mWriteBackFuture; |
125 | QSpinBox* mWriteBackFutureWeeks; | 125 | QSpinBox* mWriteBackFutureWeeks; |
126 | }; | 126 | }; |
127 | 127 | ||
128 | int globalFlagBlockStartup; | 128 | int globalFlagBlockStartup; |
129 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 129 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
130 | QMainWindow( parent, name ) | 130 | QMainWindow( parent, name ) |
131 | { | 131 | { |
132 | 132 | ||
133 | #ifdef DESKTOP_VERSION | 133 | #ifdef DESKTOP_VERSION |
134 | setFont( QFont("Arial"), 14 ); | 134 | setFont( QFont("Arial"), 14 ); |
135 | #endif | 135 | #endif |
136 | mClosed = false; | 136 | mClosed = false; |
137 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 137 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
138 | QString confFile = locateLocal("config","korganizerrc"); | 138 | QString confFile = locateLocal("config","korganizerrc"); |
139 | QFileInfo finf ( confFile ); | 139 | QFileInfo finf ( confFile ); |
140 | bool showWarning = !finf.exists(); | 140 | bool showWarning = !finf.exists(); |
141 | setIcon(SmallIcon( "ko24" ) ); | 141 | setIcon(SmallIcon( "ko24" ) ); |
142 | mBlockAtStartup = true; | 142 | mBlockAtStartup = true; |
143 | mFlagKeyPressed = false; | 143 | mFlagKeyPressed = false; |
144 | setCaption("KOrganizer/Pi"); | 144 | setCaption("KOrganizer/Pi"); |
145 | KOPrefs *p = KOPrefs::instance(); | 145 | KOPrefs *p = KOPrefs::instance(); |
146 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 146 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
147 | if ( p->mHourSize > 18 ) | 147 | if ( p->mHourSize > 18 ) |
148 | p->mHourSize = 18; | 148 | p->mHourSize = 18; |
149 | QMainWindow::ToolBarDock tbd; | 149 | QMainWindow::ToolBarDock tbd; |
150 | if ( p->mToolBarHor ) { | 150 | if ( p->mToolBarHor ) { |
151 | if ( p->mToolBarUp ) | 151 | if ( p->mToolBarUp ) |
152 | tbd = Bottom; | 152 | tbd = Bottom; |
153 | else | 153 | else |
154 | tbd = Top; | 154 | tbd = Top; |
155 | } | 155 | } |
156 | else { | 156 | else { |
157 | if ( p->mToolBarUp ) | 157 | if ( p->mToolBarUp ) |
158 | tbd = Right; | 158 | tbd = Right; |
159 | else | 159 | else |
160 | tbd = Left; | 160 | tbd = Left; |
161 | } | 161 | } |
162 | if ( KOPrefs::instance()->mUseAppColors ) | 162 | if ( KOPrefs::instance()->mUseAppColors ) |
163 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 163 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
164 | globalFlagBlockStartup = 1; | 164 | globalFlagBlockStartup = 1; |
165 | iconToolBar = new QPEToolBar( this ); | 165 | iconToolBar = new QPEToolBar( this ); |
166 | addToolBar (iconToolBar , tbd ); | 166 | addToolBar (iconToolBar , tbd ); |
167 | mCalendarModifiedFlag = false; | 167 | mCalendarModifiedFlag = false; |
168 | 168 | ||
169 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 169 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
170 | splash->setAlignment ( AlignCenter ); | 170 | splash->setAlignment ( AlignCenter ); |
171 | setCentralWidget( splash ); | 171 | setCentralWidget( splash ); |
172 | #ifndef DESKTOP_VERSION | 172 | #ifndef DESKTOP_VERSION |
173 | showMaximized(); | 173 | showMaximized(); |
174 | #endif | 174 | #endif |
175 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 175 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
176 | setDefaultPreferences(); | 176 | setDefaultPreferences(); |
177 | mCalendar = new CalendarLocal(); | 177 | mCalendar = new CalendarLocal(); |
178 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 178 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
179 | mView->hide(); | 179 | mView->hide(); |
180 | //mView->resize(splash->size() ); | 180 | //mView->resize(splash->size() ); |
181 | initActions(); | 181 | initActions(); |
182 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 182 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
183 | mSyncManager->setBlockSave(false); | 183 | mSyncManager->setBlockSave(false); |
184 | mView->setSyncManager(mSyncManager); | 184 | mView->setSyncManager(mSyncManager); |
185 | #ifndef DESKTOP_VERSION | 185 | #ifndef DESKTOP_VERSION |
186 | iconToolBar->show(); | 186 | iconToolBar->show(); |
187 | qApp->processEvents(); | 187 | qApp->processEvents(); |
188 | #endif | 188 | #endif |
189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
190 | int vh = height() ; | 190 | int vh = height() ; |
191 | int vw = width(); | 191 | int vw = width(); |
192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
194 | vh -= iconToolBar->height(); | 194 | vh -= iconToolBar->height(); |
195 | } else { | 195 | } else { |
196 | vw -= iconToolBar->height(); | 196 | vw -= iconToolBar->height(); |
197 | } | 197 | } |
198 | //mView->setMaximumSize( splash->size() ); | 198 | //mView->setMaximumSize( splash->size() ); |
199 | //mView->resize( splash->size() ); | 199 | //mView->resize( splash->size() ); |
200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
201 | mView->readSettings(); | 201 | mView->readSettings(); |
202 | bool newFile = false; | 202 | bool newFile = false; |
203 | if( !QFile::exists( defaultFileName() ) ) { | 203 | if( !QFile::exists( defaultFileName() ) ) { |
204 | QFileInfo finfo ( defaultFileName() ); | 204 | QFileInfo finfo ( defaultFileName() ); |
205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
206 | qDebug("oldfile %s ", oldFile.latin1()); | 206 | qDebug("oldfile %s ", oldFile.latin1()); |
207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
208 | finfo.setFile( oldFile ); | 208 | finfo.setFile( oldFile ); |
209 | if (finfo.exists() ) { | 209 | if (finfo.exists() ) { |
210 | KMessageBox::information( this, message); | 210 | KMessageBox::information( this, message); |
211 | mView->openCalendar( oldFile ); | 211 | mView->openCalendar( oldFile ); |
212 | qApp->processEvents(); | 212 | qApp->processEvents(); |
213 | } else { | 213 | } else { |
214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
215 | finfo.setFile( oldFile ); | 215 | finfo.setFile( oldFile ); |
216 | if (finfo.exists() ) { | 216 | if (finfo.exists() ) { |
217 | KMessageBox::information( this, message); | 217 | KMessageBox::information( this, message); |
218 | mView->openCalendar( oldFile ); | 218 | mView->openCalendar( oldFile ); |
219 | qApp->processEvents(); | 219 | qApp->processEvents(); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | mView->saveCalendar( defaultFileName() ); | 222 | mView->saveCalendar( defaultFileName() ); |
223 | newFile = true; | 223 | newFile = true; |
224 | } | 224 | } |
225 | 225 | ||
226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
227 | mView->openCalendar( defaultFileName() ); | 227 | mView->openCalendar( defaultFileName() ); |
228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
230 | 230 | ||
231 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 231 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
232 | KOPrefs::instance()->setCategoryDefaults(); | 232 | KOPrefs::instance()->setCategoryDefaults(); |
233 | int count = mView->addCategories(); | 233 | int count = mView->addCategories(); |
234 | } | 234 | } |
235 | processIncidenceSelection( 0 ); | 235 | processIncidenceSelection( 0 ); |
236 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 236 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
237 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 237 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
238 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 238 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
239 | SLOT( slotModifiedChanged( bool ) ) ); | 239 | SLOT( slotModifiedChanged( bool ) ) ); |
240 | 240 | ||
241 | 241 | ||
242 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 242 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
243 | SLOT( disableBR(bool) ) ); | 243 | SLOT( disableBR(bool) ) ); |
244 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 244 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
245 | mView->setModified( false ); | 245 | mView->setModified( false ); |
246 | mBlockAtStartup = false; | 246 | mBlockAtStartup = false; |
247 | mView->setModified( false ); | 247 | mView->setModified( false ); |
248 | setCentralWidget( mView ); | 248 | setCentralWidget( mView ); |
249 | globalFlagBlockStartup = 0; | 249 | globalFlagBlockStartup = 0; |
250 | mView->show(); | 250 | mView->show(); |
251 | delete splash; | 251 | delete splash; |
252 | if ( newFile ) | 252 | if ( newFile ) |
253 | mView->updateConfig(); | 253 | mView->updateConfig(); |
254 | // qApp->processEvents(); | 254 | // qApp->processEvents(); |
255 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 255 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
256 | //fillSyncMenu(); | 256 | //fillSyncMenu(); |
257 | 257 | ||
258 | 258 | ||
259 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 259 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
260 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 260 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
261 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 261 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
262 | mSyncManager->setDefaultFileName( defaultFileName()); | 262 | mSyncManager->setDefaultFileName( defaultFileName()); |
263 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 263 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
264 | mSyncManager->fillSyncMenu(); | 264 | mSyncManager->fillSyncMenu(); |
265 | 265 | ||
266 | 266 | ||
267 | 267 | ||
268 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 268 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
269 | if ( showWarning ) { | 269 | if ( showWarning ) { |
270 | KMessageBox::information( this, | 270 | KMessageBox::information( this, |
271 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 271 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
272 | qApp->processEvents(); | 272 | qApp->processEvents(); |
273 | mView->dialogManager()->showSyncOptions(); | 273 | mView->dialogManager()->showSyncOptions(); |
274 | } | 274 | } |
275 | 275 | ||
276 | //US listen for result adressed from Ka/Pi | 276 | //US listen for result adressed from Ka/Pi |
277 | #ifndef DESKTOP_VERSION | 277 | #ifndef DESKTOP_VERSION |
278 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 278 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
279 | #endif | 279 | #endif |
280 | #ifndef DESKTOP_VERSION | 280 | #ifndef DESKTOP_VERSION |
281 | infrared = 0; | 281 | infrared = 0; |
282 | #endif | 282 | #endif |
283 | 283 | ||
284 | mBRdisabled = false; | 284 | mBRdisabled = false; |
285 | //toggleBeamReceive(); | 285 | //toggleBeamReceive(); |
286 | } | 286 | } |
287 | MainWindow::~MainWindow() | 287 | MainWindow::~MainWindow() |
288 | { | 288 | { |
289 | //qDebug("MainWindow::~MainWindow() "); | 289 | //qDebug("MainWindow::~MainWindow() "); |
290 | //save toolbar location | 290 | //save toolbar location |
291 | delete mCalendar; | 291 | delete mCalendar; |
292 | delete mSyncManager; | 292 | delete mSyncManager; |
293 | #ifndef DESKTOP_VERSION | 293 | #ifndef DESKTOP_VERSION |
294 | if ( infrared ) | 294 | if ( infrared ) |
295 | delete infrared; | 295 | delete infrared; |
296 | #endif | 296 | #endif |
297 | 297 | ||
298 | 298 | ||
299 | } | 299 | } |
300 | 300 | ||
301 | void MainWindow::disableBR(bool b) | 301 | void MainWindow::disableBR(bool b) |
302 | { | 302 | { |
303 | #ifndef DESKTOP_VERSION | 303 | #ifndef DESKTOP_VERSION |
304 | if ( b ) { | 304 | if ( b ) { |
305 | if ( infrared ) { | 305 | if ( infrared ) { |
306 | toggleBeamReceive(); | 306 | toggleBeamReceive(); |
307 | mBRdisabled = true; | 307 | mBRdisabled = true; |
308 | } | 308 | } |
309 | mBRdisabled = true; | 309 | mBRdisabled = true; |
310 | } else { | 310 | } else { |
311 | if ( mBRdisabled ) { | 311 | if ( mBRdisabled ) { |
312 | mBRdisabled = false; | 312 | mBRdisabled = false; |
313 | //makes no sense,because other cal ap is probably running | 313 | //makes no sense,because other cal ap is probably running |
314 | // toggleBeamReceive(); | 314 | // toggleBeamReceive(); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | } | 319 | } |
320 | bool MainWindow::beamReceiveEnabled() | 320 | bool MainWindow::beamReceiveEnabled() |
321 | { | 321 | { |
322 | #ifndef DESKTOP_VERSION | 322 | #ifndef DESKTOP_VERSION |
323 | return ( infrared != 0 ); | 323 | return ( infrared != 0 ); |
324 | #endif | 324 | #endif |
325 | return false; | 325 | return false; |
326 | } | 326 | } |
327 | 327 | ||
328 | void MainWindow::toggleBeamReceive() | 328 | void MainWindow::toggleBeamReceive() |
329 | { | 329 | { |
330 | if ( mBRdisabled ) | 330 | if ( mBRdisabled ) |
331 | return; | 331 | return; |
332 | #ifndef DESKTOP_VERSION | 332 | #ifndef DESKTOP_VERSION |
333 | if ( infrared ) { | 333 | if ( infrared ) { |
334 | qDebug("disable BeamReceive "); | 334 | qDebug("disable BeamReceive "); |
335 | delete infrared; | 335 | delete infrared; |
336 | infrared = 0; | 336 | infrared = 0; |
337 | brAction->setOn(false); | 337 | brAction->setOn(false); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | qDebug("enable BeamReceive "); | 340 | qDebug("enable BeamReceive "); |
341 | brAction->setOn(true); | 341 | brAction->setOn(true); |
342 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 342 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
343 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 343 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
344 | #endif | 344 | #endif |
345 | } | 345 | } |
346 | void MainWindow::showMaximized () | 346 | void MainWindow::showMaximized () |
347 | { | 347 | { |
348 | #ifndef DESKTOP_VERSION | 348 | #ifndef DESKTOP_VERSION |
349 | if ( ! globalFlagBlockStartup ) | 349 | if ( ! globalFlagBlockStartup ) |
350 | if ( mClosed ) | 350 | if ( mClosed ) |
351 | mView->goToday(); | 351 | mView->goToday(); |
352 | #endif | 352 | #endif |
353 | QWidget::showMaximized () ; | 353 | QWidget::showMaximized () ; |
354 | mClosed = false; | 354 | mClosed = false; |
355 | } | 355 | } |
356 | void MainWindow::closeEvent( QCloseEvent* ce ) | 356 | void MainWindow::closeEvent( QCloseEvent* ce ) |
357 | { | 357 | { |
358 | 358 | ||
359 | 359 | ||
360 | 360 | ||
361 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 361 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
362 | saveOnClose(); | 362 | saveOnClose(); |
363 | mClosed = true; | 363 | mClosed = true; |
364 | ce->accept(); | 364 | ce->accept(); |
365 | return; | 365 | return; |
366 | 366 | ||
367 | } | 367 | } |
368 | 368 | ||
369 | switch( QMessageBox::information( this, "KO/Pi", | 369 | switch( QMessageBox::information( this, "KO/Pi", |
370 | i18n("Do you really want\nto close KO/Pi?"), | 370 | i18n("Do you really want\nto close KO/Pi?"), |
371 | i18n("Close"), i18n("No"), | 371 | i18n("Close"), i18n("No"), |
372 | 0, 0 ) ) { | 372 | 0, 0 ) ) { |
373 | case 0: | 373 | case 0: |
374 | saveOnClose(); | 374 | saveOnClose(); |
375 | mClosed = true; | 375 | mClosed = true; |
376 | ce->accept(); | 376 | ce->accept(); |
377 | break; | 377 | break; |
378 | case 1: | 378 | case 1: |
379 | ce->ignore(); | 379 | ce->ignore(); |
380 | break; | 380 | break; |
381 | case 2: | 381 | case 2: |
382 | 382 | ||
383 | default: | 383 | default: |
384 | break; | 384 | break; |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 390 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
391 | { | 391 | { |
392 | QDataStream stream( data, IO_ReadOnly ); | 392 | QDataStream stream( data, IO_ReadOnly ); |
393 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 393 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
394 | //QString datamess; | 394 | //QString datamess; |
395 | //qDebug("message "); | 395 | //qDebug("message "); |
396 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 396 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
397 | 397 | ||
398 | if ( cmsg == "setDocument(QString)" ) { | 398 | if ( cmsg == "setDocument(QString)" ) { |
399 | QDataStream stream( data, IO_ReadOnly ); | 399 | QDataStream stream( data, IO_ReadOnly ); |
400 | QString fileName; | 400 | QString fileName; |
401 | stream >> fileName; | 401 | stream >> fileName; |
402 | //qDebug("filename %s ", fileName.latin1()); | 402 | //qDebug("filename %s ", fileName.latin1()); |
403 | showMaximized(); | 403 | showMaximized(); |
404 | raise(); | 404 | raise(); |
405 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 405 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
406 | mSyncManager->slotSyncMenu( 1002 ); | 406 | mSyncManager->slotSyncMenu( 1002 ); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | 409 | ||
410 | if ( cmsg == "-writeFile" ) { | 410 | if ( cmsg == "-writeFile" ) { |
411 | // I made from the "-writeFile" an "-writeAlarm" | 411 | // I made from the "-writeFile" an "-writeAlarm" |
412 | mView->viewManager()->showWhatsNextView(); | 412 | mView->viewManager()->showWhatsNextView(); |
413 | mCalendar->checkAlarmForIncidence( 0, true); | 413 | mCalendar->checkAlarmForIncidence( 0, true); |
414 | showMaximized(); | 414 | showMaximized(); |
415 | raise(); | 415 | raise(); |
416 | return; | 416 | return; |
417 | 417 | ||
418 | } | 418 | } |
419 | if ( cmsg == "-writeFileSilent" ) { | 419 | if ( cmsg == "-writeFileSilent" ) { |
420 | // I made from the "-writeFile" an "-writeAlarm" | 420 | // I made from the "-writeFile" an "-writeAlarm" |
421 | // mView->viewManager()->showWhatsNextView(); | 421 | // mView->viewManager()->showWhatsNextView(); |
422 | mCalendar->checkAlarmForIncidence( 0, true); | 422 | mCalendar->checkAlarmForIncidence( 0, true); |
423 | //showMaximized(); | 423 | //showMaximized(); |
424 | //raise(); | 424 | //raise(); |
425 | hide(); | 425 | hide(); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | if ( cmsg == "-newCountdown" ) { | 428 | if ( cmsg == "-newCountdown" ) { |
429 | qDebug("newCountdown "); | 429 | qDebug("newCountdown "); |
430 | 430 | ||
431 | } | 431 | } |
432 | QString msg ; | 432 | QString msg ; |
433 | QString allmsg = cmsg; | 433 | QString allmsg = cmsg; |
434 | while ( allmsg.length() > 0 ) { | 434 | while ( allmsg.length() > 0 ) { |
435 | int nextC = allmsg.find( "-", 1 ); | 435 | int nextC = allmsg.find( "-", 1 ); |
436 | if ( nextC == -1 ) { | 436 | if ( nextC == -1 ) { |
437 | msg = allmsg; | 437 | msg = allmsg; |
438 | allmsg = ""; | 438 | allmsg = ""; |
439 | } else{ | 439 | } else{ |
440 | msg = allmsg.left( nextC ); | 440 | msg = allmsg.left( nextC ); |
441 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 441 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
442 | } | 442 | } |
443 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 443 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
444 | if ( msg == "-newEvent" ) { | 444 | if ( msg == "-newEvent" ) { |
445 | mView->newEvent(); | 445 | mView->newEvent(); |
446 | } | 446 | } |
447 | if ( msg == "-newTodo" ) { | 447 | if ( msg == "-newTodo" ) { |
448 | mView->newTodo(); | 448 | mView->newTodo(); |
449 | 449 | ||
450 | } | 450 | } |
451 | if ( msg == "-showWN" ) { | 451 | if ( msg == "-showWN" ) { |
452 | mView->viewManager()->showWhatsNextView(); | 452 | mView->viewManager()->showWhatsNextView(); |
453 | } | 453 | } |
454 | if ( msg == "-showTodo" ) { | 454 | if ( msg == "-showTodo" ) { |
455 | mView->viewManager()->showTodoView(); | 455 | mView->viewManager()->showTodoView(); |
456 | } | 456 | } |
457 | if ( msg == "-showList" ) { | 457 | if ( msg == "-showList" ) { |
458 | mView->viewManager()->showListView(); | 458 | mView->viewManager()->showListView(); |
459 | } | 459 | } |
460 | else if ( msg == "-showDay" ) { | 460 | else if ( msg == "-showDay" ) { |
461 | mView->viewManager()->showDayView(); | 461 | mView->viewManager()->showDayView(); |
462 | } | 462 | } |
463 | else if ( msg == "-showWWeek" ) { | 463 | else if ( msg == "-showWWeek" ) { |
464 | mView->viewManager()->showWorkWeekView(); | 464 | mView->viewManager()->showWorkWeekView(); |
465 | } | 465 | } |
466 | else if ( msg == "-ringSync" ) { | 466 | else if ( msg == "-ringSync" ) { |
467 | mSyncManager->multiSync( false ); | 467 | mSyncManager->multiSync( false ); |
468 | } | 468 | } |
469 | else if ( msg == "-showWeek" ) { | 469 | else if ( msg == "-showWeek" ) { |
470 | mView->viewManager()->showWeekView(); | 470 | mView->viewManager()->showWeekView(); |
471 | } | 471 | } |
472 | else if ( msg == "-showTodo" ) { | 472 | else if ( msg == "-showTodo" ) { |
473 | mView->viewManager()->showTodoView(); | 473 | mView->viewManager()->showTodoView(); |
474 | } | 474 | } |
475 | else if ( msg == "-showJournal" ) { | 475 | else if ( msg == "-showJournal" ) { |
476 | mView->dateNavigator()->selectDates( 1 ); | 476 | mView->dateNavigator()->selectDates( 1 ); |
477 | mView->dateNavigator()->selectToday(); | 477 | mView->dateNavigator()->selectToday(); |
478 | mView->viewManager()->showJournalView(); | 478 | mView->viewManager()->showJournalView(); |
479 | } | 479 | } |
480 | else if ( msg == "-showKO" ) { | 480 | else if ( msg == "-showKO" ) { |
481 | mView->viewManager()->showNextXView(); | 481 | mView->viewManager()->showNextXView(); |
482 | } | 482 | } |
483 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 483 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
484 | mView->viewManager()->showWhatsNextView(); | 484 | mView->viewManager()->showWhatsNextView(); |
485 | } | 485 | } |
486 | else if ( msg == "-showNextXView" ) { | 486 | else if ( msg == "-showNextXView" ) { |
487 | mView->viewManager()->showNextXView(); | 487 | mView->viewManager()->showNextXView(); |
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
491 | } | 491 | } |
492 | 492 | ||
493 | showMaximized(); | 493 | showMaximized(); |
494 | raise(); | 494 | raise(); |
495 | } | 495 | } |
496 | 496 | ||
497 | QPixmap MainWindow::loadPixmap( QString name ) | 497 | QPixmap MainWindow::loadPixmap( QString name ) |
498 | { | 498 | { |
499 | return SmallIcon( name ); | 499 | return SmallIcon( name ); |
500 | 500 | ||
501 | } | 501 | } |
502 | void MainWindow::initActions() | 502 | void MainWindow::initActions() |
503 | { | 503 | { |
504 | //KOPrefs::instance()->mShowFullMenu | 504 | //KOPrefs::instance()->mShowFullMenu |
505 | iconToolBar->clear(); | 505 | iconToolBar->clear(); |
506 | KOPrefs *p = KOPrefs::instance(); | 506 | KOPrefs *p = KOPrefs::instance(); |
507 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 507 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
508 | 508 | ||
509 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 509 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
510 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 510 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
511 | QPopupMenu *importMenu = new QPopupMenu( this ); | 511 | QPopupMenu *importMenu = new QPopupMenu( this ); |
512 | selectFilterMenu = new QPopupMenu( this ); | 512 | selectFilterMenu = new QPopupMenu( this ); |
513 | selectFilterMenu->setCheckable( true ); | 513 | selectFilterMenu->setCheckable( true ); |
514 | syncMenu = new QPopupMenu( this ); | 514 | syncMenu = new QPopupMenu( this ); |
515 | configureAgendaMenu = new QPopupMenu( this ); | 515 | configureAgendaMenu = new QPopupMenu( this ); |
516 | configureToolBarMenu = new QPopupMenu( this ); | 516 | configureToolBarMenu = new QPopupMenu( this ); |
517 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 517 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
518 | if ( KOPrefs::instance()->mShowFullMenu ) { | 518 | if ( KOPrefs::instance()->mShowFullMenu ) { |
519 | QMenuBar *menuBar1; | 519 | QMenuBar *menuBar1; |
520 | menuBar1 = menuBar(); | 520 | menuBar1 = menuBar(); |
521 | menuBar1->insertItem( i18n("File"), importMenu ); | 521 | menuBar1->insertItem( i18n("File"), importMenu ); |
522 | menuBar1->insertItem( i18n("View"), viewMenu ); | 522 | menuBar1->insertItem( i18n("View"), viewMenu ); |
523 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 523 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
524 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 524 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
525 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 525 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
526 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 526 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
527 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 527 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
528 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 528 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
529 | } else { | 529 | } else { |
530 | QPEMenuBar *menuBar1; | 530 | QPEMenuBar *menuBar1; |
531 | menuBar1 = new QPEMenuBar( iconToolBar ); | 531 | menuBar1 = new QPEMenuBar( iconToolBar ); |
532 | QPopupMenu *menuBar = new QPopupMenu( this ); | 532 | QPopupMenu *menuBar = new QPopupMenu( this ); |
533 | menuBar1->insertItem( i18n("ME"), menuBar); | 533 | menuBar1->insertItem( i18n("ME"), menuBar); |
534 | menuBar->insertItem( i18n("File"), importMenu ); | 534 | menuBar->insertItem( i18n("File"), importMenu ); |
535 | menuBar->insertItem( i18n("View"), viewMenu ); | 535 | menuBar->insertItem( i18n("View"), viewMenu ); |
536 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 536 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
537 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 537 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
538 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 538 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
539 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 539 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
540 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 540 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
541 | menuBar->insertItem( i18n("Help"), helpMenu ); | 541 | menuBar->insertItem( i18n("Help"), helpMenu ); |
542 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 542 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
543 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 543 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
544 | } | 544 | } |
545 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 545 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
546 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 546 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
547 | 547 | ||
548 | // ****************** | 548 | // ****************** |
549 | QAction *action; | 549 | QAction *action; |
550 | QIconSet icon; | 550 | QIconSet icon; |
551 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 551 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
552 | configureToolBarMenu->setCheckable( true ); | 552 | configureToolBarMenu->setCheckable( true ); |
553 | 553 | ||
554 | QString pathString = ""; | 554 | QString pathString = ""; |
555 | if ( !p->mToolBarMiniIcons ) { | 555 | if ( !p->mToolBarMiniIcons ) { |
556 | if ( QApplication::desktop()->width() < 480 ) | 556 | if ( QApplication::desktop()->width() < 480 ) |
557 | pathString += "icons16/"; | 557 | pathString += "icons16/"; |
558 | } else | 558 | } else |
559 | pathString += "iconsmini/"; | 559 | pathString += "iconsmini/"; |
560 | configureAgendaMenu->setCheckable( true ); | 560 | configureAgendaMenu->setCheckable( true ); |
561 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 561 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
562 | configureAgendaMenu->insertSeparator(); | 562 | configureAgendaMenu->insertSeparator(); |
563 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 563 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
564 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 564 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
565 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 565 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
566 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 566 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
567 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 567 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
568 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 568 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
569 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 569 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
570 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 570 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
571 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 571 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
572 | 572 | ||
573 | icon = loadPixmap( pathString + "configure" ); | 573 | icon = loadPixmap( pathString + "configure" ); |
574 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 574 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
575 | action->addTo( actionMenu ); | 575 | action->addTo( actionMenu ); |
576 | connect( action, SIGNAL( activated() ), | 576 | connect( action, SIGNAL( activated() ), |
577 | mView, SLOT( edit_options() ) ); | 577 | mView, SLOT( edit_options() ) ); |
578 | actionMenu->insertSeparator(); | 578 | actionMenu->insertSeparator(); |
579 | |||
580 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | ||
581 | action->addTo( actionMenu ); | ||
582 | connect( action, SIGNAL( activated() ), | ||
583 | mView, SLOT( undo_delete() ) ); | ||
584 | actionMenu->insertSeparator(); | ||
585 | |||
579 | icon = loadPixmap( pathString + "newevent" ); | 586 | icon = loadPixmap( pathString + "newevent" ); |
580 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 587 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
581 | configureToolBarMenu->insertSeparator(); | 588 | configureToolBarMenu->insertSeparator(); |
582 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 589 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
583 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 590 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
584 | ne_action->addTo( actionMenu ); | 591 | ne_action->addTo( actionMenu ); |
585 | connect( ne_action, SIGNAL( activated() ), | 592 | connect( ne_action, SIGNAL( activated() ), |
586 | mView, SLOT( newEvent() ) ); | 593 | mView, SLOT( newEvent() ) ); |
587 | icon = loadPixmap( pathString + "newtodo" ); | 594 | icon = loadPixmap( pathString + "newtodo" ); |
588 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 595 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
589 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 596 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
590 | nt_action->addTo( actionMenu ); | 597 | nt_action->addTo( actionMenu ); |
591 | connect( nt_action, SIGNAL( activated() ), | 598 | connect( nt_action, SIGNAL( activated() ), |
592 | mView, SLOT( newTodo() ) ); | 599 | mView, SLOT( newTodo() ) ); |
593 | icon = loadPixmap( pathString + "navi" ); | 600 | icon = loadPixmap( pathString + "navi" ); |
594 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 601 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
595 | action->addTo( viewMenu ); | 602 | action->addTo( viewMenu ); |
596 | connect( action, SIGNAL( activated() ), | 603 | connect( action, SIGNAL( activated() ), |
597 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 604 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
598 | icon = loadPixmap( pathString + "filter" ); | 605 | icon = loadPixmap( pathString + "filter" ); |
599 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 606 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
600 | action->addTo( viewMenu ); | 607 | action->addTo( viewMenu ); |
601 | connect( action, SIGNAL( activated() ), | 608 | connect( action, SIGNAL( activated() ), |
602 | mView, SLOT( toggleFilter() ) ); | 609 | mView, SLOT( toggleFilter() ) ); |
603 | 610 | ||
604 | 611 | ||
605 | viewMenu->insertSeparator(); | 612 | viewMenu->insertSeparator(); |
606 | icon = loadPixmap( pathString + "picker" ); | 613 | icon = loadPixmap( pathString + "picker" ); |
607 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 614 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
608 | action->addTo( viewMenu ); | 615 | action->addTo( viewMenu ); |
609 | connect( action, SIGNAL( activated() ), | 616 | connect( action, SIGNAL( activated() ), |
610 | mView, SLOT( showDatePicker() ) ); | 617 | mView, SLOT( showDatePicker() ) ); |
611 | action->addTo( iconToolBar ); | 618 | action->addTo( iconToolBar ); |
612 | viewMenu->insertSeparator(); | 619 | viewMenu->insertSeparator(); |
613 | icon = loadPixmap( pathString + "list" ); | 620 | icon = loadPixmap( pathString + "list" ); |
614 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 621 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
615 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 622 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
616 | showlist_action->addTo( viewMenu ); | 623 | showlist_action->addTo( viewMenu ); |
617 | connect( showlist_action, SIGNAL( activated() ), | 624 | connect( showlist_action, SIGNAL( activated() ), |
618 | mView->viewManager(), SLOT( showListView() ) ); | 625 | mView->viewManager(), SLOT( showListView() ) ); |
619 | 626 | ||
620 | 627 | ||
621 | icon = loadPixmap( pathString + "day" ); | 628 | icon = loadPixmap( pathString + "day" ); |
622 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 629 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
623 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 630 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
624 | day1_action->addTo( viewMenu ); | 631 | day1_action->addTo( viewMenu ); |
625 | // action->addTo( toolBar ); | 632 | // action->addTo( toolBar ); |
626 | connect( day1_action, SIGNAL( activated() ), | 633 | connect( day1_action, SIGNAL( activated() ), |
627 | mView->viewManager(), SLOT( showDayView() ) ); | 634 | mView->viewManager(), SLOT( showDayView() ) ); |
628 | 635 | ||
629 | icon = loadPixmap( pathString + "workweek" ); | 636 | icon = loadPixmap( pathString + "workweek" ); |
630 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 637 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
631 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 638 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
632 | day5_action->addTo( viewMenu ); | 639 | day5_action->addTo( viewMenu ); |
633 | connect( day5_action, SIGNAL( activated() ), | 640 | connect( day5_action, SIGNAL( activated() ), |
634 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 641 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
635 | 642 | ||
636 | icon = loadPixmap( pathString + "week" ); | 643 | icon = loadPixmap( pathString + "week" ); |
637 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 644 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
638 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 645 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
639 | day7_action->addTo( viewMenu ); | 646 | day7_action->addTo( viewMenu ); |
640 | connect( day7_action, SIGNAL( activated() ), | 647 | connect( day7_action, SIGNAL( activated() ), |
641 | mView->viewManager(), SLOT( showWeekView() ) ); | 648 | mView->viewManager(), SLOT( showWeekView() ) ); |
642 | 649 | ||
643 | icon = loadPixmap( pathString + "month" ); | 650 | icon = loadPixmap( pathString + "month" ); |
644 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 651 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
645 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 652 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
646 | month_action->addTo( viewMenu ); | 653 | month_action->addTo( viewMenu ); |
647 | connect( month_action, SIGNAL( activated() ), | 654 | connect( month_action, SIGNAL( activated() ), |
648 | mView->viewManager(), SLOT( showMonthView() ) ); | 655 | mView->viewManager(), SLOT( showMonthView() ) ); |
649 | 656 | ||
650 | icon = loadPixmap( pathString + "todo" ); | 657 | icon = loadPixmap( pathString + "todo" ); |
651 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 658 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
652 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 659 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
653 | todoview_action->addTo( viewMenu ); | 660 | todoview_action->addTo( viewMenu ); |
654 | connect( todoview_action, SIGNAL( activated() ), | 661 | connect( todoview_action, SIGNAL( activated() ), |
655 | mView->viewManager(), SLOT( showTodoView() ) ); | 662 | mView->viewManager(), SLOT( showTodoView() ) ); |
656 | 663 | ||
657 | icon = loadPixmap( pathString + "journal" ); | 664 | icon = loadPixmap( pathString + "journal" ); |
658 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 665 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
659 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 666 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
660 | viewjournal_action->addTo( viewMenu ); | 667 | viewjournal_action->addTo( viewMenu ); |
661 | connect( viewjournal_action, SIGNAL( activated() ), | 668 | connect( viewjournal_action, SIGNAL( activated() ), |
662 | mView->viewManager(), SLOT( showJournalView() ) ); | 669 | mView->viewManager(), SLOT( showJournalView() ) ); |
663 | 670 | ||
664 | icon = loadPixmap( pathString + "xdays" ); | 671 | icon = loadPixmap( pathString + "xdays" ); |
665 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 672 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
666 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 673 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
667 | xdays_action->addTo( viewMenu ); | 674 | xdays_action->addTo( viewMenu ); |
668 | connect( xdays_action, SIGNAL( activated() ), | 675 | connect( xdays_action, SIGNAL( activated() ), |
669 | mView->viewManager(), SLOT( showNextXView() ) ); | 676 | mView->viewManager(), SLOT( showNextXView() ) ); |
670 | 677 | ||
671 | icon = loadPixmap( pathString + "whatsnext" ); | 678 | icon = loadPixmap( pathString + "whatsnext" ); |
672 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 679 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
673 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 680 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
674 | whatsnext_action->addTo( viewMenu ); | 681 | whatsnext_action->addTo( viewMenu ); |
675 | connect( whatsnext_action, SIGNAL( activated() ), | 682 | connect( whatsnext_action, SIGNAL( activated() ), |
676 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 683 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
677 | 684 | ||
678 | #if 0 | 685 | #if 0 |
679 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 686 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
680 | action->addTo( viewMenu ); | 687 | action->addTo( viewMenu ); |
681 | connect( action, SIGNAL( activated() ), | 688 | connect( action, SIGNAL( activated() ), |
682 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 689 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
683 | #endif | 690 | #endif |
684 | 691 | ||
685 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 692 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
686 | this ); | 693 | this ); |
687 | mNewSubTodoAction->addTo( actionMenu ); | 694 | mNewSubTodoAction->addTo( actionMenu ); |
688 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 695 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
689 | mView, SLOT( newSubTodo() ) ); | 696 | mView, SLOT( newSubTodo() ) ); |
690 | 697 | ||
691 | actionMenu->insertSeparator(); | 698 | actionMenu->insertSeparator(); |
692 | 699 | ||
693 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 700 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
694 | mShowAction->addTo( actionMenu ); | 701 | mShowAction->addTo( actionMenu ); |
695 | connect( mShowAction, SIGNAL( activated() ), | 702 | connect( mShowAction, SIGNAL( activated() ), |
696 | mView, SLOT( showIncidence() ) ); | 703 | mView, SLOT( showIncidence() ) ); |
697 | 704 | ||
698 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 705 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
699 | mEditAction->addTo( actionMenu ); | 706 | mEditAction->addTo( actionMenu ); |
700 | connect( mEditAction, SIGNAL( activated() ), | 707 | connect( mEditAction, SIGNAL( activated() ), |
701 | mView, SLOT( editIncidence() ) ); | 708 | mView, SLOT( editIncidence() ) ); |
702 | 709 | ||
703 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 710 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
704 | mDeleteAction->addTo( actionMenu ); | 711 | mDeleteAction->addTo( actionMenu ); |
705 | connect( mDeleteAction, SIGNAL( activated() ), | 712 | connect( mDeleteAction, SIGNAL( activated() ), |
706 | mView, SLOT( deleteIncidence() ) ); | 713 | mView, SLOT( deleteIncidence() ) ); |
707 | 714 | ||
708 | 715 | ||
709 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 716 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
710 | mCloneAction->addTo( actionMenu ); | 717 | mCloneAction->addTo( actionMenu ); |
711 | connect( mCloneAction, SIGNAL( activated() ), | 718 | connect( mCloneAction, SIGNAL( activated() ), |
712 | mView, SLOT( cloneIncidence() ) ); | 719 | mView, SLOT( cloneIncidence() ) ); |
713 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 720 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
714 | mMoveAction->addTo( actionMenu ); | 721 | mMoveAction->addTo( actionMenu ); |
715 | connect( mMoveAction, SIGNAL( activated() ), | 722 | connect( mMoveAction, SIGNAL( activated() ), |
716 | mView, SLOT( moveIncidence() ) ); | 723 | mView, SLOT( moveIncidence() ) ); |
717 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 724 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
718 | mBeamAction->addTo( actionMenu ); | 725 | mBeamAction->addTo( actionMenu ); |
719 | connect( mBeamAction, SIGNAL( activated() ), | 726 | connect( mBeamAction, SIGNAL( activated() ), |
720 | mView, SLOT( beamIncidence() ) ); | 727 | mView, SLOT( beamIncidence() ) ); |
721 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 728 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
722 | mCancelAction->addTo( actionMenu ); | 729 | mCancelAction->addTo( actionMenu ); |
723 | connect( mCancelAction, SIGNAL( activated() ), | 730 | connect( mCancelAction, SIGNAL( activated() ), |
724 | mView, SLOT( toggleCancelIncidence() ) ); | 731 | mView, SLOT( toggleCancelIncidence() ) ); |
725 | 732 | ||
726 | actionMenu->insertSeparator(); | 733 | actionMenu->insertSeparator(); |
727 | 734 | ||
728 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 735 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
729 | this ); | 736 | this ); |
730 | action->addTo( actionMenu ); | 737 | action->addTo( actionMenu ); |
731 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 738 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
732 | 739 | ||
733 | icon = loadPixmap( pathString + "search" ); | 740 | icon = loadPixmap( pathString + "search" ); |
734 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 741 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
735 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 742 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
736 | search_action->addTo( actionMenu ); | 743 | search_action->addTo( actionMenu ); |
737 | connect( search_action, SIGNAL( activated() ), | 744 | connect( search_action, SIGNAL( activated() ), |
738 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 745 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
739 | 746 | ||
740 | icon = loadPixmap( pathString + "today" ); | 747 | icon = loadPixmap( pathString + "today" ); |
741 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 748 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
742 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 749 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
743 | today_action->addTo( actionMenu ); | 750 | today_action->addTo( actionMenu ); |
744 | connect( today_action, SIGNAL( activated() ), | 751 | connect( today_action, SIGNAL( activated() ), |
745 | mView, SLOT( goToday() ) ); | 752 | mView, SLOT( goToday() ) ); |
746 | 753 | ||
747 | if ( KOPrefs::instance()->mShowFullMenu ) { | 754 | if ( KOPrefs::instance()->mShowFullMenu ) { |
748 | actionMenu->insertSeparator(); | 755 | actionMenu->insertSeparator(); |
749 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 756 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
750 | 757 | ||
751 | } | 758 | } |
752 | // actionMenu->insertSeparator(); | 759 | // actionMenu->insertSeparator(); |
753 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 760 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
754 | this ); | 761 | this ); |
755 | action->addTo( importMenu ); | 762 | action->addTo( importMenu ); |
756 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 763 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
757 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 764 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
758 | this ); | 765 | this ); |
759 | action->addTo( importMenu ); | 766 | action->addTo( importMenu ); |
760 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 767 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
761 | importMenu->insertSeparator(); | 768 | importMenu->insertSeparator(); |
762 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 769 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
763 | this ); | 770 | this ); |
764 | action->addTo( importMenu ); | 771 | action->addTo( importMenu ); |
765 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 772 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
766 | #ifndef DESKTOP_VERSION | 773 | #ifndef DESKTOP_VERSION |
767 | importMenu->insertSeparator(); | 774 | importMenu->insertSeparator(); |
768 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 775 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
769 | this ); | 776 | this ); |
770 | action->addTo( importMenu ); | 777 | action->addTo( importMenu ); |
771 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 778 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
772 | #else | 779 | #else |
773 | #ifdef _WIN32_ | 780 | #ifdef _WIN32_ |
774 | importMenu->insertSeparator(); | 781 | importMenu->insertSeparator(); |
775 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 782 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
776 | this ); | 783 | this ); |
777 | action->addTo( importMenu ); | 784 | action->addTo( importMenu ); |
778 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 785 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
779 | #endif | 786 | #endif |
780 | #endif | 787 | #endif |
781 | 788 | ||
782 | importMenu->insertSeparator(); | 789 | importMenu->insertSeparator(); |
783 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 790 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
784 | this ); | 791 | this ); |
785 | action->addTo( importMenu ); | 792 | action->addTo( importMenu ); |
786 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 793 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
787 | 794 | ||
788 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 795 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
789 | this ); | 796 | this ); |
790 | action->addTo( importMenu ); | 797 | action->addTo( importMenu ); |
791 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 798 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
792 | 799 | ||
793 | importMenu->insertSeparator(); | 800 | importMenu->insertSeparator(); |
794 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 801 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
795 | this ); | 802 | this ); |
796 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 803 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
797 | 804 | ||
798 | 805 | ||
799 | //LR | 806 | //LR |
800 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 807 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
801 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 808 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
802 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 809 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
803 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 810 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
804 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 811 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
805 | 812 | ||
806 | importMenu->insertSeparator(); | 813 | importMenu->insertSeparator(); |
807 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 814 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
808 | this ); | 815 | this ); |
809 | action->addTo( importMenu ); | 816 | action->addTo( importMenu ); |
810 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 817 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
811 | #ifndef DESKTOP_VERSION | 818 | #ifndef DESKTOP_VERSION |
812 | importMenu->insertSeparator(); | 819 | importMenu->insertSeparator(); |
813 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 820 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
814 | this ); | 821 | this ); |
815 | brAction->addTo( importMenu ); | 822 | brAction->addTo( importMenu ); |
816 | brAction->setToggleAction (true ) ; | 823 | brAction->setToggleAction (true ) ; |
817 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 824 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
818 | 825 | ||
819 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 826 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
820 | this ); | 827 | this ); |
821 | action->addTo( importMenu ); | 828 | action->addTo( importMenu ); |
822 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 829 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
823 | 830 | ||
824 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 831 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
825 | this ); | 832 | this ); |
826 | action->addTo( importMenu ); | 833 | action->addTo( importMenu ); |
827 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 834 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
828 | #else | 835 | #else |
829 | importMenu->insertSeparator(); | 836 | importMenu->insertSeparator(); |
830 | icon = loadPixmap( pathString + "print" ); | 837 | icon = loadPixmap( pathString + "print" ); |
831 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 838 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
832 | action->addTo( importMenu ); | 839 | action->addTo( importMenu ); |
833 | connect( action, SIGNAL( activated() ), | 840 | connect( action, SIGNAL( activated() ), |
834 | this, SLOT( printCal() ) ); | 841 | this, SLOT( printCal() ) ); |
835 | 842 | ||
836 | icon = loadPixmap( pathString + "print" ); | 843 | icon = loadPixmap( pathString + "print" ); |
837 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 844 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
838 | action->addTo( importMenu ); | 845 | action->addTo( importMenu ); |
839 | connect( action, SIGNAL( activated() ), | 846 | connect( action, SIGNAL( activated() ), |
840 | this, SLOT( printSel() ) ); | 847 | this, SLOT( printSel() ) ); |
841 | #endif | 848 | #endif |
842 | importMenu->insertSeparator(); | 849 | importMenu->insertSeparator(); |
843 | action = new QAction( "beam all", i18n("Save"), 0, | 850 | action = new QAction( "beam all", i18n("Save"), 0, |
844 | this ); | 851 | this ); |
845 | action->addTo( importMenu ); | 852 | action->addTo( importMenu ); |
846 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 853 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
847 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 854 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
848 | this ); | 855 | this ); |
849 | action->addTo( importMenu ); | 856 | action->addTo( importMenu ); |
850 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 857 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
851 | 858 | ||
852 | //menuBar->insertItem( "Configure",configureMenu ); | 859 | //menuBar->insertItem( "Configure",configureMenu ); |
853 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 860 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
854 | icon = loadPixmap( "korganizer/korganizer" ); | 861 | icon = loadPixmap( "korganizer/korganizer" ); |
855 | 862 | ||
856 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 863 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
857 | action->addTo( helpMenu ); | 864 | action->addTo( helpMenu ); |
858 | connect( action, SIGNAL( activated() ), | 865 | connect( action, SIGNAL( activated() ), |
859 | SLOT( whatsNew() ) ); | 866 | SLOT( whatsNew() ) ); |
860 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 867 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
861 | action->addTo( helpMenu ); | 868 | action->addTo( helpMenu ); |
862 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
863 | SLOT( features() ) ); | 870 | SLOT( features() ) ); |
864 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 871 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
865 | action->addTo( helpMenu ); | 872 | action->addTo( helpMenu ); |
866 | connect( action, SIGNAL( activated() ), | 873 | connect( action, SIGNAL( activated() ), |
867 | SLOT( keyBindings() ) ); | 874 | SLOT( keyBindings() ) ); |
868 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 875 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
869 | action->addTo( helpMenu ); | 876 | action->addTo( helpMenu ); |
870 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
871 | SLOT( synchowto() ) ); | 878 | SLOT( synchowto() ) ); |
872 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 879 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
873 | action->addTo( helpMenu ); | 880 | action->addTo( helpMenu ); |
874 | connect( action, SIGNAL( activated() ), | 881 | connect( action, SIGNAL( activated() ), |
875 | SLOT( kdesynchowto() ) ); | 882 | SLOT( kdesynchowto() ) ); |
876 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 883 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
877 | action->addTo( helpMenu ); | 884 | action->addTo( helpMenu ); |
878 | connect( action, SIGNAL( activated() ), | 885 | connect( action, SIGNAL( activated() ), |
879 | SLOT( multisynchowto() ) ); | 886 | SLOT( multisynchowto() ) ); |
880 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 887 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
881 | action->addTo( helpMenu ); | 888 | action->addTo( helpMenu ); |
882 | connect( action, SIGNAL( activated() ), | 889 | connect( action, SIGNAL( activated() ), |
883 | SLOT( aboutAutoSaving() ) ); | 890 | SLOT( aboutAutoSaving() ) ); |
884 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 891 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
885 | action->addTo( helpMenu ); | 892 | action->addTo( helpMenu ); |
886 | connect( action, SIGNAL( activated() ), | 893 | connect( action, SIGNAL( activated() ), |
887 | SLOT( aboutKnownBugs() ) ); | 894 | SLOT( aboutKnownBugs() ) ); |
888 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 895 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
889 | action->addTo( helpMenu ); | 896 | action->addTo( helpMenu ); |
890 | connect( action, SIGNAL( activated() ), | 897 | connect( action, SIGNAL( activated() ), |
891 | SLOT( usertrans() ) ); | 898 | SLOT( usertrans() ) ); |
892 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 899 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
893 | action->addTo( helpMenu ); | 900 | action->addTo( helpMenu ); |
894 | connect( action, SIGNAL( activated() ), | 901 | connect( action, SIGNAL( activated() ), |
895 | SLOT( faq() ) ); | 902 | SLOT( faq() ) ); |
896 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 903 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
897 | action->addTo( helpMenu ); | 904 | action->addTo( helpMenu ); |
898 | connect( action, SIGNAL( activated() ), | 905 | connect( action, SIGNAL( activated() ), |
899 | SLOT( licence() ) ); | 906 | SLOT( licence() ) ); |
900 | action = new QAction( "about", i18n("About..."), 0, this ); | 907 | action = new QAction( "about", i18n("About..."), 0, this ); |
901 | action->addTo( helpMenu ); | 908 | action->addTo( helpMenu ); |
902 | connect( action, SIGNAL( activated() ), | 909 | connect( action, SIGNAL( activated() ), |
903 | SLOT( about() ) ); | 910 | SLOT( about() ) ); |
904 | //menuBar->insertSeparator(); | 911 | //menuBar->insertSeparator(); |
905 | 912 | ||
906 | // ****************************************************** | 913 | // ****************************************************** |
907 | // menubar icons | 914 | // menubar icons |
908 | 915 | ||
909 | 916 | ||
910 | iconToolBar->setHorizontalStretchable (true ); | 917 | iconToolBar->setHorizontalStretchable (true ); |
911 | //menuBar->insertItem( iconToolBar ); | 918 | //menuBar->insertItem( iconToolBar ); |
912 | //xdays_action | 919 | //xdays_action |
913 | if (p-> mShowIconNewEvent) | 920 | if (p-> mShowIconNewEvent) |
914 | ne_action->addTo( iconToolBar ); | 921 | ne_action->addTo( iconToolBar ); |
915 | if (p->mShowIconNewTodo ) | 922 | if (p->mShowIconNewTodo ) |
916 | nt_action->addTo( iconToolBar ); | 923 | nt_action->addTo( iconToolBar ); |
917 | if (p-> mShowIconSearch) | 924 | if (p-> mShowIconSearch) |
918 | search_action->addTo( iconToolBar ); | 925 | search_action->addTo( iconToolBar ); |
919 | if (p-> mShowIconNext) | 926 | if (p-> mShowIconNext) |
920 | whatsnext_action->addTo( iconToolBar ); | 927 | whatsnext_action->addTo( iconToolBar ); |
921 | if (p-> mShowIconNextDays) | 928 | if (p-> mShowIconNextDays) |
922 | xdays_action->addTo( iconToolBar ); | 929 | xdays_action->addTo( iconToolBar ); |
923 | if (p-> mShowIconList) | 930 | if (p-> mShowIconList) |
924 | showlist_action->addTo( iconToolBar ); | 931 | showlist_action->addTo( iconToolBar ); |
925 | if (p-> mShowIconDay1) | 932 | if (p-> mShowIconDay1) |
926 | day1_action->addTo( iconToolBar ); | 933 | day1_action->addTo( iconToolBar ); |
927 | if (p-> mShowIconDay5) | 934 | if (p-> mShowIconDay5) |
928 | day5_action->addTo( iconToolBar ); | 935 | day5_action->addTo( iconToolBar ); |
929 | if (p-> mShowIconDay7) | 936 | if (p-> mShowIconDay7) |
930 | day7_action->addTo( iconToolBar ); | 937 | day7_action->addTo( iconToolBar ); |
931 | if (p-> mShowIconMonth) | 938 | if (p-> mShowIconMonth) |
932 | month_action->addTo( iconToolBar ); | 939 | month_action->addTo( iconToolBar ); |
933 | if (p-> mShowIconTodoview) | 940 | if (p-> mShowIconTodoview) |
934 | todoview_action->addTo( iconToolBar ); | 941 | todoview_action->addTo( iconToolBar ); |
935 | if (p-> mShowIconJournal) | 942 | if (p-> mShowIconJournal) |
936 | viewjournal_action->addTo( iconToolBar ); | 943 | viewjournal_action->addTo( iconToolBar ); |
937 | icon = loadPixmap( pathString + "2leftarrowB" ); | 944 | icon = loadPixmap( pathString + "2leftarrowB" ); |
938 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 945 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
939 | if (p-> mShowIconBackFast) { | 946 | if (p-> mShowIconBackFast) { |
940 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 947 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
941 | connect( action, SIGNAL( activated() ), | 948 | connect( action, SIGNAL( activated() ), |
942 | mView, SLOT( goPreviousMonth() ) ); | 949 | mView, SLOT( goPreviousMonth() ) ); |
943 | action->addTo( iconToolBar ); | 950 | action->addTo( iconToolBar ); |
944 | } | 951 | } |
945 | icon = loadPixmap( pathString + "1leftarrowB" ); | 952 | icon = loadPixmap( pathString + "1leftarrowB" ); |
946 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 953 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
947 | if (p-> mShowIconBack) { | 954 | if (p-> mShowIconBack) { |
948 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 955 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
949 | connect( action, SIGNAL( activated() ), | 956 | connect( action, SIGNAL( activated() ), |
950 | mView, SLOT( goPrevious() ) ); | 957 | mView, SLOT( goPrevious() ) ); |
951 | action->addTo( iconToolBar ); | 958 | action->addTo( iconToolBar ); |
952 | } | 959 | } |
953 | if (p-> mShowIconToday) | 960 | if (p-> mShowIconToday) |
954 | today_action->addTo( iconToolBar ); | 961 | today_action->addTo( iconToolBar ); |
955 | icon = loadPixmap( pathString + "1rightarrowB" ); | 962 | icon = loadPixmap( pathString + "1rightarrowB" ); |
956 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 963 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
957 | if (p-> mShowIconForward) { | 964 | if (p-> mShowIconForward) { |
958 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 965 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
959 | connect( action, SIGNAL( activated() ), | 966 | connect( action, SIGNAL( activated() ), |
960 | mView, SLOT( goNext() ) ); | 967 | mView, SLOT( goNext() ) ); |
961 | action->addTo( iconToolBar ); | 968 | action->addTo( iconToolBar ); |
962 | } | 969 | } |
963 | icon = loadPixmap( pathString + "2rightarrowB" ); | 970 | icon = loadPixmap( pathString + "2rightarrowB" ); |
964 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 971 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
965 | if (p-> mShowIconForwardFast) { | 972 | if (p-> mShowIconForwardFast) { |
966 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 973 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
967 | connect( action, SIGNAL( activated() ), | 974 | connect( action, SIGNAL( activated() ), |
968 | mView, SLOT( goNextMonth() ) ); | 975 | mView, SLOT( goNextMonth() ) ); |
969 | action->addTo( iconToolBar ); | 976 | action->addTo( iconToolBar ); |
970 | } | 977 | } |
971 | 978 | ||
972 | 979 | ||
973 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 980 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
974 | 981 | ||
975 | if (p-> mShowIconNewEvent) | 982 | if (p-> mShowIconNewEvent) |
976 | configureToolBarMenu->setItemChecked( 10, true ); | 983 | configureToolBarMenu->setItemChecked( 10, true ); |
977 | if (p->mShowIconNewTodo ) | 984 | if (p->mShowIconNewTodo ) |
978 | configureToolBarMenu->setItemChecked( 20, true ); | 985 | configureToolBarMenu->setItemChecked( 20, true ); |
979 | if (p-> mShowIconSearch) | 986 | if (p-> mShowIconSearch) |
980 | configureToolBarMenu->setItemChecked( 120, true ); | 987 | configureToolBarMenu->setItemChecked( 120, true ); |
981 | if (p-> mShowIconList) | 988 | if (p-> mShowIconList) |
982 | configureToolBarMenu->setItemChecked( 30, true ); | 989 | configureToolBarMenu->setItemChecked( 30, true ); |
983 | if (p-> mShowIconDay1) | 990 | if (p-> mShowIconDay1) |
984 | configureToolBarMenu->setItemChecked( 40, true ); | 991 | configureToolBarMenu->setItemChecked( 40, true ); |
985 | if (p-> mShowIconDay5) | 992 | if (p-> mShowIconDay5) |
986 | configureToolBarMenu->setItemChecked( 50, true ); | 993 | configureToolBarMenu->setItemChecked( 50, true ); |
987 | if (p-> mShowIconDay7) | 994 | if (p-> mShowIconDay7) |
988 | configureToolBarMenu->setItemChecked( 60, true ); | 995 | configureToolBarMenu->setItemChecked( 60, true ); |
989 | if (p-> mShowIconMonth) | 996 | if (p-> mShowIconMonth) |
990 | configureToolBarMenu->setItemChecked( 70, true ); | 997 | configureToolBarMenu->setItemChecked( 70, true ); |
991 | if (p-> mShowIconTodoview) | 998 | if (p-> mShowIconTodoview) |
992 | configureToolBarMenu->setItemChecked( 80, true ); | 999 | configureToolBarMenu->setItemChecked( 80, true ); |
993 | if (p-> mShowIconBackFast) | 1000 | if (p-> mShowIconBackFast) |
994 | configureToolBarMenu->setItemChecked( 200, true ); | 1001 | configureToolBarMenu->setItemChecked( 200, true ); |
995 | if (p-> mShowIconBack) | 1002 | if (p-> mShowIconBack) |
996 | configureToolBarMenu->setItemChecked( 210, true ); | 1003 | configureToolBarMenu->setItemChecked( 210, true ); |
997 | if (p-> mShowIconToday) | 1004 | if (p-> mShowIconToday) |
998 | configureToolBarMenu->setItemChecked( 130, true ); | 1005 | configureToolBarMenu->setItemChecked( 130, true ); |
999 | if (p-> mShowIconForward) | 1006 | if (p-> mShowIconForward) |
1000 | configureToolBarMenu->setItemChecked( 220, true ); | 1007 | configureToolBarMenu->setItemChecked( 220, true ); |
1001 | if (p-> mShowIconForwardFast) | 1008 | if (p-> mShowIconForwardFast) |
1002 | configureToolBarMenu->setItemChecked( 230, true ); | 1009 | configureToolBarMenu->setItemChecked( 230, true ); |
1003 | if (p-> mShowIconNextDays) | 1010 | if (p-> mShowIconNextDays) |
1004 | configureToolBarMenu->setItemChecked( 100, true ); | 1011 | configureToolBarMenu->setItemChecked( 100, true ); |
1005 | if (p-> mShowIconNext) | 1012 | if (p-> mShowIconNext) |
1006 | configureToolBarMenu->setItemChecked( 110, true ); | 1013 | configureToolBarMenu->setItemChecked( 110, true ); |
1007 | if (p-> mShowIconJournal) | 1014 | if (p-> mShowIconJournal) |
1008 | configureToolBarMenu->setItemChecked( 90, true ); | 1015 | configureToolBarMenu->setItemChecked( 90, true ); |
1009 | if (p-> mShowIconWhatsThis) | 1016 | if (p-> mShowIconWhatsThis) |
1010 | configureToolBarMenu->setItemChecked( 300, true ); | 1017 | configureToolBarMenu->setItemChecked( 300, true ); |
1011 | 1018 | ||
1012 | QLabel* dummy = new QLabel( iconToolBar ); | 1019 | QLabel* dummy = new QLabel( iconToolBar ); |
1013 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1020 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1014 | if (!p-> mShowIconStretch) | 1021 | if (!p-> mShowIconStretch) |
1015 | iconToolBar->setStretchableWidget ( dummy ) ; | 1022 | iconToolBar->setStretchableWidget ( dummy ) ; |
1016 | else | 1023 | else |
1017 | configureToolBarMenu->setItemChecked( 5, true ); | 1024 | configureToolBarMenu->setItemChecked( 5, true ); |
1018 | if (p-> mShowIconWhatsThis) | 1025 | if (p-> mShowIconWhatsThis) |
1019 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1026 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1020 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1027 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1021 | configureAgenda( p->mHourSize ); | 1028 | configureAgenda( p->mHourSize ); |
1022 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1029 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1023 | } | 1030 | } |
1024 | 1031 | ||
1025 | void MainWindow::exportToPhone( int mode ) | 1032 | void MainWindow::exportToPhone( int mode ) |
1026 | { | 1033 | { |
1027 | 1034 | ||
1028 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1035 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1029 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1036 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1030 | KOex2phonePrefs ex2phone; | 1037 | KOex2phonePrefs ex2phone; |
1031 | 1038 | ||
1032 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1039 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1033 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1040 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1034 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1041 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1035 | if ( mode == 1 ) | 1042 | if ( mode == 1 ) |
1036 | ex2phone.setCaption(i18n("Export complete calendar")); | 1043 | ex2phone.setCaption(i18n("Export complete calendar")); |
1037 | if ( mode == 2 ) | 1044 | if ( mode == 2 ) |
1038 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1045 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1039 | 1046 | ||
1040 | if ( !ex2phone.exec() ) { | 1047 | if ( !ex2phone.exec() ) { |
1041 | return; | 1048 | return; |
1042 | } | 1049 | } |
1043 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1050 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1044 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1051 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1045 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1052 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1046 | 1053 | ||
1047 | int inFuture = 0; | 1054 | int inFuture = 0; |
1048 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1055 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1049 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1056 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1050 | QPtrList<Incidence> delSel; | 1057 | QPtrList<Incidence> delSel; |
1051 | if ( mode == 1 ) | 1058 | if ( mode == 1 ) |
1052 | delSel = mCalendar->rawIncidences(); | 1059 | delSel = mCalendar->rawIncidences(); |
1053 | if ( mode == 2 ) | 1060 | if ( mode == 2 ) |
1054 | delSel = mCalendar->incidences(); | 1061 | delSel = mCalendar->incidences(); |
1055 | CalendarLocal* cal = new CalendarLocal(); | 1062 | CalendarLocal* cal = new CalendarLocal(); |
1056 | cal->setLocalTime(); | 1063 | cal->setLocalTime(); |
1057 | Incidence *incidence = delSel.first(); | 1064 | Incidence *incidence = delSel.first(); |
1058 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1065 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1059 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1066 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1060 | while ( incidence ) { | 1067 | while ( incidence ) { |
1061 | if ( incidence->type() != "Journal" ) { | 1068 | if ( incidence->type() != "Journal" ) { |
1062 | bool add = true; | 1069 | bool add = true; |
1063 | if ( inFuture ) { | 1070 | if ( inFuture ) { |
1064 | QDateTime dt; | 1071 | QDateTime dt; |
1065 | if ( incidence->type() == "Todo" ) { | 1072 | if ( incidence->type() == "Todo" ) { |
1066 | Todo * t = (Todo*)incidence; | 1073 | Todo * t = (Todo*)incidence; |
1067 | if ( t->hasDueDate() ) | 1074 | if ( t->hasDueDate() ) |
1068 | dt = t->dtDue(); | 1075 | dt = t->dtDue(); |
1069 | else | 1076 | else |
1070 | dt = cur.addSecs( 62 ); | 1077 | dt = cur.addSecs( 62 ); |
1071 | } | 1078 | } |
1072 | else { | 1079 | else { |
1073 | bool ok; | 1080 | bool ok; |
1074 | dt = incidence->getNextOccurence( cur, &ok ); | 1081 | dt = incidence->getNextOccurence( cur, &ok ); |
1075 | if ( !ok ) | 1082 | if ( !ok ) |
1076 | dt = cur.addSecs( -62 ); | 1083 | dt = cur.addSecs( -62 ); |
1077 | } | 1084 | } |
1078 | if ( dt < cur || dt > end ) { | 1085 | if ( dt < cur || dt > end ) { |
1079 | add = false; | 1086 | add = false; |
1080 | } | 1087 | } |
1081 | } | 1088 | } |
1082 | if ( add ) { | 1089 | if ( add ) { |
1083 | Incidence *in = incidence->clone(); | 1090 | Incidence *in = incidence->clone(); |
1084 | cal->addIncidence( in ); | 1091 | cal->addIncidence( in ); |
1085 | } | 1092 | } |
1086 | } | 1093 | } |
1087 | incidence = delSel.next(); | 1094 | incidence = delSel.next(); |
1088 | } | 1095 | } |
1089 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1096 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1090 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1097 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1091 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1098 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1092 | 1099 | ||
1093 | setCaption( i18n("Writing to phone...")); | 1100 | setCaption( i18n("Writing to phone...")); |
1094 | if ( PhoneFormat::writeToPhone( cal ) ) | 1101 | if ( PhoneFormat::writeToPhone( cal ) ) |
1095 | setCaption( i18n("Export to phone successful!")); | 1102 | setCaption( i18n("Export to phone successful!")); |
1096 | else | 1103 | else |
1097 | setCaption( i18n("Error exporting to phone!")); | 1104 | setCaption( i18n("Error exporting to phone!")); |
1098 | delete cal; | 1105 | delete cal; |
1099 | } | 1106 | } |
1100 | 1107 | ||
1101 | 1108 | ||
1102 | void MainWindow::setDefaultPreferences() | 1109 | void MainWindow::setDefaultPreferences() |
1103 | { | 1110 | { |
1104 | KOPrefs *p = KOPrefs::instance(); | 1111 | KOPrefs *p = KOPrefs::instance(); |
1105 | 1112 | ||
1106 | p->mCompactDialogs = true; | 1113 | p->mCompactDialogs = true; |
1107 | p->mConfirm = true; | 1114 | p->mConfirm = true; |
1108 | // p->mEnableQuickTodo = false; | 1115 | // p->mEnableQuickTodo = false; |
1109 | 1116 | ||
1110 | } | 1117 | } |
1111 | 1118 | ||
1112 | QString MainWindow::resourcePath() | 1119 | QString MainWindow::resourcePath() |
1113 | { | 1120 | { |
1114 | return KGlobal::iconLoader()->iconPath(); | 1121 | return KGlobal::iconLoader()->iconPath(); |
1115 | } | 1122 | } |
1116 | 1123 | ||
1117 | void MainWindow::displayText( QString text ,QString cap ) | 1124 | void MainWindow::displayText( QString text ,QString cap ) |
1118 | { | 1125 | { |
1119 | QDialog dia( this, "name", true ); ; | 1126 | QDialog dia( this, "name", true ); ; |
1120 | dia.setCaption( cap ); | 1127 | dia.setCaption( cap ); |
1121 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1128 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1122 | lay->setSpacing( 3 ); | 1129 | lay->setSpacing( 3 ); |
1123 | lay->setMargin( 3 ); | 1130 | lay->setMargin( 3 ); |
1124 | QTextBrowser tb ( &dia ); | 1131 | QTextBrowser tb ( &dia ); |
1125 | lay->addWidget( &tb ); | 1132 | lay->addWidget( &tb ); |
1126 | tb.setText( text ); | 1133 | tb.setText( text ); |
1127 | #ifdef DESKTOP_VERSION | 1134 | #ifdef DESKTOP_VERSION |
1128 | dia.resize( 640, 480); | 1135 | dia.resize( 640, 480); |
1129 | #else | 1136 | #else |
1130 | dia.showMaximized(); | 1137 | dia.showMaximized(); |
1131 | #endif | 1138 | #endif |
1132 | dia.exec(); | 1139 | dia.exec(); |
1133 | } | 1140 | } |
1134 | void MainWindow::displayFile( QString fn, QString cap ) | 1141 | void MainWindow::displayFile( QString fn, QString cap ) |
1135 | { | 1142 | { |
1136 | QString fileName = resourcePath() + fn; | 1143 | QString fileName = resourcePath() + fn; |
1137 | QString text; | 1144 | QString text; |
1138 | QFile file( fileName ); | 1145 | QFile file( fileName ); |
1139 | if (!file.open( IO_ReadOnly ) ) { | 1146 | if (!file.open( IO_ReadOnly ) ) { |
1140 | return ; | 1147 | return ; |
1141 | 1148 | ||
1142 | } | 1149 | } |
1143 | QTextStream ts( &file ); | 1150 | QTextStream ts( &file ); |
1144 | text = ts.read(); | 1151 | text = ts.read(); |
1145 | file.close(); | 1152 | file.close(); |
1146 | displayText( text, cap); | 1153 | displayText( text, cap); |
1147 | } | 1154 | } |
1148 | void MainWindow::features() | 1155 | void MainWindow::features() |
1149 | { | 1156 | { |
1150 | 1157 | ||
1151 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1158 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1152 | } | 1159 | } |
1153 | 1160 | ||
1154 | void MainWindow::usertrans() | 1161 | void MainWindow::usertrans() |
1155 | { | 1162 | { |
1156 | 1163 | ||
1157 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1164 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1158 | } | 1165 | } |
1159 | 1166 | ||
1160 | void MainWindow::kdesynchowto() | 1167 | void MainWindow::kdesynchowto() |
1161 | { | 1168 | { |
1162 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1169 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1163 | } | 1170 | } |
1164 | void MainWindow::multisynchowto() | 1171 | void MainWindow::multisynchowto() |
1165 | { | 1172 | { |
1166 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1173 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1167 | } | 1174 | } |
1168 | void MainWindow::synchowto() | 1175 | void MainWindow::synchowto() |
1169 | { | 1176 | { |
1170 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1177 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1171 | } | 1178 | } |
1172 | void MainWindow::faq() | 1179 | void MainWindow::faq() |
1173 | { | 1180 | { |
1174 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1181 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1175 | 1182 | ||
1176 | } | 1183 | } |
1177 | void MainWindow::whatsNew() | 1184 | void MainWindow::whatsNew() |
1178 | { | 1185 | { |
1179 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1186 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1180 | 1187 | ||
1181 | } | 1188 | } |
1182 | void MainWindow::licence() | 1189 | void MainWindow::licence() |
1183 | { | 1190 | { |
1184 | KApplication::showLicence(); | 1191 | KApplication::showLicence(); |
1185 | 1192 | ||
1186 | } | 1193 | } |
1187 | void MainWindow::about() | 1194 | void MainWindow::about() |
1188 | { | 1195 | { |
1189 | QString version; | 1196 | QString version; |
1190 | #include <../version> | 1197 | #include <../version> |
1191 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1198 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1192 | i18n("KOrganizer/Platform-independent\n") + | 1199 | i18n("KOrganizer/Platform-independent\n") + |
1193 | "(KO/Pi) " + version + " - " + | 1200 | "(KO/Pi) " + version + " - " + |
1194 | 1201 | ||
1195 | #ifdef DESKTOP_VERSION | 1202 | #ifdef DESKTOP_VERSION |
1196 | i18n("Desktop Edition\n") + | 1203 | i18n("Desktop Edition\n") + |
1197 | #else | 1204 | #else |
1198 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1205 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1199 | #endif | 1206 | #endif |
1200 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1207 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1201 | } | 1208 | } |
1202 | void MainWindow::keyBindings() | 1209 | void MainWindow::keyBindings() |
1203 | { | 1210 | { |
1204 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1211 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1205 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1212 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1206 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1213 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1207 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1214 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1208 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1215 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1209 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1216 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1210 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1217 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1211 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1218 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1212 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1219 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1213 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1220 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1214 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1221 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1215 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1222 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1216 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1223 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1217 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1224 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1218 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1225 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1219 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1226 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1220 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1227 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1221 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1228 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1222 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1229 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1223 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1230 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1224 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1231 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1225 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1232 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1226 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1233 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1227 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1234 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1228 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1235 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1229 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1236 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1230 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1237 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1231 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1238 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1232 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1239 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1233 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1240 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1234 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1241 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1235 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1242 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1236 | i18n("<p><h3>In list view:</h3></p>\n") + | 1243 | i18n("<p><h3>In list view:</h3></p>\n") + |
1237 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1244 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1238 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1245 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1239 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1246 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1240 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1247 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1241 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1248 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1242 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1249 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1243 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1250 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1244 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1251 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1245 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1252 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1246 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1253 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1247 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1254 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1248 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1255 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1249 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1256 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1250 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1257 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1251 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1258 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1252 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1259 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1253 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1260 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1254 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1261 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1255 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1262 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1256 | displayText( text, cap); | 1263 | displayText( text, cap); |
1257 | 1264 | ||
1258 | } | 1265 | } |
1259 | void MainWindow::aboutAutoSaving() | 1266 | void MainWindow::aboutAutoSaving() |
1260 | { | 1267 | { |
1261 | QMessageBox* msg; | 1268 | QMessageBox* msg; |
1262 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1269 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1263 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1270 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1264 | QMessageBox::Ok, | 1271 | QMessageBox::Ok, |
1265 | QMessageBox::NoButton, | 1272 | QMessageBox::NoButton, |
1266 | QMessageBox::NoButton); | 1273 | QMessageBox::NoButton); |
1267 | msg->exec(); | 1274 | msg->exec(); |
1268 | delete msg; | 1275 | delete msg; |
1269 | 1276 | ||
1270 | 1277 | ||
1271 | } | 1278 | } |
1272 | void MainWindow::aboutKnownBugs() | 1279 | void MainWindow::aboutKnownBugs() |
1273 | { | 1280 | { |
1274 | QMessageBox* msg; | 1281 | QMessageBox* msg; |
1275 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1282 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1276 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1283 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1277 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1284 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1278 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1285 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1279 | i18n("\nor report them in the bugtracker on\n") + | 1286 | i18n("\nor report them in the bugtracker on\n") + |
1280 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1287 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1281 | QMessageBox::NoIcon, | 1288 | QMessageBox::NoIcon, |
1282 | QMessageBox::Ok, | 1289 | QMessageBox::Ok, |
1283 | QMessageBox::NoButton, | 1290 | QMessageBox::NoButton, |
1284 | QMessageBox::NoButton); | 1291 | QMessageBox::NoButton); |
1285 | msg->exec(); | 1292 | msg->exec(); |
1286 | delete msg; | 1293 | delete msg; |
1287 | 1294 | ||
1288 | } | 1295 | } |
1289 | 1296 | ||
1290 | QString MainWindow::defaultFileName() | 1297 | QString MainWindow::defaultFileName() |
1291 | { | 1298 | { |
1292 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1299 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1293 | } | 1300 | } |
1294 | QString MainWindow::syncFileName() | 1301 | QString MainWindow::syncFileName() |
1295 | { | 1302 | { |
1296 | #ifdef DESKTOP_VERSION | 1303 | #ifdef DESKTOP_VERSION |
1297 | return locateLocal( "tmp", "synccalendar.ics" ); | 1304 | return locateLocal( "tmp", "synccalendar.ics" ); |
1298 | #else | 1305 | #else |
1299 | return QString( "/tmp/synccalendar.ics" ); | 1306 | return QString( "/tmp/synccalendar.ics" ); |
1300 | #endif | 1307 | #endif |
1301 | } | 1308 | } |
1302 | 1309 | ||
1303 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1310 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1304 | { | 1311 | { |
1305 | if ( !incidence ) { | 1312 | if ( !incidence ) { |
1306 | enableIncidenceActions( false ); | 1313 | enableIncidenceActions( false ); |
1307 | 1314 | ||
1308 | mNewSubTodoAction->setEnabled( false ); | 1315 | mNewSubTodoAction->setEnabled( false ); |
1309 | setCaptionToDates(); | 1316 | setCaptionToDates(); |
1310 | return; | 1317 | return; |
1311 | 1318 | ||
1312 | } | 1319 | } |
1313 | 1320 | ||
1314 | //KGlobal::locale()->formatDateTime(nextA, true); | 1321 | //KGlobal::locale()->formatDateTime(nextA, true); |
1315 | QString startString = ""; | 1322 | QString startString = ""; |
1316 | if ( incidence->type() != "Todo" ) { | 1323 | if ( incidence->type() != "Todo" ) { |
1317 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1324 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1318 | if ( incidence->doesFloat() ) { | 1325 | if ( incidence->doesFloat() ) { |
1319 | startString += ": "+incidence->dtStartDateStr( true ); | 1326 | startString += ": "+incidence->dtStartDateStr( true ); |
1320 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1327 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1321 | 1328 | ||
1322 | } else { | 1329 | } else { |
1323 | startString = ": "+incidence->dtStartStr(true); | 1330 | startString = ": "+incidence->dtStartStr(true); |
1324 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1331 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1325 | 1332 | ||
1326 | } | 1333 | } |
1327 | 1334 | ||
1328 | } else { | 1335 | } else { |
1329 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1336 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1330 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1337 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1331 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1338 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1332 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1339 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1333 | } | 1340 | } |
1334 | 1341 | ||
1335 | } | 1342 | } |
1336 | else | 1343 | else |
1337 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1344 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1338 | if ( !incidence->location().isEmpty() ) | 1345 | if ( !incidence->location().isEmpty() ) |
1339 | startString += " (" +incidence->location()+")"; | 1346 | startString += " (" +incidence->location()+")"; |
1340 | setCaption( incidence->summary()+startString); | 1347 | setCaption( incidence->summary()+startString); |
1341 | 1348 | ||
1342 | enableIncidenceActions( true ); | 1349 | enableIncidenceActions( true ); |
1343 | 1350 | ||
1344 | if ( incidence->type() == "Event" ) { | 1351 | if ( incidence->type() == "Event" ) { |
1345 | mShowAction->setText( i18n("Show Event...") ); | 1352 | mShowAction->setText( i18n("Show Event...") ); |
1346 | mEditAction->setText( i18n("Edit Event...") ); | 1353 | mEditAction->setText( i18n("Edit Event...") ); |
1347 | mDeleteAction->setText( i18n("Delete Event...") ); | 1354 | mDeleteAction->setText( i18n("Delete Event...") ); |
1348 | 1355 | ||
1349 | mNewSubTodoAction->setEnabled( false ); | 1356 | mNewSubTodoAction->setEnabled( false ); |
1350 | } else if ( incidence->type() == "Todo" ) { | 1357 | } else if ( incidence->type() == "Todo" ) { |
1351 | mShowAction->setText( i18n("Show Todo...") ); | 1358 | mShowAction->setText( i18n("Show Todo...") ); |
1352 | mEditAction->setText( i18n("Edit Todo...") ); | 1359 | mEditAction->setText( i18n("Edit Todo...") ); |
1353 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1360 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1354 | 1361 | ||
1355 | mNewSubTodoAction->setEnabled( true ); | 1362 | mNewSubTodoAction->setEnabled( true ); |
1356 | } else { | 1363 | } else { |
1357 | mShowAction->setText( i18n("Show...") ); | 1364 | mShowAction->setText( i18n("Show...") ); |
1358 | mShowAction->setText( i18n("Edit...") ); | 1365 | mShowAction->setText( i18n("Edit...") ); |
1359 | mShowAction->setText( i18n("Delete...") ); | 1366 | mShowAction->setText( i18n("Delete...") ); |
1360 | 1367 | ||
1361 | mNewSubTodoAction->setEnabled( false ); | 1368 | mNewSubTodoAction->setEnabled( false ); |
1362 | } | 1369 | } |
1363 | } | 1370 | } |
1364 | 1371 | ||
1365 | void MainWindow::enableIncidenceActions( bool enabled ) | 1372 | void MainWindow::enableIncidenceActions( bool enabled ) |
1366 | { | 1373 | { |
1367 | mShowAction->setEnabled( enabled ); | 1374 | mShowAction->setEnabled( enabled ); |
1368 | mEditAction->setEnabled( enabled ); | 1375 | mEditAction->setEnabled( enabled ); |
1369 | mDeleteAction->setEnabled( enabled ); | 1376 | mDeleteAction->setEnabled( enabled ); |
1370 | 1377 | ||
1371 | mCloneAction->setEnabled( enabled ); | 1378 | mCloneAction->setEnabled( enabled ); |
1372 | mMoveAction->setEnabled( enabled ); | 1379 | mMoveAction->setEnabled( enabled ); |
1373 | mBeamAction->setEnabled( enabled ); | 1380 | mBeamAction->setEnabled( enabled ); |
1374 | mCancelAction->setEnabled( enabled ); | 1381 | mCancelAction->setEnabled( enabled ); |
1375 | } | 1382 | } |
1376 | 1383 | ||
1377 | void MainWindow::importOL() | 1384 | void MainWindow::importOL() |
1378 | { | 1385 | { |
1379 | #ifdef _WIN32_ | 1386 | #ifdef _WIN32_ |
1380 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1387 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1381 | id->exec(); | 1388 | id->exec(); |
1382 | delete id; | 1389 | delete id; |
1383 | mView->updateView(); | 1390 | mView->updateView(); |
1384 | #endif | 1391 | #endif |
1385 | } | 1392 | } |
1386 | void MainWindow::importBday() | 1393 | void MainWindow::importBday() |
1387 | { | 1394 | { |
1388 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1395 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1389 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1396 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1390 | i18n("Import!"), i18n("Cancel"), 0, | 1397 | i18n("Import!"), i18n("Cancel"), 0, |
1391 | 0, 1 ); | 1398 | 0, 1 ); |
1392 | if ( result == 0 ) { | 1399 | if ( result == 0 ) { |
1393 | mView->importBday(); | 1400 | mView->importBday(); |
1394 | 1401 | ||
1395 | } | 1402 | } |
1396 | 1403 | ||
1397 | 1404 | ||
1398 | } | 1405 | } |
1399 | void MainWindow::importQtopia() | 1406 | void MainWindow::importQtopia() |
1400 | { | 1407 | { |
1401 | #ifndef DESKTOP_VERSION | 1408 | #ifndef DESKTOP_VERSION |
1402 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1409 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1403 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1410 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1404 | i18n("Import!"), i18n("Cancel"), 0, | 1411 | i18n("Import!"), i18n("Cancel"), 0, |
1405 | 0, 1 ); | 1412 | 0, 1 ); |
1406 | if ( result == 0 ) { | 1413 | if ( result == 0 ) { |
1407 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1414 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1408 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1415 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1409 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1416 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1410 | mView->importQtopia( categories, datebook, todolist ); | 1417 | mView->importQtopia( categories, datebook, todolist ); |
1411 | } | 1418 | } |
1412 | #else | 1419 | #else |
1413 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1420 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1414 | i18n("Not supported \non desktop!\n"), | 1421 | i18n("Not supported \non desktop!\n"), |
1415 | i18n("Ok"), i18n("Cancel"), 0, | 1422 | i18n("Ok"), i18n("Cancel"), 0, |
1416 | 0, 1 ); | 1423 | 0, 1 ); |
1417 | 1424 | ||
1418 | #endif | 1425 | #endif |
1419 | } | 1426 | } |
1420 | 1427 | ||
1421 | void MainWindow::saveOnClose() | 1428 | void MainWindow::saveOnClose() |
1422 | { | 1429 | { |
1423 | KOPrefs *p = KOPrefs::instance(); | 1430 | KOPrefs *p = KOPrefs::instance(); |
1424 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1431 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1425 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1432 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1426 | iconToolBar->y() > height()/2; | 1433 | iconToolBar->y() > height()/2; |
1427 | mView->writeSettings(); | 1434 | mView->writeSettings(); |
1428 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1435 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1429 | save(); | 1436 | save(); |
1430 | } | 1437 | } |
1431 | void MainWindow::slotModifiedChanged( bool changed ) | 1438 | void MainWindow::slotModifiedChanged( bool changed ) |
1432 | { | 1439 | { |
1433 | if ( mBlockAtStartup ) | 1440 | if ( mBlockAtStartup ) |
1434 | return; | 1441 | return; |
1435 | int msec; | 1442 | int msec; |
1436 | // we store the changes after 1 minute, | 1443 | // we store the changes after 1 minute, |
1437 | // and for safety reasons after 10 minutes again | 1444 | // and for safety reasons after 10 minutes again |
1438 | if ( !mSyncManager->blockSave() ) | 1445 | if ( !mSyncManager->blockSave() ) |
1439 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1446 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1440 | else | 1447 | else |
1441 | msec = 1000 * 600; | 1448 | msec = 1000 * 600; |
1442 | mSaveTimer.start( msec, true ); // 1 minute | 1449 | mSaveTimer.start( msec, true ); // 1 minute |
1443 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1450 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1444 | mCalendarModifiedFlag = true; | 1451 | mCalendarModifiedFlag = true; |
1445 | } | 1452 | } |
1446 | void MainWindow::save() | 1453 | void MainWindow::save() |
1447 | { | 1454 | { |
1448 | if ( mSyncManager->blockSave() ) | 1455 | if ( mSyncManager->blockSave() ) |
1449 | return; | 1456 | return; |
1450 | mSyncManager->setBlockSave(true); | 1457 | mSyncManager->setBlockSave(true); |
1451 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1458 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1452 | 1459 | ||
1453 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1460 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1454 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1461 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1455 | qDebug("KO: Start saving data to file!"); | 1462 | qDebug("KO: Start saving data to file!"); |
1456 | mView->saveCalendar( defaultFileName() ); | 1463 | mView->saveCalendar( defaultFileName() ); |
1457 | 1464 | ||
1458 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1465 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1459 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1466 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1460 | QString savemes; | 1467 | QString savemes; |
1461 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1468 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1462 | setCaption(savemes); | 1469 | setCaption(savemes); |
1463 | } else | 1470 | } else |
1464 | setCaption(i18n("Saving cancelled!")); | 1471 | setCaption(i18n("Saving cancelled!")); |
1465 | mCalendarModifiedFlag = false; | 1472 | mCalendarModifiedFlag = false; |
1466 | mSyncManager->setBlockSave( false ); | 1473 | mSyncManager->setBlockSave( false ); |
1467 | } | 1474 | } |
1468 | 1475 | ||
1469 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1476 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1470 | { | 1477 | { |
1471 | if ( !e->isAutoRepeat() ) { | 1478 | if ( !e->isAutoRepeat() ) { |
1472 | mFlagKeyPressed = false; | 1479 | mFlagKeyPressed = false; |
1473 | } | 1480 | } |
1474 | } | 1481 | } |
1475 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1482 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1476 | { | 1483 | { |
1477 | qApp->processEvents(); | 1484 | qApp->processEvents(); |
1478 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1485 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1479 | e->ignore(); | 1486 | e->ignore(); |
1480 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1487 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1481 | return; | 1488 | return; |
1482 | } | 1489 | } |
1483 | if (! e->isAutoRepeat() ) | 1490 | if (! e->isAutoRepeat() ) |
1484 | mFlagKeyPressed = true; | 1491 | mFlagKeyPressed = true; |
1485 | KOPrefs *p = KOPrefs::instance(); | 1492 | KOPrefs *p = KOPrefs::instance(); |
1486 | bool showSelectedDates = false; | 1493 | bool showSelectedDates = false; |
1487 | int size; | 1494 | int size; |
1488 | int pro = 0; | 1495 | int pro = 0; |
1489 | //qDebug("MainWindow::keyPressEvent "); | 1496 | //qDebug("MainWindow::keyPressEvent "); |
1490 | switch ( e->key() ) { | 1497 | switch ( e->key() ) { |
1491 | case Qt::Key_Right: | 1498 | case Qt::Key_Right: |
1492 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1499 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1493 | mView->goNextMonth(); | 1500 | mView->goNextMonth(); |
1494 | else | 1501 | else |
1495 | mView->goNext(); | 1502 | mView->goNext(); |
1496 | showSelectedDates = true; | 1503 | showSelectedDates = true; |
1497 | break; | 1504 | break; |
1498 | case Qt::Key_Left: | 1505 | case Qt::Key_Left: |
1499 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1506 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1500 | mView->goPreviousMonth(); | 1507 | mView->goPreviousMonth(); |
1501 | else | 1508 | else |
1502 | mView->goPrevious(); | 1509 | mView->goPrevious(); |
1503 | showSelectedDates = true; | 1510 | showSelectedDates = true; |
1504 | break; | 1511 | break; |
1505 | case Qt::Key_Down: | 1512 | case Qt::Key_Down: |
1506 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1513 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1507 | break; | 1514 | break; |
1508 | case Qt::Key_Up: | 1515 | case Qt::Key_Up: |
1509 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1516 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1510 | break; | 1517 | break; |
1511 | case Qt::Key_I: | 1518 | case Qt::Key_I: |
1512 | mView->showIncidence(); | 1519 | mView->showIncidence(); |
1513 | break; | 1520 | break; |
1514 | case Qt::Key_Delete: | 1521 | case Qt::Key_Delete: |
1515 | case Qt::Key_Backspace: | 1522 | case Qt::Key_Backspace: |
1516 | mView->deleteIncidence(); | 1523 | mView->deleteIncidence(); |
1517 | break; | 1524 | break; |
1518 | case Qt::Key_D: | 1525 | case Qt::Key_D: |
1519 | mView->viewManager()->showDayView(); | 1526 | mView->viewManager()->showDayView(); |
1520 | showSelectedDates = true; | 1527 | showSelectedDates = true; |
1521 | break; | 1528 | break; |
1522 | case Qt::Key_O: | 1529 | case Qt::Key_O: |
1523 | mView->toggleFilerEnabled( ); | 1530 | mView->toggleFilerEnabled( ); |
1524 | break; | 1531 | break; |
1525 | case Qt::Key_0: | 1532 | case Qt::Key_0: |
1526 | case Qt::Key_1: | 1533 | case Qt::Key_1: |
1527 | case Qt::Key_2: | 1534 | case Qt::Key_2: |
1528 | case Qt::Key_3: | 1535 | case Qt::Key_3: |
1529 | case Qt::Key_4: | 1536 | case Qt::Key_4: |
1530 | case Qt::Key_5: | 1537 | case Qt::Key_5: |
1531 | case Qt::Key_6: | 1538 | case Qt::Key_6: |
1532 | case Qt::Key_7: | 1539 | case Qt::Key_7: |
1533 | case Qt::Key_8: | 1540 | case Qt::Key_8: |
1534 | case Qt::Key_9: | 1541 | case Qt::Key_9: |
1535 | pro = e->key()-48; | 1542 | pro = e->key()-48; |
1536 | if ( pro == 0 ) | 1543 | if ( pro == 0 ) |
1537 | pro = 10; | 1544 | pro = 10; |
1538 | if ( e->state() == Qt::ControlButton) | 1545 | if ( e->state() == Qt::ControlButton) |
1539 | pro += 10; | 1546 | pro += 10; |
1540 | break; | 1547 | break; |
1541 | case Qt::Key_M: | 1548 | case Qt::Key_M: |
1542 | mView->viewManager()->showMonthView(); | 1549 | mView->viewManager()->showMonthView(); |
1543 | showSelectedDates = true; | 1550 | showSelectedDates = true; |
1544 | break; | 1551 | break; |
1545 | case Qt::Key_Insert: | 1552 | case Qt::Key_Insert: |
1546 | mView->newEvent(); | 1553 | mView->newEvent(); |
1547 | break; | 1554 | break; |
1548 | case Qt::Key_S : | 1555 | case Qt::Key_S : |
1549 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1556 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1550 | mView->newSubTodo(); | 1557 | mView->newSubTodo(); |
1551 | else | 1558 | else |
1552 | mView->dialogManager()->showSearchDialog(); | 1559 | mView->dialogManager()->showSearchDialog(); |
1553 | break; | 1560 | break; |
1554 | case Qt::Key_Y : | 1561 | case Qt::Key_Y : |
1555 | case Qt::Key_Z : | 1562 | case Qt::Key_Z : |
1556 | mView->viewManager()->showWorkWeekView(); | 1563 | mView->viewManager()->showWorkWeekView(); |
1557 | showSelectedDates = true; | 1564 | showSelectedDates = true; |
1558 | break; | 1565 | break; |
1559 | case Qt::Key_U : | 1566 | case Qt::Key_U : |
1560 | mView->viewManager()->showWeekView(); | 1567 | mView->viewManager()->showWeekView(); |
1561 | showSelectedDates = true; | 1568 | showSelectedDates = true; |
1562 | break; | 1569 | break; |
1563 | case Qt::Key_H : | 1570 | case Qt::Key_H : |
1564 | keyBindings(); | 1571 | keyBindings(); |
1565 | break; | 1572 | break; |
1566 | case Qt::Key_W: | 1573 | case Qt::Key_W: |
1567 | mView->viewManager()->showWhatsNextView(); | 1574 | mView->viewManager()->showWhatsNextView(); |
1568 | break; | 1575 | break; |
1569 | case Qt::Key_L: | 1576 | case Qt::Key_L: |
1570 | mView->viewManager()->showListView(); | 1577 | mView->viewManager()->showListView(); |
1571 | break; | 1578 | break; |
1572 | case Qt::Key_N: | 1579 | case Qt::Key_N: |
1573 | mView->viewManager()->showNextXView(); | 1580 | mView->viewManager()->showNextXView(); |
1574 | showSelectedDates = true; | 1581 | showSelectedDates = true; |
1575 | break; | 1582 | break; |
1576 | case Qt::Key_V: | 1583 | case Qt::Key_V: |
1577 | mView->viewManager()->showTodoView(); | 1584 | mView->viewManager()->showTodoView(); |
1578 | break; | 1585 | break; |
1579 | case Qt::Key_C: | 1586 | case Qt::Key_C: |
1580 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1587 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1581 | break; | 1588 | break; |
1582 | case Qt::Key_P: | 1589 | case Qt::Key_P: |
1583 | mView->showDatePicker( ); | 1590 | mView->showDatePicker( ); |
1584 | break; | 1591 | break; |
1585 | case Qt::Key_F: | 1592 | case Qt::Key_F: |
1586 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1593 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1587 | mView->editFilters(); | 1594 | mView->editFilters(); |
1588 | else | 1595 | else |
1589 | mView->toggleFilter(); | 1596 | mView->toggleFilter(); |
1590 | break; | 1597 | break; |
1591 | case Qt::Key_X: | 1598 | case Qt::Key_X: |
1592 | mView->toggleDateNavigatorWidget(); | 1599 | mView->toggleDateNavigatorWidget(); |
1593 | break; | 1600 | break; |
1594 | case Qt::Key_Space: | 1601 | case Qt::Key_Space: |
1595 | mView->toggleExpand(); | 1602 | mView->toggleExpand(); |
1596 | break; | 1603 | break; |
1597 | case Qt::Key_A: | 1604 | case Qt::Key_A: |
1598 | mView->toggleAllDaySize(); | 1605 | mView->toggleAllDaySize(); |
1599 | break; | 1606 | break; |
1600 | case Qt::Key_T: | 1607 | case Qt::Key_T: |
1601 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1608 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1602 | mView->newTodo(); | 1609 | mView->newTodo(); |
1603 | else { | 1610 | else { |
1604 | mView->goToday(); | 1611 | mView->goToday(); |
1605 | showSelectedDates = true; | 1612 | showSelectedDates = true; |
1606 | } | 1613 | } |
1607 | break; | 1614 | break; |
1608 | case Qt::Key_J: | 1615 | case Qt::Key_J: |
1609 | mView->viewManager()->showJournalView(); | 1616 | mView->viewManager()->showJournalView(); |
1610 | break; | 1617 | break; |
1611 | case Qt::Key_B: | 1618 | case Qt::Key_B: |
1612 | mView->editIncidenceDescription();; | 1619 | mView->editIncidenceDescription();; |
1613 | break; | 1620 | break; |
1614 | // case Qt::Key_Return: | 1621 | // case Qt::Key_Return: |
1615 | case Qt::Key_E: | 1622 | case Qt::Key_E: |
1616 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1623 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1617 | mView->newEvent(); | 1624 | mView->newEvent(); |
1618 | else | 1625 | else |
1619 | mView->editIncidence(); | 1626 | mView->editIncidence(); |
1620 | break; | 1627 | break; |
1621 | case Qt::Key_Plus: | 1628 | case Qt::Key_Plus: |
1622 | size = p->mHourSize +2; | 1629 | size = p->mHourSize +2; |
1623 | if ( size <= 18 ) | 1630 | if ( size <= 18 ) |
1624 | configureAgenda( size ); | 1631 | configureAgenda( size ); |
1625 | break; | 1632 | break; |
1626 | case Qt::Key_Minus: | 1633 | case Qt::Key_Minus: |
1627 | size = p->mHourSize - 2; | 1634 | size = p->mHourSize - 2; |
1628 | if ( size >= 4 ) | 1635 | if ( size >= 4 ) |
1629 | configureAgenda( size ); | 1636 | configureAgenda( size ); |
1630 | break; | 1637 | break; |
1631 | 1638 | ||
1632 | 1639 | ||
1633 | default: | 1640 | default: |
1634 | e->ignore(); | 1641 | e->ignore(); |
1635 | } | 1642 | } |
1636 | if ( pro > 0 ) { | 1643 | if ( pro > 0 ) { |
1637 | mView->selectFilter( pro-1 ); | 1644 | mView->selectFilter( pro-1 ); |
1638 | } | 1645 | } |
1639 | if ( showSelectedDates ) { | 1646 | if ( showSelectedDates ) { |
1640 | ;// setCaptionToDates(); | 1647 | ;// setCaptionToDates(); |
1641 | } | 1648 | } |
1642 | 1649 | ||
1643 | } | 1650 | } |
1644 | 1651 | ||
1645 | void MainWindow::fillFilterMenu() | 1652 | void MainWindow::fillFilterMenu() |
1646 | { | 1653 | { |
1647 | selectFilterMenu->clear(); | 1654 | selectFilterMenu->clear(); |
1648 | bool disable = false; | 1655 | bool disable = false; |
1649 | if ( mView->filterView()->filtersEnabled() ) { | 1656 | if ( mView->filterView()->filtersEnabled() ) { |
1650 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1657 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1651 | } | 1658 | } |
1652 | else { | 1659 | else { |
1653 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1660 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1654 | disable = true; | 1661 | disable = true; |
1655 | } | 1662 | } |
1656 | selectFilterMenu->insertSeparator(); | 1663 | selectFilterMenu->insertSeparator(); |
1657 | QPtrList<CalFilter> fili = mView->filters(); | 1664 | QPtrList<CalFilter> fili = mView->filters(); |
1658 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1665 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1659 | CalFilter *filter = fili.first(); | 1666 | CalFilter *filter = fili.first(); |
1660 | int iii = 1; | 1667 | int iii = 1; |
1661 | while(filter) { | 1668 | while(filter) { |
1662 | selectFilterMenu->insertItem( filter->name(), iii ); | 1669 | selectFilterMenu->insertItem( filter->name(), iii ); |
1663 | if ( filter == curfilter) | 1670 | if ( filter == curfilter) |
1664 | selectFilterMenu->setItemChecked( iii, true ); | 1671 | selectFilterMenu->setItemChecked( iii, true ); |
1665 | if ( disable ) | 1672 | if ( disable ) |
1666 | selectFilterMenu->setItemEnabled( iii, false ); | 1673 | selectFilterMenu->setItemEnabled( iii, false ); |
1667 | filter = fili.next(); | 1674 | filter = fili.next(); |
1668 | ++iii; | 1675 | ++iii; |
1669 | } | 1676 | } |
1670 | } | 1677 | } |
1671 | void MainWindow::selectFilter( int fil ) | 1678 | void MainWindow::selectFilter( int fil ) |
1672 | { | 1679 | { |
1673 | if ( fil == 0 ) { | 1680 | if ( fil == 0 ) { |
1674 | mView->toggleFilerEnabled( ); | 1681 | mView->toggleFilerEnabled( ); |
1675 | } else { | 1682 | } else { |
1676 | mView->selectFilter( fil-1 ); | 1683 | mView->selectFilter( fil-1 ); |
1677 | } | 1684 | } |
1678 | } | 1685 | } |
1679 | void MainWindow::configureToolBar( int item ) | 1686 | void MainWindow::configureToolBar( int item ) |
1680 | { | 1687 | { |
1681 | 1688 | ||
1682 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1689 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1683 | KOPrefs *p = KOPrefs::instance(); | 1690 | KOPrefs *p = KOPrefs::instance(); |
1684 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1691 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1685 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1692 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1686 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1693 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1687 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1694 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1688 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1695 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1689 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1696 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1690 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1697 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1691 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1698 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1692 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1699 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1693 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1700 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1694 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1701 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1695 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1702 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1696 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1703 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1697 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1704 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1698 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1705 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1699 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1706 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1700 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1707 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1701 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1708 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1702 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1709 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1703 | // initActions(); | 1710 | // initActions(); |
1704 | } | 1711 | } |
1705 | 1712 | ||
1706 | void MainWindow::setCaptionToDates() | 1713 | void MainWindow::setCaptionToDates() |
1707 | { | 1714 | { |
1708 | QString selDates; | 1715 | QString selDates; |
1709 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1716 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1710 | if (mView->startDate() < mView->endDate() ) | 1717 | if (mView->startDate() < mView->endDate() ) |
1711 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1718 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1712 | setCaption( i18n("Dates: ") + selDates ); | 1719 | setCaption( i18n("Dates: ") + selDates ); |
1713 | 1720 | ||
1714 | } | 1721 | } |
1715 | // parameter item == 0: reinit | 1722 | // parameter item == 0: reinit |
1716 | void MainWindow::configureAgenda( int item ) | 1723 | void MainWindow::configureAgenda( int item ) |
1717 | { | 1724 | { |
1718 | 1725 | ||
1719 | KOPrefs *p = KOPrefs::instance(); | 1726 | KOPrefs *p = KOPrefs::instance(); |
1720 | 1727 | ||
1721 | int i; | 1728 | int i; |
1722 | if ( item == 1 ) { | 1729 | if ( item == 1 ) { |
1723 | mView->toggleAllDaySize(); | 1730 | mView->toggleAllDaySize(); |
1724 | return; | 1731 | return; |
1725 | } | 1732 | } |
1726 | // do not allow 4 for widgets higher than 480 | 1733 | // do not allow 4 for widgets higher than 480 |
1727 | // if ( QApplication::desktop()->height() > 480 ) { | 1734 | // if ( QApplication::desktop()->height() > 480 ) { |
1728 | // if ( item == 4 ) | 1735 | // if ( item == 4 ) |
1729 | // item = 6; | 1736 | // item = 6; |
1730 | // } | 1737 | // } |
1731 | for ( i = 4; i <= 18; i= i+2 ) | 1738 | for ( i = 4; i <= 18; i= i+2 ) |
1732 | configureAgendaMenu->setItemChecked( i, false ); | 1739 | configureAgendaMenu->setItemChecked( i, false ); |
1733 | configureAgendaMenu->setItemChecked( item, true ); | 1740 | configureAgendaMenu->setItemChecked( item, true ); |
1734 | if ( p->mHourSize == item ) | 1741 | if ( p->mHourSize == item ) |
1735 | return; | 1742 | return; |
1736 | p->mHourSize=item; | 1743 | p->mHourSize=item; |
1737 | mView->viewManager()->agendaView()->updateConfig(); | 1744 | mView->viewManager()->agendaView()->updateConfig(); |
1738 | } | 1745 | } |
1739 | 1746 | ||
1740 | void MainWindow::saveCalendar() | 1747 | void MainWindow::saveCalendar() |
1741 | { | 1748 | { |
1742 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1749 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1743 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1750 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1744 | 1751 | ||
1745 | if ( fn == "" ) | 1752 | if ( fn == "" ) |
1746 | return; | 1753 | return; |
1747 | QFileInfo info; | 1754 | QFileInfo info; |
1748 | info.setFile( fn ); | 1755 | info.setFile( fn ); |
1749 | QString mes; | 1756 | QString mes; |
1750 | bool createbup = true; | 1757 | bool createbup = true; |
1751 | if ( info. exists() ) { | 1758 | if ( info. exists() ) { |
1752 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1759 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1753 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1760 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1754 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1761 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1755 | 0, 1 ); | 1762 | 0, 1 ); |
1756 | if ( result != 0 ) { | 1763 | if ( result != 0 ) { |
1757 | createbup = false; | 1764 | createbup = false; |
1758 | } | 1765 | } |
1759 | } | 1766 | } |
1760 | if ( createbup ) { | 1767 | if ( createbup ) { |
1761 | mView->saveCalendar( fn ); | 1768 | mView->saveCalendar( fn ); |
1762 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1769 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1763 | KOPrefs::instance()->mLastSaveFile = fn; | 1770 | KOPrefs::instance()->mLastSaveFile = fn; |
1764 | setCaption(mes); | 1771 | setCaption(mes); |
1765 | } | 1772 | } |
1766 | } | 1773 | } |
1767 | void MainWindow::loadCalendar() | 1774 | void MainWindow::loadCalendar() |
1768 | { | 1775 | { |
1769 | 1776 | ||
1770 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1777 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1771 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1778 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1772 | 1779 | ||
1773 | if ( fn == "" ) | 1780 | if ( fn == "" ) |
1774 | return; | 1781 | return; |
1775 | QFileInfo info; | 1782 | QFileInfo info; |
1776 | info.setFile( fn ); | 1783 | info.setFile( fn ); |
1777 | QString mess; | 1784 | QString mess; |
1778 | bool loadbup = true; | 1785 | bool loadbup = true; |
1779 | if ( info. exists() ) { | 1786 | if ( info. exists() ) { |
1780 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1787 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1781 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1788 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1782 | mess, | 1789 | mess, |
1783 | i18n("Load!"), i18n("Cancel"), 0, | 1790 | i18n("Load!"), i18n("Cancel"), 0, |
1784 | 0, 1 ); | 1791 | 0, 1 ); |
1785 | if ( result != 0 ) { | 1792 | if ( result != 0 ) { |
1786 | loadbup = false; | 1793 | loadbup = false; |
1787 | } | 1794 | } |
1788 | } else { | 1795 | } else { |
1789 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1796 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1790 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1797 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1791 | 0, 1 ); | 1798 | 0, 1 ); |
1792 | 1799 | ||
1793 | return; | 1800 | return; |
1794 | } | 1801 | } |
1795 | if ( loadbup ) { | 1802 | if ( loadbup ) { |
1796 | mView->openCalendar( fn ); | 1803 | mView->openCalendar( fn ); |
1797 | KOPrefs::instance()->mLastLoadFile = fn; | 1804 | KOPrefs::instance()->mLastLoadFile = fn; |
1798 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1805 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1799 | setCaption(mess); | 1806 | setCaption(mess); |
1800 | } | 1807 | } |
1801 | 1808 | ||
1802 | } | 1809 | } |
1803 | void MainWindow::quickImportIcal() | 1810 | void MainWindow::quickImportIcal() |
1804 | { | 1811 | { |
1805 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1812 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1806 | } | 1813 | } |
1807 | void MainWindow::importFile( QString fn, bool quick ) | 1814 | void MainWindow::importFile( QString fn, bool quick ) |
1808 | { | 1815 | { |
1809 | QFileInfo info; | 1816 | QFileInfo info; |
1810 | info.setFile( fn ); | 1817 | info.setFile( fn ); |
1811 | QString mess; | 1818 | QString mess; |
1812 | bool loadbup = true; | 1819 | bool loadbup = true; |
1813 | if ( !info. exists() ) { | 1820 | if ( !info. exists() ) { |
1814 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1821 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1815 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1822 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1816 | mess ); | 1823 | mess ); |
1817 | return; | 1824 | return; |
1818 | } | 1825 | } |
1819 | int result = 0; | 1826 | int result = 0; |
1820 | if ( !quick ) { | 1827 | if ( !quick ) { |
1821 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1828 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1822 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1829 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1823 | mess, | 1830 | mess, |
1824 | "Import", "Cancel", 0, | 1831 | "Import", "Cancel", 0, |
1825 | 0, 1 ); | 1832 | 0, 1 ); |
1826 | } | 1833 | } |
1827 | if ( result == 0 ) { | 1834 | if ( result == 0 ) { |
1828 | if ( mView->openCalendar( fn, true )) { | 1835 | if ( mView->openCalendar( fn, true )) { |
1829 | KOPrefs::instance()->mLastImportFile = fn; | 1836 | KOPrefs::instance()->mLastImportFile = fn; |
1830 | setCaption(i18n("Imported file successfully")); | 1837 | setCaption(i18n("Imported file successfully")); |
1831 | } else { | 1838 | } else { |
1832 | setCaption(i18n("Error importing file")); | 1839 | setCaption(i18n("Error importing file")); |
1833 | } | 1840 | } |
1834 | } | 1841 | } |
1835 | } | 1842 | } |
1836 | 1843 | ||
1837 | void MainWindow::importIcal() | 1844 | void MainWindow::importIcal() |
1838 | { | 1845 | { |
1839 | 1846 | ||
1840 | QString fn =KOPrefs::instance()->mLastImportFile; | 1847 | QString fn =KOPrefs::instance()->mLastImportFile; |
1841 | 1848 | ||
1842 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1849 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1843 | if ( fn == "" ) | 1850 | if ( fn == "" ) |
1844 | return; | 1851 | return; |
1845 | importFile( fn, true ); | 1852 | importFile( fn, true ); |
1846 | 1853 | ||
1847 | } | 1854 | } |
1848 | 1855 | ||
1849 | void MainWindow::exportVCalendar() | 1856 | void MainWindow::exportVCalendar() |
1850 | { | 1857 | { |
1851 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1858 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1852 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1859 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1853 | if ( fn == "" ) | 1860 | if ( fn == "" ) |
1854 | return; | 1861 | return; |
1855 | QFileInfo info; | 1862 | QFileInfo info; |
1856 | info.setFile( fn ); | 1863 | info.setFile( fn ); |
1857 | QString mes; | 1864 | QString mes; |
1858 | bool createbup = true; | 1865 | bool createbup = true; |
1859 | if ( info. exists() ) { | 1866 | if ( info. exists() ) { |
1860 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1867 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1861 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1868 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1862 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1869 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1863 | 0, 1 ); | 1870 | 0, 1 ); |
1864 | if ( result != 0 ) { | 1871 | if ( result != 0 ) { |
1865 | createbup = false; | 1872 | createbup = false; |
1866 | } | 1873 | } |
1867 | } | 1874 | } |
1868 | if ( createbup ) { | 1875 | if ( createbup ) { |
1869 | if ( mView->exportVCalendar( fn ) ) { | 1876 | if ( mView->exportVCalendar( fn ) ) { |
1870 | KOPrefs::instance()->mLastVcalFile = fn; | 1877 | KOPrefs::instance()->mLastVcalFile = fn; |
1871 | if ( fn.length() > 20 ) | 1878 | if ( fn.length() > 20 ) |
1872 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1879 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1873 | else | 1880 | else |
1874 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1881 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1875 | setCaption(mes); | 1882 | setCaption(mes); |
1876 | } | 1883 | } |
1877 | } | 1884 | } |
1878 | 1885 | ||
1879 | } | 1886 | } |
1880 | 1887 | ||
1881 | void MainWindow::syncFileRequest() | 1888 | void MainWindow::syncFileRequest() |
1882 | { | 1889 | { |
1883 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1890 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1884 | mSyncManager->slotSyncMenu( 999 ); | 1891 | mSyncManager->slotSyncMenu( 999 ); |
1885 | } | 1892 | } |
1886 | save(); | 1893 | save(); |
1887 | } | 1894 | } |
1888 | void MainWindow::getFile( bool success ) | 1895 | void MainWindow::getFile( bool success ) |
1889 | { | 1896 | { |
1890 | if ( ! success ) { | 1897 | if ( ! success ) { |
1891 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1898 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1892 | return; | 1899 | return; |
1893 | } | 1900 | } |
1894 | mView->openCalendar( defaultFileName() ); | 1901 | mView->openCalendar( defaultFileName() ); |
1895 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1902 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1896 | mSyncManager->slotSyncMenu( 999 ); | 1903 | mSyncManager->slotSyncMenu( 999 ); |
1897 | } | 1904 | } |
1898 | setCaption( i18n("Pi-Sync successful!") ); | 1905 | setCaption( i18n("Pi-Sync successful!") ); |
1899 | } | 1906 | } |
1900 | 1907 | ||
1901 | void MainWindow::printSel( ) | 1908 | void MainWindow::printSel( ) |
1902 | { | 1909 | { |
1903 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1910 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1904 | } | 1911 | } |
1905 | 1912 | ||
1906 | void MainWindow::printCal() | 1913 | void MainWindow::printCal() |
1907 | { | 1914 | { |
1908 | mView->print();//mCp->showDialog(); | 1915 | mView->print();//mCp->showDialog(); |
1909 | } | 1916 | } |
1910 | 1917 | ||
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 52daaaa..88351eb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,457 +1,466 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); | 41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | 55 | mUndoIncidence = 0; | |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | ||
113 | delete mUndoIncidence; | ||
112 | } | 114 | } |
113 | 115 | ||
114 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
115 | { | 117 | { |
116 | return mOwner; | 118 | return mOwner; |
117 | } | 119 | } |
118 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | ||
122 | { | ||
123 | if (!mUndoIncidence) | ||
124 | return false; | ||
125 | addIncidence(mUndoIncidence); | ||
126 | mUndoIncidence = 0; | ||
127 | } | ||
119 | void Calendar::setOwner(const QString &os) | 128 | void Calendar::setOwner(const QString &os) |
120 | { | 129 | { |
121 | int i; | 130 | int i; |
122 | mOwner = os; | 131 | mOwner = os; |
123 | i = mOwner.find(','); | 132 | i = mOwner.find(','); |
124 | if (i != -1) | 133 | if (i != -1) |
125 | mOwner = mOwner.left(i); | 134 | mOwner = mOwner.left(i); |
126 | 135 | ||
127 | setModified( true ); | 136 | setModified( true ); |
128 | } | 137 | } |
129 | 138 | ||
130 | void Calendar::setTimeZone(const QString & tz) | 139 | void Calendar::setTimeZone(const QString & tz) |
131 | { | 140 | { |
132 | bool neg = FALSE; | 141 | bool neg = FALSE; |
133 | int hours, minutes; | 142 | int hours, minutes; |
134 | QString tmpStr(tz); | 143 | QString tmpStr(tz); |
135 | 144 | ||
136 | if (tmpStr.left(1) == "-") | 145 | if (tmpStr.left(1) == "-") |
137 | neg = TRUE; | 146 | neg = TRUE; |
138 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 147 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
139 | tmpStr.remove(0, 1); | 148 | tmpStr.remove(0, 1); |
140 | hours = tmpStr.left(2).toInt(); | 149 | hours = tmpStr.left(2).toInt(); |
141 | if (tmpStr.length() > 2) | 150 | if (tmpStr.length() > 2) |
142 | minutes = tmpStr.right(2).toInt(); | 151 | minutes = tmpStr.right(2).toInt(); |
143 | else | 152 | else |
144 | minutes = 0; | 153 | minutes = 0; |
145 | mTimeZone = (60*hours+minutes); | 154 | mTimeZone = (60*hours+minutes); |
146 | if (neg) | 155 | if (neg) |
147 | mTimeZone = -mTimeZone; | 156 | mTimeZone = -mTimeZone; |
148 | mLocalTime = false; | 157 | mLocalTime = false; |
149 | 158 | ||
150 | setModified( true ); | 159 | setModified( true ); |
151 | } | 160 | } |
152 | 161 | ||
153 | QString Calendar::getTimeZoneStr() const | 162 | QString Calendar::getTimeZoneStr() const |
154 | { | 163 | { |
155 | if (mLocalTime) | 164 | if (mLocalTime) |
156 | return ""; | 165 | return ""; |
157 | QString tmpStr; | 166 | QString tmpStr; |
158 | int hours = abs(mTimeZone / 60); | 167 | int hours = abs(mTimeZone / 60); |
159 | int minutes = abs(mTimeZone % 60); | 168 | int minutes = abs(mTimeZone % 60); |
160 | bool neg = mTimeZone < 0; | 169 | bool neg = mTimeZone < 0; |
161 | 170 | ||
162 | tmpStr.sprintf("%c%.2d%.2d", | 171 | tmpStr.sprintf("%c%.2d%.2d", |
163 | (neg ? '-' : '+'), | 172 | (neg ? '-' : '+'), |
164 | hours, minutes); | 173 | hours, minutes); |
165 | return tmpStr; | 174 | return tmpStr; |
166 | } | 175 | } |
167 | 176 | ||
168 | void Calendar::setTimeZone(int tz) | 177 | void Calendar::setTimeZone(int tz) |
169 | { | 178 | { |
170 | mTimeZone = tz; | 179 | mTimeZone = tz; |
171 | mLocalTime = false; | 180 | mLocalTime = false; |
172 | 181 | ||
173 | setModified( true ); | 182 | setModified( true ); |
174 | } | 183 | } |
175 | 184 | ||
176 | int Calendar::getTimeZone() const | 185 | int Calendar::getTimeZone() const |
177 | { | 186 | { |
178 | return mTimeZone; | 187 | return mTimeZone; |
179 | } | 188 | } |
180 | 189 | ||
181 | void Calendar::setTimeZoneId(const QString &id) | 190 | void Calendar::setTimeZoneId(const QString &id) |
182 | { | 191 | { |
183 | mTimeZoneId = id; | 192 | mTimeZoneId = id; |
184 | mLocalTime = false; | 193 | mLocalTime = false; |
185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 194 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
186 | if ( mTimeZone > 1000) | 195 | if ( mTimeZone > 1000) |
187 | setLocalTime(); | 196 | setLocalTime(); |
188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 197 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
189 | setModified( true ); | 198 | setModified( true ); |
190 | } | 199 | } |
191 | 200 | ||
192 | QString Calendar::timeZoneId() const | 201 | QString Calendar::timeZoneId() const |
193 | { | 202 | { |
194 | return mTimeZoneId; | 203 | return mTimeZoneId; |
195 | } | 204 | } |
196 | 205 | ||
197 | void Calendar::setLocalTime() | 206 | void Calendar::setLocalTime() |
198 | { | 207 | { |
199 | //qDebug("Calendar::setLocalTime() "); | 208 | //qDebug("Calendar::setLocalTime() "); |
200 | mLocalTime = true; | 209 | mLocalTime = true; |
201 | mTimeZone = 0; | 210 | mTimeZone = 0; |
202 | mTimeZoneId = ""; | 211 | mTimeZoneId = ""; |
203 | 212 | ||
204 | setModified( true ); | 213 | setModified( true ); |
205 | } | 214 | } |
206 | 215 | ||
207 | bool Calendar::isLocalTime() const | 216 | bool Calendar::isLocalTime() const |
208 | { | 217 | { |
209 | return mLocalTime; | 218 | return mLocalTime; |
210 | } | 219 | } |
211 | 220 | ||
212 | const QString &Calendar::getEmail() | 221 | const QString &Calendar::getEmail() |
213 | { | 222 | { |
214 | return mOwnerEmail; | 223 | return mOwnerEmail; |
215 | } | 224 | } |
216 | 225 | ||
217 | void Calendar::setEmail(const QString &e) | 226 | void Calendar::setEmail(const QString &e) |
218 | { | 227 | { |
219 | mOwnerEmail = e; | 228 | mOwnerEmail = e; |
220 | 229 | ||
221 | setModified( true ); | 230 | setModified( true ); |
222 | } | 231 | } |
223 | 232 | ||
224 | void Calendar::setFilter(CalFilter *filter) | 233 | void Calendar::setFilter(CalFilter *filter) |
225 | { | 234 | { |
226 | mFilter = filter; | 235 | mFilter = filter; |
227 | } | 236 | } |
228 | 237 | ||
229 | CalFilter *Calendar::filter() | 238 | CalFilter *Calendar::filter() |
230 | { | 239 | { |
231 | return mFilter; | 240 | return mFilter; |
232 | } | 241 | } |
233 | 242 | ||
234 | QPtrList<Incidence> Calendar::incidences() | 243 | QPtrList<Incidence> Calendar::incidences() |
235 | { | 244 | { |
236 | QPtrList<Incidence> incidences; | 245 | QPtrList<Incidence> incidences; |
237 | 246 | ||
238 | Incidence *i; | 247 | Incidence *i; |
239 | 248 | ||
240 | QPtrList<Event> e = events(); | 249 | QPtrList<Event> e = events(); |
241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 250 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
242 | 251 | ||
243 | QPtrList<Todo> t = todos(); | 252 | QPtrList<Todo> t = todos(); |
244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 253 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
245 | 254 | ||
246 | QPtrList<Journal> j = journals(); | 255 | QPtrList<Journal> j = journals(); |
247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 256 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
248 | 257 | ||
249 | return incidences; | 258 | return incidences; |
250 | } | 259 | } |
251 | 260 | ||
252 | void Calendar::resetPilotStat(int id ) | 261 | void Calendar::resetPilotStat(int id ) |
253 | { | 262 | { |
254 | QPtrList<Incidence> incidences; | 263 | QPtrList<Incidence> incidences; |
255 | 264 | ||
256 | Incidence *i; | 265 | Incidence *i; |
257 | 266 | ||
258 | QPtrList<Event> e = rawEvents(); | 267 | QPtrList<Event> e = rawEvents(); |
259 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 268 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
260 | 269 | ||
261 | QPtrList<Todo> t = rawTodos(); | 270 | QPtrList<Todo> t = rawTodos(); |
262 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 271 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
263 | 272 | ||
264 | QPtrList<Journal> j = journals(); | 273 | QPtrList<Journal> j = journals(); |
265 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 274 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
266 | } | 275 | } |
267 | void Calendar::resetTempSyncStat() | 276 | void Calendar::resetTempSyncStat() |
268 | { | 277 | { |
269 | QPtrList<Incidence> incidences; | 278 | QPtrList<Incidence> incidences; |
270 | 279 | ||
271 | Incidence *i; | 280 | Incidence *i; |
272 | 281 | ||
273 | QPtrList<Event> e = rawEvents(); | 282 | QPtrList<Event> e = rawEvents(); |
274 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 283 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
275 | 284 | ||
276 | QPtrList<Todo> t = rawTodos(); | 285 | QPtrList<Todo> t = rawTodos(); |
277 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 286 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
278 | 287 | ||
279 | QPtrList<Journal> j = journals(); | 288 | QPtrList<Journal> j = journals(); |
280 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 289 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
281 | } | 290 | } |
282 | QPtrList<Incidence> Calendar::rawIncidences() | 291 | QPtrList<Incidence> Calendar::rawIncidences() |
283 | { | 292 | { |
284 | QPtrList<Incidence> incidences; | 293 | QPtrList<Incidence> incidences; |
285 | 294 | ||
286 | Incidence *i; | 295 | Incidence *i; |
287 | 296 | ||
288 | QPtrList<Event> e = rawEvents(); | 297 | QPtrList<Event> e = rawEvents(); |
289 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 298 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
290 | 299 | ||
291 | QPtrList<Todo> t = rawTodos(); | 300 | QPtrList<Todo> t = rawTodos(); |
292 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 301 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
293 | 302 | ||
294 | QPtrList<Journal> j = journals(); | 303 | QPtrList<Journal> j = journals(); |
295 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 304 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
296 | 305 | ||
297 | return incidences; | 306 | return incidences; |
298 | } | 307 | } |
299 | 308 | ||
300 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 309 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
301 | { | 310 | { |
302 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 311 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
303 | mFilter->apply(&el); | 312 | mFilter->apply(&el); |
304 | return el; | 313 | return el; |
305 | } | 314 | } |
306 | 315 | ||
307 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 316 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
308 | { | 317 | { |
309 | QPtrList<Event> el = rawEventsForDate(qdt); | 318 | QPtrList<Event> el = rawEventsForDate(qdt); |
310 | mFilter->apply(&el); | 319 | mFilter->apply(&el); |
311 | return el; | 320 | return el; |
312 | } | 321 | } |
313 | 322 | ||
314 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 323 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
315 | bool inclusive) | 324 | bool inclusive) |
316 | { | 325 | { |
317 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 326 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
318 | mFilter->apply(&el); | 327 | mFilter->apply(&el); |
319 | return el; | 328 | return el; |
320 | } | 329 | } |
321 | 330 | ||
322 | QPtrList<Event> Calendar::events() | 331 | QPtrList<Event> Calendar::events() |
323 | { | 332 | { |
324 | QPtrList<Event> el = rawEvents(); | 333 | QPtrList<Event> el = rawEvents(); |
325 | mFilter->apply(&el); | 334 | mFilter->apply(&el); |
326 | return el; | 335 | return el; |
327 | } | 336 | } |
328 | 337 | ||
329 | 338 | ||
330 | bool Calendar::addIncidence(Incidence *i) | 339 | bool Calendar::addIncidence(Incidence *i) |
331 | { | 340 | { |
332 | Incidence::AddVisitor<Calendar> v(this); | 341 | Incidence::AddVisitor<Calendar> v(this); |
333 | 342 | ||
334 | return i->accept(v); | 343 | return i->accept(v); |
335 | } | 344 | } |
336 | void Calendar::deleteIncidence(Incidence *in) | 345 | void Calendar::deleteIncidence(Incidence *in) |
337 | { | 346 | { |
338 | if ( in->type() == "Event" ) | 347 | if ( in->type() == "Event" ) |
339 | deleteEvent( (Event*) in ); | 348 | deleteEvent( (Event*) in ); |
340 | else if ( in->type() =="Todo" ) | 349 | else if ( in->type() =="Todo" ) |
341 | deleteTodo( (Todo*) in); | 350 | deleteTodo( (Todo*) in); |
342 | else if ( in->type() =="Journal" ) | 351 | else if ( in->type() =="Journal" ) |
343 | deleteJournal( (Journal*) in ); | 352 | deleteJournal( (Journal*) in ); |
344 | } | 353 | } |
345 | 354 | ||
346 | Incidence* Calendar::incidence( const QString& uid ) | 355 | Incidence* Calendar::incidence( const QString& uid ) |
347 | { | 356 | { |
348 | Incidence* i; | 357 | Incidence* i; |
349 | 358 | ||
350 | if( (i = todo( uid )) != 0 ) | 359 | if( (i = todo( uid )) != 0 ) |
351 | return i; | 360 | return i; |
352 | if( (i = event( uid )) != 0 ) | 361 | if( (i = event( uid )) != 0 ) |
353 | return i; | 362 | return i; |
354 | if( (i = journal( uid )) != 0 ) | 363 | if( (i = journal( uid )) != 0 ) |
355 | return i; | 364 | return i; |
356 | 365 | ||
357 | return 0; | 366 | return 0; |
358 | } | 367 | } |
359 | 368 | ||
360 | QPtrList<Todo> Calendar::todos() | 369 | QPtrList<Todo> Calendar::todos() |
361 | { | 370 | { |
362 | QPtrList<Todo> tl = rawTodos(); | 371 | QPtrList<Todo> tl = rawTodos(); |
363 | mFilter->apply( &tl ); | 372 | mFilter->apply( &tl ); |
364 | return tl; | 373 | return tl; |
365 | } | 374 | } |
366 | 375 | ||
367 | // When this is called, the todo have already been added to the calendar. | 376 | // When this is called, the todo have already been added to the calendar. |
368 | // This method is only about linking related todos | 377 | // This method is only about linking related todos |
369 | void Calendar::setupRelations( Incidence *incidence ) | 378 | void Calendar::setupRelations( Incidence *incidence ) |
370 | { | 379 | { |
371 | QString uid = incidence->uid(); | 380 | QString uid = incidence->uid(); |
372 | //qDebug("Calendar::setupRelations "); | 381 | //qDebug("Calendar::setupRelations "); |
373 | // First, go over the list of orphans and see if this is their parent | 382 | // First, go over the list of orphans and see if this is their parent |
374 | while( Incidence* i = mOrphans[ uid ] ) { | 383 | while( Incidence* i = mOrphans[ uid ] ) { |
375 | mOrphans.remove( uid ); | 384 | mOrphans.remove( uid ); |
376 | i->setRelatedTo( incidence ); | 385 | i->setRelatedTo( incidence ); |
377 | incidence->addRelation( i ); | 386 | incidence->addRelation( i ); |
378 | mOrphanUids.remove( i->uid() ); | 387 | mOrphanUids.remove( i->uid() ); |
379 | } | 388 | } |
380 | 389 | ||
381 | // Now see about this incidences parent | 390 | // Now see about this incidences parent |
382 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 391 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
383 | // This incidence has a uid it is related to, but is not registered to it yet | 392 | // This incidence has a uid it is related to, but is not registered to it yet |
384 | // Try to find it | 393 | // Try to find it |
385 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 394 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
386 | if( parent ) { | 395 | if( parent ) { |
387 | // Found it | 396 | // Found it |
388 | incidence->setRelatedTo( parent ); | 397 | incidence->setRelatedTo( parent ); |
389 | parent->addRelation( incidence ); | 398 | parent->addRelation( incidence ); |
390 | } else { | 399 | } else { |
391 | // Not found, put this in the mOrphans list | 400 | // Not found, put this in the mOrphans list |
392 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 401 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
393 | mOrphanUids.insert( incidence->uid(), incidence ); | 402 | mOrphanUids.insert( incidence->uid(), incidence ); |
394 | } | 403 | } |
395 | } | 404 | } |
396 | } | 405 | } |
397 | 406 | ||
398 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 407 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
399 | void Calendar::removeRelations( Incidence *incidence ) | 408 | void Calendar::removeRelations( Incidence *incidence ) |
400 | { | 409 | { |
401 | // qDebug("Calendar::removeRelations "); | 410 | // qDebug("Calendar::removeRelations "); |
402 | QString uid = incidence->uid(); | 411 | QString uid = incidence->uid(); |
403 | 412 | ||
404 | QPtrList<Incidence> relations = incidence->relations(); | 413 | QPtrList<Incidence> relations = incidence->relations(); |
405 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 414 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
406 | if( !mOrphanUids.find( i->uid() ) ) { | 415 | if( !mOrphanUids.find( i->uid() ) ) { |
407 | mOrphans.insert( uid, i ); | 416 | mOrphans.insert( uid, i ); |
408 | mOrphanUids.insert( i->uid(), i ); | 417 | mOrphanUids.insert( i->uid(), i ); |
409 | i->setRelatedTo( 0 ); | 418 | i->setRelatedTo( 0 ); |
410 | i->setRelatedToUid( uid ); | 419 | i->setRelatedToUid( uid ); |
411 | } | 420 | } |
412 | 421 | ||
413 | // If this incidence is related to something else, tell that about it | 422 | // If this incidence is related to something else, tell that about it |
414 | if( incidence->relatedTo() ) | 423 | if( incidence->relatedTo() ) |
415 | incidence->relatedTo()->removeRelation( incidence ); | 424 | incidence->relatedTo()->removeRelation( incidence ); |
416 | 425 | ||
417 | // Remove this one from the orphans list | 426 | // Remove this one from the orphans list |
418 | if( mOrphanUids.remove( uid ) ) | 427 | if( mOrphanUids.remove( uid ) ) |
419 | // This incidence is located in the orphans list - it should be removed | 428 | // This incidence is located in the orphans list - it should be removed |
420 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 429 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
421 | // Removing wasn't that easy | 430 | // Removing wasn't that easy |
422 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 431 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
423 | if( it.current()->uid() == uid ) { | 432 | if( it.current()->uid() == uid ) { |
424 | mOrphans.remove( it.currentKey() ); | 433 | mOrphans.remove( it.currentKey() ); |
425 | break; | 434 | break; |
426 | } | 435 | } |
427 | } | 436 | } |
428 | } | 437 | } |
429 | } | 438 | } |
430 | 439 | ||
431 | void Calendar::registerObserver( Observer *observer ) | 440 | void Calendar::registerObserver( Observer *observer ) |
432 | { | 441 | { |
433 | mObserver = observer; | 442 | mObserver = observer; |
434 | mNewObserver = true; | 443 | mNewObserver = true; |
435 | } | 444 | } |
436 | 445 | ||
437 | void Calendar::setModified( bool modified ) | 446 | void Calendar::setModified( bool modified ) |
438 | { | 447 | { |
439 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 448 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
440 | if ( modified != mModified || mNewObserver ) { | 449 | if ( modified != mModified || mNewObserver ) { |
441 | mNewObserver = false; | 450 | mNewObserver = false; |
442 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 451 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
443 | mModified = modified; | 452 | mModified = modified; |
444 | } | 453 | } |
445 | } | 454 | } |
446 | 455 | ||
447 | void Calendar::setLoadedProductId( const QString &id ) | 456 | void Calendar::setLoadedProductId( const QString &id ) |
448 | { | 457 | { |
449 | mLoadedProductId = id; | 458 | mLoadedProductId = id; |
450 | } | 459 | } |
451 | 460 | ||
452 | QString Calendar::loadedProductId() | 461 | QString Calendar::loadedProductId() |
453 | { | 462 | { |
454 | return mLoadedProductId; | 463 | return mLoadedProductId; |
455 | } | 464 | } |
456 | 465 | ||
457 | //#include "calendar.moc" | 466 | //#include "calendar.moc" |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b7d6a1f..2f2c3aa 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,353 +1,356 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | ||
69 | bool undoDeleteIncidence(); | ||
68 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
70 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
71 | /** | 73 | /** |
72 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
73 | */ | 75 | */ |
74 | virtual void close() = 0; | 76 | virtual void close() = 0; |
75 | 77 | ||
76 | /** | 78 | /** |
77 | Sync changes in memory to persistant storage. | 79 | Sync changes in memory to persistant storage. |
78 | */ | 80 | */ |
79 | virtual void save() = 0; | 81 | virtual void save() = 0; |
80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
81 | virtual void removeSyncInfo( QString syncProfile) = 0; | 83 | virtual void removeSyncInfo( QString syncProfile) = 0; |
82 | virtual bool isSaving() { return false; } | 84 | virtual bool isSaving() { return false; } |
83 | 85 | ||
84 | /** | 86 | /** |
85 | Return the owner of the calendar's full name. | 87 | Return the owner of the calendar's full name. |
86 | */ | 88 | */ |
87 | const QString &getOwner() const; | 89 | const QString &getOwner() const; |
88 | /** | 90 | /** |
89 | Set the owner of the calendar. Should be owner's full name. | 91 | Set the owner of the calendar. Should be owner's full name. |
90 | */ | 92 | */ |
91 | void setOwner( const QString &os ); | 93 | void setOwner( const QString &os ); |
92 | /** | 94 | /** |
93 | Return the email address of the calendar owner. | 95 | Return the email address of the calendar owner. |
94 | */ | 96 | */ |
95 | const QString &getEmail(); | 97 | const QString &getEmail(); |
96 | /** | 98 | /** |
97 | Set the email address of the calendar owner. | 99 | Set the email address of the calendar owner. |
98 | */ | 100 | */ |
99 | void setEmail( const QString & ); | 101 | void setEmail( const QString & ); |
100 | 102 | ||
101 | /** | 103 | /** |
102 | Set time zone from a timezone string (e.g. -2:00) | 104 | Set time zone from a timezone string (e.g. -2:00) |
103 | */ | 105 | */ |
104 | void setTimeZone( const QString &tz ); | 106 | void setTimeZone( const QString &tz ); |
105 | /** | 107 | /** |
106 | Set time zone from a minutes value (e.g. -60) | 108 | Set time zone from a minutes value (e.g. -60) |
107 | */ | 109 | */ |
108 | void setTimeZone( int tz ); | 110 | void setTimeZone( int tz ); |
109 | /** | 111 | /** |
110 | Return time zone as offest in minutes. | 112 | Return time zone as offest in minutes. |
111 | */ | 113 | */ |
112 | int getTimeZone() const; | 114 | int getTimeZone() const; |
113 | /** | 115 | /** |
114 | Compute an ISO 8601 format string from the time zone. | 116 | Compute an ISO 8601 format string from the time zone. |
115 | */ | 117 | */ |
116 | QString getTimeZoneStr() const; | 118 | QString getTimeZoneStr() const; |
117 | /** | 119 | /** |
118 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
119 | values). | 121 | values). |
120 | */ | 122 | */ |
121 | void setTimeZoneId( const QString & ); | 123 | void setTimeZoneId( const QString & ); |
122 | /** | 124 | /** |
123 | Return time zone id. | 125 | Return time zone id. |
124 | */ | 126 | */ |
125 | QString timeZoneId() const; | 127 | QString timeZoneId() const; |
126 | /** | 128 | /** |
127 | Use local time, not UTC or a time zone. | 129 | Use local time, not UTC or a time zone. |
128 | */ | 130 | */ |
129 | void setLocalTime(); | 131 | void setLocalTime(); |
130 | /** | 132 | /** |
131 | Return whether local time is being used. | 133 | Return whether local time is being used. |
132 | */ | 134 | */ |
133 | bool isLocalTime() const; | 135 | bool isLocalTime() const; |
134 | 136 | ||
135 | /** | 137 | /** |
136 | Add an incidence to calendar. | 138 | Add an incidence to calendar. |
137 | 139 | ||
138 | @return true on success, false on error. | 140 | @return true on success, false on error. |
139 | */ | 141 | */ |
140 | virtual bool addIncidence( Incidence * ); | 142 | virtual bool addIncidence( Incidence * ); |
141 | /** | 143 | /** |
142 | Return filtered list of all incidences of this calendar. | 144 | Return filtered list of all incidences of this calendar. |
143 | */ | 145 | */ |
144 | virtual QPtrList<Incidence> incidences(); | 146 | virtual QPtrList<Incidence> incidences(); |
145 | 147 | ||
146 | /** | 148 | /** |
147 | Return unfiltered list of all incidences of this calendar. | 149 | Return unfiltered list of all incidences of this calendar. |
148 | */ | 150 | */ |
149 | virtual QPtrList<Incidence> rawIncidences(); | 151 | virtual QPtrList<Incidence> rawIncidences(); |
150 | 152 | ||
151 | /** | 153 | /** |
152 | Adds a Event to this calendar object. | 154 | Adds a Event to this calendar object. |
153 | @param anEvent a pointer to the event to add | 155 | @param anEvent a pointer to the event to add |
154 | 156 | ||
155 | @return true on success, false on error. | 157 | @return true on success, false on error. |
156 | */ | 158 | */ |
157 | virtual bool addEventNoDup( Event *event ) = 0; | 159 | virtual bool addEventNoDup( Event *event ) = 0; |
158 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 160 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
159 | virtual bool addEvent( Event *anEvent ) = 0; | 161 | virtual bool addEvent( Event *anEvent ) = 0; |
160 | /** | 162 | /** |
161 | Delete event from calendar. | 163 | Delete event from calendar. |
162 | */ | 164 | */ |
163 | virtual void deleteEvent( Event * ) = 0; | 165 | virtual void deleteEvent( Event * ) = 0; |
164 | /** | 166 | /** |
165 | Retrieves an event on the basis of the unique string ID. | 167 | Retrieves an event on the basis of the unique string ID. |
166 | */ | 168 | */ |
167 | virtual Event *event( const QString &UniqueStr ) = 0; | 169 | virtual Event *event( const QString &UniqueStr ) = 0; |
168 | virtual Event *event( QString, QString ) = 0; | 170 | virtual Event *event( QString, QString ) = 0; |
169 | /** | 171 | /** |
170 | Builds and then returns a list of all events that match for the | 172 | Builds and then returns a list of all events that match for the |
171 | date specified. useful for dayView, etc. etc. | 173 | date specified. useful for dayView, etc. etc. |
172 | The calendar filter is applied. | 174 | The calendar filter is applied. |
173 | */ | 175 | */ |
174 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 176 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
175 | /** | 177 | /** |
176 | Get events, which occur on the given date. | 178 | Get events, which occur on the given date. |
177 | The calendar filter is applied. | 179 | The calendar filter is applied. |
178 | */ | 180 | */ |
179 | QPtrList<Event> events( const QDateTime &qdt ); | 181 | QPtrList<Event> events( const QDateTime &qdt ); |
180 | /** | 182 | /** |
181 | Get events in a range of dates. If inclusive is set to true, only events | 183 | Get events in a range of dates. If inclusive is set to true, only events |
182 | are returned, which are completely included in the range. | 184 | are returned, which are completely included in the range. |
183 | The calendar filter is applied. | 185 | The calendar filter is applied. |
184 | */ | 186 | */ |
185 | QPtrList<Event> events( const QDate &start, const QDate &end, | 187 | QPtrList<Event> events( const QDate &start, const QDate &end, |
186 | bool inclusive = false); | 188 | bool inclusive = false); |
187 | /** | 189 | /** |
188 | Return filtered list of all events in calendar. | 190 | Return filtered list of all events in calendar. |
189 | */ | 191 | */ |
190 | virtual QPtrList<Event> events(); | 192 | virtual QPtrList<Event> events(); |
191 | /** | 193 | /** |
192 | Return unfiltered list of all events in calendar. | 194 | Return unfiltered list of all events in calendar. |
193 | */ | 195 | */ |
194 | virtual QPtrList<Event> rawEvents() = 0; | 196 | virtual QPtrList<Event> rawEvents() = 0; |
195 | 197 | ||
196 | /** | 198 | /** |
197 | Add a todo to the todolist. | 199 | Add a todo to the todolist. |
198 | 200 | ||
199 | @return true on success, false on error. | 201 | @return true on success, false on error. |
200 | */ | 202 | */ |
201 | virtual bool addTodo( Todo *todo ) = 0; | 203 | virtual bool addTodo( Todo *todo ) = 0; |
202 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 204 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
203 | /** | 205 | /** |
204 | Remove a todo from the todolist. | 206 | Remove a todo from the todolist. |
205 | */ | 207 | */ |
206 | virtual void deleteTodo( Todo * ) = 0; | 208 | virtual void deleteTodo( Todo * ) = 0; |
207 | virtual void deleteJournal( Journal * ) = 0; | 209 | virtual void deleteJournal( Journal * ) = 0; |
208 | /** | 210 | /** |
209 | Return filterd list of todos. | 211 | Return filterd list of todos. |
210 | */ | 212 | */ |
211 | virtual QPtrList<Todo> todos(); | 213 | virtual QPtrList<Todo> todos(); |
212 | /** | 214 | /** |
213 | Searches todolist for an event with this unique string identifier, | 215 | Searches todolist for an event with this unique string identifier, |
214 | returns a pointer or null. | 216 | returns a pointer or null. |
215 | */ | 217 | */ |
216 | virtual Todo *todo( const QString &uid ) = 0; | 218 | virtual Todo *todo( const QString &uid ) = 0; |
217 | virtual Todo *todo( QString, QString ) = 0; | 219 | virtual Todo *todo( QString, QString ) = 0; |
218 | /** | 220 | /** |
219 | Returns list of todos due on the specified date. | 221 | Returns list of todos due on the specified date. |
220 | */ | 222 | */ |
221 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 223 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
222 | /** | 224 | /** |
223 | Return unfiltered list of todos. | 225 | Return unfiltered list of todos. |
224 | */ | 226 | */ |
225 | virtual QPtrList<Todo> rawTodos() = 0; | 227 | virtual QPtrList<Todo> rawTodos() = 0; |
226 | 228 | ||
227 | /** | 229 | /** |
228 | Add a Journal entry to calendar. | 230 | Add a Journal entry to calendar. |
229 | 231 | ||
230 | @return true on success, false on error. | 232 | @return true on success, false on error. |
231 | */ | 233 | */ |
232 | virtual bool addJournal( Journal * ) = 0; | 234 | virtual bool addJournal( Journal * ) = 0; |
233 | /** | 235 | /** |
234 | Return Journal for given date. | 236 | Return Journal for given date. |
235 | */ | 237 | */ |
236 | virtual Journal *journal( const QDate & ) = 0; | 238 | virtual Journal *journal( const QDate & ) = 0; |
237 | /** | 239 | /** |
238 | Return Journal with given UID. | 240 | Return Journal with given UID. |
239 | */ | 241 | */ |
240 | virtual Journal *journal( const QString &UID ) = 0; | 242 | virtual Journal *journal( const QString &UID ) = 0; |
241 | /** | 243 | /** |
242 | Return list of all Journal entries. | 244 | Return list of all Journal entries. |
243 | */ | 245 | */ |
244 | virtual QPtrList<Journal> journals() = 0; | 246 | virtual QPtrList<Journal> journals() = 0; |
245 | 247 | ||
246 | /** | 248 | /** |
247 | Searches all incidence types for an incidence with this unique | 249 | Searches all incidence types for an incidence with this unique |
248 | string identifier, returns a pointer or null. | 250 | string identifier, returns a pointer or null. |
249 | */ | 251 | */ |
250 | Incidence* incidence( const QString&UID ); | 252 | Incidence* incidence( const QString&UID ); |
251 | 253 | ||
252 | /** | 254 | /** |
253 | Setup relations for an incidence. | 255 | Setup relations for an incidence. |
254 | */ | 256 | */ |
255 | virtual void setupRelations( Incidence * ); | 257 | virtual void setupRelations( Incidence * ); |
256 | /** | 258 | /** |
257 | Remove all relations to an incidence | 259 | Remove all relations to an incidence |
258 | */ | 260 | */ |
259 | virtual void removeRelations( Incidence * ); | 261 | virtual void removeRelations( Incidence * ); |
260 | 262 | ||
261 | /** | 263 | /** |
262 | Set calendar filter, which filters events for the events() functions. | 264 | Set calendar filter, which filters events for the events() functions. |
263 | The Filter object is owned by the caller. | 265 | The Filter object is owned by the caller. |
264 | */ | 266 | */ |
265 | void setFilter( CalFilter * ); | 267 | void setFilter( CalFilter * ); |
266 | /** | 268 | /** |
267 | Return calendar filter. | 269 | Return calendar filter. |
268 | */ | 270 | */ |
269 | CalFilter *filter(); | 271 | CalFilter *filter(); |
270 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 272 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
271 | virtual QString nextSummary( ) const = 0; | 273 | virtual QString nextSummary( ) const = 0; |
272 | virtual void reInitAlarmSettings() = 0; | 274 | virtual void reInitAlarmSettings() = 0; |
273 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 275 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
274 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 276 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
275 | /** | 277 | /** |
276 | Return all alarms, which ocur in the given time interval. | 278 | Return all alarms, which ocur in the given time interval. |
277 | */ | 279 | */ |
278 | virtual Alarm::List alarms( const QDateTime &from, | 280 | virtual Alarm::List alarms( const QDateTime &from, |
279 | const QDateTime &to ) = 0; | 281 | const QDateTime &to ) = 0; |
280 | 282 | ||
281 | class Observer { | 283 | class Observer { |
282 | public: | 284 | public: |
283 | virtual void calendarModified( bool, Calendar * ) = 0; | 285 | virtual void calendarModified( bool, Calendar * ) = 0; |
284 | }; | 286 | }; |
285 | 287 | ||
286 | void registerObserver( Observer * ); | 288 | void registerObserver( Observer * ); |
287 | 289 | ||
288 | void setModified( bool ); | 290 | void setModified( bool ); |
289 | 291 | ||
290 | /** | 292 | /** |
291 | Set product id returned by loadedProductId(). This function is only | 293 | Set product id returned by loadedProductId(). This function is only |
292 | useful for the calendar loading code. | 294 | useful for the calendar loading code. |
293 | */ | 295 | */ |
294 | void setLoadedProductId( const QString & ); | 296 | void setLoadedProductId( const QString & ); |
295 | /** | 297 | /** |
296 | Return product id taken from file that has been loaded. Returns | 298 | Return product id taken from file that has been loaded. Returns |
297 | QString::null, if no calendar has been loaded. | 299 | QString::null, if no calendar has been loaded. |
298 | */ | 300 | */ |
299 | QString loadedProductId(); | 301 | QString loadedProductId(); |
300 | 302 | ||
301 | signals: | 303 | signals: |
302 | void calendarChanged(); | 304 | void calendarChanged(); |
303 | void calendarSaved(); | 305 | void calendarSaved(); |
304 | void calendarLoaded(); | 306 | void calendarLoaded(); |
305 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 307 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
306 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 308 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
307 | 309 | ||
308 | protected: | 310 | protected: |
309 | /** | 311 | /** |
310 | Get unfiltered events, which occur on the given date. | 312 | Get unfiltered events, which occur on the given date. |
311 | */ | 313 | */ |
312 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 314 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
313 | /** | 315 | /** |
314 | Get unfiltered events, which occur on the given date. | 316 | Get unfiltered events, which occur on the given date. |
315 | */ | 317 | */ |
316 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 318 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
317 | bool sorted = false ) = 0; | 319 | bool sorted = false ) = 0; |
318 | /** | 320 | /** |
319 | Get events in a range of dates. If inclusive is set to true, only events | 321 | Get events in a range of dates. If inclusive is set to true, only events |
320 | are returned, which are completely included in the range. | 322 | are returned, which are completely included in the range. |
321 | */ | 323 | */ |
322 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 324 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
323 | bool inclusive = false ) = 0; | 325 | bool inclusive = false ) = 0; |
324 | Incidence *mNextAlarmIncidence; | 326 | Incidence *mNextAlarmIncidence; |
327 | Incidence *mUndoIncidence; | ||
325 | 328 | ||
326 | private: | 329 | private: |
327 | void init(); | 330 | void init(); |
328 | 331 | ||
329 | QString mOwner; // who the calendar belongs to | 332 | QString mOwner; // who the calendar belongs to |
330 | QString mOwnerEmail; // email address of the owner | 333 | QString mOwnerEmail; // email address of the owner |
331 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 334 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
332 | bool mLocalTime; // use local time, not UTC or a time zone | 335 | bool mLocalTime; // use local time, not UTC or a time zone |
333 | 336 | ||
334 | CalFilter *mFilter; | 337 | CalFilter *mFilter; |
335 | CalFilter *mDefaultFilter; | 338 | CalFilter *mDefaultFilter; |
336 | 339 | ||
337 | QString mTimeZoneId; | 340 | QString mTimeZoneId; |
338 | 341 | ||
339 | Observer *mObserver; | 342 | Observer *mObserver; |
340 | bool mNewObserver; | 343 | bool mNewObserver; |
341 | 344 | ||
342 | bool mModified; | 345 | bool mModified; |
343 | 346 | ||
344 | QString mLoadedProductId; | 347 | QString mLoadedProductId; |
345 | 348 | ||
346 | // This list is used to put together related todos | 349 | // This list is used to put together related todos |
347 | QDict<Incidence> mOrphans; | 350 | QDict<Incidence> mOrphans; |
348 | QDict<Incidence> mOrphanUids; | 351 | QDict<Incidence> mOrphanUids; |
349 | }; | 352 | }; |
350 | 353 | ||
351 | } | 354 | } |
352 | 355 | ||
353 | #endif | 356 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3f46d53..12294c0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,719 +1,724 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | close(); | 68 | close(); |
69 | } | 69 | } |
70 | 70 | ||
71 | bool CalendarLocal::load( const QString &fileName ) | 71 | bool CalendarLocal::load( const QString &fileName ) |
72 | { | 72 | { |
73 | FileStorage storage( this, fileName ); | 73 | FileStorage storage( this, fileName ); |
74 | return storage.load(); | 74 | return storage.load(); |
75 | } | 75 | } |
76 | 76 | ||
77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
78 | { | 78 | { |
79 | FileStorage storage( this, fileName, format ); | 79 | FileStorage storage( this, fileName, format ); |
80 | return storage.save(); | 80 | return storage.save(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void CalendarLocal::close() | 83 | void CalendarLocal::close() |
84 | { | 84 | { |
85 | mEventList.setAutoDelete( true ); | 85 | mEventList.setAutoDelete( true ); |
86 | mTodoList.setAutoDelete( true ); | 86 | mTodoList.setAutoDelete( true ); |
87 | mJournalList.setAutoDelete( false ); | 87 | mJournalList.setAutoDelete( false ); |
88 | 88 | ||
89 | mEventList.clear(); | 89 | mEventList.clear(); |
90 | mTodoList.clear(); | 90 | mTodoList.clear(); |
91 | mJournalList.clear(); | 91 | mJournalList.clear(); |
92 | 92 | ||
93 | mEventList.setAutoDelete( false ); | 93 | mEventList.setAutoDelete( false ); |
94 | mTodoList.setAutoDelete( false ); | 94 | mTodoList.setAutoDelete( false ); |
95 | mJournalList.setAutoDelete( false ); | 95 | mJournalList.setAutoDelete( false ); |
96 | 96 | ||
97 | setModified( false ); | 97 | setModified( false ); |
98 | } | 98 | } |
99 | 99 | ||
100 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 100 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
101 | { | 101 | { |
102 | QString cat; | 102 | QString cat; |
103 | bool isBirthday = true; | 103 | bool isBirthday = true; |
104 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 104 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
105 | isBirthday = false; | 105 | isBirthday = false; |
106 | cat = i18n( "Anniversary" ); | 106 | cat = i18n( "Anniversary" ); |
107 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 107 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
108 | isBirthday = true; | 108 | isBirthday = true; |
109 | cat = i18n( "Birthday" ); | 109 | cat = i18n( "Birthday" ); |
110 | } else { | 110 | } else { |
111 | qDebug("addAnniversaryNoDup called without fitting category! "); | 111 | qDebug("addAnniversaryNoDup called without fitting category! "); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | Event * eve; | 114 | Event * eve; |
115 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 115 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
116 | if ( !(eve->categories().contains( cat ) )) | 116 | if ( !(eve->categories().contains( cat ) )) |
117 | continue; | 117 | continue; |
118 | // now we have an event with fitting category | 118 | // now we have an event with fitting category |
119 | if ( eve->dtStart().date() != event->dtStart().date() ) | 119 | if ( eve->dtStart().date() != event->dtStart().date() ) |
120 | continue; | 120 | continue; |
121 | // now we have an event with fitting category+date | 121 | // now we have an event with fitting category+date |
122 | if ( eve->summary() != event->summary() ) | 122 | if ( eve->summary() != event->summary() ) |
123 | continue; | 123 | continue; |
124 | // now we have an event with fitting category+date+summary | 124 | // now we have an event with fitting category+date+summary |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | return addEvent( event ); | 127 | return addEvent( event ); |
128 | 128 | ||
129 | } | 129 | } |
130 | bool CalendarLocal::addEventNoDup( Event *event ) | 130 | bool CalendarLocal::addEventNoDup( Event *event ) |
131 | { | 131 | { |
132 | Event * eve; | 132 | Event * eve; |
133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
134 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | return addEvent( event ); | 139 | return addEvent( event ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool CalendarLocal::addEvent( Event *event ) | 142 | bool CalendarLocal::addEvent( Event *event ) |
143 | { | 143 | { |
144 | insertEvent( event ); | 144 | insertEvent( event ); |
145 | 145 | ||
146 | event->registerObserver( this ); | 146 | event->registerObserver( this ); |
147 | 147 | ||
148 | setModified( true ); | 148 | setModified( true ); |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | if ( mUndoIncidence ) delete mUndoIncidence; | |
156 | 156 | mUndoIncidence = event->clone(); | |
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *CalendarLocal::event( const QString &uid ) |
164 | { | 164 | { |
165 | 165 | ||
166 | Event *event; | 166 | Event *event; |
167 | 167 | ||
168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
169 | if ( event->uid() == uid ) { | 169 | if ( event->uid() == uid ) { |
170 | return event; | 170 | return event; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
177 | { | 177 | { |
178 | Todo * eve; | 178 | Todo * eve; |
179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
180 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
181 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | return addTodo( todo ); | 185 | return addTodo( todo ); |
186 | } | 186 | } |
187 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
188 | { | 188 | { |
189 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
190 | 190 | ||
191 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
192 | 192 | ||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | if ( mUndoIncidence ) delete mUndoIncidence; |
205 | mUndoIncidence = todo->clone(); | ||
206 | removeRelations( todo ); | ||
205 | 207 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 208 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 209 | setModified( true ); |
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 213 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 214 | { |
213 | return mTodoList; | 215 | return mTodoList; |
214 | } | 216 | } |
215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 217 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
216 | { | 218 | { |
217 | Todo *todo; | 219 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 220 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->getID( syncProf ) == id ) return todo; | 221 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 222 | } |
221 | 223 | ||
222 | return 0; | 224 | return 0; |
223 | } | 225 | } |
224 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 226 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
225 | { | 227 | { |
226 | QPtrList<Incidence> all = rawIncidences() ; | 228 | QPtrList<Incidence> all = rawIncidences() ; |
227 | Incidence *inc; | 229 | Incidence *inc; |
228 | for ( inc = all.first(); inc; inc = all.next() ) { | 230 | for ( inc = all.first(); inc; inc = all.next() ) { |
229 | inc->removeID( syncProfile ); | 231 | inc->removeID( syncProfile ); |
230 | } | 232 | } |
231 | if ( syncProfile.isEmpty() ) { | 233 | if ( syncProfile.isEmpty() ) { |
232 | QPtrList<Event> el; | 234 | QPtrList<Event> el; |
233 | Event *todo; | 235 | Event *todo; |
234 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 236 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
235 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 237 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
236 | el.append( todo ); | 238 | el.append( todo ); |
237 | } | 239 | } |
238 | for ( todo = el.first(); todo; todo = el.next() ) { | 240 | for ( todo = el.first(); todo; todo = el.next() ) { |
239 | deleteIncidence ( todo ); | 241 | deleteIncidence ( todo ); |
240 | } | 242 | } |
241 | } else { | 243 | } else { |
242 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 244 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
243 | deleteIncidence ( lse ); | 245 | deleteIncidence ( lse ); |
244 | } | 246 | } |
245 | } | 247 | } |
246 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 248 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
247 | { | 249 | { |
248 | QPtrList<Event> el; | 250 | QPtrList<Event> el; |
249 | Event *todo; | 251 | Event *todo; |
250 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 252 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
251 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 253 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
252 | if ( todo->summary().left(3) == "E: " ) | 254 | if ( todo->summary().left(3) == "E: " ) |
253 | el.append( todo ); | 255 | el.append( todo ); |
254 | } | 256 | } |
255 | 257 | ||
256 | return el; | 258 | return el; |
257 | 259 | ||
258 | } | 260 | } |
259 | Event *CalendarLocal::event( QString syncProf, QString id ) | 261 | Event *CalendarLocal::event( QString syncProf, QString id ) |
260 | { | 262 | { |
261 | Event *todo; | 263 | Event *todo; |
262 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 264 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
263 | if ( todo->getID( syncProf ) == id ) return todo; | 265 | if ( todo->getID( syncProf ) == id ) return todo; |
264 | } | 266 | } |
265 | 267 | ||
266 | return 0; | 268 | return 0; |
267 | } | 269 | } |
268 | Todo *CalendarLocal::todo( const QString &uid ) | 270 | Todo *CalendarLocal::todo( const QString &uid ) |
269 | { | 271 | { |
270 | Todo *todo; | 272 | Todo *todo; |
271 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 273 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
272 | if ( todo->uid() == uid ) return todo; | 274 | if ( todo->uid() == uid ) return todo; |
273 | } | 275 | } |
274 | 276 | ||
275 | return 0; | 277 | return 0; |
276 | } | 278 | } |
277 | QString CalendarLocal::nextSummary() const | 279 | QString CalendarLocal::nextSummary() const |
278 | { | 280 | { |
279 | return mNextSummary; | 281 | return mNextSummary; |
280 | } | 282 | } |
281 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 283 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
282 | { | 284 | { |
283 | return mNextAlarmEventDateTime; | 285 | return mNextAlarmEventDateTime; |
284 | } | 286 | } |
285 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 287 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
286 | { | 288 | { |
287 | //mNextAlarmIncidence | 289 | //mNextAlarmIncidence |
288 | //mNextAlarmDateTime | 290 | //mNextAlarmDateTime |
289 | //return mNextSummary; | 291 | //return mNextSummary; |
290 | //return mNextAlarmEventDateTime; | 292 | //return mNextAlarmEventDateTime; |
291 | bool newNextAlarm = false; | 293 | bool newNextAlarm = false; |
292 | bool computeNextAlarm = false; | 294 | bool computeNextAlarm = false; |
293 | bool ok; | 295 | bool ok; |
294 | int offset; | 296 | int offset; |
295 | QDateTime nextA; | 297 | QDateTime nextA; |
296 | // QString nextSum; | 298 | // QString nextSum; |
297 | //QDateTime nextEvent; | 299 | //QDateTime nextEvent; |
298 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 300 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
299 | computeNextAlarm = true; | 301 | computeNextAlarm = true; |
300 | } else { | 302 | } else { |
301 | if ( ! deleted ) { | 303 | if ( ! deleted ) { |
302 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 304 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
303 | if ( ok ) { | 305 | if ( ok ) { |
304 | if ( nextA < mNextAlarmDateTime ) { | 306 | if ( nextA < mNextAlarmDateTime ) { |
305 | deRegisterAlarm(); | 307 | deRegisterAlarm(); |
306 | mNextAlarmDateTime = nextA; | 308 | mNextAlarmDateTime = nextA; |
307 | mNextSummary = incidence->summary(); | 309 | mNextSummary = incidence->summary(); |
308 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 310 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
309 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 311 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
310 | newNextAlarm = true; | 312 | newNextAlarm = true; |
311 | mNextAlarmIncidence = incidence; | 313 | mNextAlarmIncidence = incidence; |
312 | } else { | 314 | } else { |
313 | if ( incidence == mNextAlarmIncidence ) { | 315 | if ( incidence == mNextAlarmIncidence ) { |
314 | computeNextAlarm = true; | 316 | computeNextAlarm = true; |
315 | } | 317 | } |
316 | } | 318 | } |
317 | } else { | 319 | } else { |
318 | if ( mNextAlarmIncidence == incidence ) { | 320 | if ( mNextAlarmIncidence == incidence ) { |
319 | computeNextAlarm = true; | 321 | computeNextAlarm = true; |
320 | } | 322 | } |
321 | } | 323 | } |
322 | } else { // deleted | 324 | } else { // deleted |
323 | if ( incidence == mNextAlarmIncidence ) { | 325 | if ( incidence == mNextAlarmIncidence ) { |
324 | computeNextAlarm = true; | 326 | computeNextAlarm = true; |
325 | } | 327 | } |
326 | } | 328 | } |
327 | } | 329 | } |
328 | if ( computeNextAlarm ) { | 330 | if ( computeNextAlarm ) { |
329 | deRegisterAlarm(); | 331 | deRegisterAlarm(); |
330 | nextA = nextAlarm( 1000 ); | 332 | nextA = nextAlarm( 1000 ); |
331 | if (! mNextAlarmIncidence ) { | 333 | if (! mNextAlarmIncidence ) { |
332 | return; | 334 | return; |
333 | } | 335 | } |
334 | newNextAlarm = true; | 336 | newNextAlarm = true; |
335 | } | 337 | } |
336 | if ( newNextAlarm ) | 338 | if ( newNextAlarm ) |
337 | registerAlarm(); | 339 | registerAlarm(); |
338 | } | 340 | } |
339 | QString CalendarLocal:: getAlarmNotification() | 341 | QString CalendarLocal:: getAlarmNotification() |
340 | { | 342 | { |
341 | QString ret; | 343 | QString ret; |
342 | // this should not happen | 344 | // this should not happen |
343 | if (! mNextAlarmIncidence ) | 345 | if (! mNextAlarmIncidence ) |
344 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 346 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
345 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 347 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
346 | if ( alarm->type() == Alarm::Procedure ) { | 348 | if ( alarm->type() == Alarm::Procedure ) { |
347 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 349 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
348 | } else { | 350 | } else { |
349 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 351 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
350 | } | 352 | } |
351 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 353 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
352 | if ( mNextSummary.length() > 25 ) | 354 | if ( mNextSummary.length() > 25 ) |
353 | ret += "\n" + mNextSummary.mid(25, 25 ); | 355 | ret += "\n" + mNextSummary.mid(25, 25 ); |
354 | ret+= "\n"+mNextAlarmEventDateTimeString; | 356 | ret+= "\n"+mNextAlarmEventDateTimeString; |
355 | return ret; | 357 | return ret; |
356 | } | 358 | } |
357 | void CalendarLocal::registerAlarm() | 359 | void CalendarLocal::registerAlarm() |
358 | { | 360 | { |
359 | mLastAlarmNotificationString = getAlarmNotification(); | 361 | mLastAlarmNotificationString = getAlarmNotification(); |
360 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 362 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
361 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 363 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
362 | // #ifndef DESKTOP_VERSION | 364 | // #ifndef DESKTOP_VERSION |
363 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 365 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
364 | // #endif | 366 | // #endif |
365 | } | 367 | } |
366 | void CalendarLocal::deRegisterAlarm() | 368 | void CalendarLocal::deRegisterAlarm() |
367 | { | 369 | { |
368 | if ( mLastAlarmNotificationString.isNull() ) | 370 | if ( mLastAlarmNotificationString.isNull() ) |
369 | return; | 371 | return; |
370 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 372 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
371 | 373 | ||
372 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 374 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
373 | // #ifndef DESKTOP_VERSION | 375 | // #ifndef DESKTOP_VERSION |
374 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 376 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
375 | // #endif | 377 | // #endif |
376 | } | 378 | } |
377 | 379 | ||
378 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 380 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
379 | { | 381 | { |
380 | QPtrList<Todo> todos; | 382 | QPtrList<Todo> todos; |
381 | 383 | ||
382 | Todo *todo; | 384 | Todo *todo; |
383 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 385 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
384 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 386 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
385 | todos.append( todo ); | 387 | todos.append( todo ); |
386 | } | 388 | } |
387 | } | 389 | } |
388 | 390 | ||
389 | filter()->apply( &todos ); | 391 | filter()->apply( &todos ); |
390 | return todos; | 392 | return todos; |
391 | } | 393 | } |
392 | void CalendarLocal::reInitAlarmSettings() | 394 | void CalendarLocal::reInitAlarmSettings() |
393 | { | 395 | { |
394 | if ( !mNextAlarmIncidence ) { | 396 | if ( !mNextAlarmIncidence ) { |
395 | nextAlarm( 1000 ); | 397 | nextAlarm( 1000 ); |
396 | } | 398 | } |
397 | deRegisterAlarm(); | 399 | deRegisterAlarm(); |
398 | mNextAlarmIncidence = 0; | 400 | mNextAlarmIncidence = 0; |
399 | checkAlarmForIncidence( 0, false ); | 401 | checkAlarmForIncidence( 0, false ); |
400 | 402 | ||
401 | } | 403 | } |
402 | 404 | ||
403 | 405 | ||
404 | 406 | ||
405 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 407 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
406 | { | 408 | { |
407 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 409 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
408 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 410 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
409 | QDateTime next; | 411 | QDateTime next; |
410 | Event *e; | 412 | Event *e; |
411 | bool ok; | 413 | bool ok; |
412 | bool found = false; | 414 | bool found = false; |
413 | int offset; | 415 | int offset; |
414 | mNextAlarmIncidence = 0; | 416 | mNextAlarmIncidence = 0; |
415 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 417 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
416 | next = e->getNextAlarmDateTime(& ok, &offset ) ; | 418 | next = e->getNextAlarmDateTime(& ok, &offset ) ; |
417 | if ( ok ) { | 419 | if ( ok ) { |
418 | if ( next < nextA ) { | 420 | if ( next < nextA ) { |
419 | nextA = next; | 421 | nextA = next; |
420 | found = true; | 422 | found = true; |
421 | mNextSummary = e->summary(); | 423 | mNextSummary = e->summary(); |
422 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 424 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
423 | mNextAlarmIncidence = (Incidence *) e; | 425 | mNextAlarmIncidence = (Incidence *) e; |
424 | } | 426 | } |
425 | } | 427 | } |
426 | } | 428 | } |
427 | Todo *t; | 429 | Todo *t; |
428 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 430 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
429 | next = t->getNextAlarmDateTime(& ok, &offset ) ; | 431 | next = t->getNextAlarmDateTime(& ok, &offset ) ; |
430 | if ( ok ) { | 432 | if ( ok ) { |
431 | if ( next < nextA ) { | 433 | if ( next < nextA ) { |
432 | nextA = next; | 434 | nextA = next; |
433 | found = true; | 435 | found = true; |
434 | mNextSummary = t->summary(); | 436 | mNextSummary = t->summary(); |
435 | mNextAlarmEventDateTime = next.addSecs(offset ); | 437 | mNextAlarmEventDateTime = next.addSecs(offset ); |
436 | mNextAlarmIncidence = (Incidence *) t; | 438 | mNextAlarmIncidence = (Incidence *) t; |
437 | } | 439 | } |
438 | } | 440 | } |
439 | } | 441 | } |
440 | if ( mNextAlarmIncidence ) { | 442 | if ( mNextAlarmIncidence ) { |
441 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 443 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
442 | mNextAlarmDateTime = nextA; | 444 | mNextAlarmDateTime = nextA; |
443 | } | 445 | } |
444 | return nextA; | 446 | return nextA; |
445 | } | 447 | } |
446 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 448 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
447 | { | 449 | { |
448 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 450 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
449 | } | 451 | } |
450 | 452 | ||
451 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 453 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
452 | { | 454 | { |
453 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " | 455 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " |
454 | << to.toString() << ")\n"; | 456 | << to.toString() << ")\n"; |
455 | 457 | ||
456 | Alarm::List alarms; | 458 | Alarm::List alarms; |
457 | 459 | ||
458 | Event *e; | 460 | Event *e; |
459 | 461 | ||
460 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 462 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
461 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 463 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
462 | else appendAlarms( alarms, e, from, to ); | 464 | else appendAlarms( alarms, e, from, to ); |
463 | } | 465 | } |
464 | 466 | ||
465 | Todo *t; | 467 | Todo *t; |
466 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 468 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
467 | appendAlarms( alarms, t, from, to ); | 469 | appendAlarms( alarms, t, from, to ); |
468 | } | 470 | } |
469 | 471 | ||
470 | return alarms; | 472 | return alarms; |
471 | } | 473 | } |
472 | 474 | ||
473 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 475 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
474 | const QDateTime &from, const QDateTime &to ) | 476 | const QDateTime &from, const QDateTime &to ) |
475 | { | 477 | { |
476 | QPtrList<Alarm> alarmList = incidence->alarms(); | 478 | QPtrList<Alarm> alarmList = incidence->alarms(); |
477 | Alarm *alarm; | 479 | Alarm *alarm; |
478 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 480 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
479 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 481 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
480 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 482 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
481 | if ( alarm->enabled() ) { | 483 | if ( alarm->enabled() ) { |
482 | if ( alarm->time() >= from && alarm->time() <= to ) { | 484 | if ( alarm->time() >= from && alarm->time() <= to ) { |
483 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() | 485 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() |
484 | << "': " << alarm->time().toString() << endl; | 486 | << "': " << alarm->time().toString() << endl; |
485 | alarms.append( alarm ); | 487 | alarms.append( alarm ); |
486 | } | 488 | } |
487 | } | 489 | } |
488 | } | 490 | } |
489 | } | 491 | } |
490 | 492 | ||
491 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 493 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
492 | Incidence *incidence, | 494 | Incidence *incidence, |
493 | const QDateTime &from, | 495 | const QDateTime &from, |
494 | const QDateTime &to ) | 496 | const QDateTime &to ) |
495 | { | 497 | { |
496 | 498 | ||
497 | QPtrList<Alarm> alarmList = incidence->alarms(); | 499 | QPtrList<Alarm> alarmList = incidence->alarms(); |
498 | Alarm *alarm; | 500 | Alarm *alarm; |
499 | QDateTime qdt; | 501 | QDateTime qdt; |
500 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 502 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
501 | if (incidence->recursOn(from.date())) { | 503 | if (incidence->recursOn(from.date())) { |
502 | qdt.setTime(alarm->time().time()); | 504 | qdt.setTime(alarm->time().time()); |
503 | qdt.setDate(from.date()); | 505 | qdt.setDate(from.date()); |
504 | } | 506 | } |
505 | else qdt = alarm->time(); | 507 | else qdt = alarm->time(); |
506 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 508 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
507 | if ( alarm->enabled() ) { | 509 | if ( alarm->enabled() ) { |
508 | if ( qdt >= from && qdt <= to ) { | 510 | if ( qdt >= from && qdt <= to ) { |
509 | alarms.append( alarm ); | 511 | alarms.append( alarm ); |
510 | } | 512 | } |
511 | } | 513 | } |
512 | } | 514 | } |
513 | } | 515 | } |
514 | 516 | ||
515 | 517 | ||
516 | /****************************** PROTECTED METHODS ****************************/ | 518 | /****************************** PROTECTED METHODS ****************************/ |
517 | 519 | ||
518 | // after changes are made to an event, this should be called. | 520 | // after changes are made to an event, this should be called. |
519 | void CalendarLocal::update( IncidenceBase *incidence ) | 521 | void CalendarLocal::update( IncidenceBase *incidence ) |
520 | { | 522 | { |
521 | incidence->setSyncStatus( Event::SYNCMOD ); | 523 | incidence->setSyncStatus( Event::SYNCMOD ); |
522 | incidence->setLastModified( QDateTime::currentDateTime() ); | 524 | incidence->setLastModified( QDateTime::currentDateTime() ); |
523 | // we should probably update the revision number here, | 525 | // we should probably update the revision number here, |
524 | // or internally in the Event itself when certain things change. | 526 | // or internally in the Event itself when certain things change. |
525 | // need to verify with ical documentation. | 527 | // need to verify with ical documentation. |
526 | 528 | ||
527 | setModified( true ); | 529 | setModified( true ); |
528 | } | 530 | } |
529 | 531 | ||
530 | void CalendarLocal::insertEvent( Event *event ) | 532 | void CalendarLocal::insertEvent( Event *event ) |
531 | { | 533 | { |
532 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 534 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
533 | } | 535 | } |
534 | 536 | ||
535 | 537 | ||
536 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 538 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
537 | { | 539 | { |
538 | QPtrList<Event> eventList; | 540 | QPtrList<Event> eventList; |
539 | 541 | ||
540 | Event *event; | 542 | Event *event; |
541 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 543 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
542 | if ( event->doesRecur() ) { | 544 | if ( event->doesRecur() ) { |
543 | if ( event->isMultiDay() ) { | 545 | if ( event->isMultiDay() ) { |
544 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 546 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
545 | int i; | 547 | int i; |
546 | for ( i = 0; i <= extraDays; i++ ) { | 548 | for ( i = 0; i <= extraDays; i++ ) { |
547 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 549 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
548 | eventList.append( event ); | 550 | eventList.append( event ); |
549 | break; | 551 | break; |
550 | } | 552 | } |
551 | } | 553 | } |
552 | } else { | 554 | } else { |
553 | if ( event->recursOn( qd ) ) | 555 | if ( event->recursOn( qd ) ) |
554 | eventList.append( event ); | 556 | eventList.append( event ); |
555 | } | 557 | } |
556 | } else { | 558 | } else { |
557 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 559 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
558 | eventList.append( event ); | 560 | eventList.append( event ); |
559 | } | 561 | } |
560 | } | 562 | } |
561 | } | 563 | } |
562 | 564 | ||
563 | if ( !sorted ) { | 565 | if ( !sorted ) { |
564 | return eventList; | 566 | return eventList; |
565 | } | 567 | } |
566 | 568 | ||
567 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 569 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
568 | // now, we have to sort it based on dtStart.time() | 570 | // now, we have to sort it based on dtStart.time() |
569 | QPtrList<Event> eventListSorted; | 571 | QPtrList<Event> eventListSorted; |
570 | Event *sortEvent; | 572 | Event *sortEvent; |
571 | for ( event = eventList.first(); event; event = eventList.next() ) { | 573 | for ( event = eventList.first(); event; event = eventList.next() ) { |
572 | sortEvent = eventListSorted.first(); | 574 | sortEvent = eventListSorted.first(); |
573 | int i = 0; | 575 | int i = 0; |
574 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 576 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
575 | { | 577 | { |
576 | i++; | 578 | i++; |
577 | sortEvent = eventListSorted.next(); | 579 | sortEvent = eventListSorted.next(); |
578 | } | 580 | } |
579 | eventListSorted.insert( i, event ); | 581 | eventListSorted.insert( i, event ); |
580 | } | 582 | } |
581 | return eventListSorted; | 583 | return eventListSorted; |
582 | } | 584 | } |
583 | 585 | ||
584 | 586 | ||
585 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
586 | bool inclusive ) | 588 | bool inclusive ) |
587 | { | 589 | { |
588 | Event *event = 0; | 590 | Event *event = 0; |
589 | 591 | ||
590 | QPtrList<Event> eventList; | 592 | QPtrList<Event> eventList; |
591 | 593 | ||
592 | // Get non-recurring events | 594 | // Get non-recurring events |
593 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 595 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
594 | if ( event->doesRecur() ) { | 596 | if ( event->doesRecur() ) { |
595 | QDate rStart = event->dtStart().date(); | 597 | QDate rStart = event->dtStart().date(); |
596 | bool found = false; | 598 | bool found = false; |
597 | if ( inclusive ) { | 599 | if ( inclusive ) { |
598 | if ( rStart >= start && rStart <= end ) { | 600 | if ( rStart >= start && rStart <= end ) { |
599 | // Start date of event is in range. Now check for end date. | 601 | // Start date of event is in range. Now check for end date. |
600 | // if duration is negative, event recurs forever, so do not include it. | 602 | // if duration is negative, event recurs forever, so do not include it. |
601 | if ( event->recurrence()->duration() == 0 ) { // End date set | 603 | if ( event->recurrence()->duration() == 0 ) { // End date set |
602 | QDate rEnd = event->recurrence()->endDate(); | 604 | QDate rEnd = event->recurrence()->endDate(); |
603 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 605 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
604 | found = true; | 606 | found = true; |
605 | } | 607 | } |
606 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 608 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
607 | // TODO: Calculate end date from duration. Should be done in Event | 609 | // TODO: Calculate end date from duration. Should be done in Event |
608 | // For now exclude all events with a duration. | 610 | // For now exclude all events with a duration. |
609 | } | 611 | } |
610 | } | 612 | } |
611 | } else { | 613 | } else { |
612 | bool founOne; | 614 | bool founOne; |
613 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 615 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
614 | if ( founOne ) { | 616 | if ( founOne ) { |
615 | if ( next <= end ) { | 617 | if ( next <= end ) { |
616 | found = true; | 618 | found = true; |
617 | } | 619 | } |
618 | } | 620 | } |
619 | 621 | ||
620 | /* | 622 | /* |
621 | // crap !!! | 623 | // crap !!! |
622 | if ( rStart <= end ) { // Start date not after range | 624 | if ( rStart <= end ) { // Start date not after range |
623 | if ( rStart >= start ) { // Start date within range | 625 | if ( rStart >= start ) { // Start date within range |
624 | found = true; | 626 | found = true; |
625 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 627 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
626 | found = true; | 628 | found = true; |
627 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 629 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
628 | QDate rEnd = event->recurrence()->endDate(); | 630 | QDate rEnd = event->recurrence()->endDate(); |
629 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 631 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
630 | found = true; | 632 | found = true; |
631 | } | 633 | } |
632 | } else { // Duration set | 634 | } else { // Duration set |
633 | // TODO: Calculate end date from duration. Should be done in Event | 635 | // TODO: Calculate end date from duration. Should be done in Event |
634 | // For now include all events with a duration. | 636 | // For now include all events with a duration. |
635 | found = true; | 637 | found = true; |
636 | } | 638 | } |
637 | } | 639 | } |
638 | */ | 640 | */ |
639 | 641 | ||
640 | } | 642 | } |
641 | 643 | ||
642 | if ( found ) eventList.append( event ); | 644 | if ( found ) eventList.append( event ); |
643 | } else { | 645 | } else { |
644 | QDate s = event->dtStart().date(); | 646 | QDate s = event->dtStart().date(); |
645 | QDate e = event->dtEnd().date(); | 647 | QDate e = event->dtEnd().date(); |
646 | 648 | ||
647 | if ( inclusive ) { | 649 | if ( inclusive ) { |
648 | if ( s >= start && e <= end ) { | 650 | if ( s >= start && e <= end ) { |
649 | eventList.append( event ); | 651 | eventList.append( event ); |
650 | } | 652 | } |
651 | } else { | 653 | } else { |
652 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 654 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
653 | eventList.append( event ); | 655 | eventList.append( event ); |
654 | } | 656 | } |
655 | } | 657 | } |
656 | } | 658 | } |
657 | } | 659 | } |
658 | 660 | ||
659 | return eventList; | 661 | return eventList; |
660 | } | 662 | } |
661 | 663 | ||
662 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 664 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
663 | { | 665 | { |
664 | return rawEventsForDate( qdt.date() ); | 666 | return rawEventsForDate( qdt.date() ); |
665 | } | 667 | } |
666 | 668 | ||
667 | QPtrList<Event> CalendarLocal::rawEvents() | 669 | QPtrList<Event> CalendarLocal::rawEvents() |
668 | { | 670 | { |
669 | return mEventList; | 671 | return mEventList; |
670 | } | 672 | } |
671 | 673 | ||
672 | bool CalendarLocal::addJournal(Journal *journal) | 674 | bool CalendarLocal::addJournal(Journal *journal) |
673 | { | 675 | { |
674 | if ( journal->dtStart().isValid()) | 676 | if ( journal->dtStart().isValid()) |
675 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 677 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
676 | else | 678 | else |
677 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 679 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
678 | 680 | ||
679 | mJournalList.append(journal); | 681 | mJournalList.append(journal); |
680 | 682 | ||
681 | journal->registerObserver( this ); | 683 | journal->registerObserver( this ); |
682 | 684 | ||
683 | setModified( true ); | 685 | setModified( true ); |
684 | 686 | ||
685 | return true; | 687 | return true; |
686 | } | 688 | } |
687 | 689 | ||
688 | void CalendarLocal::deleteJournal( Journal *journal ) | 690 | void CalendarLocal::deleteJournal( Journal *journal ) |
689 | { | 691 | { |
692 | if ( mUndoIncidence ) delete mUndoIncidence; | ||
693 | mUndoIncidence = journal->clone(); | ||
694 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | ||
690 | if ( mJournalList.removeRef(journal) ) { | 695 | if ( mJournalList.removeRef(journal) ) { |
691 | setModified( true ); | 696 | setModified( true ); |
692 | } | 697 | } |
693 | } | 698 | } |
694 | 699 | ||
695 | Journal *CalendarLocal::journal( const QDate &date ) | 700 | Journal *CalendarLocal::journal( const QDate &date ) |
696 | { | 701 | { |
697 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 702 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
698 | 703 | ||
699 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 704 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
700 | if ( it->dtStart().date() == date ) | 705 | if ( it->dtStart().date() == date ) |
701 | return it; | 706 | return it; |
702 | 707 | ||
703 | return 0; | 708 | return 0; |
704 | } | 709 | } |
705 | 710 | ||
706 | Journal *CalendarLocal::journal( const QString &uid ) | 711 | Journal *CalendarLocal::journal( const QString &uid ) |
707 | { | 712 | { |
708 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 713 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
709 | if ( it->uid() == uid ) | 714 | if ( it->uid() == uid ) |
710 | return it; | 715 | return it; |
711 | 716 | ||
712 | return 0; | 717 | return 0; |
713 | } | 718 | } |
714 | 719 | ||
715 | QPtrList<Journal> CalendarLocal::journals() | 720 | QPtrList<Journal> CalendarLocal::journals() |
716 | { | 721 | { |
717 | return mJournalList; | 722 | return mJournalList; |
718 | } | 723 | } |
719 | 724 | ||
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 5a9ef0e..28402ae 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,603 +1,617 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | } | 42 | } |
43 | 43 | ||
44 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 44 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
45 | { | 45 | { |
46 | // TODO: reenable attributes currently commented out. | 46 | // TODO: reenable attributes currently commented out. |
47 | mRevision = i.mRevision; | 47 | mRevision = i.mRevision; |
48 | mCreated = i.mCreated; | 48 | mCreated = i.mCreated; |
49 | mDescription = i.mDescription; | 49 | mDescription = i.mDescription; |
50 | mSummary = i.mSummary; | 50 | mSummary = i.mSummary; |
51 | mCategories = i.mCategories; | 51 | mCategories = i.mCategories; |
52 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 52 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
53 | mRelatedTo = 0; | 53 | mRelatedTo = 0; |
54 | mRelatedToUid = i.mRelatedToUid; | 54 | mRelatedToUid = i.mRelatedToUid; |
55 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 55 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
56 | mExDates = i.mExDates; | 56 | mExDates = i.mExDates; |
57 | mAttachments = i.mAttachments; | 57 | mAttachments = i.mAttachments; |
58 | mResources = i.mResources; | 58 | mResources = i.mResources; |
59 | mSecrecy = i.mSecrecy; | 59 | mSecrecy = i.mSecrecy; |
60 | mPriority = i.mPriority; | 60 | mPriority = i.mPriority; |
61 | mLocation = i.mLocation; | 61 | mLocation = i.mLocation; |
62 | mCancelled = i.mCancelled; | 62 | mCancelled = i.mCancelled; |
63 | mHasStartDate = i.mHasStartDate; | 63 | mHasStartDate = i.mHasStartDate; |
64 | QPtrListIterator<Alarm> it( i.mAlarms ); | 64 | QPtrListIterator<Alarm> it( i.mAlarms ); |
65 | const Alarm *a; | 65 | const Alarm *a; |
66 | while( (a = it.current()) ) { | 66 | while( (a = it.current()) ) { |
67 | Alarm *b = new Alarm( *a ); | 67 | Alarm *b = new Alarm( *a ); |
68 | b->setParent( this ); | 68 | b->setParent( this ); |
69 | mAlarms.append( b ); | 69 | mAlarms.append( b ); |
70 | 70 | ||
71 | ++it; | 71 | ++it; |
72 | } | 72 | } |
73 | mAlarms.setAutoDelete(true); | 73 | mAlarms.setAutoDelete(true); |
74 | 74 | ||
75 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 75 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
76 | } | 76 | } |
77 | 77 | ||
78 | Incidence::~Incidence() | 78 | Incidence::~Incidence() |
79 | { | 79 | { |
80 | 80 | ||
81 | Incidence *ev; | 81 | Incidence *ev; |
82 | QPtrList<Incidence> Relations = relations(); | 82 | QPtrList<Incidence> Relations = relations(); |
83 | for (ev=Relations.first();ev;ev=Relations.next()) { | 83 | for (ev=Relations.first();ev;ev=Relations.next()) { |
84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
85 | } | 85 | } |
86 | if (relatedTo()) relatedTo()->removeRelation(this); | 86 | if (relatedTo()) relatedTo()->removeRelation(this); |
87 | delete mRecurrence; | 87 | delete mRecurrence; |
88 | 88 | ||
89 | } | 89 | } |
90 | 90 | ||
91 | bool Incidence::cancelled() const | 91 | bool Incidence::cancelled() const |
92 | { | 92 | { |
93 | return mCancelled; | 93 | return mCancelled; |
94 | } | 94 | } |
95 | void Incidence::setCancelled( bool b ) | 95 | void Incidence::setCancelled( bool b ) |
96 | { | 96 | { |
97 | mCancelled = b; | 97 | mCancelled = b; |
98 | updated(); | 98 | updated(); |
99 | } | 99 | } |
100 | bool Incidence::hasStartDate() const | 100 | bool Incidence::hasStartDate() const |
101 | { | 101 | { |
102 | return mHasStartDate; | 102 | return mHasStartDate; |
103 | } | 103 | } |
104 | 104 | ||
105 | void Incidence::setHasStartDate(bool f) | 105 | void Incidence::setHasStartDate(bool f) |
106 | { | 106 | { |
107 | if (mReadOnly) return; | 107 | if (mReadOnly) return; |
108 | mHasStartDate = f; | 108 | mHasStartDate = f; |
109 | updated(); | 109 | updated(); |
110 | } | 110 | } |
111 | 111 | ||
112 | // A string comparison that considers that null and empty are the same | 112 | // A string comparison that considers that null and empty are the same |
113 | static bool stringCompare( const QString& s1, const QString& s2 ) | 113 | static bool stringCompare( const QString& s1, const QString& s2 ) |
114 | { | 114 | { |
115 | if ( s1.isEmpty() && s2.isEmpty() ) | 115 | if ( s1.isEmpty() && s2.isEmpty() ) |
116 | return true; | 116 | return true; |
117 | return s1 == s2; | 117 | return s1 == s2; |
118 | } | 118 | } |
119 | 119 | ||
120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
121 | { | 121 | { |
122 | 122 | ||
123 | if( i1.alarms().count() != i2.alarms().count() ) { | 123 | if( i1.alarms().count() != i2.alarms().count() ) { |
124 | return false; // no need to check further | 124 | return false; // no need to check further |
125 | } | 125 | } |
126 | if ( i1.alarms().count() > 0 ) { | 126 | if ( i1.alarms().count() > 0 ) { |
127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
128 | { | 128 | { |
129 | qDebug("alarm not equal "); | 129 | qDebug("alarm not equal "); |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | #if 0 | 133 | #if 0 |
134 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 134 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
135 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 135 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
137 | if( *a1.current() == *a2.current() ) { | 137 | if( *a1.current() == *a2.current() ) { |
138 | continue; | 138 | continue; |
139 | } | 139 | } |
140 | else { | 140 | else { |
141 | return false; | 141 | return false; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
147 | return false; | 147 | return false; |
148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
149 | if ( i1.hasStartDate() ) { | 149 | if ( i1.hasStartDate() ) { |
150 | if ( i1.dtStart() != i2.dtStart() ) | 150 | if ( i1.dtStart() != i2.dtStart() ) |
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
157 | qDebug("recurrence is NOT equal "); | 157 | qDebug("recurrence is NOT equal "); |
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | return | 160 | return |
161 | // i1.created() == i2.created() && | 161 | // i1.created() == i2.created() && |
162 | stringCompare( i1.description(), i2.description() ) && | 162 | stringCompare( i1.description(), i2.description() ) && |
163 | stringCompare( i1.summary(), i2.summary() ) && | 163 | stringCompare( i1.summary(), i2.summary() ) && |
164 | i1.categories() == i2.categories() && | 164 | i1.categories() == i2.categories() && |
165 | // no need to compare mRelatedTo | 165 | // no need to compare mRelatedTo |
166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
167 | // i1.relations() == i2.relations() && | 167 | // i1.relations() == i2.relations() && |
168 | i1.exDates() == i2.exDates() && | 168 | i1.exDates() == i2.exDates() && |
169 | i1.attachments() == i2.attachments() && | 169 | i1.attachments() == i2.attachments() && |
170 | i1.resources() == i2.resources() && | 170 | i1.resources() == i2.resources() && |
171 | i1.secrecy() == i2.secrecy() && | 171 | i1.secrecy() == i2.secrecy() && |
172 | i1.priority() == i2.priority() && | 172 | i1.priority() == i2.priority() && |
173 | stringCompare( i1.location(), i2.location() ); | 173 | stringCompare( i1.location(), i2.location() ); |
174 | } | 174 | } |
175 | 175 | ||
176 | Incidence* Incidence::recreateCloneException( QDate d ) | ||
177 | { | ||
178 | Incidence* newInc = clone(); | ||
179 | newInc->recreate(); | ||
180 | if ( doesRecur() ) { | ||
181 | addExDate( d ); | ||
182 | newInc->recurrence()->unsetRecurs(); | ||
183 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | ||
184 | QTime tim = dtStart().time(); | ||
185 | newInc->setDtStart( QDateTime(d, tim) ); | ||
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | ||
187 | } | ||
188 | return newInc; | ||
189 | } | ||
176 | 190 | ||
177 | void Incidence::recreate() | 191 | void Incidence::recreate() |
178 | { | 192 | { |
179 | setCreated(QDateTime::currentDateTime()); | 193 | setCreated(QDateTime::currentDateTime()); |
180 | 194 | ||
181 | setUid(CalFormat::createUniqueId()); | 195 | setUid(CalFormat::createUniqueId()); |
182 | 196 | ||
183 | setRevision(0); | 197 | setRevision(0); |
184 | setIDStr( ":" ); | 198 | setIDStr( ":" ); |
185 | setLastModified(QDateTime::currentDateTime()); | 199 | setLastModified(QDateTime::currentDateTime()); |
186 | } | 200 | } |
187 | 201 | ||
188 | void Incidence::setReadOnly( bool readOnly ) | 202 | void Incidence::setReadOnly( bool readOnly ) |
189 | { | 203 | { |
190 | IncidenceBase::setReadOnly( readOnly ); | 204 | IncidenceBase::setReadOnly( readOnly ); |
191 | recurrence()->setRecurReadOnly( readOnly); | 205 | recurrence()->setRecurReadOnly( readOnly); |
192 | } | 206 | } |
193 | 207 | ||
194 | void Incidence::setCreated(QDateTime created) | 208 | void Incidence::setCreated(QDateTime created) |
195 | { | 209 | { |
196 | if (mReadOnly) return; | 210 | if (mReadOnly) return; |
197 | mCreated = getEvenTime(created); | 211 | mCreated = getEvenTime(created); |
198 | } | 212 | } |
199 | 213 | ||
200 | QDateTime Incidence::created() const | 214 | QDateTime Incidence::created() const |
201 | { | 215 | { |
202 | return mCreated; | 216 | return mCreated; |
203 | } | 217 | } |
204 | 218 | ||
205 | void Incidence::setRevision(int rev) | 219 | void Incidence::setRevision(int rev) |
206 | { | 220 | { |
207 | if (mReadOnly) return; | 221 | if (mReadOnly) return; |
208 | mRevision = rev; | 222 | mRevision = rev; |
209 | 223 | ||
210 | updated(); | 224 | updated(); |
211 | } | 225 | } |
212 | 226 | ||
213 | int Incidence::revision() const | 227 | int Incidence::revision() const |
214 | { | 228 | { |
215 | return mRevision; | 229 | return mRevision; |
216 | } | 230 | } |
217 | 231 | ||
218 | void Incidence::setDtStart(const QDateTime &dtStart) | 232 | void Incidence::setDtStart(const QDateTime &dtStart) |
219 | { | 233 | { |
220 | 234 | ||
221 | QDateTime dt = getEvenTime(dtStart); | 235 | QDateTime dt = getEvenTime(dtStart); |
222 | recurrence()->setRecurStart( dt); | 236 | recurrence()->setRecurStart( dt); |
223 | IncidenceBase::setDtStart( dt ); | 237 | IncidenceBase::setDtStart( dt ); |
224 | } | 238 | } |
225 | 239 | ||
226 | void Incidence::setDescription(const QString &description) | 240 | void Incidence::setDescription(const QString &description) |
227 | { | 241 | { |
228 | if (mReadOnly) return; | 242 | if (mReadOnly) return; |
229 | mDescription = description; | 243 | mDescription = description; |
230 | updated(); | 244 | updated(); |
231 | } | 245 | } |
232 | 246 | ||
233 | QString Incidence::description() const | 247 | QString Incidence::description() const |
234 | { | 248 | { |
235 | return mDescription; | 249 | return mDescription; |
236 | } | 250 | } |
237 | 251 | ||
238 | 252 | ||
239 | void Incidence::setSummary(const QString &summary) | 253 | void Incidence::setSummary(const QString &summary) |
240 | { | 254 | { |
241 | if (mReadOnly) return; | 255 | if (mReadOnly) return; |
242 | mSummary = summary; | 256 | mSummary = summary; |
243 | updated(); | 257 | updated(); |
244 | } | 258 | } |
245 | 259 | ||
246 | QString Incidence::summary() const | 260 | QString Incidence::summary() const |
247 | { | 261 | { |
248 | return mSummary; | 262 | return mSummary; |
249 | } | 263 | } |
250 | 264 | ||
251 | void Incidence::setCategories(const QStringList &categories) | 265 | void Incidence::setCategories(const QStringList &categories) |
252 | { | 266 | { |
253 | if (mReadOnly) return; | 267 | if (mReadOnly) return; |
254 | mCategories = categories; | 268 | mCategories = categories; |
255 | updated(); | 269 | updated(); |
256 | } | 270 | } |
257 | 271 | ||
258 | // TODO: remove setCategories(QString) function | 272 | // TODO: remove setCategories(QString) function |
259 | void Incidence::setCategories(const QString &catStr) | 273 | void Incidence::setCategories(const QString &catStr) |
260 | { | 274 | { |
261 | if (mReadOnly) return; | 275 | if (mReadOnly) return; |
262 | mCategories.clear(); | 276 | mCategories.clear(); |
263 | 277 | ||
264 | if (catStr.isEmpty()) return; | 278 | if (catStr.isEmpty()) return; |
265 | 279 | ||
266 | mCategories = QStringList::split(",",catStr); | 280 | mCategories = QStringList::split(",",catStr); |
267 | 281 | ||
268 | QStringList::Iterator it; | 282 | QStringList::Iterator it; |
269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 283 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
270 | *it = (*it).stripWhiteSpace(); | 284 | *it = (*it).stripWhiteSpace(); |
271 | } | 285 | } |
272 | 286 | ||
273 | updated(); | 287 | updated(); |
274 | } | 288 | } |
275 | 289 | ||
276 | QStringList Incidence::categories() const | 290 | QStringList Incidence::categories() const |
277 | { | 291 | { |
278 | return mCategories; | 292 | return mCategories; |
279 | } | 293 | } |
280 | 294 | ||
281 | QString Incidence::categoriesStr() | 295 | QString Incidence::categoriesStr() |
282 | { | 296 | { |
283 | return mCategories.join(","); | 297 | return mCategories.join(","); |
284 | } | 298 | } |
285 | 299 | ||
286 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 300 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
287 | { | 301 | { |
288 | if (mReadOnly) return; | 302 | if (mReadOnly) return; |
289 | mRelatedToUid = relatedToUid; | 303 | mRelatedToUid = relatedToUid; |
290 | } | 304 | } |
291 | 305 | ||
292 | QString Incidence::relatedToUid() const | 306 | QString Incidence::relatedToUid() const |
293 | { | 307 | { |
294 | return mRelatedToUid; | 308 | return mRelatedToUid; |
295 | } | 309 | } |
296 | 310 | ||
297 | void Incidence::setRelatedTo(Incidence *relatedTo) | 311 | void Incidence::setRelatedTo(Incidence *relatedTo) |
298 | { | 312 | { |
299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 313 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 314 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
301 | if (mReadOnly || mRelatedTo == relatedTo) return; | 315 | if (mReadOnly || mRelatedTo == relatedTo) return; |
302 | if(mRelatedTo) { | 316 | if(mRelatedTo) { |
303 | // updated(); | 317 | // updated(); |
304 | mRelatedTo->removeRelation(this); | 318 | mRelatedTo->removeRelation(this); |
305 | } | 319 | } |
306 | mRelatedTo = relatedTo; | 320 | mRelatedTo = relatedTo; |
307 | if (mRelatedTo) mRelatedTo->addRelation(this); | 321 | if (mRelatedTo) mRelatedTo->addRelation(this); |
308 | } | 322 | } |
309 | 323 | ||
310 | Incidence *Incidence::relatedTo() const | 324 | Incidence *Incidence::relatedTo() const |
311 | { | 325 | { |
312 | return mRelatedTo; | 326 | return mRelatedTo; |
313 | } | 327 | } |
314 | 328 | ||
315 | QPtrList<Incidence> Incidence::relations() const | 329 | QPtrList<Incidence> Incidence::relations() const |
316 | { | 330 | { |
317 | return mRelations; | 331 | return mRelations; |
318 | } | 332 | } |
319 | 333 | ||
320 | void Incidence::addRelation(Incidence *event) | 334 | void Incidence::addRelation(Incidence *event) |
321 | { | 335 | { |
322 | if( mRelations.findRef( event ) == -1 ) { | 336 | if( mRelations.findRef( event ) == -1 ) { |
323 | mRelations.append(event); | 337 | mRelations.append(event); |
324 | //updated(); | 338 | //updated(); |
325 | } | 339 | } |
326 | } | 340 | } |
327 | 341 | ||
328 | void Incidence::removeRelation(Incidence *event) | 342 | void Incidence::removeRelation(Incidence *event) |
329 | { | 343 | { |
330 | 344 | ||
331 | mRelations.removeRef(event); | 345 | mRelations.removeRef(event); |
332 | 346 | ||
333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 347 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
334 | } | 348 | } |
335 | 349 | ||
336 | bool Incidence::recursOn(const QDate &qd) const | 350 | bool Incidence::recursOn(const QDate &qd) const |
337 | { | 351 | { |
338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 352 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
339 | else return false; | 353 | else return false; |
340 | } | 354 | } |
341 | 355 | ||
342 | void Incidence::setExDates(const DateList &exDates) | 356 | void Incidence::setExDates(const DateList &exDates) |
343 | { | 357 | { |
344 | if (mReadOnly) return; | 358 | if (mReadOnly) return; |
345 | mExDates = exDates; | 359 | mExDates = exDates; |
346 | 360 | ||
347 | recurrence()->setRecurExDatesCount(mExDates.count()); | 361 | recurrence()->setRecurExDatesCount(mExDates.count()); |
348 | 362 | ||
349 | updated(); | 363 | updated(); |
350 | } | 364 | } |
351 | 365 | ||
352 | void Incidence::addExDate(const QDate &date) | 366 | void Incidence::addExDate(const QDate &date) |
353 | { | 367 | { |
354 | if (mReadOnly) return; | 368 | if (mReadOnly) return; |
355 | mExDates.append(date); | 369 | mExDates.append(date); |
356 | 370 | ||
357 | recurrence()->setRecurExDatesCount(mExDates.count()); | 371 | recurrence()->setRecurExDatesCount(mExDates.count()); |
358 | 372 | ||
359 | updated(); | 373 | updated(); |
360 | } | 374 | } |
361 | 375 | ||
362 | DateList Incidence::exDates() const | 376 | DateList Incidence::exDates() const |
363 | { | 377 | { |
364 | return mExDates; | 378 | return mExDates; |
365 | } | 379 | } |
366 | 380 | ||
367 | bool Incidence::isException(const QDate &date) const | 381 | bool Incidence::isException(const QDate &date) const |
368 | { | 382 | { |
369 | DateList::ConstIterator it; | 383 | DateList::ConstIterator it; |
370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 384 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
371 | if ( (*it) == date ) { | 385 | if ( (*it) == date ) { |
372 | return true; | 386 | return true; |
373 | } | 387 | } |
374 | } | 388 | } |
375 | 389 | ||
376 | return false; | 390 | return false; |
377 | } | 391 | } |
378 | 392 | ||
379 | void Incidence::addAttachment(Attachment *attachment) | 393 | void Incidence::addAttachment(Attachment *attachment) |
380 | { | 394 | { |
381 | if (mReadOnly || !attachment) return; | 395 | if (mReadOnly || !attachment) return; |
382 | mAttachments.append(attachment); | 396 | mAttachments.append(attachment); |
383 | updated(); | 397 | updated(); |
384 | } | 398 | } |
385 | 399 | ||
386 | void Incidence::deleteAttachment(Attachment *attachment) | 400 | void Incidence::deleteAttachment(Attachment *attachment) |
387 | { | 401 | { |
388 | mAttachments.removeRef(attachment); | 402 | mAttachments.removeRef(attachment); |
389 | } | 403 | } |
390 | 404 | ||
391 | void Incidence::deleteAttachments(const QString& mime) | 405 | void Incidence::deleteAttachments(const QString& mime) |
392 | { | 406 | { |
393 | Attachment *at = mAttachments.first(); | 407 | Attachment *at = mAttachments.first(); |
394 | while (at) { | 408 | while (at) { |
395 | if (at->mimeType() == mime) | 409 | if (at->mimeType() == mime) |
396 | mAttachments.remove(); | 410 | mAttachments.remove(); |
397 | else | 411 | else |
398 | at = mAttachments.next(); | 412 | at = mAttachments.next(); |
399 | } | 413 | } |
400 | } | 414 | } |
401 | 415 | ||
402 | QPtrList<Attachment> Incidence::attachments() const | 416 | QPtrList<Attachment> Incidence::attachments() const |
403 | { | 417 | { |
404 | return mAttachments; | 418 | return mAttachments; |
405 | } | 419 | } |
406 | 420 | ||
407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 421 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
408 | { | 422 | { |
409 | QPtrList<Attachment> attachments; | 423 | QPtrList<Attachment> attachments; |
410 | QPtrListIterator<Attachment> it( mAttachments ); | 424 | QPtrListIterator<Attachment> it( mAttachments ); |
411 | Attachment *at; | 425 | Attachment *at; |
412 | while ( (at = it.current()) ) { | 426 | while ( (at = it.current()) ) { |
413 | if (at->mimeType() == mime) | 427 | if (at->mimeType() == mime) |
414 | attachments.append(at); | 428 | attachments.append(at); |
415 | ++it; | 429 | ++it; |
416 | } | 430 | } |
417 | 431 | ||
418 | return attachments; | 432 | return attachments; |
419 | } | 433 | } |
420 | 434 | ||
421 | void Incidence::setResources(const QStringList &resources) | 435 | void Incidence::setResources(const QStringList &resources) |
422 | { | 436 | { |
423 | if (mReadOnly) return; | 437 | if (mReadOnly) return; |
424 | mResources = resources; | 438 | mResources = resources; |
425 | updated(); | 439 | updated(); |
426 | } | 440 | } |
427 | 441 | ||
428 | QStringList Incidence::resources() const | 442 | QStringList Incidence::resources() const |
429 | { | 443 | { |
430 | return mResources; | 444 | return mResources; |
431 | } | 445 | } |
432 | 446 | ||
433 | 447 | ||
434 | void Incidence::setPriority(int priority) | 448 | void Incidence::setPriority(int priority) |
435 | { | 449 | { |
436 | if (mReadOnly) return; | 450 | if (mReadOnly) return; |
437 | mPriority = priority; | 451 | mPriority = priority; |
438 | updated(); | 452 | updated(); |
439 | } | 453 | } |
440 | 454 | ||
441 | int Incidence::priority() const | 455 | int Incidence::priority() const |
442 | { | 456 | { |
443 | return mPriority; | 457 | return mPriority; |
444 | } | 458 | } |
445 | 459 | ||
446 | void Incidence::setSecrecy(int sec) | 460 | void Incidence::setSecrecy(int sec) |
447 | { | 461 | { |
448 | if (mReadOnly) return; | 462 | if (mReadOnly) return; |
449 | mSecrecy = sec; | 463 | mSecrecy = sec; |
450 | updated(); | 464 | updated(); |
451 | } | 465 | } |
452 | 466 | ||
453 | int Incidence::secrecy() const | 467 | int Incidence::secrecy() const |
454 | { | 468 | { |
455 | return mSecrecy; | 469 | return mSecrecy; |
456 | } | 470 | } |
457 | 471 | ||
458 | QString Incidence::secrecyStr() const | 472 | QString Incidence::secrecyStr() const |
459 | { | 473 | { |
460 | return secrecyName(mSecrecy); | 474 | return secrecyName(mSecrecy); |
461 | } | 475 | } |
462 | 476 | ||
463 | QString Incidence::secrecyName(int secrecy) | 477 | QString Incidence::secrecyName(int secrecy) |
464 | { | 478 | { |
465 | switch (secrecy) { | 479 | switch (secrecy) { |
466 | case SecrecyPublic: | 480 | case SecrecyPublic: |
467 | return i18n("Public"); | 481 | return i18n("Public"); |
468 | break; | 482 | break; |
469 | case SecrecyPrivate: | 483 | case SecrecyPrivate: |
470 | return i18n("Private"); | 484 | return i18n("Private"); |
471 | break; | 485 | break; |
472 | case SecrecyConfidential: | 486 | case SecrecyConfidential: |
473 | return i18n("Confidential"); | 487 | return i18n("Confidential"); |
474 | break; | 488 | break; |
475 | default: | 489 | default: |
476 | return i18n("Undefined"); | 490 | return i18n("Undefined"); |
477 | break; | 491 | break; |
478 | } | 492 | } |
479 | } | 493 | } |
480 | 494 | ||
481 | QStringList Incidence::secrecyList() | 495 | QStringList Incidence::secrecyList() |
482 | { | 496 | { |
483 | QStringList list; | 497 | QStringList list; |
484 | list << secrecyName(SecrecyPublic); | 498 | list << secrecyName(SecrecyPublic); |
485 | list << secrecyName(SecrecyPrivate); | 499 | list << secrecyName(SecrecyPrivate); |
486 | list << secrecyName(SecrecyConfidential); | 500 | list << secrecyName(SecrecyConfidential); |
487 | 501 | ||
488 | return list; | 502 | return list; |
489 | } | 503 | } |
490 | 504 | ||
491 | 505 | ||
492 | QPtrList<Alarm> Incidence::alarms() const | 506 | QPtrList<Alarm> Incidence::alarms() const |
493 | { | 507 | { |
494 | return mAlarms; | 508 | return mAlarms; |
495 | } | 509 | } |
496 | 510 | ||
497 | Alarm* Incidence::newAlarm() | 511 | Alarm* Incidence::newAlarm() |
498 | { | 512 | { |
499 | Alarm* alarm = new Alarm(this); | 513 | Alarm* alarm = new Alarm(this); |
500 | mAlarms.append(alarm); | 514 | mAlarms.append(alarm); |
501 | // updated(); | 515 | // updated(); |
502 | return alarm; | 516 | return alarm; |
503 | } | 517 | } |
504 | 518 | ||
505 | void Incidence::addAlarm(Alarm *alarm) | 519 | void Incidence::addAlarm(Alarm *alarm) |
506 | { | 520 | { |
507 | mAlarms.append(alarm); | 521 | mAlarms.append(alarm); |
508 | updated(); | 522 | updated(); |
509 | } | 523 | } |
510 | 524 | ||
511 | void Incidence::removeAlarm(Alarm *alarm) | 525 | void Incidence::removeAlarm(Alarm *alarm) |
512 | { | 526 | { |
513 | mAlarms.removeRef(alarm); | 527 | mAlarms.removeRef(alarm); |
514 | updated(); | 528 | updated(); |
515 | } | 529 | } |
516 | 530 | ||
517 | void Incidence::clearAlarms() | 531 | void Incidence::clearAlarms() |
518 | { | 532 | { |
519 | mAlarms.clear(); | 533 | mAlarms.clear(); |
520 | updated(); | 534 | updated(); |
521 | } | 535 | } |
522 | 536 | ||
523 | bool Incidence::isAlarmEnabled() const | 537 | bool Incidence::isAlarmEnabled() const |
524 | { | 538 | { |
525 | Alarm* alarm; | 539 | Alarm* alarm; |
526 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 540 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
527 | if (alarm->enabled()) | 541 | if (alarm->enabled()) |
528 | return true; | 542 | return true; |
529 | } | 543 | } |
530 | return false; | 544 | return false; |
531 | } | 545 | } |
532 | 546 | ||
533 | Recurrence *Incidence::recurrence() const | 547 | Recurrence *Incidence::recurrence() const |
534 | { | 548 | { |
535 | return mRecurrence; | 549 | return mRecurrence; |
536 | } | 550 | } |
537 | void Incidence::setRecurrence( Recurrence * r) | 551 | void Incidence::setRecurrence( Recurrence * r) |
538 | { | 552 | { |
539 | delete mRecurrence; | 553 | delete mRecurrence; |
540 | mRecurrence = r; | 554 | mRecurrence = r; |
541 | } | 555 | } |
542 | 556 | ||
543 | void Incidence::setLocation(const QString &location) | 557 | void Incidence::setLocation(const QString &location) |
544 | { | 558 | { |
545 | if (mReadOnly) return; | 559 | if (mReadOnly) return; |
546 | mLocation = location; | 560 | mLocation = location; |
547 | updated(); | 561 | updated(); |
548 | } | 562 | } |
549 | 563 | ||
550 | QString Incidence::location() const | 564 | QString Incidence::location() const |
551 | { | 565 | { |
552 | return mLocation; | 566 | return mLocation; |
553 | } | 567 | } |
554 | 568 | ||
555 | ushort Incidence::doesRecur() const | 569 | ushort Incidence::doesRecur() const |
556 | { | 570 | { |
557 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 571 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
558 | else return Recurrence::rNone; | 572 | else return Recurrence::rNone; |
559 | } | 573 | } |
560 | 574 | ||
561 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 575 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
562 | { | 576 | { |
563 | QDateTime incidenceStart = dt; | 577 | QDateTime incidenceStart = dt; |
564 | *ok = false; | 578 | *ok = false; |
565 | if ( doesRecur() ) { | 579 | if ( doesRecur() ) { |
566 | bool last; | 580 | bool last; |
567 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 581 | recurrence()->getPreviousDateTime( incidenceStart , &last ); |
568 | int count = 0; | 582 | int count = 0; |
569 | if ( !last ) { | 583 | if ( !last ) { |
570 | while ( !last ) { | 584 | while ( !last ) { |
571 | ++count; | 585 | ++count; |
572 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 586 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
573 | if ( recursOn( incidenceStart.date() ) ) { | 587 | if ( recursOn( incidenceStart.date() ) ) { |
574 | last = true; // exit while llop | 588 | last = true; // exit while llop |
575 | } else { | 589 | } else { |
576 | if ( last ) { // no alarm on last recurrence | 590 | if ( last ) { // no alarm on last recurrence |
577 | return QDateTime (); | 591 | return QDateTime (); |
578 | } | 592 | } |
579 | int year = incidenceStart.date().year(); | 593 | int year = incidenceStart.date().year(); |
580 | // workaround for bug in recurrence | 594 | // workaround for bug in recurrence |
581 | if ( count == 100 || year < 1980 || year > 5000 ) { | 595 | if ( count == 100 || year < 1980 || year > 5000 ) { |
582 | return QDateTime (); | 596 | return QDateTime (); |
583 | } | 597 | } |
584 | incidenceStart = incidenceStart.addSecs( 1 ); | 598 | incidenceStart = incidenceStart.addSecs( 1 ); |
585 | } | 599 | } |
586 | } | 600 | } |
587 | } else { | 601 | } else { |
588 | return QDateTime (); | 602 | return QDateTime (); |
589 | } | 603 | } |
590 | } else { | 604 | } else { |
591 | if ( hasStartDate () ) { | 605 | if ( hasStartDate () ) { |
592 | incidenceStart = dtStart(); | 606 | incidenceStart = dtStart(); |
593 | } | 607 | } |
594 | if ( type() =="Todo" ) { | 608 | if ( type() =="Todo" ) { |
595 | if ( ((Todo*)this)->hasDueDate() ) | 609 | if ( ((Todo*)this)->hasDueDate() ) |
596 | incidenceStart = ((Todo*)this)->dtDue(); | 610 | incidenceStart = ((Todo*)this)->dtDue(); |
597 | 611 | ||
598 | } | 612 | } |
599 | } | 613 | } |
600 | if ( incidenceStart > dt ) | 614 | if ( incidenceStart > dt ) |
601 | *ok = true; | 615 | *ok = true; |
602 | return incidenceStart; | 616 | return incidenceStart; |
603 | } | 617 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 7dc6f10..1807bc4 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,298 +1,299 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | 115 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 117 | void setReadOnly( bool ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 120 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 121 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 122 | modification date and revision number. |
123 | */ | 123 | */ |
124 | void recreate(); | 124 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | ||
125 | 126 | ||
126 | /** set creation date */ | 127 | /** set creation date */ |
127 | void setCreated(QDateTime); | 128 | void setCreated(QDateTime); |
128 | /** return time and date of creation. */ | 129 | /** return time and date of creation. */ |
129 | QDateTime created() const; | 130 | QDateTime created() const; |
130 | 131 | ||
131 | /** set the number of revisions this event has seen */ | 132 | /** set the number of revisions this event has seen */ |
132 | void setRevision(int rev); | 133 | void setRevision(int rev); |
133 | /** return the number of revisions this event has seen */ | 134 | /** return the number of revisions this event has seen */ |
134 | int revision() const; | 135 | int revision() const; |
135 | 136 | ||
136 | /** Set starting date/time. */ | 137 | /** Set starting date/time. */ |
137 | virtual void setDtStart(const QDateTime &dtStart); | 138 | virtual void setDtStart(const QDateTime &dtStart); |
138 | /** Return the incidence's ending date/time as a QDateTime. */ | 139 | /** Return the incidence's ending date/time as a QDateTime. */ |
139 | virtual QDateTime dtEnd() const { return QDateTime(); } | 140 | virtual QDateTime dtEnd() const { return QDateTime(); } |
140 | 141 | ||
141 | /** sets the event's lengthy description. */ | 142 | /** sets the event's lengthy description. */ |
142 | void setDescription(const QString &description); | 143 | void setDescription(const QString &description); |
143 | /** returns a reference to the event's description. */ | 144 | /** returns a reference to the event's description. */ |
144 | QString description() const; | 145 | QString description() const; |
145 | 146 | ||
146 | /** sets the event's short summary. */ | 147 | /** sets the event's short summary. */ |
147 | void setSummary(const QString &summary); | 148 | void setSummary(const QString &summary); |
148 | /** returns a reference to the event's summary. */ | 149 | /** returns a reference to the event's summary. */ |
149 | QString summary() const; | 150 | QString summary() const; |
150 | 151 | ||
151 | /** set event's applicable categories */ | 152 | /** set event's applicable categories */ |
152 | void setCategories(const QStringList &categories); | 153 | void setCategories(const QStringList &categories); |
153 | /** set event's categories based on a comma delimited string */ | 154 | /** set event's categories based on a comma delimited string */ |
154 | void setCategories(const QString &catStr); | 155 | void setCategories(const QString &catStr); |
155 | /** return categories in a list */ | 156 | /** return categories in a list */ |
156 | QStringList categories() const; | 157 | QStringList categories() const; |
157 | /** return categories as a comma separated string */ | 158 | /** return categories as a comma separated string */ |
158 | QString categoriesStr(); | 159 | QString categoriesStr(); |
159 | 160 | ||
160 | /** point at some other event to which the event relates. This function should | 161 | /** point at some other event to which the event relates. This function should |
161 | * only be used when constructing a calendar before the related Event | 162 | * only be used when constructing a calendar before the related Event |
162 | * exists. */ | 163 | * exists. */ |
163 | void setRelatedToUid(const QString &); | 164 | void setRelatedToUid(const QString &); |
164 | /** what event does this one relate to? This function should | 165 | /** what event does this one relate to? This function should |
165 | * only be used when constructing a calendar before the related Event | 166 | * only be used when constructing a calendar before the related Event |
166 | * exists. */ | 167 | * exists. */ |
167 | QString relatedToUid() const; | 168 | QString relatedToUid() const; |
168 | /** point at some other event to which the event relates */ | 169 | /** point at some other event to which the event relates */ |
169 | void setRelatedTo(Incidence *relatedTo); | 170 | void setRelatedTo(Incidence *relatedTo); |
170 | /** what event does this one relate to? */ | 171 | /** what event does this one relate to? */ |
171 | Incidence *relatedTo() const; | 172 | Incidence *relatedTo() const; |
172 | /** All events that are related to this event */ | 173 | /** All events that are related to this event */ |
173 | QPtrList<Incidence> relations() const; | 174 | QPtrList<Incidence> relations() const; |
174 | /** Add an event which is related to this event */ | 175 | /** Add an event which is related to this event */ |
175 | void addRelation(Incidence *); | 176 | void addRelation(Incidence *); |
176 | /** Remove event that is related to this event */ | 177 | /** Remove event that is related to this event */ |
177 | void removeRelation(Incidence *); | 178 | void removeRelation(Incidence *); |
178 | 179 | ||
179 | /** returns the list of dates which are exceptions to the recurrence rule */ | 180 | /** returns the list of dates which are exceptions to the recurrence rule */ |
180 | DateList exDates() const; | 181 | DateList exDates() const; |
181 | /** sets the list of dates which are exceptions to the recurrence rule */ | 182 | /** sets the list of dates which are exceptions to the recurrence rule */ |
182 | void setExDates(const DateList &_exDates); | 183 | void setExDates(const DateList &_exDates); |
183 | void setExDates(const char *dates); | 184 | void setExDates(const char *dates); |
184 | /** Add a date to the list of exceptions of the recurrence rule. */ | 185 | /** Add a date to the list of exceptions of the recurrence rule. */ |
185 | void addExDate(const QDate &date); | 186 | void addExDate(const QDate &date); |
186 | 187 | ||
187 | /** returns true if there is an exception for this date in the recurrence | 188 | /** returns true if there is an exception for this date in the recurrence |
188 | rule set, or false otherwise. */ | 189 | rule set, or false otherwise. */ |
189 | bool isException(const QDate &qd) const; | 190 | bool isException(const QDate &qd) const; |
190 | 191 | ||
191 | /** add attachment to this event */ | 192 | /** add attachment to this event */ |
192 | void addAttachment(Attachment *attachment); | 193 | void addAttachment(Attachment *attachment); |
193 | /** remove and delete a specific attachment */ | 194 | /** remove and delete a specific attachment */ |
194 | void deleteAttachment(Attachment *attachment); | 195 | void deleteAttachment(Attachment *attachment); |
195 | /** remove and delete all attachments with this mime type */ | 196 | /** remove and delete all attachments with this mime type */ |
196 | void deleteAttachments(const QString& mime); | 197 | void deleteAttachments(const QString& mime); |
197 | /** return list of all associated attachments */ | 198 | /** return list of all associated attachments */ |
198 | QPtrList<Attachment> attachments() const; | 199 | QPtrList<Attachment> attachments() const; |
199 | /** find a list of attachments with this mime type */ | 200 | /** find a list of attachments with this mime type */ |
200 | QPtrList<Attachment> attachments(const QString& mime) const; | 201 | QPtrList<Attachment> attachments(const QString& mime) const; |
201 | 202 | ||
202 | /** sets the event's status the value specified. See the enumeration | 203 | /** sets the event's status the value specified. See the enumeration |
203 | * above for possible values. */ | 204 | * above for possible values. */ |
204 | void setSecrecy(int); | 205 | void setSecrecy(int); |
205 | /** return the event's secrecy. */ | 206 | /** return the event's secrecy. */ |
206 | int secrecy() const; | 207 | int secrecy() const; |
207 | /** return the event's secrecy in string format. */ | 208 | /** return the event's secrecy in string format. */ |
208 | QString secrecyStr() const; | 209 | QString secrecyStr() const; |
209 | /** return list of all availbale secrecy classes */ | 210 | /** return list of all availbale secrecy classes */ |
210 | static QStringList secrecyList(); | 211 | static QStringList secrecyList(); |
211 | /** return human-readable name of secrecy class */ | 212 | /** return human-readable name of secrecy class */ |
212 | static QString secrecyName(int); | 213 | static QString secrecyName(int); |
213 | 214 | ||
214 | /** returns TRUE if the date specified is one on which the event will | 215 | /** returns TRUE if the date specified is one on which the event will |
215 | * recur. */ | 216 | * recur. */ |
216 | bool recursOn(const QDate &qd) const; | 217 | bool recursOn(const QDate &qd) const; |
217 | 218 | ||
218 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
219 | 220 | ||
220 | /** set resources used, such as Office, Car, etc. */ | 221 | /** set resources used, such as Office, Car, etc. */ |
221 | void setResources(const QStringList &resources); | 222 | void setResources(const QStringList &resources); |
222 | /** return list of current resources */ | 223 | /** return list of current resources */ |
223 | QStringList resources() const; | 224 | QStringList resources() const; |
224 | 225 | ||
225 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
226 | void setPriority(int priority); | 227 | void setPriority(int priority); |
227 | /** get the event's priority */ | 228 | /** get the event's priority */ |
228 | int priority() const; | 229 | int priority() const; |
229 | 230 | ||
230 | /** All alarms that are associated with this incidence */ | 231 | /** All alarms that are associated with this incidence */ |
231 | QPtrList<Alarm> alarms() const; | 232 | QPtrList<Alarm> alarms() const; |
232 | /** Create a new alarm which is associated with this incidence */ | 233 | /** Create a new alarm which is associated with this incidence */ |
233 | Alarm* newAlarm(); | 234 | Alarm* newAlarm(); |
234 | /** Add an alarm which is associated with this incidence */ | 235 | /** Add an alarm which is associated with this incidence */ |
235 | void addAlarm(Alarm*); | 236 | void addAlarm(Alarm*); |
236 | /** Remove an alarm that is associated with this incidence */ | 237 | /** Remove an alarm that is associated with this incidence */ |
237 | void removeAlarm(Alarm*); | 238 | void removeAlarm(Alarm*); |
238 | /** Remove all alarms that are associated with this incidence */ | 239 | /** Remove all alarms that are associated with this incidence */ |
239 | void clearAlarms(); | 240 | void clearAlarms(); |
240 | /** return whether any alarm associated with this incidence is enabled */ | 241 | /** return whether any alarm associated with this incidence is enabled */ |
241 | bool isAlarmEnabled() const; | 242 | bool isAlarmEnabled() const; |
242 | 243 | ||
243 | /** | 244 | /** |
244 | Return the recurrence rule associated with this incidence. If there is | 245 | Return the recurrence rule associated with this incidence. If there is |
245 | none, returns an appropriate (non-0) object. | 246 | none, returns an appropriate (non-0) object. |
246 | */ | 247 | */ |
247 | Recurrence *recurrence() const; | 248 | Recurrence *recurrence() const; |
248 | void setRecurrence(Recurrence * r); | 249 | void setRecurrence(Recurrence * r); |
249 | /** | 250 | /** |
250 | Forward to Recurrence::doesRecur(). | 251 | Forward to Recurrence::doesRecur(). |
251 | */ | 252 | */ |
252 | ushort doesRecur() const; | 253 | ushort doesRecur() const; |
253 | 254 | ||
254 | /** set the event's/todo's location. Do _not_ use it with journal */ | 255 | /** set the event's/todo's location. Do _not_ use it with journal */ |
255 | void setLocation(const QString &location); | 256 | void setLocation(const QString &location); |
256 | /** return the event's/todo's location. Do _not_ use it with journal */ | 257 | /** return the event's/todo's location. Do _not_ use it with journal */ |
257 | QString location() const; | 258 | QString location() const; |
258 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
259 | bool hasStartDate() const; | 260 | bool hasStartDate() const; |
260 | /** sets the event's hasStartDate value. */ | 261 | /** sets the event's hasStartDate value. */ |
261 | void setHasStartDate(bool f); | 262 | void setHasStartDate(bool f); |
262 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
263 | bool cancelled() const; | 264 | bool cancelled() const; |
264 | void setCancelled( bool b ); | 265 | void setCancelled( bool b ); |
265 | 266 | ||
266 | protected: | 267 | protected: |
267 | QPtrList<Alarm> mAlarms; | 268 | QPtrList<Alarm> mAlarms; |
268 | private: | 269 | private: |
269 | int mRevision; | 270 | int mRevision; |
270 | bool mCancelled; | 271 | bool mCancelled; |
271 | 272 | ||
272 | // base components of jounal, event and todo | 273 | // base components of jounal, event and todo |
273 | QDateTime mCreated; | 274 | QDateTime mCreated; |
274 | QString mDescription; | 275 | QString mDescription; |
275 | QString mSummary; | 276 | QString mSummary; |
276 | QStringList mCategories; | 277 | QStringList mCategories; |
277 | Incidence *mRelatedTo; | 278 | Incidence *mRelatedTo; |
278 | QString mRelatedToUid; | 279 | QString mRelatedToUid; |
279 | QPtrList<Incidence> mRelations; | 280 | QPtrList<Incidence> mRelations; |
280 | DateList mExDates; | 281 | DateList mExDates; |
281 | QPtrList<Attachment> mAttachments; | 282 | QPtrList<Attachment> mAttachments; |
282 | QStringList mResources; | 283 | QStringList mResources; |
283 | bool mHasStartDate; // if todo has associated start date | 284 | bool mHasStartDate; // if todo has associated start date |
284 | 285 | ||
285 | int mSecrecy; | 286 | int mSecrecy; |
286 | int mPriority; // 1 = highest, 2 = less, etc. | 287 | int mPriority; // 1 = highest, 2 = less, etc. |
287 | 288 | ||
288 | //QPtrList<Alarm> mAlarms; | 289 | //QPtrList<Alarm> mAlarms; |
289 | Recurrence *mRecurrence; | 290 | Recurrence *mRecurrence; |
290 | 291 | ||
291 | QString mLocation; | 292 | QString mLocation; |
292 | }; | 293 | }; |
293 | 294 | ||
294 | bool operator==( const Incidence&, const Incidence& ); | 295 | bool operator==( const Incidence&, const Incidence& ); |
295 | 296 | ||
296 | } | 297 | } |
297 | 298 | ||
298 | #endif | 299 | #endif |
@@ -1 +1 @@ | |||
version = "1.9.14"; | version = "1.9.15"; | ||