author | zautrix <zautrix> | 2004-10-16 13:36:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-16 13:36:11 (UTC) |
commit | c3325ebbb92a2814fcb622caaf71316cfa0c2908 (patch) (unidiff) | |
tree | b53545c39f84fc6ce694f371509b4a9fe2ddd743 | |
parent | 023b3c542a6dd4d1c4b53dba6bb2c68f605a7917 (diff) | |
download | kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.zip kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.gz kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.bz2 |
made todos reparentable
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 8 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 88 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 3 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 | ||||
-rw-r--r-- | microkde/kdeui/klistview.cpp | 7 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 1 |
9 files changed, 122 insertions, 7 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index eb232fa..e17297a 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,373 +1,381 @@ | |||
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.8 ************ | ||
4 | |||
5 | Fixed character decoding in OM/Pi. | ||
6 | (e.g. German "Umlaute" were not displayed properly.) | ||
7 | |||
8 | Made is possible to reparent todos in KO/Pi. | ||
9 | Use contextmenu or keys (look at Help-Keys + Colors) for that. | ||
10 | |||
3 | ********** VERSION 1.9.7 ************ | 11 | ********** VERSION 1.9.7 ************ |
4 | 12 | ||
5 | KO/Pi - KA/Pi on Windows: | 13 | KO/Pi - KA/Pi on Windows: |
6 | Now a directory can be defined by the user, where the | 14 | Now a directory can be defined by the user, where the |
7 | application/config data should be saved. | 15 | application/config data should be saved. |
8 | Define your desired path in the evironment variable | 16 | Define your desired path in the evironment variable |
9 | MICROKDEHOME | 17 | MICROKDEHOME |
10 | before starting KO/Pi or KA/Pi. | 18 | before starting KO/Pi or KA/Pi. |
11 | 19 | ||
12 | An easy Kx/Pi to Kx/Pi syncing is now possible | 20 | An easy Kx/Pi to Kx/Pi syncing is now possible |
13 | (it is called Pi-Sync) via network. | 21 | (it is called Pi-Sync) via network. |
14 | Please look at the Sync Howto. | 22 | Please look at the Sync Howto. |
15 | 23 | ||
16 | Exporting of calendar data and contacts to mobile phones is now possible. | 24 | Exporting of calendar data and contacts to mobile phones is now possible. |
17 | The SyncHowto is updated with information howto | 25 | The SyncHowto is updated with information howto |
18 | access/sync mobile phones. | 26 | access/sync mobile phones. |
19 | Please look at the Sync Howto. | 27 | Please look at the Sync Howto. |
20 | 28 | ||
21 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. | 29 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. |
22 | Please disable Fastload for the original contact/calendar applications | 30 | Please disable Fastload for the original contact/calendar applications |
23 | and close them. | 31 | and close them. |
24 | KO/Pi and KA/Pi must be running in order to receive the data. | 32 | KO/Pi and KA/Pi must be running in order to receive the data. |
25 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) | 33 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) |
26 | 34 | ||
27 | In the KA/Pi details view are now the preferred tel. numbers displayed on top | 35 | In the KA/Pi details view are now the preferred tel. numbers displayed on top |
28 | of the other data ( emails/tel.numbers/addresses) | 36 | of the other data ( emails/tel.numbers/addresses) |
29 | 37 | ||
30 | Fixed some syncing problems in KA/Pi. | 38 | Fixed some syncing problems in KA/Pi. |
31 | 39 | ||
32 | Added font settings for the KA/Pi details view. | 40 | Added font settings for the KA/Pi details view. |
33 | Added fields "children's name" and "gender" to KA/Pi. | 41 | Added fields "children's name" and "gender" to KA/Pi. |
34 | 42 | ||
35 | Made searching in KA/Pi better: | 43 | Made searching in KA/Pi better: |
36 | Now the first item in a view is selected after a search automatically and | 44 | Now the first item in a view is selected after a search automatically and |
37 | the views can be scrolled up/down when the search input field has the keyboard focus. | 45 | the views can be scrolled up/down when the search input field has the keyboard focus. |
38 | 46 | ||
39 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. | 47 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. |
40 | 48 | ||
41 | 49 | ||
42 | ********** VERSION 1.9.6 ************ | 50 | ********** VERSION 1.9.6 ************ |
43 | 51 | ||
44 | Changes in the external application communication on the Zaurus | 52 | Changes in the external application communication on the Zaurus |
45 | in order to use less RAM when the apps are running. | 53 | in order to use less RAM when the apps are running. |
46 | First syncing of addressbooks (KA/Pi) is possible. | 54 | First syncing of addressbooks (KA/Pi) is possible. |
47 | 55 | ||
48 | 56 | ||
49 | ********** VERSION 1.9.5a ************ | 57 | ********** VERSION 1.9.5a ************ |
50 | 58 | ||
51 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. | 59 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. |
52 | Fixed some small bugs. | 60 | Fixed some small bugs. |
53 | KA/Pi shows now the birthday in summary view. | 61 | KA/Pi shows now the birthday in summary view. |
54 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi | 62 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi |
55 | for displaying dates. | 63 | for displaying dates. |
56 | 64 | ||
57 | 65 | ||
58 | ********** VERSION 1.9.5 ************ | 66 | ********** VERSION 1.9.5 ************ |
59 | 67 | ||
60 | There is still no Addressbook syncing! | 68 | There is still no Addressbook syncing! |
61 | 69 | ||
62 | New in 1.9.5: | 70 | New in 1.9.5: |
63 | 71 | ||
64 | Many bugfixes. | 72 | Many bugfixes. |
65 | Better searching in KA/Pi. | 73 | Better searching in KA/Pi. |
66 | You can configure in KA/Pi if you want to search only after | 74 | You can configure in KA/Pi if you want to search only after |
67 | <return> key pressed. | 75 | <return> key pressed. |
68 | 76 | ||
69 | Better mail downloading in OM/Pi. | 77 | Better mail downloading in OM/Pi. |
70 | 78 | ||
71 | First experimental alpha version of sync of KO/Pi with mobile phones. | 79 | First experimental alpha version of sync of KO/Pi with mobile phones. |
72 | See gammu documentation for supported phones. | 80 | See gammu documentation for supported phones. |
73 | 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. | 81 | 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. |
74 | Quick hint how to use: | 82 | Quick hint how to use: |
75 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! | 83 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! |
76 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. | 84 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. |
77 | Create syncprofile - mobile device | 85 | Create syncprofile - mobile device |
78 | Remove entry for model. (Leave empty ). | 86 | Remove entry for model. (Leave empty ). |
79 | Enable infrared on Zaurus and your Phone. | 87 | Enable infrared on Zaurus and your Phone. |
80 | Sync. | 88 | Sync. |
81 | To get a more detailed log, start kopi from konsole. | 89 | To get a more detailed log, start kopi from konsole. |
82 | 90 | ||
83 | ********** VERSION 1.9.4 ************ | 91 | ********** VERSION 1.9.4 ************ |
84 | 92 | ||
85 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. | 93 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. |
86 | 94 | ||
87 | WARNING: | 95 | WARNING: |
88 | PLEASE BACKUP ALL YOUR DATA! | 96 | PLEASE BACKUP ALL YOUR DATA! |
89 | We have changed a lot and maybe there are some unknown problems. | 97 | We have changed a lot and maybe there are some unknown problems. |
90 | 98 | ||
91 | SYNC HANDLING HAS CHANGED! | 99 | SYNC HANDLING HAS CHANGED! |
92 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 100 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
93 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 101 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
94 | 102 | ||
95 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. | 103 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. |
96 | 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. | 104 | 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. |
97 | 105 | ||
98 | As programs are available: | 106 | As programs are available: |
99 | KO/Pi (korganizer ipk) - a calendar program. | 107 | KO/Pi (korganizer ipk) - a calendar program. |
100 | KA/Pi (kaddressbook ipk ) - an addressbook | 108 | KA/Pi (kaddressbook ipk ) - an addressbook |
101 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. | 109 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. |
102 | 110 | ||
103 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. | 111 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. |
104 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) | 112 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) |
105 | 113 | ||
106 | All the applications are installed in a "Pim" TAB. | 114 | All the applications are installed in a "Pim" TAB. |
107 | 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 | 115 | 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 |
108 | 116 | ||
109 | All the application are integrated. | 117 | All the application are integrated. |
110 | 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. | 118 | 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. |
111 | 119 | ||
112 | HINT: | 120 | HINT: |
113 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. | 121 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. |
114 | 122 | ||
115 | What's new? | 123 | What's new? |
116 | 124 | ||
117 | SYNC HANDLING HAS CHANGED! | 125 | SYNC HANDLING HAS CHANGED! |
118 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 126 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
119 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 127 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
120 | 128 | ||
121 | New in OM/Pi: | 129 | New in OM/Pi: |
122 | 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. | 130 | 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. |
123 | 131 | ||
124 | New in KO/Pi: | 132 | New in KO/Pi: |
125 | French is now available for KO/Pi. | 133 | French is now available for KO/Pi. |
126 | Choose menu:Actions - Configure:TAB locale | 134 | Choose menu:Actions - Configure:TAB locale |
127 | Syncing has changed. | 135 | Syncing has changed. |
128 | Phone sync available soon. | 136 | Phone sync available soon. |
129 | Not much changes, I cannot remember them ... | 137 | Not much changes, I cannot remember them ... |
130 | 138 | ||
131 | New in KA/Pi: | 139 | New in KA/Pi: |
132 | Beaming possible. | 140 | Beaming possible. |
133 | Sharp DTM readonly access possible( create a new DTM resource ); | 141 | Sharp DTM readonly access possible( create a new DTM resource ); |
134 | Better searching possible. | 142 | Better searching possible. |
135 | Search is performed only after pressing the return key. | 143 | Search is performed only after pressing the return key. |
136 | Use wildcard * to specify parts of a name. | 144 | Use wildcard * to specify parts of a name. |
137 | 145 | ||
138 | 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 * . | 146 | 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 * . |
139 | 147 | ||
140 | A big improvement is the new management of the contact access. | 148 | A big improvement is the new management of the contact access. |
141 | In version 1.9.3, every application was using their own addressbook access data. | 149 | In version 1.9.3, every application was using their own addressbook access data. |
142 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. | 150 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. |
143 | That was wasting of memory, if you had several hundreds of contacts. | 151 | That was wasting of memory, if you had several hundreds of contacts. |
144 | 152 | ||
145 | Now only KA/Pi accesses the addressbook. | 153 | Now only KA/Pi accesses the addressbook. |
146 | 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. | 154 | 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. |
147 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. | 155 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. |
148 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. | 156 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. |
149 | 157 | ||
150 | New in the KO/Pi alarm applet: | 158 | New in the KO/Pi alarm applet: |
151 | Configure your own timer popup menu! | 159 | Configure your own timer popup menu! |
152 | (Text and minutes for timer countdown) | 160 | (Text and minutes for timer countdown) |
153 | Just edit the file | 161 | Just edit the file |
154 | (yourhomedir)/.kopialarmtimerrc | 162 | (yourhomedir)/.kopialarmtimerrc |
155 | and start/stop a timer to get a new menu with the data of this file. | 163 | and start/stop a timer to get a new menu with the data of this file. |
156 | 164 | ||
157 | ********** VERSION 1.9.3 ************ | 165 | ********** VERSION 1.9.3 ************ |
158 | 1) | 166 | 1) |
159 | Now KO/Pi on Windows imports directly the calendar data of | 167 | Now KO/Pi on Windows imports directly the calendar data of |
160 | an installed Outlook. Should work with OL version >= 2000. | 168 | an installed Outlook. Should work with OL version >= 2000. |
161 | 169 | ||
162 | ********** VERSION 1.9.2 ************ | 170 | ********** VERSION 1.9.2 ************ |
163 | 1) | 171 | 1) |
164 | KDE-Pim/Pi has got a new member: | 172 | KDE-Pim/Pi has got a new member: |
165 | KmicroMail (KM/Pi) is a mail program, | 173 | KmicroMail (KM/Pi) is a mail program, |
166 | which can handle IMAP and POP mail access. | 174 | which can handle IMAP and POP mail access. |
167 | It is based on Opie-Mail v3. | 175 | It is based on Opie-Mail v3. |
168 | All dependencies to the Opie libraries ar removed, | 176 | All dependencies to the Opie libraries ar removed, |
169 | such that no additional Opie lib is needed. | 177 | such that no additional Opie lib is needed. |
170 | It is already integrated in KO/Pi and KA/Pi. | 178 | It is already integrated in KO/Pi and KA/Pi. |
171 | It it now available for the Zaurus,probably it | 179 | It it now available for the Zaurus,probably it |
172 | will be available for other platforms later. | 180 | will be available for other platforms later. |
173 | Hint: | 181 | Hint: |
174 | Create your own contact (name + email) | 182 | Create your own contact (name + email) |
175 | in KA/Pi, select this contact and choose menu: | 183 | in KA/Pi, select this contact and choose menu: |
176 | Settings - Set Who Am I. | 184 | Settings - Set Who Am I. |
177 | Now the settings of this contact are used as | 185 | Now the settings of this contact are used as |
178 | the sender data in KM/Pi. | 186 | the sender data in KM/Pi. |
179 | 2) | 187 | 2) |
180 | KDE-Pim/Pi is split up in five different | 188 | KDE-Pim/Pi is split up in five different |
181 | packages now precompiled for Sharp Zaurus: | 189 | packages now precompiled for Sharp Zaurus: |
182 | --kmicrokdelibs_1.9.2_arm.ipk | 190 | --kmicrokdelibs_1.9.2_arm.ipk |
183 | The libs are needed for any | 191 | The libs are needed for any |
184 | of the following programs: | 192 | of the following programs: |
185 | --kaddressbook_1.9.2_arm.ipk | 193 | --kaddressbook_1.9.2_arm.ipk |
186 | --kmicromail_1.9.2_arm.ipk | 194 | --kmicromail_1.9.2_arm.ipk |
187 | --korganizer_1.9.2_arm.ipk | 195 | --korganizer_1.9.2_arm.ipk |
188 | Independ from that, there is the alarm applet | 196 | Independ from that, there is the alarm applet |
189 | available for KO/Pi, which also offers | 197 | available for KO/Pi, which also offers |
190 | quick access for a new mail or | 198 | quick access for a new mail or |
191 | showing the addressbook.: | 199 | showing the addressbook.: |
192 | --korganizer-alarm_1.9.2_arm.ipk | 200 | --korganizer-alarm_1.9.2_arm.ipk |
193 | Independend means, that the alarm applet | 201 | Independend means, that the alarm applet |
194 | does not need any of the libs or programs above to run. | 202 | does not need any of the libs or programs above to run. |
195 | But it would be quite useless without these programs. | 203 | But it would be quite useless without these programs. |
196 | NOTE: | 204 | NOTE: |
197 | If you get a | 205 | If you get a |
198 | "This application depends on other programs" | 206 | "This application depends on other programs" |
199 | during installation of | 207 | during installation of |
200 | --kmicrokdelibs_1.9.2_arm.ipk | 208 | --kmicrokdelibs_1.9.2_arm.ipk |
201 | you probably do not have to care about that. | 209 | you probably do not have to care about that. |
202 | kmicrokdelibs_1.9.2 will come with some | 210 | kmicrokdelibs_1.9.2 will come with some |
203 | resource plugins, which needs additional libraries. | 211 | resource plugins, which needs additional libraries. |
204 | (E.g. libopie1, if you want to use the | 212 | (E.g. libopie1, if you want to use the |
205 | opie resource connector in KA/Pi). | 213 | opie resource connector in KA/Pi). |
206 | If you do not have this libraries installed, | 214 | If you do not have this libraries installed, |
207 | you simply cannot use the resource. | 215 | you simply cannot use the resource. |
208 | To make it clear: | 216 | To make it clear: |
209 | If the libraries are missing, the applications | 217 | If the libraries are missing, the applications |
210 | using kmicrokdelibs will start, | 218 | using kmicrokdelibs will start, |
211 | because the resources are plugins. | 219 | because the resources are plugins. |
212 | 3) | 220 | 3) |
213 | KO/Pi and friends are now installable on SD-Card! | 221 | KO/Pi and friends are now installable on SD-Card! |
214 | It is recommended to install all libs and apps | 222 | It is recommended to install all libs and apps |
215 | on the SD card or all in the internal storage. | 223 | on the SD card or all in the internal storage. |
216 | There may be problems, if this is mixed. | 224 | There may be problems, if this is mixed. |
217 | 4) | 225 | 4) |
218 | Fixed two bugs in the alarm notification on Windows. | 226 | Fixed two bugs in the alarm notification on Windows. |
219 | 5) | 227 | 5) |
220 | Great improvement! | 228 | Great improvement! |
221 | KO/Pi uses now the latest version of libical. | 229 | KO/Pi uses now the latest version of libical. |
222 | Libical is the library which actually reads | 230 | Libical is the library which actually reads |
223 | the calendar files and extract the data from it. | 231 | the calendar files and extract the data from it. |
224 | With the old version, there were problems | 232 | With the old version, there were problems |
225 | (crashes or program hangs) when licical did read | 233 | (crashes or program hangs) when licical did read |
226 | files, which were not stored from KO/Pi. | 234 | files, which were not stored from KO/Pi. |
227 | I do not know, if the new libical works perfect, | 235 | I do not know, if the new libical works perfect, |
228 | but actually it works much better than | 236 | but actually it works much better than |
229 | the old version. | 237 | the old version. |
230 | There are no problems with compatibility with | 238 | There are no problems with compatibility with |
231 | old calendar files of KO/Pi, of course! | 239 | old calendar files of KO/Pi, of course! |
232 | 6) | 240 | 6) |
233 | New in KA/Pi: | 241 | New in KA/Pi: |
234 | Opie addressbook resource connector available! | 242 | Opie addressbook resource connector available! |
235 | You will need libopie1 and the opie addressbook, | 243 | You will need libopie1 and the opie addressbook, |
236 | of course. | 244 | of course. |
237 | With the Opie addressbook resource connector, | 245 | With the Opie addressbook resource connector, |
238 | you can access the Opie addressbook readonly in KA/Pi. | 246 | you can access the Opie addressbook readonly in KA/Pi. |
239 | If you want to edit or import the data into KA/Pi, | 247 | If you want to edit or import the data into KA/Pi, |
240 | do this: | 248 | do this: |
241 | a) Create an Opie resource. | 249 | a) Create an Opie resource. |
242 | (Menu: Settings-Configure Resources). | 250 | (Menu: Settings-Configure Resources). |
243 | After configuration and restarting KA/Pi you should see | 251 | After configuration and restarting KA/Pi you should see |
244 | the Opie contacts in KA/Pi. | 252 | the Opie contacts in KA/Pi. |
245 | b) Select some or all Opie contacts. | 253 | b) Select some or all Opie contacts. |
246 | (NOTE: +++++ | 254 | (NOTE: +++++ |
247 | To know exactly, what contacts are Opie contacts, | 255 | To know exactly, what contacts are Opie contacts, |
248 | do this: Choose menu: | 256 | do this: Choose menu: |
249 | View-Modify View - TAB Fields. | 257 | View-Modify View - TAB Fields. |
250 | Select in the above list "Resource" and click | 258 | Select in the above list "Resource" and click |
251 | down arrow to add it to the "Selected fields". | 259 | down arrow to add it to the "Selected fields". |
252 | Click OK. | 260 | Click OK. |
253 | Now you have a new column "Resource" in your list, | 261 | Now you have a new column "Resource" in your list, |
254 | where you can see, what an Opie resource is. | 262 | where you can see, what an Opie resource is. |
255 | ++++ NOTE end.) | 263 | ++++ NOTE end.) |
256 | Ok, we do have now some Opie contacts seleted. | 264 | Ok, we do have now some Opie contacts seleted. |
257 | (Use SHIFT or CTRL key in order to multiple select). | 265 | (Use SHIFT or CTRL key in order to multiple select). |
258 | c) Choose menu: Edit-Copy. | 266 | c) Choose menu: Edit-Copy. |
259 | d) Choose menu: Edit-Paste. | 267 | d) Choose menu: Edit-Paste. |
260 | e) Select the resource, you want to add the contacts to. | 268 | e) Select the resource, you want to add the contacts to. |
261 | Congrats! Now you have read/write access to the copied | 269 | Congrats! Now you have read/write access to the copied |
262 | opie contacts as "real" KA/Pi contacts. | 270 | opie contacts as "real" KA/Pi contacts. |
263 | 271 | ||
264 | 272 | ||
265 | ********** VERSION 1.9.1 ************ | 273 | ********** VERSION 1.9.1 ************ |
266 | 1) | 274 | 1) |
267 | +++ IMPORTANT 1 +++ | 275 | +++ IMPORTANT 1 +++ |
268 | 276 | ||
269 | The storing place of the default calendar | 277 | The storing place of the default calendar |
270 | file has changed! | 278 | file has changed! |
271 | The default calendar file was | 279 | The default calendar file was |
272 | Applications/korganizer/mycalendar.ics | 280 | Applications/korganizer/mycalendar.ics |
273 | on Zaurus and | 281 | on Zaurus and |
274 | (yourHomeDir)/korganizer/mycalendar.ics | 282 | (yourHomeDir)/korganizer/mycalendar.ics |
275 | on Windows/Linux desktop. Now it is | 283 | on Windows/Linux desktop. Now it is |
276 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics | 284 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics |
277 | on Zaurus, Windows and Linux. | 285 | on Zaurus, Windows and Linux. |
278 | To load the old file, choose menu | 286 | To load the old file, choose menu |
279 | File-Load calendar backup. | 287 | File-Load calendar backup. |
280 | (It should be loaded automatically | 288 | (It should be loaded automatically |
281 | at startup with a warning message displayed). | 289 | at startup with a warning message displayed). |
282 | The place of the configuration file has changed too. | 290 | The place of the configuration file has changed too. |
283 | If you want to use your old KO/Pi config, | 291 | If you want to use your old KO/Pi config, |
284 | copy it to | 292 | copy it to |
285 | (yourHomeDir)/kdepim/config/korganizerrc | 293 | (yourHomeDir)/kdepim/config/korganizerrc |
286 | Please read VERSION 1.9.0 - topic 3) as well! | 294 | Please read VERSION 1.9.0 - topic 3) as well! |
287 | 295 | ||
288 | +++ IMPORTANT 2 +++ | 296 | +++ IMPORTANT 2 +++ |
289 | 297 | ||
290 | Because of the new paths, you will need | 298 | Because of the new paths, you will need |
291 | a new version of the KO/Pi alarm applet | 299 | a new version of the KO/Pi alarm applet |
292 | for Zaurus. | 300 | for Zaurus. |
293 | Use version >= 1.9.1 | 301 | Use version >= 1.9.1 |
294 | 302 | ||
295 | 2) | 303 | 2) |
296 | Now the QWhat'sThis Icon works for items | 304 | Now the QWhat'sThis Icon works for items |
297 | in the month view as well. | 305 | in the month view as well. |
298 | (See VERSION 1.7.8 Topic 1) ). | 306 | (See VERSION 1.7.8 Topic 1) ). |
299 | 3) | 307 | 3) |
300 | You can import birtsdays/anniversaries | 308 | You can import birtsdays/anniversaries |
301 | from KA/Pi into KO/Pi. | 309 | from KA/Pi into KO/Pi. |
302 | Choose menu File-Import birthdays. | 310 | Choose menu File-Import birthdays. |
303 | If you import twice, already imported items | 311 | If you import twice, already imported items |
304 | will not be imported again, if they | 312 | will not be imported again, if they |
305 | have not been changed in KO/Pi. | 313 | have not been changed in KO/Pi. |
306 | 4) | 314 | 4) |
307 | When syncing with sharp DTM, now a progress | 315 | When syncing with sharp DTM, now a progress |
308 | is shown, when the data is written back. | 316 | is shown, when the data is written back. |
309 | If there is much data in KO/Pi and no data | 317 | If there is much data in KO/Pi and no data |
310 | in DTM, that can take a long time. | 318 | in DTM, that can take a long time. |
311 | (But only for the first time ). | 319 | (But only for the first time ). |
312 | 5) | 320 | 5) |
313 | In the search dialog, you can search | 321 | In the search dialog, you can search |
314 | now for the name/email of an attendee | 322 | now for the name/email of an attendee |
315 | of an event/todo. | 323 | of an event/todo. |
316 | To get more space for displaying | 324 | To get more space for displaying |
317 | search results, the buttons | 325 | search results, the buttons |
318 | for "search" and "close" on the | 326 | for "search" and "close" on the |
319 | bottom are removed in the PDA version. | 327 | bottom are removed in the PDA version. |
320 | You have to click OK in the top right | 328 | You have to click OK in the top right |
321 | corner to do a search. | 329 | corner to do a search. |
322 | 6) | 330 | 6) |
323 | Now it is possible to disable the displaying | 331 | Now it is possible to disable the displaying |
324 | of todo items in the Allday part of the Agenda. | 332 | of todo items in the Allday part of the Agenda. |
325 | Choose Menu Action-Configure, | 333 | Choose Menu Action-Configure, |
326 | TAB Todo View, checkbox | 334 | TAB Todo View, checkbox |
327 | "Allday Agenda view shows todos" | 335 | "Allday Agenda view shows todos" |
328 | 7) | 336 | 7) |
329 | If FastLoad is enabled, now the settings and the | 337 | If FastLoad is enabled, now the settings and the |
330 | calendar data are saved, when KO/Pi is closed. | 338 | calendar data are saved, when KO/Pi is closed. |
331 | (If no Fastload is enabled, KO/Pi saves | 339 | (If no Fastload is enabled, KO/Pi saves |
332 | the data as well, of course) | 340 | the data as well, of course) |
333 | 8) | 341 | 8) |
334 | The Agenda View has a minimize-splitter now, | 342 | The Agenda View has a minimize-splitter now, |
335 | such that the height of the allday part can be | 343 | such that the height of the allday part can be |
336 | changed quickly. | 344 | changed quickly. |
337 | 345 | ||
338 | ********** VERSION 1.9.0 ************ | 346 | ********** VERSION 1.9.0 ************ |
339 | 1) | 347 | 1) |
340 | KO/Pi is now merged with the new microKDE from KA/Pi. | 348 | KO/Pi is now merged with the new microKDE from KA/Pi. |
341 | KO/Pi accesses now KA/Pi as the addressbook. | 349 | KO/Pi accesses now KA/Pi as the addressbook. |
342 | The other ddressbook-plugins are not working any longer. | 350 | The other ddressbook-plugins are not working any longer. |
343 | (It is planned, that later KA/Pi itself uses these plugins) | 351 | (It is planned, that later KA/Pi itself uses these plugins) |
344 | New versions of KO/Pi are only available | 352 | New versions of KO/Pi are only available |
345 | together with KA/Pi as the KDE-Pim/Pi package. | 353 | together with KA/Pi as the KDE-Pim/Pi package. |
346 | 2) | 354 | 2) |
347 | If you click on an attendee of a meeting in the | 355 | If you click on an attendee of a meeting in the |
348 | event viewer, a detailed summary of the | 356 | event viewer, a detailed summary of the |
349 | attendee is shown. | 357 | attendee is shown. |
350 | 3) | 358 | 3) |
351 | The place of the configuration file has changed. | 359 | The place of the configuration file has changed. |
352 | If you want to use your old KO/Pi config, copy | 360 | If you want to use your old KO/Pi config, copy |
353 | Applications/korganizer/config_korganizerrc | 361 | Applications/korganizer/config_korganizerrc |
354 | to | 362 | to |
355 | Applications/korganizer/config/korganizerrc | 363 | Applications/korganizer/config/korganizerrc |
356 | 364 | ||
357 | ********** VERSION 1.7.8 ************ | 365 | ********** VERSION 1.7.8 ************ |
358 | 1) | 366 | 1) |
359 | Now the QWhat'sThis ist working. | 367 | Now the QWhat'sThis ist working. |
360 | Enable the QWhat'sThis icon in the toolbar. | 368 | Enable the QWhat'sThis icon in the toolbar. |
361 | (You have to restart to reload the changed toolbar config). | 369 | (You have to restart to reload the changed toolbar config). |
362 | Now click on the QWhat'sThis Icon | 370 | Now click on the QWhat'sThis Icon |
363 | in the top right corner of KO/Pi. | 371 | in the top right corner of KO/Pi. |
364 | Then click on an item in the Agenda View: | 372 | Then click on an item in the Agenda View: |
365 | You will get a detailed display of the items content. | 373 | You will get a detailed display of the items content. |
366 | 2) | 374 | 2) |
367 | Some other very minor changes. | 375 | Some other very minor changes. |
368 | But I have forgotten the details ... | 376 | But I have forgotten the details ... |
369 | For that reason I start this log here: | 377 | For that reason I start this log here: |
370 | To document my changes, when I am doing it. | 378 | To document my changes, when I am doing it. |
371 | 379 | ||
372 | ********** VERSION 1.7.7 ************ | 380 | ********** VERSION 1.7.7 ************ |
373 | Stable Version of KO/Pi \ No newline at end of file | 381 | Stable Version of KO/Pi \ No newline at end of file |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e4a11f5..1f8ad5b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3732 +1,3748 @@ | |||
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 * ) ), | ||
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | ||
422 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
423 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
425 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
426 | 428 | ||
427 | 429 | ||
428 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
429 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
430 | 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 & ) ) ); |
431 | 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 & ) ) ); |
432 | 434 | ||
433 | 435 | ||
434 | 436 | ||
435 | 437 | ||
436 | 438 | ||
437 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
438 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
439 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
440 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
441 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
442 | 444 | ||
443 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
444 | 446 | ||
445 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
446 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
447 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
448 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
449 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
450 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
451 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
452 | 454 | ||
453 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
454 | 456 | ||
455 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
456 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
457 | 459 | ||
458 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
459 | 461 | ||
460 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
461 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
462 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
463 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
464 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
465 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
466 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
467 | 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 & ) ) ); |
468 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
469 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
470 | 472 | ||
471 | 473 | ||
472 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
473 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
474 | 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&)), |
475 | 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&))); |
476 | #endif | 478 | #endif |
477 | 479 | ||
478 | } | 480 | } |
479 | 481 | ||
480 | 482 | ||
481 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
482 | { | 484 | { |
483 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
484 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
485 | delete mDialogManager; | 487 | delete mDialogManager; |
486 | delete mViewManager; | 488 | delete mViewManager; |
487 | delete mStorage; | 489 | delete mStorage; |
488 | delete mDateFrame ; | 490 | delete mDateFrame ; |
489 | delete beamDialog; | 491 | delete beamDialog; |
490 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
491 | } | 493 | } |
492 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
493 | { | 495 | { |
494 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
495 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
496 | } | 498 | } |
497 | 499 | ||
498 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
499 | { | 501 | { |
500 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
501 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
502 | 504 | ||
503 | } | 505 | } |
504 | 506 | ||
505 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
506 | { | 508 | { |
507 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
508 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
509 | 511 | ||
510 | } | 512 | } |
511 | 513 | ||
512 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
513 | { | 515 | { |
514 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
515 | } | 517 | } |
516 | 518 | ||
517 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
518 | { | 520 | { |
519 | 521 | ||
520 | QString mess = msg; | 522 | QString mess = msg; |
521 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
522 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
523 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
524 | QString tempfilename; | 526 | QString tempfilename; |
525 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
526 | bool error = false; | 528 | bool error = false; |
527 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
528 | if ( len < 2 ) | 530 | if ( len < 2 ) |
529 | error = true; | 531 | error = true; |
530 | else { | 532 | else { |
531 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
532 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
533 | error = true; | 535 | error = true; |
534 | } | 536 | } |
535 | if ( ! error ) { | 537 | if ( ! error ) { |
536 | filename = tempfilename; | 538 | filename = tempfilename; |
537 | } | 539 | } |
538 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
539 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
540 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
541 | return; | 543 | return; |
542 | } | 544 | } |
543 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
544 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
545 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
546 | return; | 548 | return; |
547 | } | 549 | } |
548 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
549 | bool error = false; | 551 | bool error = false; |
550 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
551 | if ( len < 2 ) | 553 | if ( len < 2 ) |
552 | error = true; | 554 | error = true; |
553 | else { | 555 | else { |
554 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
555 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
556 | error = true; | 558 | error = true; |
557 | } | 559 | } |
558 | if ( error ) { | 560 | if ( error ) { |
559 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
560 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
561 | } else { | 563 | } else { |
562 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
563 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
564 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
565 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
566 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
567 | return; | 569 | return; |
568 | } | 570 | } |
569 | #else | 571 | #else |
570 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
571 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
572 | p->start(); | 574 | p->start(); |
573 | return; | 575 | return; |
574 | #endif | 576 | #endif |
575 | 577 | ||
576 | return; | 578 | return; |
577 | } | 579 | } |
578 | 580 | ||
579 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
580 | } | 582 | } |
581 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
582 | bool error = false; | 584 | bool error = false; |
583 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
584 | if ( len < 2 ) | 586 | if ( len < 2 ) |
585 | error = true; | 587 | error = true; |
586 | else { | 588 | else { |
587 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
588 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
589 | error = true; | 591 | error = true; |
590 | } | 592 | } |
591 | if ( ! error ) { | 593 | if ( ! error ) { |
592 | filename = tempfilename; | 594 | filename = tempfilename; |
593 | } | 595 | } |
594 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
595 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
596 | } | 598 | } |
597 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
598 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
599 | } | 601 | } |
600 | 602 | ||
601 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
602 | 604 | ||
603 | 605 | ||
604 | } | 606 | } |
605 | 607 | ||
606 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
607 | { | 609 | { |
608 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
609 | 611 | ||
610 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
611 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
612 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
613 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
614 | 616 | ||
615 | } | 617 | } |
616 | 618 | ||
617 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
618 | { | 620 | { |
619 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
620 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
621 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
622 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
623 | #endif | 625 | #endif |
624 | return; | 626 | return; |
625 | } | 627 | } |
626 | int maxSec; | 628 | int maxSec; |
627 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
628 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
629 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
630 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
631 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
632 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
633 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
634 | return; | 636 | return; |
635 | } else { | 637 | } else { |
636 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
637 | } | 639 | } |
638 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
639 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
640 | 642 | ||
641 | } | 643 | } |
642 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
643 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
644 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
645 | { | 647 | { |
646 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
647 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
648 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
649 | } | 651 | } |
650 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
651 | { | 653 | { |
652 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
653 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
654 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
655 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
656 | #endif | 658 | #endif |
657 | return; | 659 | return; |
658 | } | 660 | } |
659 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
660 | } | 662 | } |
661 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
662 | { | 664 | { |
663 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
664 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
665 | } | 667 | } |
666 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
667 | { | 669 | { |
668 | return mViewManager; | 670 | return mViewManager; |
669 | } | 671 | } |
670 | 672 | ||
671 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
672 | { | 674 | { |
673 | return mDialogManager; | 675 | return mDialogManager; |
674 | } | 676 | } |
675 | 677 | ||
676 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
677 | { | 679 | { |
678 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
679 | 681 | ||
680 | return dates.first(); | 682 | return dates.first(); |
681 | } | 683 | } |
682 | 684 | ||
683 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
684 | { | 686 | { |
685 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
686 | 688 | ||
687 | return dates.last(); | 689 | return dates.last(); |
688 | } | 690 | } |
689 | 691 | ||
690 | 692 | ||
691 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
692 | { | 694 | { |
693 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
694 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
695 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
696 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
697 | } | 699 | } |
698 | #endif | 700 | #endif |
699 | } | 701 | } |
700 | 702 | ||
701 | 703 | ||
702 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
703 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
704 | 706 | ||
705 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
706 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
707 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
708 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
709 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
710 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
711 | 713 | ||
712 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
713 | { | 715 | { |
714 | 716 | ||
715 | //void setZaurusId(int id); | 717 | //void setZaurusId(int id); |
716 | // int zaurusId() const; | 718 | // int zaurusId() const; |
717 | // void setZaurusUid(int id); | 719 | // void setZaurusUid(int id); |
718 | // int zaurusUid() const; | 720 | // int zaurusUid() const; |
719 | // void setZaurusStat(int id); | 721 | // void setZaurusStat(int id); |
720 | // int zaurusStat() const; | 722 | // int zaurusStat() const; |
721 | // 0 equal | 723 | // 0 equal |
722 | // 1 take local | 724 | // 1 take local |
723 | // 2 take remote | 725 | // 2 take remote |
724 | // 3 cancel | 726 | // 3 cancel |
725 | QDateTime lastSync = mLastCalendarSync; | 727 | QDateTime lastSync = mLastCalendarSync; |
726 | QDateTime localMod = local->lastModified(); | 728 | QDateTime localMod = local->lastModified(); |
727 | QDateTime remoteMod = remote->lastModified(); | 729 | QDateTime remoteMod = remote->lastModified(); |
728 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
729 | bool remCh, locCh; | 731 | bool remCh, locCh; |
730 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
731 | //if ( remCh ) | 733 | //if ( remCh ) |
732 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
733 | locCh = ( localMod > mLastCalendarSync ); | 735 | locCh = ( localMod > mLastCalendarSync ); |
734 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
735 | //qDebug("both not changed "); | 737 | //qDebug("both not changed "); |
736 | lastSync = localMod.addDays(1); | 738 | lastSync = localMod.addDays(1); |
737 | if ( mode <= SYNC_PREF_ASK ) | 739 | if ( mode <= SYNC_PREF_ASK ) |
738 | return 0; | 740 | return 0; |
739 | } else { | 741 | } else { |
740 | if ( locCh ) { | 742 | if ( locCh ) { |
741 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
742 | lastSync = localMod.addDays( -1 ); | 744 | lastSync = localMod.addDays( -1 ); |
743 | if ( !remCh ) | 745 | if ( !remCh ) |
744 | remoteMod = ( lastSync.addDays( -1 ) ); | 746 | remoteMod = ( lastSync.addDays( -1 ) ); |
745 | } else { | 747 | } else { |
746 | //qDebug(" not loc changed "); | 748 | //qDebug(" not loc changed "); |
747 | lastSync = localMod.addDays( 1 ); | 749 | lastSync = localMod.addDays( 1 ); |
748 | if ( remCh ) | 750 | if ( remCh ) |
749 | remoteMod =( lastSync.addDays( 1 ) ); | 751 | remoteMod =( lastSync.addDays( 1 ) ); |
750 | 752 | ||
751 | } | 753 | } |
752 | } | 754 | } |
753 | full = true; | 755 | full = true; |
754 | if ( mode < SYNC_PREF_ASK ) | 756 | if ( mode < SYNC_PREF_ASK ) |
755 | mode = SYNC_PREF_ASK; | 757 | mode = SYNC_PREF_ASK; |
756 | } else { | 758 | } else { |
757 | if ( localMod == remoteMod ) | 759 | if ( localMod == remoteMod ) |
758 | if ( local->revision() == remote->revision() ) | 760 | if ( local->revision() == remote->revision() ) |
759 | return 0; | 761 | return 0; |
760 | 762 | ||
761 | } | 763 | } |
762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
763 | 765 | ||
764 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
765 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
766 | //full = true; //debug only | 768 | //full = true; //debug only |
767 | if ( full ) { | 769 | if ( full ) { |
768 | bool equ = false; | 770 | bool equ = false; |
769 | if ( local->type() == "Event" ) { | 771 | if ( local->type() == "Event" ) { |
770 | equ = (*((Event*) local) == *((Event*) remote)); | 772 | equ = (*((Event*) local) == *((Event*) remote)); |
771 | } | 773 | } |
772 | else if ( local->type() =="Todo" ) | 774 | else if ( local->type() =="Todo" ) |
773 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 775 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
774 | else if ( local->type() =="Journal" ) | 776 | else if ( local->type() =="Journal" ) |
775 | equ = (*((Journal*) local) == *((Journal*) remote)); | 777 | equ = (*((Journal*) local) == *((Journal*) remote)); |
776 | if ( equ ) { | 778 | if ( equ ) { |
777 | //qDebug("equal "); | 779 | //qDebug("equal "); |
778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
780 | } | 782 | } |
781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
782 | return 0; | 784 | return 0; |
783 | 785 | ||
784 | }//else //debug only | 786 | }//else //debug only |
785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 787 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
786 | } | 788 | } |
787 | int result; | 789 | int result; |
788 | bool localIsNew; | 790 | bool localIsNew; |
789 | //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() ); | 791 | //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() ); |
790 | 792 | ||
791 | if ( full && mode < SYNC_PREF_NEWEST ) | 793 | if ( full && mode < SYNC_PREF_NEWEST ) |
792 | mode = SYNC_PREF_ASK; | 794 | mode = SYNC_PREF_ASK; |
793 | 795 | ||
794 | switch( mode ) { | 796 | switch( mode ) { |
795 | case SYNC_PREF_LOCAL: | 797 | case SYNC_PREF_LOCAL: |
796 | if ( lastSync > remoteMod ) | 798 | if ( lastSync > remoteMod ) |
797 | return 1; | 799 | return 1; |
798 | if ( lastSync > localMod ) | 800 | if ( lastSync > localMod ) |
799 | return 2; | 801 | return 2; |
800 | return 1; | 802 | return 1; |
801 | break; | 803 | break; |
802 | case SYNC_PREF_REMOTE: | 804 | case SYNC_PREF_REMOTE: |
803 | if ( lastSync > remoteMod ) | 805 | if ( lastSync > remoteMod ) |
804 | return 1; | 806 | return 1; |
805 | if ( lastSync > localMod ) | 807 | if ( lastSync > localMod ) |
806 | return 2; | 808 | return 2; |
807 | return 2; | 809 | return 2; |
808 | break; | 810 | break; |
809 | case SYNC_PREF_NEWEST: | 811 | case SYNC_PREF_NEWEST: |
810 | if ( localMod > remoteMod ) | 812 | if ( localMod > remoteMod ) |
811 | return 1; | 813 | return 1; |
812 | else | 814 | else |
813 | return 2; | 815 | return 2; |
814 | break; | 816 | break; |
815 | case SYNC_PREF_ASK: | 817 | case SYNC_PREF_ASK: |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 818 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
817 | if ( lastSync > remoteMod ) | 819 | if ( lastSync > remoteMod ) |
818 | return 1; | 820 | return 1; |
819 | if ( lastSync > localMod ) | 821 | if ( lastSync > localMod ) |
820 | return 2; | 822 | return 2; |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 823 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
822 | localIsNew = localMod >= remoteMod; | 824 | localIsNew = localMod >= remoteMod; |
823 | if ( localIsNew ) | 825 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 1 ); | 826 | getEventViewerDialog()->setColorMode( 1 ); |
825 | else | 827 | else |
826 | getEventViewerDialog()->setColorMode( 2 ); | 828 | getEventViewerDialog()->setColorMode( 2 ); |
827 | getEventViewerDialog()->setIncidence(local); | 829 | getEventViewerDialog()->setIncidence(local); |
828 | if ( localIsNew ) | 830 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
830 | else | 832 | else |
831 | getEventViewerDialog()->setColorMode( 1 ); | 833 | getEventViewerDialog()->setColorMode( 1 ); |
832 | getEventViewerDialog()->addIncidence(remote); | 834 | getEventViewerDialog()->addIncidence(remote); |
833 | getEventViewerDialog()->setColorMode( 0 ); | 835 | getEventViewerDialog()->setColorMode( 0 ); |
834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 836 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 837 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
836 | getEventViewerDialog()->showMe(); | 838 | getEventViewerDialog()->showMe(); |
837 | result = getEventViewerDialog()->executeS( localIsNew ); | 839 | result = getEventViewerDialog()->executeS( localIsNew ); |
838 | return result; | 840 | return result; |
839 | 841 | ||
840 | break; | 842 | break; |
841 | case SYNC_PREF_FORCE_LOCAL: | 843 | case SYNC_PREF_FORCE_LOCAL: |
842 | return 1; | 844 | return 1; |
843 | break; | 845 | break; |
844 | case SYNC_PREF_FORCE_REMOTE: | 846 | case SYNC_PREF_FORCE_REMOTE: |
845 | return 2; | 847 | return 2; |
846 | break; | 848 | break; |
847 | 849 | ||
848 | default: | 850 | default: |
849 | // SYNC_PREF_TAKE_BOTH not implemented | 851 | // SYNC_PREF_TAKE_BOTH not implemented |
850 | break; | 852 | break; |
851 | } | 853 | } |
852 | return 0; | 854 | return 0; |
853 | } | 855 | } |
854 | Event* CalendarView::getLastSyncEvent() | 856 | Event* CalendarView::getLastSyncEvent() |
855 | { | 857 | { |
856 | Event* lse; | 858 | Event* lse; |
857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 859 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 860 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
859 | if (!lse) { | 861 | if (!lse) { |
860 | lse = new Event(); | 862 | lse = new Event(); |
861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
862 | QString sum = ""; | 864 | QString sum = ""; |
863 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 865 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
864 | sum = "E: "; | 866 | sum = "E: "; |
865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 867 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
866 | lse->setDtStart( mLastCalendarSync ); | 868 | lse->setDtStart( mLastCalendarSync ); |
867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 869 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
868 | lse->setCategories( i18n("SyncEvent") ); | 870 | lse->setCategories( i18n("SyncEvent") ); |
869 | lse->setReadOnly( true ); | 871 | lse->setReadOnly( true ); |
870 | mCalendar->addEvent( lse ); | 872 | mCalendar->addEvent( lse ); |
871 | } | 873 | } |
872 | 874 | ||
873 | return lse; | 875 | return lse; |
874 | 876 | ||
875 | } | 877 | } |
876 | 878 | ||
877 | // we check, if the to delete event has a id for a profile | 879 | // we check, if the to delete event has a id for a profile |
878 | // if yes, we set this id in the profile to delete | 880 | // if yes, we set this id in the profile to delete |
879 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 881 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
880 | { | 882 | { |
881 | if ( lastSync.count() == 0 ) { | 883 | if ( lastSync.count() == 0 ) { |
882 | //qDebug(" lastSync.count() == 0"); | 884 | //qDebug(" lastSync.count() == 0"); |
883 | return; | 885 | return; |
884 | } | 886 | } |
885 | if ( toDelete->type() == "Journal" ) | 887 | if ( toDelete->type() == "Journal" ) |
886 | return; | 888 | return; |
887 | 889 | ||
888 | Event* eve = lastSync.first(); | 890 | Event* eve = lastSync.first(); |
889 | 891 | ||
890 | while ( eve ) { | 892 | while ( eve ) { |
891 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
892 | if ( !id.isEmpty() ) { | 894 | if ( !id.isEmpty() ) { |
893 | QString des = eve->description(); | 895 | QString des = eve->description(); |
894 | QString pref = "e"; | 896 | QString pref = "e"; |
895 | if ( toDelete->type() == "Todo" ) | 897 | if ( toDelete->type() == "Todo" ) |
896 | pref = "t"; | 898 | pref = "t"; |
897 | des += pref+ id + ","; | 899 | des += pref+ id + ","; |
898 | eve->setReadOnly( false ); | 900 | eve->setReadOnly( false ); |
899 | eve->setDescription( des ); | 901 | eve->setDescription( des ); |
900 | //qDebug("setdes %s ", des.latin1()); | 902 | //qDebug("setdes %s ", des.latin1()); |
901 | eve->setReadOnly( true ); | 903 | eve->setReadOnly( true ); |
902 | } | 904 | } |
903 | eve = lastSync.next(); | 905 | eve = lastSync.next(); |
904 | } | 906 | } |
905 | 907 | ||
906 | } | 908 | } |
907 | void CalendarView::checkExternalId( Incidence * inc ) | 909 | void CalendarView::checkExternalId( Incidence * inc ) |
908 | { | 910 | { |
909 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
910 | checkExternSyncEvent( lastSync, inc ); | 912 | checkExternSyncEvent( lastSync, inc ); |
911 | 913 | ||
912 | } | 914 | } |
913 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
914 | { | 916 | { |
915 | bool syncOK = true; | 917 | bool syncOK = true; |
916 | int addedEvent = 0; | 918 | int addedEvent = 0; |
917 | int addedEventR = 0; | 919 | int addedEventR = 0; |
918 | int deletedEventR = 0; | 920 | int deletedEventR = 0; |
919 | int deletedEventL = 0; | 921 | int deletedEventL = 0; |
920 | int changedLocal = 0; | 922 | int changedLocal = 0; |
921 | int changedRemote = 0; | 923 | int changedRemote = 0; |
922 | //QPtrList<Event> el = local->rawEvents(); | 924 | //QPtrList<Event> el = local->rawEvents(); |
923 | Event* eventR; | 925 | Event* eventR; |
924 | QString uid; | 926 | QString uid; |
925 | int take; | 927 | int take; |
926 | Event* eventL; | 928 | Event* eventL; |
927 | Event* eventRSync; | 929 | Event* eventRSync; |
928 | Event* eventLSync; | 930 | Event* eventLSync; |
929 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
930 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
931 | bool fullDateRange = false; | 933 | bool fullDateRange = false; |
932 | local->resetTempSyncStat(); | 934 | local->resetTempSyncStat(); |
933 | mLastCalendarSync = QDateTime::currentDateTime(); | 935 | mLastCalendarSync = QDateTime::currentDateTime(); |
934 | QDateTime modifiedCalendar = mLastCalendarSync;; | 936 | QDateTime modifiedCalendar = mLastCalendarSync;; |
935 | eventLSync = getLastSyncEvent(); | 937 | eventLSync = getLastSyncEvent(); |
936 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 938 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
937 | if ( eventR ) { | 939 | if ( eventR ) { |
938 | eventRSync = (Event*) eventR->clone(); | 940 | eventRSync = (Event*) eventR->clone(); |
939 | remote->deleteEvent(eventR ); | 941 | remote->deleteEvent(eventR ); |
940 | 942 | ||
941 | } else { | 943 | } else { |
942 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 944 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
943 | eventRSync = (Event*)eventLSync->clone(); | 945 | eventRSync = (Event*)eventLSync->clone(); |
944 | } else { | 946 | } else { |
945 | fullDateRange = true; | 947 | fullDateRange = true; |
946 | eventRSync = new Event(); | 948 | eventRSync = new Event(); |
947 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 949 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
948 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 950 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
949 | eventRSync->setDtStart( mLastCalendarSync ); | 951 | eventRSync->setDtStart( mLastCalendarSync ); |
950 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 952 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
951 | eventRSync->setCategories( i18n("SyncEvent") ); | 953 | eventRSync->setCategories( i18n("SyncEvent") ); |
952 | } | 954 | } |
953 | } | 955 | } |
954 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 956 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
955 | fullDateRange = true; | 957 | fullDateRange = true; |
956 | 958 | ||
957 | if ( ! fullDateRange ) { | 959 | if ( ! fullDateRange ) { |
958 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 960 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
959 | 961 | ||
960 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 962 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
961 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 963 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
962 | fullDateRange = true; | 964 | fullDateRange = true; |
963 | } | 965 | } |
964 | } | 966 | } |
965 | if ( fullDateRange ) | 967 | if ( fullDateRange ) |
966 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 968 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
967 | else | 969 | else |
968 | mLastCalendarSync = eventLSync->dtStart(); | 970 | mLastCalendarSync = eventLSync->dtStart(); |
969 | // for resyncing if own file has changed | 971 | // for resyncing if own file has changed |
970 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 972 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
971 | mLastCalendarSync = loadedFileVersion; | 973 | mLastCalendarSync = loadedFileVersion; |
972 | qDebug("setting mLastCalendarSync "); | 974 | qDebug("setting mLastCalendarSync "); |
973 | } | 975 | } |
974 | //qDebug("*************************** "); | 976 | //qDebug("*************************** "); |
975 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 977 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
976 | QPtrList<Incidence> er = remote->rawIncidences(); | 978 | QPtrList<Incidence> er = remote->rawIncidences(); |
977 | Incidence* inR = er.first(); | 979 | Incidence* inR = er.first(); |
978 | Incidence* inL; | 980 | Incidence* inL; |
979 | QProgressBar bar( er.count(),0 ); | 981 | QProgressBar bar( er.count(),0 ); |
980 | bar.setCaption (i18n("Syncing - close to abort!") ); | 982 | bar.setCaption (i18n("Syncing - close to abort!") ); |
981 | 983 | ||
982 | int w = 300; | 984 | int w = 300; |
983 | if ( QApplication::desktop()->width() < 320 ) | 985 | if ( QApplication::desktop()->width() < 320 ) |
984 | w = 220; | 986 | w = 220; |
985 | int h = bar.sizeHint().height() ; | 987 | int h = bar.sizeHint().height() ; |
986 | int dw = QApplication::desktop()->width(); | 988 | int dw = QApplication::desktop()->width(); |
987 | int dh = QApplication::desktop()->height(); | 989 | int dh = QApplication::desktop()->height(); |
988 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 990 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
989 | bar.show(); | 991 | bar.show(); |
990 | int modulo = (er.count()/10)+1; | 992 | int modulo = (er.count()/10)+1; |
991 | int incCounter = 0; | 993 | int incCounter = 0; |
992 | while ( inR ) { | 994 | while ( inR ) { |
993 | if ( ! bar.isVisible() ) | 995 | if ( ! bar.isVisible() ) |
994 | return false; | 996 | return false; |
995 | if ( incCounter % modulo == 0 ) | 997 | if ( incCounter % modulo == 0 ) |
996 | bar.setProgress( incCounter ); | 998 | bar.setProgress( incCounter ); |
997 | ++incCounter; | 999 | ++incCounter; |
998 | uid = inR->uid(); | 1000 | uid = inR->uid(); |
999 | bool skipIncidence = false; | 1001 | bool skipIncidence = false; |
1000 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1002 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1001 | skipIncidence = true; | 1003 | skipIncidence = true; |
1002 | QString idS; | 1004 | QString idS; |
1003 | qApp->processEvents(); | 1005 | qApp->processEvents(); |
1004 | if ( !skipIncidence ) { | 1006 | if ( !skipIncidence ) { |
1005 | inL = local->incidence( uid ); | 1007 | inL = local->incidence( uid ); |
1006 | if ( inL ) { // maybe conflict - same uid in both calendars | 1008 | if ( inL ) { // maybe conflict - same uid in both calendars |
1007 | int maxrev = inL->revision(); | 1009 | int maxrev = inL->revision(); |
1008 | if ( maxrev < inR->revision() ) | 1010 | if ( maxrev < inR->revision() ) |
1009 | maxrev = inR->revision(); | 1011 | maxrev = inR->revision(); |
1010 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1012 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1011 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1013 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1012 | if ( take == 3 ) | 1014 | if ( take == 3 ) |
1013 | return false; | 1015 | return false; |
1014 | if ( take == 1 ) {// take local | 1016 | if ( take == 1 ) {// take local |
1015 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1017 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1016 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1018 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1017 | else | 1019 | else |
1018 | idS = inR->IDStr(); | 1020 | idS = inR->IDStr(); |
1019 | remote->deleteIncidence( inR ); | 1021 | remote->deleteIncidence( inR ); |
1020 | if ( inL->revision() < maxrev ) | 1022 | if ( inL->revision() < maxrev ) |
1021 | inL->setRevision( maxrev ); | 1023 | inL->setRevision( maxrev ); |
1022 | inR = inL->clone(); | 1024 | inR = inL->clone(); |
1023 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1025 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1024 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1026 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1025 | inR->setIDStr( idS ); | 1027 | inR->setIDStr( idS ); |
1026 | remote->addIncidence( inR ); | 1028 | remote->addIncidence( inR ); |
1027 | ++changedRemote; | 1029 | ++changedRemote; |
1028 | } else { | 1030 | } else { |
1029 | if ( inR->revision() < maxrev ) | 1031 | if ( inR->revision() < maxrev ) |
1030 | inR->setRevision( maxrev ); | 1032 | inR->setRevision( maxrev ); |
1031 | idS = inL->IDStr(); | 1033 | idS = inL->IDStr(); |
1032 | local->deleteIncidence( inL ); | 1034 | local->deleteIncidence( inL ); |
1033 | inL = inR->clone(); | 1035 | inL = inR->clone(); |
1034 | inL->setIDStr( idS ); | 1036 | inL->setIDStr( idS ); |
1035 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1037 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1036 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1038 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1037 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1039 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1038 | } | 1040 | } |
1039 | local->addIncidence( inL ); | 1041 | local->addIncidence( inL ); |
1040 | ++changedLocal; | 1042 | ++changedLocal; |
1041 | } | 1043 | } |
1042 | } | 1044 | } |
1043 | } else { // no conflict | 1045 | } else { // no conflict |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1046 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | QString des = eventLSync->description(); | 1047 | QString des = eventLSync->description(); |
1046 | QString pref = "e"; | 1048 | QString pref = "e"; |
1047 | if ( inR->type() == "Todo" ) | 1049 | if ( inR->type() == "Todo" ) |
1048 | pref = "t"; | 1050 | pref = "t"; |
1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1051 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1052 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1051 | //remote->deleteIncidence( inR ); | 1053 | //remote->deleteIncidence( inR ); |
1052 | ++deletedEventR; | 1054 | ++deletedEventR; |
1053 | } else { | 1055 | } else { |
1054 | inR->setLastModified( modifiedCalendar ); | 1056 | inR->setLastModified( modifiedCalendar ); |
1055 | inL = inR->clone(); | 1057 | inL = inR->clone(); |
1056 | local->addIncidence( inL ); | 1058 | local->addIncidence( inL ); |
1057 | ++addedEvent; | 1059 | ++addedEvent; |
1058 | } | 1060 | } |
1059 | } else { | 1061 | } else { |
1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1062 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1061 | inR->setLastModified( modifiedCalendar ); | 1063 | inR->setLastModified( modifiedCalendar ); |
1062 | local->addIncidence( inR->clone() ); | 1064 | local->addIncidence( inR->clone() ); |
1063 | ++addedEvent; | 1065 | ++addedEvent; |
1064 | } else { | 1066 | } else { |
1065 | checkExternSyncEvent(eventRSyncSharp, inR); | 1067 | checkExternSyncEvent(eventRSyncSharp, inR); |
1066 | remote->deleteIncidence( inR ); | 1068 | remote->deleteIncidence( inR ); |
1067 | ++deletedEventR; | 1069 | ++deletedEventR; |
1068 | } | 1070 | } |
1069 | } | 1071 | } |
1070 | } | 1072 | } |
1071 | } | 1073 | } |
1072 | inR = er.next(); | 1074 | inR = er.next(); |
1073 | } | 1075 | } |
1074 | QPtrList<Incidence> el = local->rawIncidences(); | 1076 | QPtrList<Incidence> el = local->rawIncidences(); |
1075 | inL = el.first(); | 1077 | inL = el.first(); |
1076 | modulo = (el.count()/10)+1; | 1078 | modulo = (el.count()/10)+1; |
1077 | bar.setCaption (i18n("Add / remove events") ); | 1079 | bar.setCaption (i18n("Add / remove events") ); |
1078 | bar.setTotalSteps ( el.count() ) ; | 1080 | bar.setTotalSteps ( el.count() ) ; |
1079 | bar.show(); | 1081 | bar.show(); |
1080 | incCounter = 0; | 1082 | incCounter = 0; |
1081 | 1083 | ||
1082 | while ( inL ) { | 1084 | while ( inL ) { |
1083 | 1085 | ||
1084 | qApp->processEvents(); | 1086 | qApp->processEvents(); |
1085 | if ( ! bar.isVisible() ) | 1087 | if ( ! bar.isVisible() ) |
1086 | return false; | 1088 | return false; |
1087 | if ( incCounter % modulo == 0 ) | 1089 | if ( incCounter % modulo == 0 ) |
1088 | bar.setProgress( incCounter ); | 1090 | bar.setProgress( incCounter ); |
1089 | ++incCounter; | 1091 | ++incCounter; |
1090 | uid = inL->uid(); | 1092 | uid = inL->uid(); |
1091 | bool skipIncidence = false; | 1093 | bool skipIncidence = false; |
1092 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1094 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1093 | skipIncidence = true; | 1095 | skipIncidence = true; |
1094 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1095 | skipIncidence = true; | 1097 | skipIncidence = true; |
1096 | if ( !skipIncidence ) { | 1098 | if ( !skipIncidence ) { |
1097 | inR = remote->incidence( uid ); | 1099 | inR = remote->incidence( uid ); |
1098 | if ( ! inR ) { | 1100 | if ( ! inR ) { |
1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1100 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1101 | checkExternSyncEvent(eventLSyncSharp, inL); | 1103 | checkExternSyncEvent(eventLSyncSharp, inL); |
1102 | local->deleteIncidence( inL ); | 1104 | local->deleteIncidence( inL ); |
1103 | ++deletedEventL; | 1105 | ++deletedEventL; |
1104 | } else { | 1106 | } else { |
1105 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1107 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1106 | inL->removeID(mCurrentSyncDevice ); | 1108 | inL->removeID(mCurrentSyncDevice ); |
1107 | ++addedEventR; | 1109 | ++addedEventR; |
1108 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1110 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1109 | inL->setLastModified( modifiedCalendar ); | 1111 | inL->setLastModified( modifiedCalendar ); |
1110 | inR = inL->clone(); | 1112 | inR = inL->clone(); |
1111 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1113 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1112 | remote->addIncidence( inR ); | 1114 | remote->addIncidence( inR ); |
1113 | } | 1115 | } |
1114 | } | 1116 | } |
1115 | } else { | 1117 | } else { |
1116 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1118 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1117 | checkExternSyncEvent(eventLSyncSharp, inL); | 1119 | checkExternSyncEvent(eventLSyncSharp, inL); |
1118 | local->deleteIncidence( inL ); | 1120 | local->deleteIncidence( inL ); |
1119 | ++deletedEventL; | 1121 | ++deletedEventL; |
1120 | } else { | 1122 | } else { |
1121 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1123 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1122 | ++addedEventR; | 1124 | ++addedEventR; |
1123 | inL->setLastModified( modifiedCalendar ); | 1125 | inL->setLastModified( modifiedCalendar ); |
1124 | remote->addIncidence( inL->clone() ); | 1126 | remote->addIncidence( inL->clone() ); |
1125 | } | 1127 | } |
1126 | } | 1128 | } |
1127 | } | 1129 | } |
1128 | } | 1130 | } |
1129 | } | 1131 | } |
1130 | inL = el.next(); | 1132 | inL = el.next(); |
1131 | } | 1133 | } |
1132 | int delFut = 0; | 1134 | int delFut = 0; |
1133 | int remRem = 0; | 1135 | int remRem = 0; |
1134 | if ( mSyncManager->mWriteBackInFuture ) { | 1136 | if ( mSyncManager->mWriteBackInFuture ) { |
1135 | er = remote->rawIncidences(); | 1137 | er = remote->rawIncidences(); |
1136 | remRem = er.count(); | 1138 | remRem = er.count(); |
1137 | inR = er.first(); | 1139 | inR = er.first(); |
1138 | QDateTime dt; | 1140 | QDateTime dt; |
1139 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1141 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1140 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1142 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1141 | while ( inR ) { | 1143 | while ( inR ) { |
1142 | if ( inR->type() == "Todo" ) { | 1144 | if ( inR->type() == "Todo" ) { |
1143 | Todo * t = (Todo*)inR; | 1145 | Todo * t = (Todo*)inR; |
1144 | if ( t->hasDueDate() ) | 1146 | if ( t->hasDueDate() ) |
1145 | dt = t->dtDue(); | 1147 | dt = t->dtDue(); |
1146 | else | 1148 | else |
1147 | dt = cur.addSecs( 62 ); | 1149 | dt = cur.addSecs( 62 ); |
1148 | } | 1150 | } |
1149 | else if (inR->type() == "Event" ) { | 1151 | else if (inR->type() == "Event" ) { |
1150 | bool ok; | 1152 | bool ok; |
1151 | dt = inR->getNextOccurence( cur, &ok ); | 1153 | dt = inR->getNextOccurence( cur, &ok ); |
1152 | if ( !ok ) | 1154 | if ( !ok ) |
1153 | dt = cur.addSecs( -62 ); | 1155 | dt = cur.addSecs( -62 ); |
1154 | } | 1156 | } |
1155 | else | 1157 | else |
1156 | dt = inR->dtStart(); | 1158 | dt = inR->dtStart(); |
1157 | if ( dt < cur || dt > end ) { | 1159 | if ( dt < cur || dt > end ) { |
1158 | remote->deleteIncidence( inR ); | 1160 | remote->deleteIncidence( inR ); |
1159 | ++delFut; | 1161 | ++delFut; |
1160 | } | 1162 | } |
1161 | inR = er.next(); | 1163 | inR = er.next(); |
1162 | } | 1164 | } |
1163 | } | 1165 | } |
1164 | bar.hide(); | 1166 | bar.hide(); |
1165 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1167 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1166 | eventLSync->setReadOnly( false ); | 1168 | eventLSync->setReadOnly( false ); |
1167 | eventLSync->setDtStart( mLastCalendarSync ); | 1169 | eventLSync->setDtStart( mLastCalendarSync ); |
1168 | eventRSync->setDtStart( mLastCalendarSync ); | 1170 | eventRSync->setDtStart( mLastCalendarSync ); |
1169 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1171 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1170 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1172 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1171 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1173 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1172 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1174 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1173 | eventLSync->setReadOnly( true ); | 1175 | eventLSync->setReadOnly( true ); |
1174 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1176 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1175 | remote->addEvent( eventRSync ); | 1177 | remote->addEvent( eventRSync ); |
1176 | QString mes; | 1178 | QString mes; |
1177 | 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 ); | 1179 | 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 ); |
1178 | QString delmess; | 1180 | QString delmess; |
1179 | if ( delFut ) { | 1181 | if ( delFut ) { |
1180 | 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); | 1182 | 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); |
1181 | mes += delmess; | 1183 | mes += delmess; |
1182 | } | 1184 | } |
1183 | if ( mSyncManager->mShowSyncSummary ) { | 1185 | if ( mSyncManager->mShowSyncSummary ) { |
1184 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1186 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1185 | } | 1187 | } |
1186 | qDebug( mes ); | 1188 | qDebug( mes ); |
1187 | mCalendar->checkAlarmForIncidence( 0, true ); | 1189 | mCalendar->checkAlarmForIncidence( 0, true ); |
1188 | return syncOK; | 1190 | return syncOK; |
1189 | } | 1191 | } |
1190 | 1192 | ||
1191 | void CalendarView::setSyncDevice( QString s ) | 1193 | void CalendarView::setSyncDevice( QString s ) |
1192 | { | 1194 | { |
1193 | mCurrentSyncDevice= s; | 1195 | mCurrentSyncDevice= s; |
1194 | } | 1196 | } |
1195 | void CalendarView::setSyncName( QString s ) | 1197 | void CalendarView::setSyncName( QString s ) |
1196 | { | 1198 | { |
1197 | mCurrentSyncName= s; | 1199 | mCurrentSyncName= s; |
1198 | } | 1200 | } |
1199 | bool CalendarView::syncCalendar(QString filename, int mode) | 1201 | bool CalendarView::syncCalendar(QString filename, int mode) |
1200 | { | 1202 | { |
1201 | //qDebug("syncCalendar %s ", filename.latin1()); | 1203 | //qDebug("syncCalendar %s ", filename.latin1()); |
1202 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1204 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1203 | CalendarLocal* calendar = new CalendarLocal(); | 1205 | CalendarLocal* calendar = new CalendarLocal(); |
1204 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1206 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1205 | FileStorage* storage = new FileStorage( calendar ); | 1207 | FileStorage* storage = new FileStorage( calendar ); |
1206 | bool syncOK = false; | 1208 | bool syncOK = false; |
1207 | storage->setFileName( filename ); | 1209 | storage->setFileName( filename ); |
1208 | // qDebug("loading ... "); | 1210 | // qDebug("loading ... "); |
1209 | if ( storage->load() ) { | 1211 | if ( storage->load() ) { |
1210 | getEventViewerDialog()->setSyncMode( true ); | 1212 | getEventViewerDialog()->setSyncMode( true ); |
1211 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1213 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1212 | getEventViewerDialog()->setSyncMode( false ); | 1214 | getEventViewerDialog()->setSyncMode( false ); |
1213 | if ( syncOK ) { | 1215 | if ( syncOK ) { |
1214 | if ( mSyncManager->mWriteBackFile ) | 1216 | if ( mSyncManager->mWriteBackFile ) |
1215 | { | 1217 | { |
1216 | storage->setSaveFormat( new ICalFormat() ); | 1218 | storage->setSaveFormat( new ICalFormat() ); |
1217 | storage->save(); | 1219 | storage->save(); |
1218 | } | 1220 | } |
1219 | } | 1221 | } |
1220 | setModified( true ); | 1222 | setModified( true ); |
1221 | } | 1223 | } |
1222 | delete storage; | 1224 | delete storage; |
1223 | delete calendar; | 1225 | delete calendar; |
1224 | if ( syncOK ) | 1226 | if ( syncOK ) |
1225 | updateView(); | 1227 | updateView(); |
1226 | return syncOK; | 1228 | return syncOK; |
1227 | } | 1229 | } |
1228 | 1230 | ||
1229 | void CalendarView::syncExternal( int mode ) | 1231 | void CalendarView::syncExternal( int mode ) |
1230 | { | 1232 | { |
1231 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1233 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1232 | 1234 | ||
1233 | qApp->processEvents(); | 1235 | qApp->processEvents(); |
1234 | CalendarLocal* calendar = new CalendarLocal(); | 1236 | CalendarLocal* calendar = new CalendarLocal(); |
1235 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1237 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1236 | bool syncOK = false; | 1238 | bool syncOK = false; |
1237 | bool loadSuccess = false; | 1239 | bool loadSuccess = false; |
1238 | PhoneFormat* phoneFormat = 0; | 1240 | PhoneFormat* phoneFormat = 0; |
1239 | #ifndef DESKTOP_VERSION | 1241 | #ifndef DESKTOP_VERSION |
1240 | SharpFormat* sharpFormat = 0; | 1242 | SharpFormat* sharpFormat = 0; |
1241 | if ( mode == 0 ) { // sharp | 1243 | if ( mode == 0 ) { // sharp |
1242 | sharpFormat = new SharpFormat () ; | 1244 | sharpFormat = new SharpFormat () ; |
1243 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1245 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1244 | 1246 | ||
1245 | } else | 1247 | } else |
1246 | #endif | 1248 | #endif |
1247 | if ( mode == 1 ) { // phone | 1249 | if ( mode == 1 ) { // phone |
1248 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1250 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1249 | mSyncManager->mPhoneDevice, | 1251 | mSyncManager->mPhoneDevice, |
1250 | mSyncManager->mPhoneConnection, | 1252 | mSyncManager->mPhoneConnection, |
1251 | mSyncManager->mPhoneModel); | 1253 | mSyncManager->mPhoneModel); |
1252 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1254 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1253 | 1255 | ||
1254 | } else | 1256 | } else |
1255 | return; | 1257 | return; |
1256 | if ( loadSuccess ) { | 1258 | if ( loadSuccess ) { |
1257 | getEventViewerDialog()->setSyncMode( true ); | 1259 | getEventViewerDialog()->setSyncMode( true ); |
1258 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1260 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1259 | getEventViewerDialog()->setSyncMode( false ); | 1261 | getEventViewerDialog()->setSyncMode( false ); |
1260 | qApp->processEvents(); | 1262 | qApp->processEvents(); |
1261 | if ( syncOK ) { | 1263 | if ( syncOK ) { |
1262 | if ( mSyncManager->mWriteBackFile ) | 1264 | if ( mSyncManager->mWriteBackFile ) |
1263 | { | 1265 | { |
1264 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1266 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1265 | Incidence* inc = iL.first(); | 1267 | Incidence* inc = iL.first(); |
1266 | if ( phoneFormat ) { | 1268 | if ( phoneFormat ) { |
1267 | while ( inc ) { | 1269 | while ( inc ) { |
1268 | inc->removeID(mCurrentSyncDevice); | 1270 | inc->removeID(mCurrentSyncDevice); |
1269 | inc = iL.next(); | 1271 | inc = iL.next(); |
1270 | } | 1272 | } |
1271 | } | 1273 | } |
1272 | #ifndef DESKTOP_VERSION | 1274 | #ifndef DESKTOP_VERSION |
1273 | if ( sharpFormat ) | 1275 | if ( sharpFormat ) |
1274 | sharpFormat->save(calendar); | 1276 | sharpFormat->save(calendar); |
1275 | #endif | 1277 | #endif |
1276 | if ( phoneFormat ) | 1278 | if ( phoneFormat ) |
1277 | phoneFormat->save(calendar); | 1279 | phoneFormat->save(calendar); |
1278 | iL = calendar->rawIncidences(); | 1280 | iL = calendar->rawIncidences(); |
1279 | inc = iL.first(); | 1281 | inc = iL.first(); |
1280 | Incidence* loc; | 1282 | Incidence* loc; |
1281 | while ( inc ) { | 1283 | while ( inc ) { |
1282 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1284 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1283 | loc = mCalendar->incidence(inc->uid() ); | 1285 | loc = mCalendar->incidence(inc->uid() ); |
1284 | if ( loc ) { | 1286 | if ( loc ) { |
1285 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1287 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1286 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1288 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1287 | } | 1289 | } |
1288 | } | 1290 | } |
1289 | inc = iL.next(); | 1291 | inc = iL.next(); |
1290 | } | 1292 | } |
1291 | Incidence* lse = getLastSyncEvent(); | 1293 | Incidence* lse = getLastSyncEvent(); |
1292 | if ( lse ) { | 1294 | if ( lse ) { |
1293 | lse->setReadOnly( false ); | 1295 | lse->setReadOnly( false ); |
1294 | lse->setDescription( "" ); | 1296 | lse->setDescription( "" ); |
1295 | lse->setReadOnly( true ); | 1297 | lse->setReadOnly( true ); |
1296 | } | 1298 | } |
1297 | } | 1299 | } |
1298 | } | 1300 | } |
1299 | setModified( true ); | 1301 | setModified( true ); |
1300 | } else { | 1302 | } else { |
1301 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1303 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1302 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1304 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1303 | question, i18n("Ok")) ; | 1305 | question, i18n("Ok")) ; |
1304 | 1306 | ||
1305 | } | 1307 | } |
1306 | delete calendar; | 1308 | delete calendar; |
1307 | updateView(); | 1309 | updateView(); |
1308 | return ;//syncOK; | 1310 | return ;//syncOK; |
1309 | 1311 | ||
1310 | } | 1312 | } |
1311 | 1313 | ||
1312 | bool CalendarView::importBday() | 1314 | bool CalendarView::importBday() |
1313 | { | 1315 | { |
1314 | #ifndef KORG_NOKABC | 1316 | #ifndef KORG_NOKABC |
1315 | 1317 | ||
1316 | #ifdef DESKTOP_VERSION | 1318 | #ifdef DESKTOP_VERSION |
1317 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1319 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1318 | KABC::AddressBook::Iterator it; | 1320 | KABC::AddressBook::Iterator it; |
1319 | int count = 0; | 1321 | int count = 0; |
1320 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1322 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1321 | ++count; | 1323 | ++count; |
1322 | } | 1324 | } |
1323 | QProgressBar bar(count,0 ); | 1325 | QProgressBar bar(count,0 ); |
1324 | int w = 300; | 1326 | int w = 300; |
1325 | if ( QApplication::desktop()->width() < 320 ) | 1327 | if ( QApplication::desktop()->width() < 320 ) |
1326 | w = 220; | 1328 | w = 220; |
1327 | int h = bar.sizeHint().height() ; | 1329 | int h = bar.sizeHint().height() ; |
1328 | int dw = QApplication::desktop()->width(); | 1330 | int dw = QApplication::desktop()->width(); |
1329 | int dh = QApplication::desktop()->height(); | 1331 | int dh = QApplication::desktop()->height(); |
1330 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1331 | bar.show(); | 1333 | bar.show(); |
1332 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1334 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1333 | qApp->processEvents(); | 1335 | qApp->processEvents(); |
1334 | count = 0; | 1336 | count = 0; |
1335 | int addCount = 0; | 1337 | int addCount = 0; |
1336 | KCal::Attendee* a = 0; | 1338 | KCal::Attendee* a = 0; |
1337 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1339 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1338 | if ( ! bar.isVisible() ) | 1340 | if ( ! bar.isVisible() ) |
1339 | return false; | 1341 | return false; |
1340 | bar.setProgress( count++ ); | 1342 | bar.setProgress( count++ ); |
1341 | qApp->processEvents(); | 1343 | qApp->processEvents(); |
1342 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1344 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1343 | if ( (*it).birthday().date().isValid() ){ | 1345 | if ( (*it).birthday().date().isValid() ){ |
1344 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1346 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1345 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1347 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1346 | ++addCount; | 1348 | ++addCount; |
1347 | } | 1349 | } |
1348 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1350 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1349 | if ( anni.isValid() ){ | 1351 | if ( anni.isValid() ){ |
1350 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1352 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1351 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1353 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1352 | ++addCount; | 1354 | ++addCount; |
1353 | } | 1355 | } |
1354 | } | 1356 | } |
1355 | updateView(); | 1357 | updateView(); |
1356 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1358 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1357 | #else //DESKTOP_VERSION | 1359 | #else //DESKTOP_VERSION |
1358 | 1360 | ||
1359 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1361 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1360 | // the result should now arrive through method insertBirthdays | 1362 | // the result should now arrive through method insertBirthdays |
1361 | 1363 | ||
1362 | #endif //DESKTOP_VERSION | 1364 | #endif //DESKTOP_VERSION |
1363 | 1365 | ||
1364 | #endif //KORG_NOKABC | 1366 | #endif //KORG_NOKABC |
1365 | 1367 | ||
1366 | 1368 | ||
1367 | return true; | 1369 | return true; |
1368 | } | 1370 | } |
1369 | 1371 | ||
1370 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1371 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1372 | const QStringList& anniversaryList, const QStringList& realNameList, | 1374 | const QStringList& anniversaryList, const QStringList& realNameList, |
1373 | const QStringList& emailList, const QStringList& assembledNameList, | 1375 | const QStringList& emailList, const QStringList& assembledNameList, |
1374 | const QStringList& uidList) | 1376 | const QStringList& uidList) |
1375 | { | 1377 | { |
1376 | qDebug("CalendarView::insertBirthdays"); | 1378 | qDebug("CalendarView::insertBirthdays"); |
1377 | if (uid == this->name()) | 1379 | if (uid == this->name()) |
1378 | { | 1380 | { |
1379 | int count = birthdayList.count(); | 1381 | int count = birthdayList.count(); |
1380 | int addCount = 0; | 1382 | int addCount = 0; |
1381 | KCal::Attendee* a = 0; | 1383 | KCal::Attendee* a = 0; |
1382 | 1384 | ||
1383 | qDebug("CalView 1 %i", count); | 1385 | qDebug("CalView 1 %i", count); |
1384 | 1386 | ||
1385 | QProgressBar bar(count,0 ); | 1387 | QProgressBar bar(count,0 ); |
1386 | int w = 300; | 1388 | int w = 300; |
1387 | if ( QApplication::desktop()->width() < 320 ) | 1389 | if ( QApplication::desktop()->width() < 320 ) |
1388 | w = 220; | 1390 | w = 220; |
1389 | int h = bar.sizeHint().height() ; | 1391 | int h = bar.sizeHint().height() ; |
1390 | int dw = QApplication::desktop()->width(); | 1392 | int dw = QApplication::desktop()->width(); |
1391 | int dh = QApplication::desktop()->height(); | 1393 | int dh = QApplication::desktop()->height(); |
1392 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1393 | bar.show(); | 1395 | bar.show(); |
1394 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1395 | qApp->processEvents(); | 1397 | qApp->processEvents(); |
1396 | 1398 | ||
1397 | QDate birthday; | 1399 | QDate birthday; |
1398 | QDate anniversary; | 1400 | QDate anniversary; |
1399 | QString realName; | 1401 | QString realName; |
1400 | QString email; | 1402 | QString email; |
1401 | QString assembledName; | 1403 | QString assembledName; |
1402 | QString uid; | 1404 | QString uid; |
1403 | bool ok = true; | 1405 | bool ok = true; |
1404 | for ( int i = 0; i < count; i++) | 1406 | for ( int i = 0; i < count; i++) |
1405 | { | 1407 | { |
1406 | if ( ! bar.isVisible() ) | 1408 | if ( ! bar.isVisible() ) |
1407 | return; | 1409 | return; |
1408 | bar.setProgress( i ); | 1410 | bar.setProgress( i ); |
1409 | qApp->processEvents(); | 1411 | qApp->processEvents(); |
1410 | 1412 | ||
1411 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1412 | if (!ok) { | 1414 | if (!ok) { |
1413 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1414 | } | 1416 | } |
1415 | 1417 | ||
1416 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1417 | if (!ok) { | 1419 | if (!ok) { |
1418 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1419 | } | 1421 | } |
1420 | realName = realNameList[i]; | 1422 | realName = realNameList[i]; |
1421 | email = emailList[i]; | 1423 | email = emailList[i]; |
1422 | assembledName = assembledNameList[i]; | 1424 | assembledName = assembledNameList[i]; |
1423 | uid = uidList[i]; | 1425 | uid = uidList[i]; |
1424 | //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() ); | 1426 | //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() ); |
1425 | 1427 | ||
1426 | if ( birthday.isValid() ){ | 1428 | if ( birthday.isValid() ){ |
1427 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1428 | KCal::Attendee::ReqParticipant,uid) ; | 1430 | KCal::Attendee::ReqParticipant,uid) ; |
1429 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1430 | ++addCount; | 1432 | ++addCount; |
1431 | } | 1433 | } |
1432 | 1434 | ||
1433 | if ( anniversary.isValid() ){ | 1435 | if ( anniversary.isValid() ){ |
1434 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1435 | KCal::Attendee::ReqParticipant,uid) ; | 1437 | KCal::Attendee::ReqParticipant,uid) ; |
1436 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1437 | ++addCount; | 1439 | ++addCount; |
1438 | } | 1440 | } |
1439 | } | 1441 | } |
1440 | 1442 | ||
1441 | updateView(); | 1443 | updateView(); |
1442 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1443 | 1445 | ||
1444 | } | 1446 | } |
1445 | 1447 | ||
1446 | } | 1448 | } |
1447 | 1449 | ||
1448 | 1450 | ||
1449 | 1451 | ||
1450 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1451 | { | 1453 | { |
1452 | //qDebug("addAnni "); | 1454 | //qDebug("addAnni "); |
1453 | Event * ev = new Event(); | 1455 | Event * ev = new Event(); |
1454 | if ( a ) { | 1456 | if ( a ) { |
1455 | ev->addAttendee( a ); | 1457 | ev->addAttendee( a ); |
1456 | } | 1458 | } |
1457 | QString kind; | 1459 | QString kind; |
1458 | if ( birthday ) | 1460 | if ( birthday ) |
1459 | kind = i18n( "Birthday" ); | 1461 | kind = i18n( "Birthday" ); |
1460 | else | 1462 | else |
1461 | kind = i18n( "Anniversary" ); | 1463 | kind = i18n( "Anniversary" ); |
1462 | ev->setSummary( name + " - " + kind ); | 1464 | ev->setSummary( name + " - " + kind ); |
1463 | ev->setOrganizer( "nobody@nowhere" ); | 1465 | ev->setOrganizer( "nobody@nowhere" ); |
1464 | ev->setCategories( kind ); | 1466 | ev->setCategories( kind ); |
1465 | ev->setDtStart( QDateTime(date) ); | 1467 | ev->setDtStart( QDateTime(date) ); |
1466 | ev->setDtEnd( QDateTime(date) ); | 1468 | ev->setDtEnd( QDateTime(date) ); |
1467 | ev->setFloats( true ); | 1469 | ev->setFloats( true ); |
1468 | Recurrence * rec = ev->recurrence(); | 1470 | Recurrence * rec = ev->recurrence(); |
1469 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1470 | rec->addYearlyNum( date.month() ); | 1472 | rec->addYearlyNum( date.month() ); |
1471 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1472 | delete ev; | 1474 | delete ev; |
1473 | return false; | 1475 | return false; |
1474 | } | 1476 | } |
1475 | return true; | 1477 | return true; |
1476 | 1478 | ||
1477 | } | 1479 | } |
1478 | bool CalendarView::importQtopia( const QString &categories, | 1480 | bool CalendarView::importQtopia( const QString &categories, |
1479 | const QString &datebook, | 1481 | const QString &datebook, |
1480 | const QString &todolist ) | 1482 | const QString &todolist ) |
1481 | { | 1483 | { |
1482 | 1484 | ||
1483 | QtopiaFormat qtopiaFormat; | 1485 | QtopiaFormat qtopiaFormat; |
1484 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1485 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1486 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1487 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1488 | 1490 | ||
1489 | updateView(); | 1491 | updateView(); |
1490 | return true; | 1492 | return true; |
1491 | 1493 | ||
1492 | #if 0 | 1494 | #if 0 |
1493 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1494 | mCurrentSyncDevice = "qtopia-XML"; | 1496 | mCurrentSyncDevice = "qtopia-XML"; |
1495 | if ( mSyncManager->mAskForPreferences ) | 1497 | if ( mSyncManager->mAskForPreferences ) |
1496 | edit_sync_options(); | 1498 | edit_sync_options(); |
1497 | qApp->processEvents(); | 1499 | qApp->processEvents(); |
1498 | CalendarLocal* calendar = new CalendarLocal(); | 1500 | CalendarLocal* calendar = new CalendarLocal(); |
1499 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1501 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1500 | bool syncOK = false; | 1502 | bool syncOK = false; |
1501 | QtopiaFormat qtopiaFormat; | 1503 | QtopiaFormat qtopiaFormat; |
1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1503 | bool loadOk = true; | 1505 | bool loadOk = true; |
1504 | if ( !categories.isEmpty() ) | 1506 | if ( !categories.isEmpty() ) |
1505 | loadOk = qtopiaFormat.load( calendar, categories ); | 1507 | loadOk = qtopiaFormat.load( calendar, categories ); |
1506 | if ( loadOk && !datebook.isEmpty() ) | 1508 | if ( loadOk && !datebook.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1509 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1508 | if ( loadOk && !todolist.isEmpty() ) | 1510 | if ( loadOk && !todolist.isEmpty() ) |
1509 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1511 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1510 | 1512 | ||
1511 | if ( loadOk ) { | 1513 | if ( loadOk ) { |
1512 | getEventViewerDialog()->setSyncMode( true ); | 1514 | getEventViewerDialog()->setSyncMode( true ); |
1513 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1514 | getEventViewerDialog()->setSyncMode( false ); | 1516 | getEventViewerDialog()->setSyncMode( false ); |
1515 | qApp->processEvents(); | 1517 | qApp->processEvents(); |
1516 | if ( syncOK ) { | 1518 | if ( syncOK ) { |
1517 | if ( mSyncManager->mWriteBackFile ) | 1519 | if ( mSyncManager->mWriteBackFile ) |
1518 | { | 1520 | { |
1519 | // write back XML file | 1521 | // write back XML file |
1520 | 1522 | ||
1521 | } | 1523 | } |
1522 | setModified( true ); | 1524 | setModified( true ); |
1523 | } | 1525 | } |
1524 | } else { | 1526 | } else { |
1525 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1526 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1527 | question, i18n("Ok")) ; | 1529 | question, i18n("Ok")) ; |
1528 | } | 1530 | } |
1529 | delete calendar; | 1531 | delete calendar; |
1530 | updateView(); | 1532 | updateView(); |
1531 | return syncOK; | 1533 | return syncOK; |
1532 | 1534 | ||
1533 | 1535 | ||
1534 | #endif | 1536 | #endif |
1535 | 1537 | ||
1536 | } | 1538 | } |
1537 | 1539 | ||
1538 | void CalendarView::setSyncEventsReadOnly() | 1540 | void CalendarView::setSyncEventsReadOnly() |
1539 | { | 1541 | { |
1540 | Event * ev; | 1542 | Event * ev; |
1541 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1543 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1542 | ev = eL.first(); | 1544 | ev = eL.first(); |
1543 | while ( ev ) { | 1545 | while ( ev ) { |
1544 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1545 | ev->setReadOnly( true ); | 1547 | ev->setReadOnly( true ); |
1546 | ev = eL.next(); | 1548 | ev = eL.next(); |
1547 | } | 1549 | } |
1548 | } | 1550 | } |
1549 | bool CalendarView::openCalendar(QString filename, bool merge) | 1551 | bool CalendarView::openCalendar(QString filename, bool merge) |
1550 | { | 1552 | { |
1551 | 1553 | ||
1552 | if (filename.isEmpty()) { | 1554 | if (filename.isEmpty()) { |
1553 | return false; | 1555 | return false; |
1554 | } | 1556 | } |
1555 | 1557 | ||
1556 | if (!QFile::exists(filename)) { | 1558 | if (!QFile::exists(filename)) { |
1557 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1558 | return false; | 1560 | return false; |
1559 | } | 1561 | } |
1560 | 1562 | ||
1561 | globalFlagBlockAgenda = 1; | 1563 | globalFlagBlockAgenda = 1; |
1562 | if (!merge) mCalendar->close(); | 1564 | if (!merge) mCalendar->close(); |
1563 | 1565 | ||
1564 | mStorage->setFileName( filename ); | 1566 | mStorage->setFileName( filename ); |
1565 | 1567 | ||
1566 | if ( mStorage->load() ) { | 1568 | if ( mStorage->load() ) { |
1567 | if ( merge ) ;//setModified( true ); | 1569 | if ( merge ) ;//setModified( true ); |
1568 | else { | 1570 | else { |
1569 | //setModified( true ); | 1571 | //setModified( true ); |
1570 | mViewManager->setDocumentId( filename ); | 1572 | mViewManager->setDocumentId( filename ); |
1571 | mDialogManager->setDocumentId( filename ); | 1573 | mDialogManager->setDocumentId( filename ); |
1572 | mTodoList->setDocumentId( filename ); | 1574 | mTodoList->setDocumentId( filename ); |
1573 | } | 1575 | } |
1574 | globalFlagBlockAgenda = 2; | 1576 | globalFlagBlockAgenda = 2; |
1575 | // if ( getLastSyncEvent() ) | 1577 | // if ( getLastSyncEvent() ) |
1576 | // getLastSyncEvent()->setReadOnly( true ); | 1578 | // getLastSyncEvent()->setReadOnly( true ); |
1577 | mCalendar->reInitAlarmSettings(); | 1579 | mCalendar->reInitAlarmSettings(); |
1578 | setSyncEventsReadOnly(); | 1580 | setSyncEventsReadOnly(); |
1579 | updateUnmanagedViews(); | 1581 | updateUnmanagedViews(); |
1580 | updateView(); | 1582 | updateView(); |
1581 | if ( filename != MainWindow::defaultFileName() ) { | 1583 | if ( filename != MainWindow::defaultFileName() ) { |
1582 | saveCalendar( MainWindow::defaultFileName() ); | 1584 | saveCalendar( MainWindow::defaultFileName() ); |
1583 | } else { | 1585 | } else { |
1584 | QFileInfo finf ( MainWindow::defaultFileName()); | 1586 | QFileInfo finf ( MainWindow::defaultFileName()); |
1585 | if ( finf.exists() ) { | 1587 | if ( finf.exists() ) { |
1586 | setLoadedFileVersion( finf.lastModified () ); | 1588 | setLoadedFileVersion( finf.lastModified () ); |
1587 | } | 1589 | } |
1588 | } | 1590 | } |
1589 | return true; | 1591 | return true; |
1590 | } else { | 1592 | } else { |
1591 | // while failing to load, the calendar object could | 1593 | // while failing to load, the calendar object could |
1592 | // have become partially populated. Clear it out. | 1594 | // have become partially populated. Clear it out. |
1593 | if ( !merge ) { | 1595 | if ( !merge ) { |
1594 | mCalendar->close(); | 1596 | mCalendar->close(); |
1595 | mViewManager->setDocumentId( filename ); | 1597 | mViewManager->setDocumentId( filename ); |
1596 | mDialogManager->setDocumentId( filename ); | 1598 | mDialogManager->setDocumentId( filename ); |
1597 | mTodoList->setDocumentId( filename ); | 1599 | mTodoList->setDocumentId( filename ); |
1598 | } | 1600 | } |
1599 | 1601 | ||
1600 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1602 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1601 | 1603 | ||
1602 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1604 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1603 | globalFlagBlockAgenda = 2; | 1605 | globalFlagBlockAgenda = 2; |
1604 | mCalendar->reInitAlarmSettings(); | 1606 | mCalendar->reInitAlarmSettings(); |
1605 | setSyncEventsReadOnly(); | 1607 | setSyncEventsReadOnly(); |
1606 | updateUnmanagedViews(); | 1608 | updateUnmanagedViews(); |
1607 | updateView(); | 1609 | updateView(); |
1608 | } | 1610 | } |
1609 | return false; | 1611 | return false; |
1610 | } | 1612 | } |
1611 | void CalendarView::showOpenError() | 1613 | void CalendarView::showOpenError() |
1612 | { | 1614 | { |
1613 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1615 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1614 | } | 1616 | } |
1615 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1617 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1616 | { | 1618 | { |
1617 | loadedFileVersion = dt; | 1619 | loadedFileVersion = dt; |
1618 | } | 1620 | } |
1619 | bool CalendarView::checkFileChanged(QString fn) | 1621 | bool CalendarView::checkFileChanged(QString fn) |
1620 | { | 1622 | { |
1621 | QFileInfo finf ( fn ); | 1623 | QFileInfo finf ( fn ); |
1622 | if ( !finf.exists() ) | 1624 | if ( !finf.exists() ) |
1623 | return true; | 1625 | return true; |
1624 | QDateTime dt = finf.lastModified (); | 1626 | QDateTime dt = finf.lastModified (); |
1625 | if ( dt <= loadedFileVersion ) | 1627 | if ( dt <= loadedFileVersion ) |
1626 | return false; | 1628 | return false; |
1627 | return true; | 1629 | return true; |
1628 | 1630 | ||
1629 | } | 1631 | } |
1630 | void CalendarView::watchSavedFile() | 1632 | void CalendarView::watchSavedFile() |
1631 | { | 1633 | { |
1632 | QFileInfo finf ( MainWindow::defaultFileName()); | 1634 | QFileInfo finf ( MainWindow::defaultFileName()); |
1633 | if ( !finf.exists() ) | 1635 | if ( !finf.exists() ) |
1634 | return; | 1636 | return; |
1635 | QDateTime dt = finf.lastModified (); | 1637 | QDateTime dt = finf.lastModified (); |
1636 | if ( dt < loadedFileVersion ) { | 1638 | if ( dt < loadedFileVersion ) { |
1637 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1639 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1638 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1640 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1639 | return; | 1641 | return; |
1640 | } | 1642 | } |
1641 | loadedFileVersion = dt; | 1643 | loadedFileVersion = dt; |
1642 | } | 1644 | } |
1643 | 1645 | ||
1644 | bool CalendarView::checkFileVersion(QString fn) | 1646 | bool CalendarView::checkFileVersion(QString fn) |
1645 | { | 1647 | { |
1646 | QFileInfo finf ( fn ); | 1648 | QFileInfo finf ( fn ); |
1647 | if ( !finf.exists() ) | 1649 | if ( !finf.exists() ) |
1648 | return true; | 1650 | return true; |
1649 | QDateTime dt = finf.lastModified (); | 1651 | QDateTime dt = finf.lastModified (); |
1650 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1652 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1651 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1653 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1652 | if ( dt <= loadedFileVersion ) | 1654 | if ( dt <= loadedFileVersion ) |
1653 | return true; | 1655 | return true; |
1654 | 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)) , | 1656 | 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)) , |
1655 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1657 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1656 | i18n("Sync+save")); | 1658 | i18n("Sync+save")); |
1657 | 1659 | ||
1658 | if ( km == KMessageBox::Cancel ) | 1660 | if ( km == KMessageBox::Cancel ) |
1659 | return false; | 1661 | return false; |
1660 | if ( km == KMessageBox::Yes ) | 1662 | if ( km == KMessageBox::Yes ) |
1661 | return true; | 1663 | return true; |
1662 | 1664 | ||
1663 | setSyncDevice("deleteaftersync" ); | 1665 | setSyncDevice("deleteaftersync" ); |
1664 | mSyncManager->mAskForPreferences = true; | 1666 | mSyncManager->mAskForPreferences = true; |
1665 | mSyncManager->mSyncAlgoPrefs = 3; | 1667 | mSyncManager->mSyncAlgoPrefs = 3; |
1666 | mSyncManager->mWriteBackFile = false; | 1668 | mSyncManager->mWriteBackFile = false; |
1667 | mSyncManager->mWriteBackExistingOnly = false; | 1669 | mSyncManager->mWriteBackExistingOnly = false; |
1668 | mSyncManager->mShowSyncSummary = false; | 1670 | mSyncManager->mShowSyncSummary = false; |
1669 | syncCalendar( fn, 3 ); | 1671 | syncCalendar( fn, 3 ); |
1670 | Event * e = getLastSyncEvent(); | 1672 | Event * e = getLastSyncEvent(); |
1671 | mCalendar->deleteEvent ( e ); | 1673 | mCalendar->deleteEvent ( e ); |
1672 | updateView(); | 1674 | updateView(); |
1673 | return true; | 1675 | return true; |
1674 | } | 1676 | } |
1675 | 1677 | ||
1676 | bool CalendarView::saveCalendar( QString filename ) | 1678 | bool CalendarView::saveCalendar( QString filename ) |
1677 | { | 1679 | { |
1678 | 1680 | ||
1679 | // Store back all unsaved data into calendar object | 1681 | // Store back all unsaved data into calendar object |
1680 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1682 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1681 | if ( mViewManager->currentView() ) | 1683 | if ( mViewManager->currentView() ) |
1682 | mViewManager->currentView()->flushView(); | 1684 | mViewManager->currentView()->flushView(); |
1683 | 1685 | ||
1684 | 1686 | ||
1685 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1687 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1686 | mStorage->setSaveFormat( new ICalFormat() ); | 1688 | mStorage->setSaveFormat( new ICalFormat() ); |
1687 | mStorage->setFileName( filename ); | 1689 | mStorage->setFileName( filename ); |
1688 | bool success; | 1690 | bool success; |
1689 | success = mStorage->save(); | 1691 | success = mStorage->save(); |
1690 | if ( !success ) { | 1692 | if ( !success ) { |
1691 | return false; | 1693 | return false; |
1692 | } | 1694 | } |
1693 | if ( filename == MainWindow::defaultFileName() ) { | 1695 | if ( filename == MainWindow::defaultFileName() ) { |
1694 | setLoadedFileVersion( lfv ); | 1696 | setLoadedFileVersion( lfv ); |
1695 | watchSavedFile(); | 1697 | watchSavedFile(); |
1696 | } | 1698 | } |
1697 | return true; | 1699 | return true; |
1698 | } | 1700 | } |
1699 | 1701 | ||
1700 | void CalendarView::closeCalendar() | 1702 | void CalendarView::closeCalendar() |
1701 | { | 1703 | { |
1702 | 1704 | ||
1703 | // child windows no longer valid | 1705 | // child windows no longer valid |
1704 | emit closingDown(); | 1706 | emit closingDown(); |
1705 | 1707 | ||
1706 | mCalendar->close(); | 1708 | mCalendar->close(); |
1707 | setModified(false); | 1709 | setModified(false); |
1708 | updateView(); | 1710 | updateView(); |
1709 | } | 1711 | } |
1710 | 1712 | ||
1711 | void CalendarView::archiveCalendar() | 1713 | void CalendarView::archiveCalendar() |
1712 | { | 1714 | { |
1713 | mDialogManager->showArchiveDialog(); | 1715 | mDialogManager->showArchiveDialog(); |
1714 | } | 1716 | } |
1715 | 1717 | ||
1716 | 1718 | ||
1717 | void CalendarView::readSettings() | 1719 | void CalendarView::readSettings() |
1718 | { | 1720 | { |
1719 | 1721 | ||
1720 | 1722 | ||
1721 | // mViewManager->showAgendaView(); | 1723 | // mViewManager->showAgendaView(); |
1722 | QString str; | 1724 | QString str; |
1723 | //qDebug("CalendarView::readSettings() "); | 1725 | //qDebug("CalendarView::readSettings() "); |
1724 | // read settings from the KConfig, supplying reasonable | 1726 | // read settings from the KConfig, supplying reasonable |
1725 | // defaults where none are to be found | 1727 | // defaults where none are to be found |
1726 | KConfig *config = KOGlobals::config(); | 1728 | KConfig *config = KOGlobals::config(); |
1727 | #ifndef KORG_NOSPLITTER | 1729 | #ifndef KORG_NOSPLITTER |
1728 | config->setGroup("KOrganizer Geometry"); | 1730 | config->setGroup("KOrganizer Geometry"); |
1729 | 1731 | ||
1730 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1732 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1731 | if (sizes.count() != 2) { | 1733 | if (sizes.count() != 2) { |
1732 | sizes << mDateNavigator->minimumSizeHint().width(); | 1734 | sizes << mDateNavigator->minimumSizeHint().width(); |
1733 | sizes << 300; | 1735 | sizes << 300; |
1734 | } | 1736 | } |
1735 | mPanner->setSizes(sizes); | 1737 | mPanner->setSizes(sizes); |
1736 | 1738 | ||
1737 | sizes = config->readIntListEntry("Separator2"); | 1739 | sizes = config->readIntListEntry("Separator2"); |
1738 | if ( ( mResourceView && sizes.count() == 4 ) || | 1740 | if ( ( mResourceView && sizes.count() == 4 ) || |
1739 | ( !mResourceView && sizes.count() == 3 ) ) { | 1741 | ( !mResourceView && sizes.count() == 3 ) ) { |
1740 | mLeftSplitter->setSizes(sizes); | 1742 | mLeftSplitter->setSizes(sizes); |
1741 | } | 1743 | } |
1742 | #endif | 1744 | #endif |
1743 | globalFlagBlockAgenda = 1; | 1745 | globalFlagBlockAgenda = 1; |
1744 | mViewManager->showAgendaView(); | 1746 | mViewManager->showAgendaView(); |
1745 | //mViewManager->readSettings( config ); | 1747 | //mViewManager->readSettings( config ); |
1746 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1748 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1747 | readFilterSettings(config); | 1749 | readFilterSettings(config); |
1748 | config->setGroup( "Views" ); | 1750 | config->setGroup( "Views" ); |
1749 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1751 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1750 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1752 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1751 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1753 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1752 | else mNavigator->selectDates( dateCount ); | 1754 | else mNavigator->selectDates( dateCount ); |
1753 | // mViewManager->readSettings( config ); | 1755 | // mViewManager->readSettings( config ); |
1754 | updateConfig(); | 1756 | updateConfig(); |
1755 | globalFlagBlockAgenda = 2; | 1757 | globalFlagBlockAgenda = 2; |
1756 | mViewManager->readSettings( config ); | 1758 | mViewManager->readSettings( config ); |
1757 | #ifdef DESKTOP_VERSION | 1759 | #ifdef DESKTOP_VERSION |
1758 | config->setGroup("WidgetLayout"); | 1760 | config->setGroup("WidgetLayout"); |
1759 | QStringList list; | 1761 | QStringList list; |
1760 | list = config->readListEntry("MainLayout"); | 1762 | list = config->readListEntry("MainLayout"); |
1761 | int x,y,w,h; | 1763 | int x,y,w,h; |
1762 | if ( ! list.isEmpty() ) { | 1764 | if ( ! list.isEmpty() ) { |
1763 | x = list[0].toInt(); | 1765 | x = list[0].toInt(); |
1764 | y = list[1].toInt(); | 1766 | y = list[1].toInt(); |
1765 | w = list[2].toInt(); | 1767 | w = list[2].toInt(); |
1766 | h = list[3].toInt(); | 1768 | h = list[3].toInt(); |
1767 | topLevelWidget()->setGeometry(x,y,w,h); | 1769 | topLevelWidget()->setGeometry(x,y,w,h); |
1768 | 1770 | ||
1769 | } else { | 1771 | } else { |
1770 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1772 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1771 | } | 1773 | } |
1772 | list = config->readListEntry("EditEventLayout"); | 1774 | list = config->readListEntry("EditEventLayout"); |
1773 | if ( ! list.isEmpty() ) { | 1775 | if ( ! list.isEmpty() ) { |
1774 | x = list[0].toInt(); | 1776 | x = list[0].toInt(); |
1775 | y = list[1].toInt(); | 1777 | y = list[1].toInt(); |
1776 | w = list[2].toInt(); | 1778 | w = list[2].toInt(); |
1777 | h = list[3].toInt(); | 1779 | h = list[3].toInt(); |
1778 | mEventEditor->setGeometry(x,y,w,h); | 1780 | mEventEditor->setGeometry(x,y,w,h); |
1779 | 1781 | ||
1780 | } | 1782 | } |
1781 | list = config->readListEntry("EditTodoLayout"); | 1783 | list = config->readListEntry("EditTodoLayout"); |
1782 | if ( ! list.isEmpty() ) { | 1784 | if ( ! list.isEmpty() ) { |
1783 | x = list[0].toInt(); | 1785 | x = list[0].toInt(); |
1784 | y = list[1].toInt(); | 1786 | y = list[1].toInt(); |
1785 | w = list[2].toInt(); | 1787 | w = list[2].toInt(); |
1786 | h = list[3].toInt(); | 1788 | h = list[3].toInt(); |
1787 | mTodoEditor->setGeometry(x,y,w,h); | 1789 | mTodoEditor->setGeometry(x,y,w,h); |
1788 | 1790 | ||
1789 | } | 1791 | } |
1790 | list = config->readListEntry("ViewerLayout"); | 1792 | list = config->readListEntry("ViewerLayout"); |
1791 | if ( ! list.isEmpty() ) { | 1793 | if ( ! list.isEmpty() ) { |
1792 | x = list[0].toInt(); | 1794 | x = list[0].toInt(); |
1793 | y = list[1].toInt(); | 1795 | y = list[1].toInt(); |
1794 | w = list[2].toInt(); | 1796 | w = list[2].toInt(); |
1795 | h = list[3].toInt(); | 1797 | h = list[3].toInt(); |
1796 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1798 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1797 | } | 1799 | } |
1798 | #endif | 1800 | #endif |
1799 | 1801 | ||
1800 | } | 1802 | } |
1801 | 1803 | ||
1802 | 1804 | ||
1803 | void CalendarView::writeSettings() | 1805 | void CalendarView::writeSettings() |
1804 | { | 1806 | { |
1805 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1807 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1806 | 1808 | ||
1807 | KConfig *config = KOGlobals::config(); | 1809 | KConfig *config = KOGlobals::config(); |
1808 | 1810 | ||
1809 | #ifndef KORG_NOSPLITTER | 1811 | #ifndef KORG_NOSPLITTER |
1810 | config->setGroup("KOrganizer Geometry"); | 1812 | config->setGroup("KOrganizer Geometry"); |
1811 | 1813 | ||
1812 | QValueList<int> list = mPanner->sizes(); | 1814 | QValueList<int> list = mPanner->sizes(); |
1813 | config->writeEntry("Separator1",list); | 1815 | config->writeEntry("Separator1",list); |
1814 | 1816 | ||
1815 | list = mLeftSplitter->sizes(); | 1817 | list = mLeftSplitter->sizes(); |
1816 | config->writeEntry("Separator2",list); | 1818 | config->writeEntry("Separator2",list); |
1817 | #endif | 1819 | #endif |
1818 | 1820 | ||
1819 | mViewManager->writeSettings( config ); | 1821 | mViewManager->writeSettings( config ); |
1820 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1822 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1821 | mDialogManager->writeSettings( config ); | 1823 | mDialogManager->writeSettings( config ); |
1822 | //KOPrefs::instance()->usrWriteConfig(); | 1824 | //KOPrefs::instance()->usrWriteConfig(); |
1823 | KOPrefs::instance()->writeConfig(); | 1825 | KOPrefs::instance()->writeConfig(); |
1824 | 1826 | ||
1825 | writeFilterSettings(config); | 1827 | writeFilterSettings(config); |
1826 | 1828 | ||
1827 | config->setGroup( "Views" ); | 1829 | config->setGroup( "Views" ); |
1828 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1830 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1829 | 1831 | ||
1830 | #ifdef DESKTOP_VERSION | 1832 | #ifdef DESKTOP_VERSION |
1831 | config->setGroup("WidgetLayout"); | 1833 | config->setGroup("WidgetLayout"); |
1832 | QStringList list ;//= config->readListEntry("MainLayout"); | 1834 | QStringList list ;//= config->readListEntry("MainLayout"); |
1833 | int x,y,w,h; | 1835 | int x,y,w,h; |
1834 | QWidget* wid; | 1836 | QWidget* wid; |
1835 | wid = topLevelWidget(); | 1837 | wid = topLevelWidget(); |
1836 | x = wid->geometry().x(); | 1838 | x = wid->geometry().x(); |
1837 | y = wid->geometry().y(); | 1839 | y = wid->geometry().y(); |
1838 | w = wid->width(); | 1840 | w = wid->width(); |
1839 | h = wid->height(); | 1841 | h = wid->height(); |
1840 | list.clear(); | 1842 | list.clear(); |
1841 | list << QString::number( x ); | 1843 | list << QString::number( x ); |
1842 | list << QString::number( y ); | 1844 | list << QString::number( y ); |
1843 | list << QString::number( w ); | 1845 | list << QString::number( w ); |
1844 | list << QString::number( h ); | 1846 | list << QString::number( h ); |
1845 | config->writeEntry("MainLayout",list ); | 1847 | config->writeEntry("MainLayout",list ); |
1846 | 1848 | ||
1847 | wid = mEventEditor; | 1849 | wid = mEventEditor; |
1848 | x = wid->geometry().x(); | 1850 | x = wid->geometry().x(); |
1849 | y = wid->geometry().y(); | 1851 | y = wid->geometry().y(); |
1850 | w = wid->width(); | 1852 | w = wid->width(); |
1851 | h = wid->height(); | 1853 | h = wid->height(); |
1852 | list.clear(); | 1854 | list.clear(); |
1853 | list << QString::number( x ); | 1855 | list << QString::number( x ); |
1854 | list << QString::number( y ); | 1856 | list << QString::number( y ); |
1855 | list << QString::number( w ); | 1857 | list << QString::number( w ); |
1856 | list << QString::number( h ); | 1858 | list << QString::number( h ); |
1857 | config->writeEntry("EditEventLayout",list ); | 1859 | config->writeEntry("EditEventLayout",list ); |
1858 | 1860 | ||
1859 | wid = mTodoEditor; | 1861 | wid = mTodoEditor; |
1860 | x = wid->geometry().x(); | 1862 | x = wid->geometry().x(); |
1861 | y = wid->geometry().y(); | 1863 | y = wid->geometry().y(); |
1862 | w = wid->width(); | 1864 | w = wid->width(); |
1863 | h = wid->height(); | 1865 | h = wid->height(); |
1864 | list.clear(); | 1866 | list.clear(); |
1865 | list << QString::number( x ); | 1867 | list << QString::number( x ); |
1866 | list << QString::number( y ); | 1868 | list << QString::number( y ); |
1867 | list << QString::number( w ); | 1869 | list << QString::number( w ); |
1868 | list << QString::number( h ); | 1870 | list << QString::number( h ); |
1869 | config->writeEntry("EditTodoLayout",list ); | 1871 | config->writeEntry("EditTodoLayout",list ); |
1870 | wid = getEventViewerDialog(); | 1872 | wid = getEventViewerDialog(); |
1871 | x = wid->geometry().x(); | 1873 | x = wid->geometry().x(); |
1872 | y = wid->geometry().y(); | 1874 | y = wid->geometry().y(); |
1873 | w = wid->width(); | 1875 | w = wid->width(); |
1874 | h = wid->height(); | 1876 | h = wid->height(); |
1875 | list.clear(); | 1877 | list.clear(); |
1876 | list << QString::number( x ); | 1878 | list << QString::number( x ); |
1877 | list << QString::number( y ); | 1879 | list << QString::number( y ); |
1878 | list << QString::number( w ); | 1880 | list << QString::number( w ); |
1879 | list << QString::number( h ); | 1881 | list << QString::number( h ); |
1880 | config->writeEntry("ViewerLayout",list ); | 1882 | config->writeEntry("ViewerLayout",list ); |
1881 | wid = mDialogManager->getSearchDialog(); | 1883 | wid = mDialogManager->getSearchDialog(); |
1882 | if ( wid ) { | 1884 | if ( wid ) { |
1883 | x = wid->geometry().x(); | 1885 | x = wid->geometry().x(); |
1884 | y = wid->geometry().y(); | 1886 | y = wid->geometry().y(); |
1885 | w = wid->width(); | 1887 | w = wid->width(); |
1886 | h = wid->height(); | 1888 | h = wid->height(); |
1887 | list.clear(); | 1889 | list.clear(); |
1888 | list << QString::number( x ); | 1890 | list << QString::number( x ); |
1889 | list << QString::number( y ); | 1891 | list << QString::number( y ); |
1890 | list << QString::number( w ); | 1892 | list << QString::number( w ); |
1891 | list << QString::number( h ); | 1893 | list << QString::number( h ); |
1892 | config->writeEntry("SearchLayout",list ); | 1894 | config->writeEntry("SearchLayout",list ); |
1893 | } | 1895 | } |
1894 | #endif | 1896 | #endif |
1895 | 1897 | ||
1896 | 1898 | ||
1897 | config->sync(); | 1899 | config->sync(); |
1898 | } | 1900 | } |
1899 | 1901 | ||
1900 | void CalendarView::readFilterSettings(KConfig *config) | 1902 | void CalendarView::readFilterSettings(KConfig *config) |
1901 | { | 1903 | { |
1902 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1904 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1903 | 1905 | ||
1904 | mFilters.clear(); | 1906 | mFilters.clear(); |
1905 | 1907 | ||
1906 | config->setGroup("General"); | 1908 | config->setGroup("General"); |
1907 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1909 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1908 | 1910 | ||
1909 | QStringList::ConstIterator it = filterList.begin(); | 1911 | QStringList::ConstIterator it = filterList.begin(); |
1910 | QStringList::ConstIterator end = filterList.end(); | 1912 | QStringList::ConstIterator end = filterList.end(); |
1911 | while(it != end) { | 1913 | while(it != end) { |
1912 | // kdDebug() << " filter: " << (*it) << endl; | 1914 | // kdDebug() << " filter: " << (*it) << endl; |
1913 | 1915 | ||
1914 | CalFilter *filter; | 1916 | CalFilter *filter; |
1915 | filter = new CalFilter(*it); | 1917 | filter = new CalFilter(*it); |
1916 | config->setGroup("Filter_" + (*it)); | 1918 | config->setGroup("Filter_" + (*it)); |
1917 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1919 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1918 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1920 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1919 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1921 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1920 | mFilters.append(filter); | 1922 | mFilters.append(filter); |
1921 | 1923 | ||
1922 | ++it; | 1924 | ++it; |
1923 | } | 1925 | } |
1924 | 1926 | ||
1925 | if (mFilters.count() == 0) { | 1927 | if (mFilters.count() == 0) { |
1926 | CalFilter *filter = new CalFilter(i18n("Default")); | 1928 | CalFilter *filter = new CalFilter(i18n("Default")); |
1927 | mFilters.append(filter); | 1929 | mFilters.append(filter); |
1928 | } | 1930 | } |
1929 | mFilterView->updateFilters(); | 1931 | mFilterView->updateFilters(); |
1930 | config->setGroup("FilterView"); | 1932 | config->setGroup("FilterView"); |
1931 | 1933 | ||
1932 | mFilterView->blockSignals(true); | 1934 | mFilterView->blockSignals(true); |
1933 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1935 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1934 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1936 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1935 | mFilterView->blockSignals(false); | 1937 | mFilterView->blockSignals(false); |
1936 | // We do it manually to avoid it being done twice by the above calls | 1938 | // We do it manually to avoid it being done twice by the above calls |
1937 | updateFilter(); | 1939 | updateFilter(); |
1938 | } | 1940 | } |
1939 | 1941 | ||
1940 | void CalendarView::writeFilterSettings(KConfig *config) | 1942 | void CalendarView::writeFilterSettings(KConfig *config) |
1941 | { | 1943 | { |
1942 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1944 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1943 | 1945 | ||
1944 | QStringList filterList; | 1946 | QStringList filterList; |
1945 | 1947 | ||
1946 | CalFilter *filter = mFilters.first(); | 1948 | CalFilter *filter = mFilters.first(); |
1947 | while(filter) { | 1949 | while(filter) { |
1948 | // kdDebug() << " fn: " << filter->name() << endl; | 1950 | // kdDebug() << " fn: " << filter->name() << endl; |
1949 | filterList << filter->name(); | 1951 | filterList << filter->name(); |
1950 | config->setGroup("Filter_" + filter->name()); | 1952 | config->setGroup("Filter_" + filter->name()); |
1951 | config->writeEntry("Criteria",filter->criteria()); | 1953 | config->writeEntry("Criteria",filter->criteria()); |
1952 | config->writeEntry("CategoryList",filter->categoryList()); | 1954 | config->writeEntry("CategoryList",filter->categoryList()); |
1953 | filter = mFilters.next(); | 1955 | filter = mFilters.next(); |
1954 | } | 1956 | } |
1955 | config->setGroup("General"); | 1957 | config->setGroup("General"); |
1956 | config->writeEntry("CalendarFilters",filterList); | 1958 | config->writeEntry("CalendarFilters",filterList); |
1957 | 1959 | ||
1958 | config->setGroup("FilterView"); | 1960 | config->setGroup("FilterView"); |
1959 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1961 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1960 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1962 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1961 | } | 1963 | } |
1962 | 1964 | ||
1963 | 1965 | ||
1964 | void CalendarView::goToday() | 1966 | void CalendarView::goToday() |
1965 | { | 1967 | { |
1966 | mNavigator->selectToday(); | 1968 | mNavigator->selectToday(); |
1967 | } | 1969 | } |
1968 | 1970 | ||
1969 | void CalendarView::goNext() | 1971 | void CalendarView::goNext() |
1970 | { | 1972 | { |
1971 | mNavigator->selectNext(); | 1973 | mNavigator->selectNext(); |
1972 | } | 1974 | } |
1973 | 1975 | ||
1974 | void CalendarView::goPrevious() | 1976 | void CalendarView::goPrevious() |
1975 | { | 1977 | { |
1976 | mNavigator->selectPrevious(); | 1978 | mNavigator->selectPrevious(); |
1977 | } | 1979 | } |
1978 | void CalendarView::goNextMonth() | 1980 | void CalendarView::goNextMonth() |
1979 | { | 1981 | { |
1980 | mNavigator->selectNextMonth(); | 1982 | mNavigator->selectNextMonth(); |
1981 | } | 1983 | } |
1982 | 1984 | ||
1983 | void CalendarView::goPreviousMonth() | 1985 | void CalendarView::goPreviousMonth() |
1984 | { | 1986 | { |
1985 | mNavigator->selectPreviousMonth(); | 1987 | mNavigator->selectPreviousMonth(); |
1986 | } | 1988 | } |
1987 | void CalendarView::writeLocale() | 1989 | void CalendarView::writeLocale() |
1988 | { | 1990 | { |
1989 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1991 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1990 | #if 0 | 1992 | #if 0 |
1991 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1993 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1992 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1994 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1993 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1995 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1994 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1996 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1995 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1997 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1996 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1998 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1997 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1999 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1998 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2000 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1999 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2001 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2000 | KOPrefs::instance()->mDaylightsavingStart, | 2002 | KOPrefs::instance()->mDaylightsavingStart, |
2001 | KOPrefs::instance()->mDaylightsavingEnd ); | 2003 | KOPrefs::instance()->mDaylightsavingEnd ); |
2002 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2004 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2003 | #endif | 2005 | #endif |
2004 | } | 2006 | } |
2005 | void CalendarView::updateConfig() | 2007 | void CalendarView::updateConfig() |
2006 | { | 2008 | { |
2007 | writeLocale(); | 2009 | writeLocale(); |
2008 | if ( KOPrefs::instance()->mUseAppColors ) | 2010 | if ( KOPrefs::instance()->mUseAppColors ) |
2009 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2011 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2010 | emit configChanged(); | 2012 | emit configChanged(); |
2011 | mTodoList->updateConfig(); | 2013 | mTodoList->updateConfig(); |
2012 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2014 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2013 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2015 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2014 | // To make the "fill window" configurations work | 2016 | // To make the "fill window" configurations work |
2015 | //mViewManager->raiseCurrentView(); | 2017 | //mViewManager->raiseCurrentView(); |
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | 2020 | ||
2019 | void CalendarView::eventChanged(Event *event) | 2021 | void CalendarView::eventChanged(Event *event) |
2020 | { | 2022 | { |
2021 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2023 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2022 | //updateUnmanagedViews(); | 2024 | //updateUnmanagedViews(); |
2023 | } | 2025 | } |
2024 | 2026 | ||
2025 | void CalendarView::eventAdded(Event *event) | 2027 | void CalendarView::eventAdded(Event *event) |
2026 | { | 2028 | { |
2027 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2029 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2028 | } | 2030 | } |
2029 | 2031 | ||
2030 | void CalendarView::eventToBeDeleted(Event *) | 2032 | void CalendarView::eventToBeDeleted(Event *) |
2031 | { | 2033 | { |
2032 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2034 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2033 | } | 2035 | } |
2034 | 2036 | ||
2035 | void CalendarView::eventDeleted() | 2037 | void CalendarView::eventDeleted() |
2036 | { | 2038 | { |
2037 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2039 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2038 | } | 2040 | } |
2039 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2041 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2040 | { | 2042 | { |
2041 | changeIncidenceDisplay((Incidence *)which, action); | 2043 | changeIncidenceDisplay((Incidence *)which, action); |
2042 | mDateNavigator->updateView(); //LR | 2044 | mDateNavigator->updateView(); //LR |
2043 | //mDialogManager->updateSearchDialog(); | 2045 | //mDialogManager->updateSearchDialog(); |
2044 | 2046 | ||
2045 | if (which) { | 2047 | if (which) { |
2046 | mViewManager->updateWNview(); | 2048 | mViewManager->updateWNview(); |
2047 | //mTodoList->updateView(); | 2049 | //mTodoList->updateView(); |
2048 | } | 2050 | } |
2049 | 2051 | ||
2050 | } | 2052 | } |
2051 | 2053 | ||
2052 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2054 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2053 | { | 2055 | { |
2054 | updateUnmanagedViews(); | 2056 | updateUnmanagedViews(); |
2055 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2057 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2056 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2058 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2057 | mCalendar->checkAlarmForIncidence( 0, true ); | 2059 | mCalendar->checkAlarmForIncidence( 0, true ); |
2058 | if ( mEventViewerDialog ) | 2060 | if ( mEventViewerDialog ) |
2059 | mEventViewerDialog->hide(); | 2061 | mEventViewerDialog->hide(); |
2060 | } | 2062 | } |
2061 | else | 2063 | else |
2062 | mCalendar->checkAlarmForIncidence( which , false ); | 2064 | mCalendar->checkAlarmForIncidence( which , false ); |
2063 | } | 2065 | } |
2064 | 2066 | ||
2065 | // most of the changeEventDisplays() right now just call the view's | 2067 | // most of the changeEventDisplays() right now just call the view's |
2066 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2068 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2067 | void CalendarView::changeEventDisplay(Event *which, int action) | 2069 | void CalendarView::changeEventDisplay(Event *which, int action) |
2068 | { | 2070 | { |
2069 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2071 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2070 | changeIncidenceDisplay((Incidence *)which, action); | 2072 | changeIncidenceDisplay((Incidence *)which, action); |
2071 | mDateNavigator->updateView(); | 2073 | mDateNavigator->updateView(); |
2072 | //mDialogManager->updateSearchDialog(); | 2074 | //mDialogManager->updateSearchDialog(); |
2073 | 2075 | ||
2074 | if (which) { | 2076 | if (which) { |
2075 | // If there is an event view visible update the display | 2077 | // If there is an event view visible update the display |
2076 | mViewManager->currentView()->changeEventDisplay(which,action); | 2078 | mViewManager->currentView()->changeEventDisplay(which,action); |
2077 | // TODO: check, if update needed | 2079 | // TODO: check, if update needed |
2078 | // if (which->getTodoStatus()) { | 2080 | // if (which->getTodoStatus()) { |
2079 | mTodoList->updateView(); | 2081 | mTodoList->updateView(); |
2080 | // } | 2082 | // } |
2081 | } else { | 2083 | } else { |
2082 | mViewManager->currentView()->updateView(); | 2084 | mViewManager->currentView()->updateView(); |
2083 | } | 2085 | } |
2084 | } | 2086 | } |
2085 | 2087 | ||
2086 | 2088 | ||
2087 | void CalendarView::updateTodoViews() | 2089 | void CalendarView::updateTodoViews() |
2088 | { | 2090 | { |
2089 | 2091 | ||
2090 | mTodoList->updateView(); | 2092 | mTodoList->updateView(); |
2091 | mViewManager->currentView()->updateView(); | 2093 | mViewManager->currentView()->updateView(); |
2092 | 2094 | ||
2093 | } | 2095 | } |
2094 | 2096 | ||
2095 | 2097 | ||
2096 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2098 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2097 | { | 2099 | { |
2098 | mTodoList->updateView(); | 2100 | mTodoList->updateView(); |
2099 | mViewManager->updateView(start, end); | 2101 | mViewManager->updateView(start, end); |
2100 | //mDateNavigator->updateView(); | 2102 | //mDateNavigator->updateView(); |
2101 | } | 2103 | } |
2102 | 2104 | ||
2103 | void CalendarView::updateView() | 2105 | void CalendarView::updateView() |
2104 | { | 2106 | { |
2105 | DateList tmpList = mNavigator->selectedDates(); | 2107 | DateList tmpList = mNavigator->selectedDates(); |
2106 | 2108 | ||
2107 | // We assume that the navigator only selects consecutive days. | 2109 | // We assume that the navigator only selects consecutive days. |
2108 | updateView( tmpList.first(), tmpList.last() ); | 2110 | updateView( tmpList.first(), tmpList.last() ); |
2109 | } | 2111 | } |
2110 | 2112 | ||
2111 | void CalendarView::updateUnmanagedViews() | 2113 | void CalendarView::updateUnmanagedViews() |
2112 | { | 2114 | { |
2113 | mDateNavigator->updateDayMatrix(); | 2115 | mDateNavigator->updateDayMatrix(); |
2114 | } | 2116 | } |
2115 | 2117 | ||
2116 | int CalendarView::msgItemDelete() | 2118 | int CalendarView::msgItemDelete() |
2117 | { | 2119 | { |
2118 | return KMessageBox::warningContinueCancel(this, | 2120 | return KMessageBox::warningContinueCancel(this, |
2119 | i18n("This item will be\npermanently deleted."), | 2121 | i18n("This item will be\npermanently deleted."), |
2120 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2122 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2121 | } | 2123 | } |
2122 | 2124 | ||
2123 | 2125 | ||
2124 | void CalendarView::edit_cut() | 2126 | void CalendarView::edit_cut() |
2125 | { | 2127 | { |
2126 | Event *anEvent=0; | 2128 | Event *anEvent=0; |
2127 | 2129 | ||
2128 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2130 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2129 | 2131 | ||
2130 | if (mViewManager->currentView()->isEventView()) { | 2132 | if (mViewManager->currentView()->isEventView()) { |
2131 | if ( incidence && incidence->type() == "Event" ) { | 2133 | if ( incidence && incidence->type() == "Event" ) { |
2132 | anEvent = static_cast<Event *>(incidence); | 2134 | anEvent = static_cast<Event *>(incidence); |
2133 | } | 2135 | } |
2134 | } | 2136 | } |
2135 | 2137 | ||
2136 | if (!anEvent) { | 2138 | if (!anEvent) { |
2137 | KNotifyClient::beep(); | 2139 | KNotifyClient::beep(); |
2138 | return; | 2140 | return; |
2139 | } | 2141 | } |
2140 | DndFactory factory( mCalendar ); | 2142 | DndFactory factory( mCalendar ); |
2141 | factory.cutEvent(anEvent); | 2143 | factory.cutEvent(anEvent); |
2142 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2144 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2143 | } | 2145 | } |
2144 | 2146 | ||
2145 | void CalendarView::edit_copy() | 2147 | void CalendarView::edit_copy() |
2146 | { | 2148 | { |
2147 | Event *anEvent=0; | 2149 | Event *anEvent=0; |
2148 | 2150 | ||
2149 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2151 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2150 | 2152 | ||
2151 | if (mViewManager->currentView()->isEventView()) { | 2153 | if (mViewManager->currentView()->isEventView()) { |
2152 | if ( incidence && incidence->type() == "Event" ) { | 2154 | if ( incidence && incidence->type() == "Event" ) { |
2153 | anEvent = static_cast<Event *>(incidence); | 2155 | anEvent = static_cast<Event *>(incidence); |
2154 | } | 2156 | } |
2155 | } | 2157 | } |
2156 | 2158 | ||
2157 | if (!anEvent) { | 2159 | if (!anEvent) { |
2158 | KNotifyClient::beep(); | 2160 | KNotifyClient::beep(); |
2159 | return; | 2161 | return; |
2160 | } | 2162 | } |
2161 | DndFactory factory( mCalendar ); | 2163 | DndFactory factory( mCalendar ); |
2162 | factory.copyEvent(anEvent); | 2164 | factory.copyEvent(anEvent); |
2163 | } | 2165 | } |
2164 | 2166 | ||
2165 | void CalendarView::edit_paste() | 2167 | void CalendarView::edit_paste() |
2166 | { | 2168 | { |
2167 | QDate date = mNavigator->selectedDates().first(); | 2169 | QDate date = mNavigator->selectedDates().first(); |
2168 | 2170 | ||
2169 | DndFactory factory( mCalendar ); | 2171 | DndFactory factory( mCalendar ); |
2170 | Event *pastedEvent = factory.pasteEvent( date ); | 2172 | Event *pastedEvent = factory.pasteEvent( date ); |
2171 | 2173 | ||
2172 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2174 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2173 | } | 2175 | } |
2174 | 2176 | ||
2175 | void CalendarView::edit_options() | 2177 | void CalendarView::edit_options() |
2176 | { | 2178 | { |
2177 | mDialogManager->showOptionsDialog(); | 2179 | mDialogManager->showOptionsDialog(); |
2178 | //writeSettings(); | 2180 | //writeSettings(); |
2179 | } | 2181 | } |
2180 | 2182 | ||
2181 | void CalendarView::slotSelectPickerDate( QDate d) | 2183 | void CalendarView::slotSelectPickerDate( QDate d) |
2182 | { | 2184 | { |
2183 | mDateFrame->hide(); | 2185 | mDateFrame->hide(); |
2184 | if ( mDatePickerMode == 1 ) { | 2186 | if ( mDatePickerMode == 1 ) { |
2185 | mNavigator->slotDaySelect( d ); | 2187 | mNavigator->slotDaySelect( d ); |
2186 | } else if ( mDatePickerMode == 2 ) { | 2188 | } else if ( mDatePickerMode == 2 ) { |
2187 | if ( mMoveIncidence->type() == "Todo" ) { | 2189 | if ( mMoveIncidence->type() == "Todo" ) { |
2188 | Todo * to = (Todo *) mMoveIncidence; | 2190 | Todo * to = (Todo *) mMoveIncidence; |
2189 | QTime tim; | 2191 | QTime tim; |
2190 | if ( to->hasDueDate() ) | 2192 | if ( to->hasDueDate() ) |
2191 | tim = to->dtDue().time(); | 2193 | tim = to->dtDue().time(); |
2192 | else { | 2194 | else { |
2193 | tim = QTime ( 0,0,0 ); | 2195 | tim = QTime ( 0,0,0 ); |
2194 | to->setFloats( true ); | 2196 | to->setFloats( true ); |
2195 | to->setHasDueDate( true ); | 2197 | to->setHasDueDate( true ); |
2196 | } | 2198 | } |
2197 | QDateTime dt ( d,tim ); | 2199 | QDateTime dt ( d,tim ); |
2198 | to->setDtDue( dt ); | 2200 | to->setDtDue( dt ); |
2199 | todoChanged( to ); | 2201 | todoChanged( to ); |
2200 | } else { | 2202 | } else { |
2201 | QTime tim = mMoveIncidence->dtStart().time(); | 2203 | QTime tim = mMoveIncidence->dtStart().time(); |
2202 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2204 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2203 | QDateTime dt ( d,tim ); | 2205 | QDateTime dt ( d,tim ); |
2204 | mMoveIncidence->setDtStart( dt ); | 2206 | mMoveIncidence->setDtStart( dt ); |
2205 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2207 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2206 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2208 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2207 | } | 2209 | } |
2208 | 2210 | ||
2209 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2211 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2210 | } | 2212 | } |
2211 | } | 2213 | } |
2212 | 2214 | ||
2213 | void CalendarView::removeCategories() | 2215 | void CalendarView::removeCategories() |
2214 | { | 2216 | { |
2215 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2217 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2216 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2218 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2217 | QStringList catIncList; | 2219 | QStringList catIncList; |
2218 | QStringList newCatList; | 2220 | QStringList newCatList; |
2219 | Incidence* inc = incList.first(); | 2221 | Incidence* inc = incList.first(); |
2220 | int i; | 2222 | int i; |
2221 | int count = 0; | 2223 | int count = 0; |
2222 | while ( inc ) { | 2224 | while ( inc ) { |
2223 | newCatList.clear(); | 2225 | newCatList.clear(); |
2224 | catIncList = inc->categories() ; | 2226 | catIncList = inc->categories() ; |
2225 | for( i = 0; i< catIncList.count(); ++i ) { | 2227 | for( i = 0; i< catIncList.count(); ++i ) { |
2226 | if ( catList.contains (catIncList[i])) | 2228 | if ( catList.contains (catIncList[i])) |
2227 | newCatList.append( catIncList[i] ); | 2229 | newCatList.append( catIncList[i] ); |
2228 | } | 2230 | } |
2229 | newCatList.sort(); | 2231 | newCatList.sort(); |
2230 | inc->setCategories( newCatList.join(",") ); | 2232 | inc->setCategories( newCatList.join(",") ); |
2231 | inc = incList.next(); | 2233 | inc = incList.next(); |
2232 | } | 2234 | } |
2233 | } | 2235 | } |
2234 | 2236 | ||
2235 | int CalendarView::addCategories() | 2237 | int CalendarView::addCategories() |
2236 | { | 2238 | { |
2237 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2239 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2238 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2240 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2239 | QStringList catIncList; | 2241 | QStringList catIncList; |
2240 | Incidence* inc = incList.first(); | 2242 | Incidence* inc = incList.first(); |
2241 | int i; | 2243 | int i; |
2242 | int count = 0; | 2244 | int count = 0; |
2243 | while ( inc ) { | 2245 | while ( inc ) { |
2244 | catIncList = inc->categories() ; | 2246 | catIncList = inc->categories() ; |
2245 | for( i = 0; i< catIncList.count(); ++i ) { | 2247 | for( i = 0; i< catIncList.count(); ++i ) { |
2246 | if ( !catList.contains (catIncList[i])) { | 2248 | if ( !catList.contains (catIncList[i])) { |
2247 | catList.append( catIncList[i] ); | 2249 | catList.append( catIncList[i] ); |
2248 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2250 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2249 | ++count; | 2251 | ++count; |
2250 | } | 2252 | } |
2251 | } | 2253 | } |
2252 | inc = incList.next(); | 2254 | inc = incList.next(); |
2253 | } | 2255 | } |
2254 | catList.sort(); | 2256 | catList.sort(); |
2255 | KOPrefs::instance()->mCustomCategories = catList; | 2257 | KOPrefs::instance()->mCustomCategories = catList; |
2256 | return count; | 2258 | return count; |
2257 | } | 2259 | } |
2258 | 2260 | ||
2259 | void CalendarView::manageCategories() | 2261 | void CalendarView::manageCategories() |
2260 | { | 2262 | { |
2261 | KOCatPrefs* cp = new KOCatPrefs(); | 2263 | KOCatPrefs* cp = new KOCatPrefs(); |
2262 | cp->show(); | 2264 | cp->show(); |
2263 | int w =cp->sizeHint().width() ; | 2265 | int w =cp->sizeHint().width() ; |
2264 | int h = cp->sizeHint().height() ; | 2266 | int h = cp->sizeHint().height() ; |
2265 | int dw = QApplication::desktop()->width(); | 2267 | int dw = QApplication::desktop()->width(); |
2266 | int dh = QApplication::desktop()->height(); | 2268 | int dh = QApplication::desktop()->height(); |
2267 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2269 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2268 | if ( !cp->exec() ) { | 2270 | if ( !cp->exec() ) { |
2269 | delete cp; | 2271 | delete cp; |
2270 | return; | 2272 | return; |
2271 | } | 2273 | } |
2272 | int count = 0; | 2274 | int count = 0; |
2273 | if ( cp->addCat() ) { | 2275 | if ( cp->addCat() ) { |
2274 | count = addCategories(); | 2276 | count = addCategories(); |
2275 | if ( count ) { | 2277 | if ( count ) { |
2276 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2278 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2277 | writeSettings(); | 2279 | writeSettings(); |
2278 | } | 2280 | } |
2279 | } else { | 2281 | } else { |
2280 | removeCategories(); | 2282 | removeCategories(); |
2281 | updateView(); | 2283 | updateView(); |
2282 | } | 2284 | } |
2283 | delete cp; | 2285 | delete cp; |
2284 | } | 2286 | } |
2285 | 2287 | ||
2286 | void CalendarView::beamIncidence(Incidence * Inc) | 2288 | void CalendarView::beamIncidence(Incidence * Inc) |
2287 | { | 2289 | { |
2288 | QPtrList<Incidence> delSel ; | 2290 | QPtrList<Incidence> delSel ; |
2289 | delSel.append(Inc); | 2291 | delSel.append(Inc); |
2290 | beamIncidenceList( delSel ); | 2292 | beamIncidenceList( delSel ); |
2291 | } | 2293 | } |
2292 | void CalendarView::beamCalendar() | 2294 | void CalendarView::beamCalendar() |
2293 | { | 2295 | { |
2294 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2296 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2295 | //qDebug("beamCalendar() "); | 2297 | //qDebug("beamCalendar() "); |
2296 | beamIncidenceList( delSel ); | 2298 | beamIncidenceList( delSel ); |
2297 | } | 2299 | } |
2298 | void CalendarView::beamFilteredCalendar() | 2300 | void CalendarView::beamFilteredCalendar() |
2299 | { | 2301 | { |
2300 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2302 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2301 | //qDebug("beamFilteredCalendar() "); | 2303 | //qDebug("beamFilteredCalendar() "); |
2302 | beamIncidenceList( delSel ); | 2304 | beamIncidenceList( delSel ); |
2303 | } | 2305 | } |
2304 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2306 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2305 | { | 2307 | { |
2306 | if ( beamDialog->exec () == QDialog::Rejected ) | 2308 | if ( beamDialog->exec () == QDialog::Rejected ) |
2307 | return; | 2309 | return; |
2308 | 2310 | ||
2309 | QString fn = "/tmp/kopibeamfile"; | 2311 | QString fn = "/tmp/kopibeamfile"; |
2310 | QString mes; | 2312 | QString mes; |
2311 | bool createbup = true; | 2313 | bool createbup = true; |
2312 | if ( createbup ) { | 2314 | if ( createbup ) { |
2313 | QString description = "\n"; | 2315 | QString description = "\n"; |
2314 | CalendarLocal* cal = new CalendarLocal(); | 2316 | CalendarLocal* cal = new CalendarLocal(); |
2315 | if ( beamDialog->beamLocal() ) | 2317 | if ( beamDialog->beamLocal() ) |
2316 | cal->setLocalTime(); | 2318 | cal->setLocalTime(); |
2317 | else | 2319 | else |
2318 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2320 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2319 | Incidence *incidence = delSel.first(); | 2321 | Incidence *incidence = delSel.first(); |
2320 | bool addText = false; | 2322 | bool addText = false; |
2321 | if ( delSel.count() < 10 ) | 2323 | if ( delSel.count() < 10 ) |
2322 | addText = true; | 2324 | addText = true; |
2323 | else { | 2325 | else { |
2324 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2326 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2325 | } | 2327 | } |
2326 | while ( incidence ) { | 2328 | while ( incidence ) { |
2327 | Incidence *in = incidence->clone(); | 2329 | Incidence *in = incidence->clone(); |
2328 | if ( ! in->summary().isEmpty() ) { | 2330 | if ( ! in->summary().isEmpty() ) { |
2329 | in->setDescription(""); | 2331 | in->setDescription(""); |
2330 | } else { | 2332 | } else { |
2331 | in->setSummary( in->description().left(20)); | 2333 | in->setSummary( in->description().left(20)); |
2332 | in->setDescription(""); | 2334 | in->setDescription(""); |
2333 | } | 2335 | } |
2334 | if ( addText ) | 2336 | if ( addText ) |
2335 | description += in->summary() + "\n"; | 2337 | description += in->summary() + "\n"; |
2336 | cal->addIncidence( in ); | 2338 | cal->addIncidence( in ); |
2337 | incidence = delSel.next(); | 2339 | incidence = delSel.next(); |
2338 | } | 2340 | } |
2339 | if ( beamDialog->beamVcal() ) { | 2341 | if ( beamDialog->beamVcal() ) { |
2340 | fn += ".vcs"; | 2342 | fn += ".vcs"; |
2341 | FileStorage storage( cal, fn, new VCalFormat ); | 2343 | FileStorage storage( cal, fn, new VCalFormat ); |
2342 | storage.save(); | 2344 | storage.save(); |
2343 | } else { | 2345 | } else { |
2344 | fn += ".ics"; | 2346 | fn += ".ics"; |
2345 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2347 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2346 | storage.save(); | 2348 | storage.save(); |
2347 | } | 2349 | } |
2348 | delete cal; | 2350 | delete cal; |
2349 | mes = i18n("KO/Pi: Ready for beaming"); | 2351 | mes = i18n("KO/Pi: Ready for beaming"); |
2350 | topLevelWidget()->setCaption(mes); | 2352 | topLevelWidget()->setCaption(mes); |
2351 | KApplication::convert2latin1( fn ); | 2353 | KApplication::convert2latin1( fn ); |
2352 | #ifndef DESKTOP_VERSION | 2354 | #ifndef DESKTOP_VERSION |
2353 | Ir *ir = new Ir( this ); | 2355 | Ir *ir = new Ir( this ); |
2354 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2356 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2355 | ir->send( fn, description, "text/x-vCalendar" ); | 2357 | ir->send( fn, description, "text/x-vCalendar" ); |
2356 | #endif | 2358 | #endif |
2357 | } | 2359 | } |
2358 | } | 2360 | } |
2359 | void CalendarView::beamDone( Ir *ir ) | 2361 | void CalendarView::beamDone( Ir *ir ) |
2360 | { | 2362 | { |
2361 | #ifndef DESKTOP_VERSION | 2363 | #ifndef DESKTOP_VERSION |
2362 | delete ir; | 2364 | delete ir; |
2363 | #endif | 2365 | #endif |
2364 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2366 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2365 | topLevelWidget()->raise(); | 2367 | topLevelWidget()->raise(); |
2366 | } | 2368 | } |
2367 | 2369 | ||
2368 | void CalendarView::moveIncidence(Incidence * inc ) | 2370 | void CalendarView::moveIncidence(Incidence * inc ) |
2369 | { | 2371 | { |
2370 | if ( !inc ) return; | 2372 | if ( !inc ) return; |
2371 | // qDebug("showDatePickerForIncidence( ) "); | 2373 | // qDebug("showDatePickerForIncidence( ) "); |
2372 | if ( mDateFrame->isVisible() ) | 2374 | if ( mDateFrame->isVisible() ) |
2373 | mDateFrame->hide(); | 2375 | mDateFrame->hide(); |
2374 | else { | 2376 | else { |
2375 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2377 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2376 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2378 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2377 | int dw = QApplication::desktop()->width(); | 2379 | int dw = QApplication::desktop()->width(); |
2378 | int dh = QApplication::desktop()->height(); | 2380 | int dh = QApplication::desktop()->height(); |
2379 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2381 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2380 | mDateFrame->show(); | 2382 | mDateFrame->show(); |
2381 | } | 2383 | } |
2382 | mDatePickerMode = 2; | 2384 | mDatePickerMode = 2; |
2383 | mMoveIncidence = inc ; | 2385 | mMoveIncidence = inc ; |
2384 | QDate da; | 2386 | QDate da; |
2385 | if ( mMoveIncidence->type() == "Todo" ) { | 2387 | if ( mMoveIncidence->type() == "Todo" ) { |
2386 | Todo * to = (Todo *) mMoveIncidence; | 2388 | Todo * to = (Todo *) mMoveIncidence; |
2387 | if ( to->hasDueDate() ) | 2389 | if ( to->hasDueDate() ) |
2388 | da = to->dtDue().date(); | 2390 | da = to->dtDue().date(); |
2389 | else | 2391 | else |
2390 | da = QDate::currentDate(); | 2392 | da = QDate::currentDate(); |
2391 | } else { | 2393 | } else { |
2392 | da = mMoveIncidence->dtStart().date(); | 2394 | da = mMoveIncidence->dtStart().date(); |
2393 | } | 2395 | } |
2394 | mDatePicker->setDate( da ); | 2396 | mDatePicker->setDate( da ); |
2395 | } | 2397 | } |
2396 | void CalendarView::showDatePicker( ) | 2398 | void CalendarView::showDatePicker( ) |
2397 | { | 2399 | { |
2398 | //qDebug("CalendarView::showDatePicker( ) "); | 2400 | //qDebug("CalendarView::showDatePicker( ) "); |
2399 | if ( mDateFrame->isVisible() ) | 2401 | if ( mDateFrame->isVisible() ) |
2400 | mDateFrame->hide(); | 2402 | mDateFrame->hide(); |
2401 | else { | 2403 | else { |
2402 | int w =mDatePicker->sizeHint().width() ; | 2404 | int w =mDatePicker->sizeHint().width() ; |
2403 | int h = mDatePicker->sizeHint().height() ; | 2405 | int h = mDatePicker->sizeHint().height() ; |
2404 | int dw = QApplication::desktop()->width(); | 2406 | int dw = QApplication::desktop()->width(); |
2405 | int dh = QApplication::desktop()->height(); | 2407 | int dh = QApplication::desktop()->height(); |
2406 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2408 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2407 | mDateFrame->show(); | 2409 | mDateFrame->show(); |
2408 | } | 2410 | } |
2409 | mDatePickerMode = 1; | 2411 | mDatePickerMode = 1; |
2410 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2412 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2411 | } | 2413 | } |
2412 | 2414 | ||
2413 | void CalendarView::showEventEditor() | 2415 | void CalendarView::showEventEditor() |
2414 | { | 2416 | { |
2415 | #ifdef DESKTOP_VERSION | 2417 | #ifdef DESKTOP_VERSION |
2416 | mEventEditor->show(); | 2418 | mEventEditor->show(); |
2417 | #else | 2419 | #else |
2418 | mEventEditor->showMaximized(); | 2420 | mEventEditor->showMaximized(); |
2419 | #endif | 2421 | #endif |
2420 | } | 2422 | } |
2421 | void CalendarView::showTodoEditor() | 2423 | void CalendarView::showTodoEditor() |
2422 | { | 2424 | { |
2423 | #ifdef DESKTOP_VERSION | 2425 | #ifdef DESKTOP_VERSION |
2424 | mTodoEditor->show(); | 2426 | mTodoEditor->show(); |
2425 | #else | 2427 | #else |
2426 | mTodoEditor->showMaximized(); | 2428 | mTodoEditor->showMaximized(); |
2427 | #endif | 2429 | #endif |
2428 | } | 2430 | } |
2429 | 2431 | ||
2430 | void CalendarView::cloneIncidence() | 2432 | void CalendarView::cloneIncidence() |
2431 | { | 2433 | { |
2432 | Incidence *incidence = currentSelection(); | 2434 | Incidence *incidence = currentSelection(); |
2433 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2435 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2434 | if ( incidence ) { | 2436 | if ( incidence ) { |
2435 | cloneIncidence(incidence); | 2437 | cloneIncidence(incidence); |
2436 | } | 2438 | } |
2437 | } | 2439 | } |
2438 | void CalendarView::moveIncidence() | 2440 | void CalendarView::moveIncidence() |
2439 | { | 2441 | { |
2440 | Incidence *incidence = currentSelection(); | 2442 | Incidence *incidence = currentSelection(); |
2441 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2443 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2442 | if ( incidence ) { | 2444 | if ( incidence ) { |
2443 | moveIncidence(incidence); | 2445 | moveIncidence(incidence); |
2444 | } | 2446 | } |
2445 | } | 2447 | } |
2446 | void CalendarView::beamIncidence() | 2448 | void CalendarView::beamIncidence() |
2447 | { | 2449 | { |
2448 | Incidence *incidence = currentSelection(); | 2450 | Incidence *incidence = currentSelection(); |
2449 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2451 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2450 | if ( incidence ) { | 2452 | if ( incidence ) { |
2451 | beamIncidence(incidence); | 2453 | beamIncidence(incidence); |
2452 | } | 2454 | } |
2453 | } | 2455 | } |
2454 | void CalendarView::toggleCancelIncidence() | 2456 | void CalendarView::toggleCancelIncidence() |
2455 | { | 2457 | { |
2456 | Incidence *incidence = currentSelection(); | 2458 | Incidence *incidence = currentSelection(); |
2457 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2459 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2458 | if ( incidence ) { | 2460 | if ( incidence ) { |
2459 | cancelIncidence(incidence); | 2461 | cancelIncidence(incidence); |
2460 | } | 2462 | } |
2461 | } | 2463 | } |
2462 | 2464 | ||
2463 | 2465 | ||
2464 | void CalendarView::cancelIncidence(Incidence * inc ) | 2466 | void CalendarView::cancelIncidence(Incidence * inc ) |
2465 | { | 2467 | { |
2466 | inc->setCancelled( ! inc->cancelled() ); | 2468 | inc->setCancelled( ! inc->cancelled() ); |
2467 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2469 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2468 | updateView(); | 2470 | updateView(); |
2469 | } | 2471 | } |
2470 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2472 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2471 | { | 2473 | { |
2472 | Incidence * newInc = orgInc->clone(); | 2474 | Incidence * newInc = orgInc->clone(); |
2473 | newInc->recreate(); | 2475 | newInc->recreate(); |
2474 | 2476 | ||
2475 | if ( newInc->type() == "Todo" ) { | 2477 | if ( newInc->type() == "Todo" ) { |
2476 | Todo* t = (Todo*) newInc; | 2478 | Todo* t = (Todo*) newInc; |
2477 | mTodoEditor->editTodo( t ); | 2479 | mTodoEditor->editTodo( t ); |
2478 | showTodoEditor(); | 2480 | showTodoEditor(); |
2479 | if ( mTodoEditor->exec() ) { | 2481 | if ( mTodoEditor->exec() ) { |
2480 | mCalendar->addTodo( t ); | 2482 | mCalendar->addTodo( t ); |
2481 | updateView(); | 2483 | updateView(); |
2482 | } else { | 2484 | } else { |
2483 | delete t; | 2485 | delete t; |
2484 | } | 2486 | } |
2485 | } | 2487 | } |
2486 | else { | 2488 | else { |
2487 | Event* e = (Event*) newInc; | 2489 | Event* e = (Event*) newInc; |
2488 | mEventEditor->editEvent( e ); | 2490 | mEventEditor->editEvent( e ); |
2489 | showEventEditor(); | 2491 | showEventEditor(); |
2490 | if ( mEventEditor->exec() ) { | 2492 | if ( mEventEditor->exec() ) { |
2491 | mCalendar->addEvent( e ); | 2493 | mCalendar->addEvent( e ); |
2492 | updateView(); | 2494 | updateView(); |
2493 | } else { | 2495 | } else { |
2494 | delete e; | 2496 | delete e; |
2495 | } | 2497 | } |
2496 | } | 2498 | } |
2497 | } | 2499 | } |
2498 | 2500 | ||
2499 | void CalendarView::newEvent() | 2501 | void CalendarView::newEvent() |
2500 | { | 2502 | { |
2501 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2503 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2502 | KOAgendaView *aView = mViewManager->agendaView(); | 2504 | KOAgendaView *aView = mViewManager->agendaView(); |
2503 | if (aView) { | 2505 | if (aView) { |
2504 | if (aView->selectionStart().isValid()) { | 2506 | if (aView->selectionStart().isValid()) { |
2505 | if (aView->selectedIsAllDay()) { | 2507 | if (aView->selectedIsAllDay()) { |
2506 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2508 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2507 | } else { | 2509 | } else { |
2508 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2510 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2509 | } | 2511 | } |
2510 | return; | 2512 | return; |
2511 | } | 2513 | } |
2512 | } | 2514 | } |
2513 | 2515 | ||
2514 | QDate date = mNavigator->selectedDates().first(); | 2516 | QDate date = mNavigator->selectedDates().first(); |
2515 | QDateTime current = QDateTime::currentDateTime(); | 2517 | QDateTime current = QDateTime::currentDateTime(); |
2516 | if ( date <= current.date() ) { | 2518 | if ( date <= current.date() ) { |
2517 | int hour = current.time().hour() +1; | 2519 | int hour = current.time().hour() +1; |
2518 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2520 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2519 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2521 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2520 | } else | 2522 | } else |
2521 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2523 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2522 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2524 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2523 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2525 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2524 | } | 2526 | } |
2525 | 2527 | ||
2526 | void CalendarView::newEvent(QDateTime fh) | 2528 | void CalendarView::newEvent(QDateTime fh) |
2527 | { | 2529 | { |
2528 | newEvent(fh, | 2530 | newEvent(fh, |
2529 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2531 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2530 | } | 2532 | } |
2531 | 2533 | ||
2532 | void CalendarView::newEvent(QDate dt) | 2534 | void CalendarView::newEvent(QDate dt) |
2533 | { | 2535 | { |
2534 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2536 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2535 | QDateTime(dt, QTime(0,0,0)), true); | 2537 | QDateTime(dt, QTime(0,0,0)), true); |
2536 | } | 2538 | } |
2537 | 2539 | ||
2538 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2540 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2539 | { | 2541 | { |
2540 | 2542 | ||
2541 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2543 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2542 | if ( mFilterView->filtersEnabled() ) { | 2544 | if ( mFilterView->filtersEnabled() ) { |
2543 | CalFilter *filter = mFilterView->selectedFilter(); | 2545 | CalFilter *filter = mFilterView->selectedFilter(); |
2544 | if (filter && filter->showCategories()) { | 2546 | if (filter && filter->showCategories()) { |
2545 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2547 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2546 | } | 2548 | } |
2547 | if ( filter ) | 2549 | if ( filter ) |
2548 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2550 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2549 | } | 2551 | } |
2550 | showEventEditor(); | 2552 | showEventEditor(); |
2551 | } | 2553 | } |
2552 | void CalendarView::todoAdded(Todo * t) | 2554 | void CalendarView::todoAdded(Todo * t) |
2553 | { | 2555 | { |
2554 | 2556 | ||
2555 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2557 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2556 | updateTodoViews(); | 2558 | updateTodoViews(); |
2557 | } | 2559 | } |
2558 | void CalendarView::todoChanged(Todo * t) | 2560 | void CalendarView::todoChanged(Todo * t) |
2559 | { | 2561 | { |
2560 | emit todoModified( t, 4 ); | 2562 | emit todoModified( t, 4 ); |
2561 | // updateTodoViews(); | 2563 | // updateTodoViews(); |
2562 | } | 2564 | } |
2563 | void CalendarView::todoToBeDeleted(Todo *) | 2565 | void CalendarView::todoToBeDeleted(Todo *) |
2564 | { | 2566 | { |
2565 | //qDebug("todoToBeDeleted(Todo *) "); | 2567 | //qDebug("todoToBeDeleted(Todo *) "); |
2566 | updateTodoViews(); | 2568 | updateTodoViews(); |
2567 | } | 2569 | } |
2568 | void CalendarView::todoDeleted() | 2570 | void CalendarView::todoDeleted() |
2569 | { | 2571 | { |
2570 | //qDebug(" todoDeleted()"); | 2572 | //qDebug(" todoDeleted()"); |
2571 | updateTodoViews(); | 2573 | updateTodoViews(); |
2572 | } | 2574 | } |
2573 | 2575 | ||
2574 | 2576 | ||
2575 | 2577 | ||
2576 | void CalendarView::newTodo() | 2578 | void CalendarView::newTodo() |
2577 | { | 2579 | { |
2578 | 2580 | ||
2579 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2581 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2580 | if ( mFilterView->filtersEnabled() ) { | 2582 | if ( mFilterView->filtersEnabled() ) { |
2581 | CalFilter *filter = mFilterView->selectedFilter(); | 2583 | CalFilter *filter = mFilterView->selectedFilter(); |
2582 | if (filter && filter->showCategories()) { | 2584 | if (filter && filter->showCategories()) { |
2583 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2585 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2584 | } | 2586 | } |
2585 | if ( filter ) | 2587 | if ( filter ) |
2586 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2588 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2587 | } | 2589 | } |
2588 | showTodoEditor(); | 2590 | showTodoEditor(); |
2589 | } | 2591 | } |
2590 | 2592 | ||
2591 | void CalendarView::newSubTodo() | 2593 | void CalendarView::newSubTodo() |
2592 | { | 2594 | { |
2593 | Todo *todo = selectedTodo(); | 2595 | Todo *todo = selectedTodo(); |
2594 | if ( todo ) newSubTodo( todo ); | 2596 | if ( todo ) newSubTodo( todo ); |
2595 | } | 2597 | } |
2596 | 2598 | ||
2597 | void CalendarView::newSubTodo(Todo *parentEvent) | 2599 | void CalendarView::newSubTodo(Todo *parentEvent) |
2598 | { | 2600 | { |
2599 | 2601 | ||
2600 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2602 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2601 | showTodoEditor(); | 2603 | showTodoEditor(); |
2602 | } | 2604 | } |
2603 | 2605 | ||
2604 | void CalendarView::newFloatingEvent() | 2606 | void CalendarView::newFloatingEvent() |
2605 | { | 2607 | { |
2606 | DateList tmpList = mNavigator->selectedDates(); | 2608 | DateList tmpList = mNavigator->selectedDates(); |
2607 | QDate date = tmpList.first(); | 2609 | QDate date = tmpList.first(); |
2608 | 2610 | ||
2609 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2611 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2610 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2612 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2611 | } | 2613 | } |
2612 | 2614 | ||
2613 | 2615 | ||
2614 | void CalendarView::editEvent( Event *event ) | 2616 | void CalendarView::editEvent( Event *event ) |
2615 | { | 2617 | { |
2616 | 2618 | ||
2617 | if ( !event ) return; | 2619 | if ( !event ) return; |
2618 | if ( event->isReadOnly() ) { | 2620 | if ( event->isReadOnly() ) { |
2619 | showEvent( event ); | 2621 | showEvent( event ); |
2620 | return; | 2622 | return; |
2621 | } | 2623 | } |
2622 | mEventEditor->editEvent( event , mFlagEditDescription); | 2624 | mEventEditor->editEvent( event , mFlagEditDescription); |
2623 | showEventEditor(); | 2625 | showEventEditor(); |
2624 | } | 2626 | } |
2625 | void CalendarView::editJournal( Journal *jour ) | 2627 | void CalendarView::editJournal( Journal *jour ) |
2626 | { | 2628 | { |
2627 | if ( !jour ) return; | 2629 | if ( !jour ) return; |
2628 | mDialogManager->hideSearchDialog(); | 2630 | mDialogManager->hideSearchDialog(); |
2629 | mViewManager->showJournalView(); | 2631 | mViewManager->showJournalView(); |
2630 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2632 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2631 | } | 2633 | } |
2632 | void CalendarView::editTodo( Todo *todo ) | 2634 | void CalendarView::editTodo( Todo *todo ) |
2633 | { | 2635 | { |
2634 | if ( !todo ) return; | 2636 | if ( !todo ) return; |
2635 | 2637 | ||
2636 | if ( todo->isReadOnly() ) { | 2638 | if ( todo->isReadOnly() ) { |
2637 | showTodo( todo ); | 2639 | showTodo( todo ); |
2638 | return; | 2640 | return; |
2639 | } | 2641 | } |
2640 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2642 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2641 | showTodoEditor(); | 2643 | showTodoEditor(); |
2642 | 2644 | ||
2643 | } | 2645 | } |
2644 | 2646 | ||
2645 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2647 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2646 | { | 2648 | { |
2647 | if ( !mEventViewerDialog ) { | 2649 | if ( !mEventViewerDialog ) { |
2648 | mEventViewerDialog = new KOEventViewerDialog(this); | 2650 | mEventViewerDialog = new KOEventViewerDialog(this); |
2649 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2651 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2650 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2652 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2651 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2653 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2652 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2654 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2653 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2655 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2654 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2656 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2655 | mEventViewerDialog->resize( 640, 480 ); | 2657 | mEventViewerDialog->resize( 640, 480 ); |
2656 | 2658 | ||
2657 | } | 2659 | } |
2658 | return mEventViewerDialog; | 2660 | return mEventViewerDialog; |
2659 | } | 2661 | } |
2660 | void CalendarView::showEvent(Event *event) | 2662 | void CalendarView::showEvent(Event *event) |
2661 | { | 2663 | { |
2662 | getEventViewerDialog()->setEvent(event); | 2664 | getEventViewerDialog()->setEvent(event); |
2663 | getEventViewerDialog()->showMe(); | 2665 | getEventViewerDialog()->showMe(); |
2664 | } | 2666 | } |
2665 | 2667 | ||
2666 | void CalendarView::showTodo(Todo *event) | 2668 | void CalendarView::showTodo(Todo *event) |
2667 | { | 2669 | { |
2668 | getEventViewerDialog()->setTodo(event); | 2670 | getEventViewerDialog()->setTodo(event); |
2669 | getEventViewerDialog()->showMe(); | 2671 | getEventViewerDialog()->showMe(); |
2670 | } | 2672 | } |
2671 | void CalendarView::showJournal( Journal *jour ) | 2673 | void CalendarView::showJournal( Journal *jour ) |
2672 | { | 2674 | { |
2673 | getEventViewerDialog()->setJournal(jour); | 2675 | getEventViewerDialog()->setJournal(jour); |
2674 | getEventViewerDialog()->showMe(); | 2676 | getEventViewerDialog()->showMe(); |
2675 | 2677 | ||
2676 | } | 2678 | } |
2677 | // void CalendarView::todoModified (Todo *event, int changed) | 2679 | // void CalendarView::todoModified (Todo *event, int changed) |
2678 | // { | 2680 | // { |
2679 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2681 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2680 | // // kdDebug() << "Todo modified and open" << endl; | 2682 | // // kdDebug() << "Todo modified and open" << endl; |
2681 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2683 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2682 | // // temp->modified (changed); | 2684 | // // temp->modified (changed); |
2683 | 2685 | ||
2684 | // // } | 2686 | // // } |
2685 | 2687 | ||
2686 | // mViewManager->updateView(); | 2688 | // mViewManager->updateView(); |
2687 | // } | 2689 | // } |
2688 | 2690 | ||
2689 | void CalendarView::appointment_show() | 2691 | void CalendarView::appointment_show() |
2690 | { | 2692 | { |
2691 | Event *anEvent = 0; | 2693 | Event *anEvent = 0; |
2692 | 2694 | ||
2693 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2695 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2694 | 2696 | ||
2695 | if (mViewManager->currentView()->isEventView()) { | 2697 | if (mViewManager->currentView()->isEventView()) { |
2696 | if ( incidence && incidence->type() == "Event" ) { | 2698 | if ( incidence && incidence->type() == "Event" ) { |
2697 | anEvent = static_cast<Event *>(incidence); | 2699 | anEvent = static_cast<Event *>(incidence); |
2698 | } | 2700 | } |
2699 | } | 2701 | } |
2700 | 2702 | ||
2701 | if (!anEvent) { | 2703 | if (!anEvent) { |
2702 | KNotifyClient::beep(); | 2704 | KNotifyClient::beep(); |
2703 | return; | 2705 | return; |
2704 | } | 2706 | } |
2705 | 2707 | ||
2706 | showEvent(anEvent); | 2708 | showEvent(anEvent); |
2707 | } | 2709 | } |
2708 | 2710 | ||
2709 | void CalendarView::appointment_edit() | 2711 | void CalendarView::appointment_edit() |
2710 | { | 2712 | { |
2711 | Event *anEvent = 0; | 2713 | Event *anEvent = 0; |
2712 | 2714 | ||
2713 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2715 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2714 | 2716 | ||
2715 | if (mViewManager->currentView()->isEventView()) { | 2717 | if (mViewManager->currentView()->isEventView()) { |
2716 | if ( incidence && incidence->type() == "Event" ) { | 2718 | if ( incidence && incidence->type() == "Event" ) { |
2717 | anEvent = static_cast<Event *>(incidence); | 2719 | anEvent = static_cast<Event *>(incidence); |
2718 | } | 2720 | } |
2719 | } | 2721 | } |
2720 | 2722 | ||
2721 | if (!anEvent) { | 2723 | if (!anEvent) { |
2722 | KNotifyClient::beep(); | 2724 | KNotifyClient::beep(); |
2723 | return; | 2725 | return; |
2724 | } | 2726 | } |
2725 | 2727 | ||
2726 | editEvent(anEvent); | 2728 | editEvent(anEvent); |
2727 | } | 2729 | } |
2728 | 2730 | ||
2729 | void CalendarView::appointment_delete() | 2731 | void CalendarView::appointment_delete() |
2730 | { | 2732 | { |
2731 | Event *anEvent = 0; | 2733 | Event *anEvent = 0; |
2732 | 2734 | ||
2733 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2735 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2734 | 2736 | ||
2735 | if (mViewManager->currentView()->isEventView()) { | 2737 | if (mViewManager->currentView()->isEventView()) { |
2736 | if ( incidence && incidence->type() == "Event" ) { | 2738 | if ( incidence && incidence->type() == "Event" ) { |
2737 | anEvent = static_cast<Event *>(incidence); | 2739 | anEvent = static_cast<Event *>(incidence); |
2738 | } | 2740 | } |
2739 | } | 2741 | } |
2740 | 2742 | ||
2741 | if (!anEvent) { | 2743 | if (!anEvent) { |
2742 | KNotifyClient::beep(); | 2744 | KNotifyClient::beep(); |
2743 | return; | 2745 | return; |
2744 | } | 2746 | } |
2745 | 2747 | ||
2746 | deleteEvent(anEvent); | 2748 | deleteEvent(anEvent); |
2747 | } | 2749 | } |
2748 | 2750 | ||
2751 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | ||
2752 | { | ||
2753 | if (!sub) return; | ||
2754 | if (!parent) return; | ||
2755 | if ( sub->relatedTo() ) | ||
2756 | sub->relatedTo()->removeRelation(sub); | ||
2757 | sub->setRelatedTo(parent); | ||
2758 | sub->setRelatedToUid(parent->uid()); | ||
2759 | parent->addRelation(sub); | ||
2760 | sub->updated(); | ||
2761 | parent->updated(); | ||
2762 | setModified(true); | ||
2763 | updateView(); | ||
2764 | } | ||
2749 | void CalendarView::todo_unsub(Todo *anTodo ) | 2765 | void CalendarView::todo_unsub(Todo *anTodo ) |
2750 | { | 2766 | { |
2751 | // Todo *anTodo = selectedTodo(); | 2767 | // Todo *anTodo = selectedTodo(); |
2752 | if (!anTodo) return; | 2768 | if (!anTodo) return; |
2753 | if (!anTodo->relatedTo()) return; | 2769 | if (!anTodo->relatedTo()) return; |
2754 | anTodo->relatedTo()->removeRelation(anTodo); | 2770 | anTodo->relatedTo()->removeRelation(anTodo); |
2755 | anTodo->setRelatedTo(0); | 2771 | anTodo->setRelatedTo(0); |
2756 | anTodo->updated(); | 2772 | anTodo->updated(); |
2757 | anTodo->setRelatedToUid(""); | 2773 | anTodo->setRelatedToUid(""); |
2758 | setModified(true); | 2774 | setModified(true); |
2759 | updateView(); | 2775 | updateView(); |
2760 | } | 2776 | } |
2761 | 2777 | ||
2762 | void CalendarView::deleteTodo(Todo *todo) | 2778 | void CalendarView::deleteTodo(Todo *todo) |
2763 | { | 2779 | { |
2764 | if (!todo) { | 2780 | if (!todo) { |
2765 | KNotifyClient::beep(); | 2781 | KNotifyClient::beep(); |
2766 | return; | 2782 | return; |
2767 | } | 2783 | } |
2768 | if (KOPrefs::instance()->mConfirm) { | 2784 | if (KOPrefs::instance()->mConfirm) { |
2769 | switch (msgItemDelete()) { | 2785 | switch (msgItemDelete()) { |
2770 | case KMessageBox::Continue: // OK | 2786 | case KMessageBox::Continue: // OK |
2771 | if (!todo->relations().isEmpty()) { | 2787 | if (!todo->relations().isEmpty()) { |
2772 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2788 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2773 | i18n("Delete To-Do")); | 2789 | i18n("Delete To-Do")); |
2774 | } else { | 2790 | } else { |
2775 | checkExternalId( todo ); | 2791 | checkExternalId( todo ); |
2776 | calendar()->deleteTodo(todo); | 2792 | calendar()->deleteTodo(todo); |
2777 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2793 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2778 | updateView(); | 2794 | updateView(); |
2779 | } | 2795 | } |
2780 | break; | 2796 | break; |
2781 | } // switch | 2797 | } // switch |
2782 | } else { | 2798 | } else { |
2783 | if (!todo->relations().isEmpty()) { | 2799 | if (!todo->relations().isEmpty()) { |
2784 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2785 | i18n("Delete To-Do")); | 2801 | i18n("Delete To-Do")); |
2786 | } else { | 2802 | } else { |
2787 | checkExternalId( todo ); | 2803 | checkExternalId( todo ); |
2788 | mCalendar->deleteTodo(todo); | 2804 | mCalendar->deleteTodo(todo); |
2789 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2790 | updateView(); | 2806 | updateView(); |
2791 | } | 2807 | } |
2792 | } | 2808 | } |
2793 | emit updateSearchDialog(); | 2809 | emit updateSearchDialog(); |
2794 | } | 2810 | } |
2795 | void CalendarView::deleteJournal(Journal *jour) | 2811 | void CalendarView::deleteJournal(Journal *jour) |
2796 | { | 2812 | { |
2797 | if (!jour) { | 2813 | if (!jour) { |
2798 | KNotifyClient::beep(); | 2814 | KNotifyClient::beep(); |
2799 | return; | 2815 | return; |
2800 | } | 2816 | } |
2801 | if (KOPrefs::instance()->mConfirm) { | 2817 | if (KOPrefs::instance()->mConfirm) { |
2802 | switch (msgItemDelete()) { | 2818 | switch (msgItemDelete()) { |
2803 | case KMessageBox::Continue: // OK | 2819 | case KMessageBox::Continue: // OK |
2804 | calendar()->deleteJournal(jour); | 2820 | calendar()->deleteJournal(jour); |
2805 | updateView(); | 2821 | updateView(); |
2806 | break; | 2822 | break; |
2807 | } // switch | 2823 | } // switch |
2808 | } else { | 2824 | } else { |
2809 | calendar()->deleteJournal(jour);; | 2825 | calendar()->deleteJournal(jour);; |
2810 | updateView(); | 2826 | updateView(); |
2811 | } | 2827 | } |
2812 | emit updateSearchDialog(); | 2828 | emit updateSearchDialog(); |
2813 | } | 2829 | } |
2814 | 2830 | ||
2815 | void CalendarView::deleteEvent(Event *anEvent) | 2831 | void CalendarView::deleteEvent(Event *anEvent) |
2816 | { | 2832 | { |
2817 | if (!anEvent) { | 2833 | if (!anEvent) { |
2818 | KNotifyClient::beep(); | 2834 | KNotifyClient::beep(); |
2819 | return; | 2835 | return; |
2820 | } | 2836 | } |
2821 | 2837 | ||
2822 | if (anEvent->recurrence()->doesRecur()) { | 2838 | if (anEvent->recurrence()->doesRecur()) { |
2823 | QDate itemDate = mViewManager->currentSelectionDate(); | 2839 | QDate itemDate = mViewManager->currentSelectionDate(); |
2824 | int km; | 2840 | int km; |
2825 | if (!itemDate.isValid()) { | 2841 | if (!itemDate.isValid()) { |
2826 | //kdDebug() << "Date Not Valid" << endl; | 2842 | //kdDebug() << "Date Not Valid" << endl; |
2827 | if (KOPrefs::instance()->mConfirm) { | 2843 | if (KOPrefs::instance()->mConfirm) { |
2828 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2844 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2829 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2845 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2830 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2846 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2831 | if ( km == KMessageBox::Continue ) | 2847 | if ( km == KMessageBox::Continue ) |
2832 | km = KMessageBox::No; // No = all below | 2848 | km = KMessageBox::No; // No = all below |
2833 | } else | 2849 | } else |
2834 | km = KMessageBox::No; | 2850 | km = KMessageBox::No; |
2835 | } else { | 2851 | } else { |
2836 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2852 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2837 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2853 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2838 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2854 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2839 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2855 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2840 | i18n("All")); | 2856 | i18n("All")); |
2841 | } | 2857 | } |
2842 | switch(km) { | 2858 | switch(km) { |
2843 | 2859 | ||
2844 | case KMessageBox::No: // Continue // all | 2860 | case KMessageBox::No: // Continue // all |
2845 | //qDebug("KMessageBox::No "); | 2861 | //qDebug("KMessageBox::No "); |
2846 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2862 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2847 | schedule(Scheduler::Cancel,anEvent); | 2863 | schedule(Scheduler::Cancel,anEvent); |
2848 | 2864 | ||
2849 | checkExternalId( anEvent); | 2865 | checkExternalId( anEvent); |
2850 | mCalendar->deleteEvent(anEvent); | 2866 | mCalendar->deleteEvent(anEvent); |
2851 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2867 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2852 | break; | 2868 | break; |
2853 | 2869 | ||
2854 | // Disabled because it does not work | 2870 | // Disabled because it does not work |
2855 | //#if 0 | 2871 | //#if 0 |
2856 | case KMessageBox::Yes: // just this one | 2872 | case KMessageBox::Yes: // just this one |
2857 | //QDate qd = mNavigator->selectedDates().first(); | 2873 | //QDate qd = mNavigator->selectedDates().first(); |
2858 | //if (!qd.isValid()) { | 2874 | //if (!qd.isValid()) { |
2859 | // kdDebug() << "no date selected, or invalid date" << endl; | 2875 | // kdDebug() << "no date selected, or invalid date" << endl; |
2860 | // KNotifyClient::beep(); | 2876 | // KNotifyClient::beep(); |
2861 | // return; | 2877 | // return; |
2862 | //} | 2878 | //} |
2863 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2879 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2864 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2880 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2865 | anEvent->addExDate(itemDate); | 2881 | anEvent->addExDate(itemDate); |
2866 | int duration = anEvent->recurrence()->duration(); | 2882 | int duration = anEvent->recurrence()->duration(); |
2867 | if ( duration > 0 ) { | 2883 | if ( duration > 0 ) { |
2868 | anEvent->recurrence()->setDuration( duration - 1 ); | 2884 | anEvent->recurrence()->setDuration( duration - 1 ); |
2869 | } | 2885 | } |
2870 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2886 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2871 | } | 2887 | } |
2872 | break; | 2888 | break; |
2873 | //#endif | 2889 | //#endif |
2874 | } // switch | 2890 | } // switch |
2875 | } else { | 2891 | } else { |
2876 | if (KOPrefs::instance()->mConfirm) { | 2892 | if (KOPrefs::instance()->mConfirm) { |
2877 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2893 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2878 | i18n("\nAre you sure you want\nto delete this event?"), | 2894 | i18n("\nAre you sure you want\nto delete this event?"), |
2879 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2895 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2880 | case KMessageBox::Continue: // OK | 2896 | case KMessageBox::Continue: // OK |
2881 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2897 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2882 | schedule(Scheduler::Cancel,anEvent); | 2898 | schedule(Scheduler::Cancel,anEvent); |
2883 | checkExternalId( anEvent); | 2899 | checkExternalId( anEvent); |
2884 | mCalendar->deleteEvent(anEvent); | 2900 | mCalendar->deleteEvent(anEvent); |
2885 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2901 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2886 | break; | 2902 | break; |
2887 | } // switch | 2903 | } // switch |
2888 | } else { | 2904 | } else { |
2889 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2905 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2890 | schedule(Scheduler::Cancel,anEvent); | 2906 | schedule(Scheduler::Cancel,anEvent); |
2891 | checkExternalId( anEvent); | 2907 | checkExternalId( anEvent); |
2892 | mCalendar->deleteEvent(anEvent); | 2908 | mCalendar->deleteEvent(anEvent); |
2893 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2909 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2894 | } | 2910 | } |
2895 | } // if-else | 2911 | } // if-else |
2896 | emit updateSearchDialog(); | 2912 | emit updateSearchDialog(); |
2897 | } | 2913 | } |
2898 | 2914 | ||
2899 | bool CalendarView::deleteEvent(const QString &uid) | 2915 | bool CalendarView::deleteEvent(const QString &uid) |
2900 | { | 2916 | { |
2901 | Event *ev = mCalendar->event(uid); | 2917 | Event *ev = mCalendar->event(uid); |
2902 | if (ev) { | 2918 | if (ev) { |
2903 | deleteEvent(ev); | 2919 | deleteEvent(ev); |
2904 | return true; | 2920 | return true; |
2905 | } else { | 2921 | } else { |
2906 | return false; | 2922 | return false; |
2907 | } | 2923 | } |
2908 | } | 2924 | } |
2909 | 2925 | ||
2910 | /*****************************************************************************/ | 2926 | /*****************************************************************************/ |
2911 | 2927 | ||
2912 | void CalendarView::action_mail() | 2928 | void CalendarView::action_mail() |
2913 | { | 2929 | { |
2914 | #ifndef KORG_NOMAIL | 2930 | #ifndef KORG_NOMAIL |
2915 | KOMailClient mailClient; | 2931 | KOMailClient mailClient; |
2916 | 2932 | ||
2917 | Incidence *incidence = currentSelection(); | 2933 | Incidence *incidence = currentSelection(); |
2918 | 2934 | ||
2919 | if (!incidence) { | 2935 | if (!incidence) { |
2920 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2936 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2921 | return; | 2937 | return; |
2922 | } | 2938 | } |
2923 | if(incidence->attendeeCount() == 0 ) { | 2939 | if(incidence->attendeeCount() == 0 ) { |
2924 | KMessageBox::sorry(this, | 2940 | KMessageBox::sorry(this, |
2925 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2941 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2926 | return; | 2942 | return; |
2927 | } | 2943 | } |
2928 | 2944 | ||
2929 | CalendarLocal cal_tmp; | 2945 | CalendarLocal cal_tmp; |
2930 | Event *event = 0; | 2946 | Event *event = 0; |
2931 | Event *ev = 0; | 2947 | Event *ev = 0; |
2932 | if ( incidence && incidence->type() == "Event" ) { | 2948 | if ( incidence && incidence->type() == "Event" ) { |
2933 | event = static_cast<Event *>(incidence); | 2949 | event = static_cast<Event *>(incidence); |
2934 | ev = new Event(*event); | 2950 | ev = new Event(*event); |
2935 | cal_tmp.addEvent(ev); | 2951 | cal_tmp.addEvent(ev); |
2936 | } | 2952 | } |
2937 | ICalFormat mForm(); | 2953 | ICalFormat mForm(); |
2938 | QString attachment = mForm.toString( &cal_tmp ); | 2954 | QString attachment = mForm.toString( &cal_tmp ); |
2939 | if (ev) delete(ev); | 2955 | if (ev) delete(ev); |
2940 | 2956 | ||
2941 | mailClient.mailAttendees(currentSelection(), attachment); | 2957 | mailClient.mailAttendees(currentSelection(), attachment); |
2942 | 2958 | ||
2943 | #endif | 2959 | #endif |
2944 | 2960 | ||
2945 | #if 0 | 2961 | #if 0 |
2946 | Event *anEvent = 0; | 2962 | Event *anEvent = 0; |
2947 | if (mViewManager->currentView()->isEventView()) { | 2963 | if (mViewManager->currentView()->isEventView()) { |
2948 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2964 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2949 | } | 2965 | } |
2950 | 2966 | ||
2951 | if (!anEvent) { | 2967 | if (!anEvent) { |
2952 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2968 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2953 | return; | 2969 | return; |
2954 | } | 2970 | } |
2955 | if(anEvent->attendeeCount() == 0 ) { | 2971 | if(anEvent->attendeeCount() == 0 ) { |
2956 | KMessageBox::sorry(this, | 2972 | KMessageBox::sorry(this, |
2957 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2973 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2958 | return; | 2974 | return; |
2959 | } | 2975 | } |
2960 | 2976 | ||
2961 | mailobject.emailEvent(anEvent); | 2977 | mailobject.emailEvent(anEvent); |
2962 | #endif | 2978 | #endif |
2963 | } | 2979 | } |
2964 | 2980 | ||
2965 | 2981 | ||
2966 | void CalendarView::schedule_publish(Incidence *incidence) | 2982 | void CalendarView::schedule_publish(Incidence *incidence) |
2967 | { | 2983 | { |
2968 | Event *event = 0; | 2984 | Event *event = 0; |
2969 | Todo *todo = 0; | 2985 | Todo *todo = 0; |
2970 | 2986 | ||
2971 | if (incidence == 0) { | 2987 | if (incidence == 0) { |
2972 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2988 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2973 | if (incidence == 0) { | 2989 | if (incidence == 0) { |
2974 | incidence = mTodoList->selectedIncidences().first(); | 2990 | incidence = mTodoList->selectedIncidences().first(); |
2975 | } | 2991 | } |
2976 | } | 2992 | } |
2977 | if ( incidence && incidence->type() == "Event" ) { | 2993 | if ( incidence && incidence->type() == "Event" ) { |
2978 | event = static_cast<Event *>(incidence); | 2994 | event = static_cast<Event *>(incidence); |
2979 | } else { | 2995 | } else { |
2980 | if ( incidence && incidence->type() == "Todo" ) { | 2996 | if ( incidence && incidence->type() == "Todo" ) { |
2981 | todo = static_cast<Todo *>(incidence); | 2997 | todo = static_cast<Todo *>(incidence); |
2982 | } | 2998 | } |
2983 | } | 2999 | } |
2984 | 3000 | ||
2985 | if (!event && !todo) { | 3001 | if (!event && !todo) { |
2986 | KMessageBox::sorry(this,i18n("No event selected.")); | 3002 | KMessageBox::sorry(this,i18n("No event selected.")); |
2987 | return; | 3003 | return; |
2988 | } | 3004 | } |
2989 | 3005 | ||
2990 | PublishDialog *publishdlg = new PublishDialog(); | 3006 | PublishDialog *publishdlg = new PublishDialog(); |
2991 | if (incidence->attendeeCount()>0) { | 3007 | if (incidence->attendeeCount()>0) { |
2992 | QPtrList<Attendee> attendees = incidence->attendees(); | 3008 | QPtrList<Attendee> attendees = incidence->attendees(); |
2993 | attendees.first(); | 3009 | attendees.first(); |
2994 | while ( attendees.current()!=0 ) { | 3010 | while ( attendees.current()!=0 ) { |
2995 | publishdlg->addAttendee(attendees.current()); | 3011 | publishdlg->addAttendee(attendees.current()); |
2996 | attendees.next(); | 3012 | attendees.next(); |
2997 | } | 3013 | } |
2998 | } | 3014 | } |
2999 | bool send = true; | 3015 | bool send = true; |
3000 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3016 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3001 | if ( publishdlg->exec() != QDialog::Accepted ) | 3017 | if ( publishdlg->exec() != QDialog::Accepted ) |
3002 | send = false; | 3018 | send = false; |
3003 | } | 3019 | } |
3004 | if ( send ) { | 3020 | if ( send ) { |
3005 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3021 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3006 | if ( event ) { | 3022 | if ( event ) { |
3007 | Event *ev = new Event(*event); | 3023 | Event *ev = new Event(*event); |
3008 | ev->registerObserver(0); | 3024 | ev->registerObserver(0); |
3009 | ev->clearAttendees(); | 3025 | ev->clearAttendees(); |
3010 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3026 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3011 | delete(ev); | 3027 | delete(ev); |
3012 | } | 3028 | } |
3013 | } else { | 3029 | } else { |
3014 | if ( todo ) { | 3030 | if ( todo ) { |
3015 | Todo *ev = new Todo(*todo); | 3031 | Todo *ev = new Todo(*todo); |
3016 | ev->registerObserver(0); | 3032 | ev->registerObserver(0); |
3017 | ev->clearAttendees(); | 3033 | ev->clearAttendees(); |
3018 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3034 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3019 | delete(ev); | 3035 | delete(ev); |
3020 | } | 3036 | } |
3021 | } | 3037 | } |
3022 | } | 3038 | } |
3023 | } | 3039 | } |
3024 | delete publishdlg; | 3040 | delete publishdlg; |
3025 | } | 3041 | } |
3026 | 3042 | ||
3027 | void CalendarView::schedule_request(Incidence *incidence) | 3043 | void CalendarView::schedule_request(Incidence *incidence) |
3028 | { | 3044 | { |
3029 | schedule(Scheduler::Request,incidence); | 3045 | schedule(Scheduler::Request,incidence); |
3030 | } | 3046 | } |
3031 | 3047 | ||
3032 | void CalendarView::schedule_refresh(Incidence *incidence) | 3048 | void CalendarView::schedule_refresh(Incidence *incidence) |
3033 | { | 3049 | { |
3034 | schedule(Scheduler::Refresh,incidence); | 3050 | schedule(Scheduler::Refresh,incidence); |
3035 | } | 3051 | } |
3036 | 3052 | ||
3037 | void CalendarView::schedule_cancel(Incidence *incidence) | 3053 | void CalendarView::schedule_cancel(Incidence *incidence) |
3038 | { | 3054 | { |
3039 | schedule(Scheduler::Cancel,incidence); | 3055 | schedule(Scheduler::Cancel,incidence); |
3040 | } | 3056 | } |
3041 | 3057 | ||
3042 | void CalendarView::schedule_add(Incidence *incidence) | 3058 | void CalendarView::schedule_add(Incidence *incidence) |
3043 | { | 3059 | { |
3044 | schedule(Scheduler::Add,incidence); | 3060 | schedule(Scheduler::Add,incidence); |
3045 | } | 3061 | } |
3046 | 3062 | ||
3047 | void CalendarView::schedule_reply(Incidence *incidence) | 3063 | void CalendarView::schedule_reply(Incidence *incidence) |
3048 | { | 3064 | { |
3049 | schedule(Scheduler::Reply,incidence); | 3065 | schedule(Scheduler::Reply,incidence); |
3050 | } | 3066 | } |
3051 | 3067 | ||
3052 | void CalendarView::schedule_counter(Incidence *incidence) | 3068 | void CalendarView::schedule_counter(Incidence *incidence) |
3053 | { | 3069 | { |
3054 | schedule(Scheduler::Counter,incidence); | 3070 | schedule(Scheduler::Counter,incidence); |
3055 | } | 3071 | } |
3056 | 3072 | ||
3057 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3073 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3058 | { | 3074 | { |
3059 | schedule(Scheduler::Declinecounter,incidence); | 3075 | schedule(Scheduler::Declinecounter,incidence); |
3060 | } | 3076 | } |
3061 | 3077 | ||
3062 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3078 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3063 | { | 3079 | { |
3064 | QDateTime start = QDateTime::currentDateTime(); | 3080 | QDateTime start = QDateTime::currentDateTime(); |
3065 | QDateTime end = start.addDays(daysToPublish); | 3081 | QDateTime end = start.addDays(daysToPublish); |
3066 | 3082 | ||
3067 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3083 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3068 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3084 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3069 | 3085 | ||
3070 | 3086 | ||
3071 | PublishDialog *publishdlg = new PublishDialog(); | 3087 | PublishDialog *publishdlg = new PublishDialog(); |
3072 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3088 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3073 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3089 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3074 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3090 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3075 | delete(freebusy); | 3091 | delete(freebusy); |
3076 | } | 3092 | } |
3077 | } | 3093 | } |
3078 | delete publishdlg; | 3094 | delete publishdlg; |
3079 | } | 3095 | } |
3080 | 3096 | ||
3081 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3097 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3082 | { | 3098 | { |
3083 | Event *event = 0; | 3099 | Event *event = 0; |
3084 | Todo *todo = 0; | 3100 | Todo *todo = 0; |
3085 | 3101 | ||
3086 | if (incidence == 0) { | 3102 | if (incidence == 0) { |
3087 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3103 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3088 | if (incidence == 0) { | 3104 | if (incidence == 0) { |
3089 | incidence = mTodoList->selectedIncidences().first(); | 3105 | incidence = mTodoList->selectedIncidences().first(); |
3090 | } | 3106 | } |
3091 | } | 3107 | } |
3092 | if ( incidence && incidence->type() == "Event" ) { | 3108 | if ( incidence && incidence->type() == "Event" ) { |
3093 | event = static_cast<Event *>(incidence); | 3109 | event = static_cast<Event *>(incidence); |
3094 | } | 3110 | } |
3095 | if ( incidence && incidence->type() == "Todo" ) { | 3111 | if ( incidence && incidence->type() == "Todo" ) { |
3096 | todo = static_cast<Todo *>(incidence); | 3112 | todo = static_cast<Todo *>(incidence); |
3097 | } | 3113 | } |
3098 | 3114 | ||
3099 | if (!event && !todo) { | 3115 | if (!event && !todo) { |
3100 | KMessageBox::sorry(this,i18n("No event selected.")); | 3116 | KMessageBox::sorry(this,i18n("No event selected.")); |
3101 | return; | 3117 | return; |
3102 | } | 3118 | } |
3103 | 3119 | ||
3104 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3120 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3105 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3121 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3106 | return; | 3122 | return; |
3107 | } | 3123 | } |
3108 | 3124 | ||
3109 | Event *ev = 0; | 3125 | Event *ev = 0; |
3110 | if (event) ev = new Event(*event); | 3126 | if (event) ev = new Event(*event); |
3111 | Todo *to = 0; | 3127 | Todo *to = 0; |
3112 | if (todo) to = new Todo(*todo); | 3128 | if (todo) to = new Todo(*todo); |
3113 | 3129 | ||
3114 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3130 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3115 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3131 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3116 | if (!me) { | 3132 | if (!me) { |
3117 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3133 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3118 | return; | 3134 | return; |
3119 | } | 3135 | } |
3120 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3136 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3121 | StatusDialog *statdlg = new StatusDialog(this); | 3137 | StatusDialog *statdlg = new StatusDialog(this); |
3122 | if (!statdlg->exec()==QDialog::Accepted) return; | 3138 | if (!statdlg->exec()==QDialog::Accepted) return; |
3123 | me->setStatus( statdlg->status() ); | 3139 | me->setStatus( statdlg->status() ); |
3124 | delete(statdlg); | 3140 | delete(statdlg); |
3125 | } | 3141 | } |
3126 | Attendee *menew = new Attendee(*me); | 3142 | Attendee *menew = new Attendee(*me); |
3127 | if (ev) { | 3143 | if (ev) { |
3128 | ev->clearAttendees(); | 3144 | ev->clearAttendees(); |
3129 | ev->addAttendee(menew,false); | 3145 | ev->addAttendee(menew,false); |
3130 | } else { | 3146 | } else { |
3131 | if (to) { | 3147 | if (to) { |
3132 | todo->clearAttendees(); | 3148 | todo->clearAttendees(); |
3133 | todo->addAttendee(menew,false); | 3149 | todo->addAttendee(menew,false); |
3134 | } | 3150 | } |
3135 | } | 3151 | } |
3136 | } | 3152 | } |
3137 | 3153 | ||
3138 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3154 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3139 | if (ev) { | 3155 | if (ev) { |
3140 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3156 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3141 | } else { | 3157 | } else { |
3142 | if (to) { | 3158 | if (to) { |
3143 | if ( !dlg->addMessage(to,method) ) delete(to); | 3159 | if ( !dlg->addMessage(to,method) ) delete(to); |
3144 | } | 3160 | } |
3145 | } | 3161 | } |
3146 | } | 3162 | } |
3147 | 3163 | ||
3148 | void CalendarView::openAddressbook() | 3164 | void CalendarView::openAddressbook() |
3149 | { | 3165 | { |
3150 | KRun::runCommand("kaddressbook"); | 3166 | KRun::runCommand("kaddressbook"); |
3151 | } | 3167 | } |
3152 | 3168 | ||
3153 | void CalendarView::setModified(bool modified) | 3169 | void CalendarView::setModified(bool modified) |
3154 | { | 3170 | { |
3155 | if ( modified ) | 3171 | if ( modified ) |
3156 | emit signalmodified(); | 3172 | emit signalmodified(); |
3157 | if (mModified != modified) { | 3173 | if (mModified != modified) { |
3158 | mModified = modified; | 3174 | mModified = modified; |
3159 | emit modifiedChanged(mModified); | 3175 | emit modifiedChanged(mModified); |
3160 | } | 3176 | } |
3161 | } | 3177 | } |
3162 | 3178 | ||
3163 | bool CalendarView::isReadOnly() | 3179 | bool CalendarView::isReadOnly() |
3164 | { | 3180 | { |
3165 | return mReadOnly; | 3181 | return mReadOnly; |
3166 | } | 3182 | } |
3167 | 3183 | ||
3168 | void CalendarView::setReadOnly(bool readOnly) | 3184 | void CalendarView::setReadOnly(bool readOnly) |
3169 | { | 3185 | { |
3170 | if (mReadOnly != readOnly) { | 3186 | if (mReadOnly != readOnly) { |
3171 | mReadOnly = readOnly; | 3187 | mReadOnly = readOnly; |
3172 | emit readOnlyChanged(mReadOnly); | 3188 | emit readOnlyChanged(mReadOnly); |
3173 | } | 3189 | } |
3174 | } | 3190 | } |
3175 | 3191 | ||
3176 | bool CalendarView::isModified() | 3192 | bool CalendarView::isModified() |
3177 | { | 3193 | { |
3178 | return mModified; | 3194 | return mModified; |
3179 | } | 3195 | } |
3180 | 3196 | ||
3181 | void CalendarView::printSetup() | 3197 | void CalendarView::printSetup() |
3182 | { | 3198 | { |
3183 | #ifndef KORG_NOPRINTER | 3199 | #ifndef KORG_NOPRINTER |
3184 | createPrinter(); | 3200 | createPrinter(); |
3185 | 3201 | ||
3186 | mCalPrinter->setupPrinter(); | 3202 | mCalPrinter->setupPrinter(); |
3187 | #endif | 3203 | #endif |
3188 | } | 3204 | } |
3189 | 3205 | ||
3190 | void CalendarView::print() | 3206 | void CalendarView::print() |
3191 | { | 3207 | { |
3192 | #ifndef KORG_NOPRINTER | 3208 | #ifndef KORG_NOPRINTER |
3193 | createPrinter(); | 3209 | createPrinter(); |
3194 | 3210 | ||
3195 | DateList tmpDateList = mNavigator->selectedDates(); | 3211 | DateList tmpDateList = mNavigator->selectedDates(); |
3196 | mCalPrinter->print(CalPrinter::Month, | 3212 | mCalPrinter->print(CalPrinter::Month, |
3197 | tmpDateList.first(), tmpDateList.last()); | 3213 | tmpDateList.first(), tmpDateList.last()); |
3198 | #endif | 3214 | #endif |
3199 | } | 3215 | } |
3200 | 3216 | ||
3201 | void CalendarView::printPreview() | 3217 | void CalendarView::printPreview() |
3202 | { | 3218 | { |
3203 | #ifndef KORG_NOPRINTER | 3219 | #ifndef KORG_NOPRINTER |
3204 | kdDebug() << "CalendarView::printPreview()" << endl; | 3220 | kdDebug() << "CalendarView::printPreview()" << endl; |
3205 | 3221 | ||
3206 | createPrinter(); | 3222 | createPrinter(); |
3207 | 3223 | ||
3208 | DateList tmpDateList = mNavigator->selectedDates(); | 3224 | DateList tmpDateList = mNavigator->selectedDates(); |
3209 | 3225 | ||
3210 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3226 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3211 | tmpDateList.last()); | 3227 | tmpDateList.last()); |
3212 | #endif | 3228 | #endif |
3213 | } | 3229 | } |
3214 | 3230 | ||
3215 | void CalendarView::exportICalendar() | 3231 | void CalendarView::exportICalendar() |
3216 | { | 3232 | { |
3217 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3233 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3218 | 3234 | ||
3219 | // Force correct extension | 3235 | // Force correct extension |
3220 | if (filename.right(4) != ".ics") filename += ".ics"; | 3236 | if (filename.right(4) != ".ics") filename += ".ics"; |
3221 | 3237 | ||
3222 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3238 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3223 | storage.save(); | 3239 | storage.save(); |
3224 | } | 3240 | } |
3225 | 3241 | ||
3226 | bool CalendarView::exportVCalendar( QString filename ) | 3242 | bool CalendarView::exportVCalendar( QString filename ) |
3227 | { | 3243 | { |
3228 | if (mCalendar->journals().count() > 0) { | 3244 | if (mCalendar->journals().count() > 0) { |
3229 | int result = KMessageBox::warningContinueCancel(this, | 3245 | int result = KMessageBox::warningContinueCancel(this, |
3230 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3246 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3231 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3247 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3232 | true); | 3248 | true); |
3233 | if (result != KMessageBox::Continue) return false; | 3249 | if (result != KMessageBox::Continue) return false; |
3234 | } | 3250 | } |
3235 | 3251 | ||
3236 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3252 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3237 | 3253 | ||
3238 | // Force correct extension | 3254 | // Force correct extension |
3239 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3255 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3240 | 3256 | ||
3241 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3257 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3242 | return storage.save(); | 3258 | return storage.save(); |
3243 | 3259 | ||
3244 | } | 3260 | } |
3245 | 3261 | ||
3246 | void CalendarView::eventUpdated(Incidence *) | 3262 | void CalendarView::eventUpdated(Incidence *) |
3247 | { | 3263 | { |
3248 | setModified(); | 3264 | setModified(); |
3249 | // Don't call updateView here. The code, which has caused the update of the | 3265 | // Don't call updateView here. The code, which has caused the update of the |
3250 | // event is responsible for updating the view. | 3266 | // event is responsible for updating the view. |
3251 | // updateView(); | 3267 | // updateView(); |
3252 | } | 3268 | } |
3253 | 3269 | ||
3254 | void CalendarView::adaptNavigationUnits() | 3270 | void CalendarView::adaptNavigationUnits() |
3255 | { | 3271 | { |
3256 | if (mViewManager->currentView()->isEventView()) { | 3272 | if (mViewManager->currentView()->isEventView()) { |
3257 | int days = mViewManager->currentView()->currentDateCount(); | 3273 | int days = mViewManager->currentView()->currentDateCount(); |
3258 | if (days == 1) { | 3274 | if (days == 1) { |
3259 | emit changeNavStringPrev(i18n("&Previous Day")); | 3275 | emit changeNavStringPrev(i18n("&Previous Day")); |
3260 | emit changeNavStringNext(i18n("&Next Day")); | 3276 | emit changeNavStringNext(i18n("&Next Day")); |
3261 | } else { | 3277 | } else { |
3262 | emit changeNavStringPrev(i18n("&Previous Week")); | 3278 | emit changeNavStringPrev(i18n("&Previous Week")); |
3263 | emit changeNavStringNext(i18n("&Next Week")); | 3279 | emit changeNavStringNext(i18n("&Next Week")); |
3264 | } | 3280 | } |
3265 | } | 3281 | } |
3266 | } | 3282 | } |
3267 | 3283 | ||
3268 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3284 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3269 | { | 3285 | { |
3270 | if ( incidence ) mTodoList->clearSelection(); | 3286 | if ( incidence ) mTodoList->clearSelection(); |
3271 | processIncidenceSelection( incidence ); | 3287 | processIncidenceSelection( incidence ); |
3272 | } | 3288 | } |
3273 | 3289 | ||
3274 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3290 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3275 | { | 3291 | { |
3276 | if ( incidence && mViewManager->currentView() ) { | 3292 | if ( incidence && mViewManager->currentView() ) { |
3277 | mViewManager->currentView()->clearSelection(); | 3293 | mViewManager->currentView()->clearSelection(); |
3278 | } | 3294 | } |
3279 | processIncidenceSelection( incidence ); | 3295 | processIncidenceSelection( incidence ); |
3280 | } | 3296 | } |
3281 | 3297 | ||
3282 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3298 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3283 | { | 3299 | { |
3284 | if ( incidence == mSelectedIncidence ) return; | 3300 | if ( incidence == mSelectedIncidence ) return; |
3285 | 3301 | ||
3286 | mSelectedIncidence = incidence; | 3302 | mSelectedIncidence = incidence; |
3287 | 3303 | ||
3288 | emit incidenceSelected( mSelectedIncidence ); | 3304 | emit incidenceSelected( mSelectedIncidence ); |
3289 | 3305 | ||
3290 | if ( incidence && incidence->type() == "Event" ) { | 3306 | if ( incidence && incidence->type() == "Event" ) { |
3291 | Event *event = static_cast<Event *>( incidence ); | 3307 | Event *event = static_cast<Event *>( incidence ); |
3292 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3308 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3293 | emit organizerEventsSelected( true ); | 3309 | emit organizerEventsSelected( true ); |
3294 | } else { | 3310 | } else { |
3295 | emit organizerEventsSelected(false); | 3311 | emit organizerEventsSelected(false); |
3296 | } | 3312 | } |
3297 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3313 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3298 | KOPrefs::instance()->email() ) ) { | 3314 | KOPrefs::instance()->email() ) ) { |
3299 | emit groupEventsSelected( true ); | 3315 | emit groupEventsSelected( true ); |
3300 | } else { | 3316 | } else { |
3301 | emit groupEventsSelected(false); | 3317 | emit groupEventsSelected(false); |
3302 | } | 3318 | } |
3303 | return; | 3319 | return; |
3304 | } else { | 3320 | } else { |
3305 | if ( incidence && incidence->type() == "Todo" ) { | 3321 | if ( incidence && incidence->type() == "Todo" ) { |
3306 | emit todoSelected( true ); | 3322 | emit todoSelected( true ); |
3307 | Todo *event = static_cast<Todo *>( incidence ); | 3323 | Todo *event = static_cast<Todo *>( incidence ); |
3308 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3324 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3309 | emit organizerEventsSelected( true ); | 3325 | emit organizerEventsSelected( true ); |
3310 | } else { | 3326 | } else { |
3311 | emit organizerEventsSelected(false); | 3327 | emit organizerEventsSelected(false); |
3312 | } | 3328 | } |
3313 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3329 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3314 | KOPrefs::instance()->email() ) ) { | 3330 | KOPrefs::instance()->email() ) ) { |
3315 | emit groupEventsSelected( true ); | 3331 | emit groupEventsSelected( true ); |
3316 | } else { | 3332 | } else { |
3317 | emit groupEventsSelected(false); | 3333 | emit groupEventsSelected(false); |
3318 | } | 3334 | } |
3319 | return; | 3335 | return; |
3320 | } else { | 3336 | } else { |
3321 | emit todoSelected( false ); | 3337 | emit todoSelected( false ); |
3322 | emit organizerEventsSelected(false); | 3338 | emit organizerEventsSelected(false); |
3323 | emit groupEventsSelected(false); | 3339 | emit groupEventsSelected(false); |
3324 | } | 3340 | } |
3325 | return; | 3341 | return; |
3326 | } | 3342 | } |
3327 | 3343 | ||
3328 | /* if ( incidence && incidence->type() == "Todo" ) { | 3344 | /* if ( incidence && incidence->type() == "Todo" ) { |
3329 | emit todoSelected( true ); | 3345 | emit todoSelected( true ); |
3330 | } else { | 3346 | } else { |
3331 | emit todoSelected( false ); | 3347 | emit todoSelected( false ); |
3332 | }*/ | 3348 | }*/ |
3333 | } | 3349 | } |
3334 | 3350 | ||
3335 | 3351 | ||
3336 | void CalendarView::checkClipboard() | 3352 | void CalendarView::checkClipboard() |
3337 | { | 3353 | { |
3338 | #ifndef KORG_NODND | 3354 | #ifndef KORG_NODND |
3339 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3355 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3340 | emit pasteEnabled(true); | 3356 | emit pasteEnabled(true); |
3341 | } else { | 3357 | } else { |
3342 | emit pasteEnabled(false); | 3358 | emit pasteEnabled(false); |
3343 | } | 3359 | } |
3344 | #endif | 3360 | #endif |
3345 | } | 3361 | } |
3346 | 3362 | ||
3347 | void CalendarView::showDates(const DateList &selectedDates) | 3363 | void CalendarView::showDates(const DateList &selectedDates) |
3348 | { | 3364 | { |
3349 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3365 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3350 | 3366 | ||
3351 | if ( mViewManager->currentView() ) { | 3367 | if ( mViewManager->currentView() ) { |
3352 | updateView( selectedDates.first(), selectedDates.last() ); | 3368 | updateView( selectedDates.first(), selectedDates.last() ); |
3353 | } else { | 3369 | } else { |
3354 | mViewManager->showAgendaView(); | 3370 | mViewManager->showAgendaView(); |
3355 | } | 3371 | } |
3356 | 3372 | ||
3357 | QString selDates; | 3373 | QString selDates; |
3358 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3374 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3359 | if (selectedDates.first() < selectedDates.last() ) | 3375 | if (selectedDates.first() < selectedDates.last() ) |
3360 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3376 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3361 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3377 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3362 | 3378 | ||
3363 | } | 3379 | } |
3364 | 3380 | ||
3365 | QPtrList<CalFilter> CalendarView::filters() | 3381 | QPtrList<CalFilter> CalendarView::filters() |
3366 | { | 3382 | { |
3367 | return mFilters; | 3383 | return mFilters; |
3368 | 3384 | ||
3369 | } | 3385 | } |
3370 | void CalendarView::editFilters() | 3386 | void CalendarView::editFilters() |
3371 | { | 3387 | { |
3372 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3388 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3373 | 3389 | ||
3374 | CalFilter *filter = mFilters.first(); | 3390 | CalFilter *filter = mFilters.first(); |
3375 | while(filter) { | 3391 | while(filter) { |
3376 | kdDebug() << " Filter: " << filter->name() << endl; | 3392 | kdDebug() << " Filter: " << filter->name() << endl; |
3377 | filter = mFilters.next(); | 3393 | filter = mFilters.next(); |
3378 | } | 3394 | } |
3379 | 3395 | ||
3380 | mDialogManager->showFilterEditDialog(&mFilters); | 3396 | mDialogManager->showFilterEditDialog(&mFilters); |
3381 | } | 3397 | } |
3382 | void CalendarView::toggleFilter() | 3398 | void CalendarView::toggleFilter() |
3383 | { | 3399 | { |
3384 | showFilter(! mFilterView->isVisible()); | 3400 | showFilter(! mFilterView->isVisible()); |
3385 | } | 3401 | } |
3386 | 3402 | ||
3387 | KOFilterView *CalendarView::filterView() | 3403 | KOFilterView *CalendarView::filterView() |
3388 | { | 3404 | { |
3389 | return mFilterView; | 3405 | return mFilterView; |
3390 | } | 3406 | } |
3391 | void CalendarView::selectFilter( int fil ) | 3407 | void CalendarView::selectFilter( int fil ) |
3392 | { | 3408 | { |
3393 | mFilterView->setSelectedFilter( fil ); | 3409 | mFilterView->setSelectedFilter( fil ); |
3394 | } | 3410 | } |
3395 | void CalendarView::showFilter(bool visible) | 3411 | void CalendarView::showFilter(bool visible) |
3396 | { | 3412 | { |
3397 | if (visible) mFilterView->show(); | 3413 | if (visible) mFilterView->show(); |
3398 | else mFilterView->hide(); | 3414 | else mFilterView->hide(); |
3399 | } | 3415 | } |
3400 | void CalendarView::toggleFilerEnabled( ) | 3416 | void CalendarView::toggleFilerEnabled( ) |
3401 | { | 3417 | { |
3402 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3418 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3403 | if ( !mFilterView->filtersEnabled() ) | 3419 | if ( !mFilterView->filtersEnabled() ) |
3404 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3420 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3405 | 3421 | ||
3406 | } | 3422 | } |
3407 | void CalendarView::updateFilter() | 3423 | void CalendarView::updateFilter() |
3408 | { | 3424 | { |
3409 | CalFilter *filter = mFilterView->selectedFilter(); | 3425 | CalFilter *filter = mFilterView->selectedFilter(); |
3410 | if (filter) { | 3426 | if (filter) { |
3411 | if (mFilterView->filtersEnabled()) { | 3427 | if (mFilterView->filtersEnabled()) { |
3412 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3428 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3413 | filter->setEnabled(true); | 3429 | filter->setEnabled(true); |
3414 | } | 3430 | } |
3415 | else filter->setEnabled(false); | 3431 | else filter->setEnabled(false); |
3416 | mCalendar->setFilter(filter); | 3432 | mCalendar->setFilter(filter); |
3417 | updateView(); | 3433 | updateView(); |
3418 | } | 3434 | } |
3419 | } | 3435 | } |
3420 | 3436 | ||
3421 | void CalendarView::filterEdited() | 3437 | void CalendarView::filterEdited() |
3422 | { | 3438 | { |
3423 | mFilterView->updateFilters(); | 3439 | mFilterView->updateFilters(); |
3424 | updateFilter(); | 3440 | updateFilter(); |
3425 | writeSettings(); | 3441 | writeSettings(); |
3426 | } | 3442 | } |
3427 | 3443 | ||
3428 | 3444 | ||
3429 | void CalendarView::takeOverEvent() | 3445 | void CalendarView::takeOverEvent() |
3430 | { | 3446 | { |
3431 | Incidence *incidence = currentSelection(); | 3447 | Incidence *incidence = currentSelection(); |
3432 | 3448 | ||
3433 | if (!incidence) return; | 3449 | if (!incidence) return; |
3434 | 3450 | ||
3435 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3451 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3436 | incidence->recreate(); | 3452 | incidence->recreate(); |
3437 | incidence->setReadOnly(false); | 3453 | incidence->setReadOnly(false); |
3438 | 3454 | ||
3439 | updateView(); | 3455 | updateView(); |
3440 | } | 3456 | } |
3441 | 3457 | ||
3442 | void CalendarView::takeOverCalendar() | 3458 | void CalendarView::takeOverCalendar() |
3443 | { | 3459 | { |
3444 | // TODO: Create Calendar::allIncidences() function and use it here | 3460 | // TODO: Create Calendar::allIncidences() function and use it here |
3445 | 3461 | ||
3446 | QPtrList<Event> events = mCalendar->events(); | 3462 | QPtrList<Event> events = mCalendar->events(); |
3447 | for(uint i=0; i<events.count(); ++i) { | 3463 | for(uint i=0; i<events.count(); ++i) { |
3448 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3464 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3449 | events.at(i)->recreate(); | 3465 | events.at(i)->recreate(); |
3450 | events.at(i)->setReadOnly(false); | 3466 | events.at(i)->setReadOnly(false); |
3451 | } | 3467 | } |
3452 | 3468 | ||
3453 | QPtrList<Todo> todos = mCalendar->todos(); | 3469 | QPtrList<Todo> todos = mCalendar->todos(); |
3454 | for(uint i=0; i<todos.count(); ++i) { | 3470 | for(uint i=0; i<todos.count(); ++i) { |
3455 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3471 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3456 | todos.at(i)->recreate(); | 3472 | todos.at(i)->recreate(); |
3457 | todos.at(i)->setReadOnly(false); | 3473 | todos.at(i)->setReadOnly(false); |
3458 | } | 3474 | } |
3459 | 3475 | ||
3460 | QPtrList<Journal> journals = mCalendar->journals(); | 3476 | QPtrList<Journal> journals = mCalendar->journals(); |
3461 | for(uint i=0; i<journals.count(); ++i) { | 3477 | for(uint i=0; i<journals.count(); ++i) { |
3462 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3478 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3463 | journals.at(i)->recreate(); | 3479 | journals.at(i)->recreate(); |
3464 | journals.at(i)->setReadOnly(false); | 3480 | journals.at(i)->setReadOnly(false); |
3465 | } | 3481 | } |
3466 | 3482 | ||
3467 | updateView(); | 3483 | updateView(); |
3468 | } | 3484 | } |
3469 | 3485 | ||
3470 | void CalendarView::showIntro() | 3486 | void CalendarView::showIntro() |
3471 | { | 3487 | { |
3472 | kdDebug() << "To be implemented." << endl; | 3488 | kdDebug() << "To be implemented." << endl; |
3473 | } | 3489 | } |
3474 | 3490 | ||
3475 | QWidgetStack *CalendarView::viewStack() | 3491 | QWidgetStack *CalendarView::viewStack() |
3476 | { | 3492 | { |
3477 | return mRightFrame; | 3493 | return mRightFrame; |
3478 | } | 3494 | } |
3479 | 3495 | ||
3480 | QWidget *CalendarView::leftFrame() | 3496 | QWidget *CalendarView::leftFrame() |
3481 | { | 3497 | { |
3482 | return mLeftFrame; | 3498 | return mLeftFrame; |
3483 | } | 3499 | } |
3484 | 3500 | ||
3485 | DateNavigator *CalendarView::dateNavigator() | 3501 | DateNavigator *CalendarView::dateNavigator() |
3486 | { | 3502 | { |
3487 | return mNavigator; | 3503 | return mNavigator; |
3488 | } | 3504 | } |
3489 | 3505 | ||
3490 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3506 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3491 | { | 3507 | { |
3492 | return mDateNavigator; | 3508 | return mDateNavigator; |
3493 | } | 3509 | } |
3494 | void CalendarView::toggleDateNavigatorWidget() | 3510 | void CalendarView::toggleDateNavigatorWidget() |
3495 | { | 3511 | { |
3496 | if (mDateNavigator->isVisible()) | 3512 | if (mDateNavigator->isVisible()) |
3497 | mDateNavigator->hide(); | 3513 | mDateNavigator->hide(); |
3498 | else | 3514 | else |
3499 | mDateNavigator->show(); | 3515 | mDateNavigator->show(); |
3500 | } | 3516 | } |
3501 | void CalendarView::addView(KOrg::BaseView *view) | 3517 | void CalendarView::addView(KOrg::BaseView *view) |
3502 | { | 3518 | { |
3503 | mViewManager->addView(view); | 3519 | mViewManager->addView(view); |
3504 | } | 3520 | } |
3505 | 3521 | ||
3506 | void CalendarView::showView(KOrg::BaseView *view) | 3522 | void CalendarView::showView(KOrg::BaseView *view) |
3507 | { | 3523 | { |
3508 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3524 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3509 | } | 3525 | } |
3510 | 3526 | ||
3511 | Incidence *CalendarView::currentSelection() | 3527 | Incidence *CalendarView::currentSelection() |
3512 | { | 3528 | { |
3513 | return mViewManager->currentSelection(); | 3529 | return mViewManager->currentSelection(); |
3514 | } | 3530 | } |
3515 | void CalendarView::toggleAllDaySize() | 3531 | void CalendarView::toggleAllDaySize() |
3516 | { | 3532 | { |
3517 | /* | 3533 | /* |
3518 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3534 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3519 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3535 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3520 | else | 3536 | else |
3521 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3537 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3522 | */ | 3538 | */ |
3523 | viewManager()->agendaView()->toggleAllDay(); | 3539 | viewManager()->agendaView()->toggleAllDay(); |
3524 | } | 3540 | } |
3525 | void CalendarView::toggleExpand() | 3541 | void CalendarView::toggleExpand() |
3526 | { | 3542 | { |
3527 | // if ( mLeftFrame->isHidden() ) { | 3543 | // if ( mLeftFrame->isHidden() ) { |
3528 | // mLeftFrame->show(); | 3544 | // mLeftFrame->show(); |
3529 | // emit calendarViewExpanded( false ); | 3545 | // emit calendarViewExpanded( false ); |
3530 | // } else { | 3546 | // } else { |
3531 | // mLeftFrame->hide(); | 3547 | // mLeftFrame->hide(); |
3532 | // emit calendarViewExpanded( true ); | 3548 | // emit calendarViewExpanded( true ); |
3533 | // } | 3549 | // } |
3534 | 3550 | ||
3535 | globalFlagBlockAgenda = 1; | 3551 | globalFlagBlockAgenda = 1; |
3536 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3552 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3537 | globalFlagBlockAgenda = 5; | 3553 | globalFlagBlockAgenda = 5; |
3538 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3554 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3539 | //mViewManager->showView( 0, true ); | 3555 | //mViewManager->showView( 0, true ); |
3540 | } | 3556 | } |
3541 | 3557 | ||
3542 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3558 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3543 | { | 3559 | { |
3544 | setModified( modified ); | 3560 | setModified( modified ); |
3545 | } | 3561 | } |
3546 | 3562 | ||
3547 | Todo *CalendarView::selectedTodo() | 3563 | Todo *CalendarView::selectedTodo() |
3548 | { | 3564 | { |
3549 | Incidence *incidence = currentSelection(); | 3565 | Incidence *incidence = currentSelection(); |
3550 | if ( incidence && incidence->type() == "Todo" ) { | 3566 | if ( incidence && incidence->type() == "Todo" ) { |
3551 | return static_cast<Todo *>( incidence ); | 3567 | return static_cast<Todo *>( incidence ); |
3552 | } | 3568 | } |
3553 | 3569 | ||
3554 | incidence = mTodoList->selectedIncidences().first(); | 3570 | incidence = mTodoList->selectedIncidences().first(); |
3555 | if ( incidence && incidence->type() == "Todo" ) { | 3571 | if ( incidence && incidence->type() == "Todo" ) { |
3556 | return static_cast<Todo *>( incidence ); | 3572 | return static_cast<Todo *>( incidence ); |
3557 | } | 3573 | } |
3558 | 3574 | ||
3559 | return 0; | 3575 | return 0; |
3560 | } | 3576 | } |
3561 | 3577 | ||
3562 | void CalendarView::dialogClosing(Incidence *in) | 3578 | void CalendarView::dialogClosing(Incidence *in) |
3563 | { | 3579 | { |
3564 | // mDialogList.remove(in); | 3580 | // mDialogList.remove(in); |
3565 | } | 3581 | } |
3566 | 3582 | ||
3567 | void CalendarView::showIncidence() | 3583 | void CalendarView::showIncidence() |
3568 | { | 3584 | { |
3569 | Incidence *incidence = currentSelection(); | 3585 | Incidence *incidence = currentSelection(); |
3570 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3586 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3571 | if ( incidence ) { | 3587 | if ( incidence ) { |
3572 | ShowIncidenceVisitor v; | 3588 | ShowIncidenceVisitor v; |
3573 | v.act( incidence, this ); | 3589 | v.act( incidence, this ); |
3574 | } | 3590 | } |
3575 | } | 3591 | } |
3576 | void CalendarView::editIncidenceDescription() | 3592 | void CalendarView::editIncidenceDescription() |
3577 | { | 3593 | { |
3578 | mFlagEditDescription = true; | 3594 | mFlagEditDescription = true; |
3579 | editIncidence(); | 3595 | editIncidence(); |
3580 | mFlagEditDescription = false; | 3596 | mFlagEditDescription = false; |
3581 | } | 3597 | } |
3582 | void CalendarView::editIncidence() | 3598 | void CalendarView::editIncidence() |
3583 | { | 3599 | { |
3584 | // qDebug("editIncidence() "); | 3600 | // qDebug("editIncidence() "); |
3585 | Incidence *incidence = currentSelection(); | 3601 | Incidence *incidence = currentSelection(); |
3586 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3602 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3587 | if ( incidence ) { | 3603 | if ( incidence ) { |
3588 | EditIncidenceVisitor v; | 3604 | EditIncidenceVisitor v; |
3589 | v.act( incidence, this ); | 3605 | v.act( incidence, this ); |
3590 | } | 3606 | } |
3591 | } | 3607 | } |
3592 | 3608 | ||
3593 | void CalendarView::deleteIncidence() | 3609 | void CalendarView::deleteIncidence() |
3594 | { | 3610 | { |
3595 | Incidence *incidence = currentSelection(); | 3611 | Incidence *incidence = currentSelection(); |
3596 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3612 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3597 | if ( incidence ) { | 3613 | if ( incidence ) { |
3598 | deleteIncidence(incidence); | 3614 | deleteIncidence(incidence); |
3599 | } | 3615 | } |
3600 | } | 3616 | } |
3601 | 3617 | ||
3602 | void CalendarView::showIncidence(Incidence *incidence) | 3618 | void CalendarView::showIncidence(Incidence *incidence) |
3603 | { | 3619 | { |
3604 | if ( incidence ) { | 3620 | if ( incidence ) { |
3605 | ShowIncidenceVisitor v; | 3621 | ShowIncidenceVisitor v; |
3606 | v.act( incidence, this ); | 3622 | v.act( incidence, this ); |
3607 | } | 3623 | } |
3608 | } | 3624 | } |
3609 | 3625 | ||
3610 | void CalendarView::editIncidence(Incidence *incidence) | 3626 | void CalendarView::editIncidence(Incidence *incidence) |
3611 | { | 3627 | { |
3612 | if ( incidence ) { | 3628 | if ( incidence ) { |
3613 | 3629 | ||
3614 | EditIncidenceVisitor v; | 3630 | EditIncidenceVisitor v; |
3615 | v.act( incidence, this ); | 3631 | v.act( incidence, this ); |
3616 | 3632 | ||
3617 | } | 3633 | } |
3618 | } | 3634 | } |
3619 | 3635 | ||
3620 | void CalendarView::deleteIncidence(Incidence *incidence) | 3636 | void CalendarView::deleteIncidence(Incidence *incidence) |
3621 | { | 3637 | { |
3622 | //qDebug(" CalendarView::deleteIncidence "); | 3638 | //qDebug(" CalendarView::deleteIncidence "); |
3623 | if ( incidence ) { | 3639 | if ( incidence ) { |
3624 | DeleteIncidenceVisitor v; | 3640 | DeleteIncidenceVisitor v; |
3625 | v.act( incidence, this ); | 3641 | v.act( incidence, this ); |
3626 | } | 3642 | } |
3627 | } | 3643 | } |
3628 | 3644 | ||
3629 | 3645 | ||
3630 | void CalendarView::lookForOutgoingMessages() | 3646 | void CalendarView::lookForOutgoingMessages() |
3631 | { | 3647 | { |
3632 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3648 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3633 | ogd->loadMessages(); | 3649 | ogd->loadMessages(); |
3634 | } | 3650 | } |
3635 | 3651 | ||
3636 | void CalendarView::lookForIncomingMessages() | 3652 | void CalendarView::lookForIncomingMessages() |
3637 | { | 3653 | { |
3638 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3654 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3639 | icd->retrieve(); | 3655 | icd->retrieve(); |
3640 | } | 3656 | } |
3641 | 3657 | ||
3642 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3658 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3643 | { | 3659 | { |
3644 | bool deleteTodo = true; | 3660 | bool deleteTodo = true; |
3645 | QPtrList<Incidence> subTodos; | 3661 | QPtrList<Incidence> subTodos; |
3646 | Incidence *aTodo; | 3662 | Incidence *aTodo; |
3647 | subTodos = t->relations(); | 3663 | subTodos = t->relations(); |
3648 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3664 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3649 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3665 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3650 | deleteTodo = false; | 3666 | deleteTodo = false; |
3651 | } | 3667 | } |
3652 | if ( deleteTodo ) { | 3668 | if ( deleteTodo ) { |
3653 | if ( t->isCompleted() ) { | 3669 | if ( t->isCompleted() ) { |
3654 | checkExternalId( t ); | 3670 | checkExternalId( t ); |
3655 | mCalendar->deleteTodo( t ); | 3671 | mCalendar->deleteTodo( t ); |
3656 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3672 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3657 | } | 3673 | } |
3658 | else | 3674 | else |
3659 | deleteTodo = false; | 3675 | deleteTodo = false; |
3660 | } | 3676 | } |
3661 | return deleteTodo; | 3677 | return deleteTodo; |
3662 | 3678 | ||
3663 | } | 3679 | } |
3664 | void CalendarView::purgeCompleted() | 3680 | void CalendarView::purgeCompleted() |
3665 | { | 3681 | { |
3666 | int result = KMessageBox::warningContinueCancel(this, | 3682 | int result = KMessageBox::warningContinueCancel(this, |
3667 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3683 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3668 | 3684 | ||
3669 | if (result == KMessageBox::Continue) { | 3685 | if (result == KMessageBox::Continue) { |
3670 | 3686 | ||
3671 | QPtrList<Todo> todoCal; | 3687 | QPtrList<Todo> todoCal; |
3672 | QPtrList<Todo> rootTodos; | 3688 | QPtrList<Todo> rootTodos; |
3673 | //QPtrList<Incidence> rel; | 3689 | //QPtrList<Incidence> rel; |
3674 | Todo *aTodo;//, *rTodo; | 3690 | Todo *aTodo;//, *rTodo; |
3675 | Incidence *rIncidence; | 3691 | Incidence *rIncidence; |
3676 | bool childDelete = false; | 3692 | bool childDelete = false; |
3677 | bool deletedOne = true; | 3693 | bool deletedOne = true; |
3678 | todoCal = calendar()->todos(); | 3694 | todoCal = calendar()->todos(); |
3679 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3695 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3680 | if ( !aTodo->relatedTo() ) | 3696 | if ( !aTodo->relatedTo() ) |
3681 | rootTodos.append( aTodo ); | 3697 | rootTodos.append( aTodo ); |
3682 | } | 3698 | } |
3683 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3699 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3684 | removeCompletedSubTodos( aTodo ); | 3700 | removeCompletedSubTodos( aTodo ); |
3685 | } | 3701 | } |
3686 | 3702 | ||
3687 | updateView(); | 3703 | updateView(); |
3688 | } | 3704 | } |
3689 | } | 3705 | } |
3690 | 3706 | ||
3691 | void CalendarView::slotCalendarChanged() | 3707 | void CalendarView::slotCalendarChanged() |
3692 | { | 3708 | { |
3693 | ; | 3709 | ; |
3694 | } | 3710 | } |
3695 | 3711 | ||
3696 | NavigatorBar *CalendarView::navigatorBar() | 3712 | NavigatorBar *CalendarView::navigatorBar() |
3697 | { | 3713 | { |
3698 | return mNavigatorBar; | 3714 | return mNavigatorBar; |
3699 | } | 3715 | } |
3700 | 3716 | ||
3701 | 3717 | ||
3702 | 3718 | ||
3703 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3719 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3704 | { | 3720 | { |
3705 | //qDebug(" alendarView::keyPressEvent "); | 3721 | //qDebug(" alendarView::keyPressEvent "); |
3706 | e->ignore(); | 3722 | e->ignore(); |
3707 | } | 3723 | } |
3708 | 3724 | ||
3709 | 3725 | ||
3710 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3726 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3711 | { | 3727 | { |
3712 | // mSyncManager = manager; | 3728 | // mSyncManager = manager; |
3713 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3729 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3714 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3730 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3715 | return syncCalendar( filename, mode ); | 3731 | return syncCalendar( filename, mode ); |
3716 | } | 3732 | } |
3717 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3733 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3718 | { | 3734 | { |
3719 | //mSyncManager = manager; | 3735 | //mSyncManager = manager; |
3720 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3736 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3721 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3737 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3722 | if ( resource == "sharp" ) | 3738 | if ( resource == "sharp" ) |
3723 | syncExternal( 0 ); | 3739 | syncExternal( 0 ); |
3724 | if ( resource == "phone" ) | 3740 | if ( resource == "phone" ) |
3725 | syncExternal( 1 ); | 3741 | syncExternal( 1 ); |
3726 | // pending setmodified | 3742 | // pending setmodified |
3727 | return true; | 3743 | return true; |
3728 | } | 3744 | } |
3729 | void CalendarView::setSyncManager(KSyncManager* manager) | 3745 | void CalendarView::setSyncManager(KSyncManager* manager) |
3730 | { | 3746 | { |
3731 | mSyncManager = manager; | 3747 | mSyncManager = manager; |
3732 | } | 3748 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 660cce7..9f56cc8 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,602 +1,603 @@ | |||
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 | /** This todo has been modified */ | 120 | /** This todo has been modified */ |
121 | void todoModified(Todo *, int); | 121 | void todoModified(Todo *, int); |
122 | 122 | ||
123 | /** when change is made to options dialog, the topwidget will catch this | 123 | /** when change is made to options dialog, the topwidget will catch this |
124 | * and emit this signal which notifies all widgets which have registered | 124 | * and emit this signal which notifies all widgets which have registered |
125 | * for notification to update their settings. */ | 125 | * for notification to update their settings. */ |
126 | void configChanged(); | 126 | void configChanged(); |
127 | /** emitted when the topwidget is closing down, so that any attached | 127 | /** emitted when the topwidget is closing down, so that any attached |
128 | child windows can also close. */ | 128 | child windows can also close. */ |
129 | void closingDown(); | 129 | void closingDown(); |
130 | /** emitted right before we die */ | 130 | /** emitted right before we die */ |
131 | void closed(QWidget *); | 131 | void closed(QWidget *); |
132 | 132 | ||
133 | /** Emitted when state of modified flag changes */ | 133 | /** Emitted when state of modified flag changes */ |
134 | void modifiedChanged(bool); | 134 | void modifiedChanged(bool); |
135 | void signalmodified(); | 135 | void signalmodified(); |
136 | 136 | ||
137 | /** Emitted when state of read-only flag changes */ | 137 | /** Emitted when state of read-only flag changes */ |
138 | void readOnlyChanged(bool); | 138 | void readOnlyChanged(bool); |
139 | 139 | ||
140 | /** Emitted when the unit of navigation changes */ | 140 | /** Emitted when the unit of navigation changes */ |
141 | void changeNavStringPrev(const QString &); | 141 | void changeNavStringPrev(const QString &); |
142 | void changeNavStringNext(const QString &); | 142 | void changeNavStringNext(const QString &); |
143 | 143 | ||
144 | /** Emitted when state of events selection has changed and user is organizer*/ | 144 | /** Emitted when state of events selection has changed and user is organizer*/ |
145 | void organizerEventsSelected(bool); | 145 | void organizerEventsSelected(bool); |
146 | /** Emitted when state of events selection has changed and user is attendee*/ | 146 | /** Emitted when state of events selection has changed and user is attendee*/ |
147 | void groupEventsSelected(bool); | 147 | void groupEventsSelected(bool); |
148 | /** | 148 | /** |
149 | Emitted when an incidence gets selected. If the selection is cleared the | 149 | Emitted when an incidence gets selected. If the selection is cleared the |
150 | signal is emitted with 0 as argument. | 150 | signal is emitted with 0 as argument. |
151 | */ | 151 | */ |
152 | void incidenceSelected( Incidence * ); | 152 | void incidenceSelected( Incidence * ); |
153 | /** Emitted, when a todoitem is selected or deselected. */ | 153 | /** Emitted, when a todoitem is selected or deselected. */ |
154 | void todoSelected( bool ); | 154 | void todoSelected( bool ); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Emitted, when clipboard content changes. Parameter indicates if paste | 157 | Emitted, when clipboard content changes. Parameter indicates if paste |
158 | is possible or not. | 158 | is possible or not. |
159 | */ | 159 | */ |
160 | void pasteEnabled(bool); | 160 | void pasteEnabled(bool); |
161 | 161 | ||
162 | /** Emitted, when the number of incoming messages has changed. */ | 162 | /** Emitted, when the number of incoming messages has changed. */ |
163 | void numIncomingChanged(int); | 163 | void numIncomingChanged(int); |
164 | 164 | ||
165 | /** Emitted, when the number of outgoing messages has changed. */ | 165 | /** Emitted, when the number of outgoing messages has changed. */ |
166 | void numOutgoingChanged(int); | 166 | void numOutgoingChanged(int); |
167 | 167 | ||
168 | /** Send status message, which can e.g. be displayed in the status bar. */ | 168 | /** Send status message, which can e.g. be displayed in the status bar. */ |
169 | void statusMessage(const QString &); | 169 | void statusMessage(const QString &); |
170 | 170 | ||
171 | void calendarViewExpanded( bool ); | 171 | void calendarViewExpanded( bool ); |
172 | void updateSearchDialog(); | 172 | void updateSearchDialog(); |
173 | 173 | ||
174 | 174 | ||
175 | public slots: | 175 | public slots: |
176 | void showOpenError(); | 176 | void showOpenError(); |
177 | void watchSavedFile(); | 177 | void watchSavedFile(); |
178 | void recheckTimerAlarm(); | 178 | void recheckTimerAlarm(); |
179 | void checkNextTimerAlarm(); | 179 | void checkNextTimerAlarm(); |
180 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
181 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | 183 | ||
184 | /** options dialog made a changed to the configuration. we catch this | 184 | /** options dialog made a changed to the configuration. we catch this |
185 | * and notify all widgets which need to update their configuration. */ | 185 | * and notify all widgets which need to update their configuration. */ |
186 | void updateConfig(); | 186 | void updateConfig(); |
187 | 187 | ||
188 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 188 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
189 | const QStringList& anniversaryList, const QStringList& realNameList, | 189 | const QStringList& anniversaryList, const QStringList& realNameList, |
190 | const QStringList& emailList, const QStringList& assembledNameList, | 190 | const QStringList& emailList, const QStringList& assembledNameList, |
191 | const QStringList& uidList); | 191 | const QStringList& uidList); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Load calendar from file \a filename. If \a merge is true, load | 194 | Load calendar from file \a filename. If \a merge is true, load |
195 | calendar into existing one, if it is false, clear calendar, before | 195 | calendar into existing one, if it is false, clear calendar, before |
196 | loading. Return true, if calendar could be successfully loaded. | 196 | loading. Return true, if calendar could be successfully loaded. |
197 | */ | 197 | */ |
198 | bool openCalendar(QString filename, bool merge=false); | 198 | bool openCalendar(QString filename, bool merge=false); |
199 | bool syncCalendar(QString filename,int mode = 0 ); | 199 | bool syncCalendar(QString filename,int mode = 0 ); |
200 | 200 | ||
201 | /** | 201 | /** |
202 | Save calendar data to file. Return true if calendar could be | 202 | Save calendar data to file. Return true if calendar could be |
203 | successfully saved. | 203 | successfully saved. |
204 | */ | 204 | */ |
205 | bool saveCalendar(QString filename); | 205 | bool saveCalendar(QString filename); |
206 | 206 | ||
207 | /** | 207 | /** |
208 | Close calendar. Clear calendar data and reset views to display an empty | 208 | Close calendar. Clear calendar data and reset views to display an empty |
209 | calendar. | 209 | calendar. |
210 | */ | 210 | */ |
211 | void closeCalendar(); | 211 | void closeCalendar(); |
212 | 212 | ||
213 | /** Archive old events of calendar */ | 213 | /** Archive old events of calendar */ |
214 | void archiveCalendar(); | 214 | void archiveCalendar(); |
215 | 215 | ||
216 | void showIncidence(); | 216 | void showIncidence(); |
217 | void editIncidence(); | 217 | void editIncidence(); |
218 | void editIncidenceDescription(); | 218 | void editIncidenceDescription(); |
219 | void deleteIncidence(); | 219 | void deleteIncidence(); |
220 | void cloneIncidence(); | 220 | void cloneIncidence(); |
221 | void moveIncidence(); | 221 | void moveIncidence(); |
222 | void beamIncidence(); | 222 | void beamIncidence(); |
223 | void toggleCancelIncidence(); | 223 | void toggleCancelIncidence(); |
224 | 224 | ||
225 | /** create an editeventwin with supplied date/time, and if bool is true, | 225 | /** create an editeventwin with supplied date/time, and if bool is true, |
226 | * make the event take all day. */ | 226 | * make the event take all day. */ |
227 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 227 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
228 | void newEvent(QDateTime fh); | 228 | void newEvent(QDateTime fh); |
229 | void newEvent(QDate dt); | 229 | void newEvent(QDate dt); |
230 | /** create new event without having a date hint. Takes current date as | 230 | /** create new event without having a date hint. Takes current date as |
231 | default hint. */ | 231 | default hint. */ |
232 | void newEvent(); | 232 | void newEvent(); |
233 | void newFloatingEvent(); | 233 | void newFloatingEvent(); |
234 | 234 | ||
235 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 235 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
236 | void showIncidence(Incidence *); | 236 | void showIncidence(Incidence *); |
237 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 237 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
238 | void editIncidence(Incidence *); | 238 | void editIncidence(Incidence *); |
239 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 239 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
240 | void deleteIncidence(Incidence *); | 240 | void deleteIncidence(Incidence *); |
241 | void cloneIncidence(Incidence *); | 241 | void cloneIncidence(Incidence *); |
242 | void cancelIncidence(Incidence *); | 242 | void cancelIncidence(Incidence *); |
243 | /** Create an editor for the supplied event. */ | 243 | /** Create an editor for the supplied event. */ |
244 | void editEvent(Event *); | 244 | void editEvent(Event *); |
245 | /** Delete the supplied event. */ | 245 | /** Delete the supplied event. */ |
246 | void deleteEvent(Event *); | 246 | void deleteEvent(Event *); |
247 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 247 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
248 | found. */ | 248 | found. */ |
249 | bool deleteEvent(const QString &uid); | 249 | bool deleteEvent(const QString &uid); |
250 | /** Create a read-only viewer dialog for the supplied event. */ | 250 | /** Create a read-only viewer dialog for the supplied event. */ |
251 | void showEvent(Event *); | 251 | void showEvent(Event *); |
252 | 252 | ||
253 | void editJournal(Journal *); | 253 | void editJournal(Journal *); |
254 | void showJournal(Journal *); | 254 | void showJournal(Journal *); |
255 | void deleteJournal(Journal *); | 255 | void deleteJournal(Journal *); |
256 | /** Create an editor dialog for a todo */ | 256 | /** Create an editor dialog for a todo */ |
257 | void editTodo(Todo *); | 257 | void editTodo(Todo *); |
258 | /** Create a read-only viewer dialog for the supplied todo */ | 258 | /** Create a read-only viewer dialog for the supplied todo */ |
259 | void showTodo(Todo *); | 259 | void showTodo(Todo *); |
260 | /** create new todo */ | 260 | /** create new todo */ |
261 | void newTodo(); | 261 | void newTodo(); |
262 | /** create new todo with a parent todo */ | 262 | /** create new todo with a parent todo */ |
263 | void newSubTodo(); | 263 | void newSubTodo(); |
264 | /** create new todo with a parent todo */ | 264 | /** create new todo with a parent todo */ |
265 | void newSubTodo(Todo *); | 265 | void newSubTodo(Todo *); |
266 | /** Delete todo */ | 266 | /** Delete todo */ |
267 | void deleteTodo(Todo *); | 267 | void deleteTodo(Todo *); |
268 | 268 | ||
269 | 269 | ||
270 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 270 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
271 | * emitted as result. */ | 271 | * emitted as result. */ |
272 | void checkClipboard(); | 272 | void checkClipboard(); |
273 | 273 | ||
274 | /** using the KConfig associated with the kapp variable, read in the | 274 | /** using the KConfig associated with the kapp variable, read in the |
275 | * settings from the config file. | 275 | * settings from the config file. |
276 | */ | 276 | */ |
277 | void readSettings(); | 277 | void readSettings(); |
278 | 278 | ||
279 | /** write current state to config file. */ | 279 | /** write current state to config file. */ |
280 | void writeSettings(); | 280 | void writeSettings(); |
281 | 281 | ||
282 | /** read settings for calendar filters */ | 282 | /** read settings for calendar filters */ |
283 | void readFilterSettings(KConfig *config); | 283 | void readFilterSettings(KConfig *config); |
284 | 284 | ||
285 | /** write settings for calendar filters */ | 285 | /** write settings for calendar filters */ |
286 | void writeFilterSettings(KConfig *config); | 286 | void writeFilterSettings(KConfig *config); |
287 | 287 | ||
288 | /** passes on the message that an event has changed to the currently | 288 | /** passes on the message that an event has changed to the currently |
289 | * activated view so that it can make appropriate display changes. */ | 289 | * activated view so that it can make appropriate display changes. */ |
290 | void changeEventDisplay(Event *, int); | 290 | void changeEventDisplay(Event *, int); |
291 | void changeIncidenceDisplay(Incidence *, int); | 291 | void changeIncidenceDisplay(Incidence *, int); |
292 | void changeTodoDisplay(Todo *, int); | 292 | void changeTodoDisplay(Todo *, int); |
293 | 293 | ||
294 | void eventAdded(Event *); | 294 | void eventAdded(Event *); |
295 | void eventChanged(Event *); | 295 | void eventChanged(Event *); |
296 | void eventToBeDeleted(Event *); | 296 | void eventToBeDeleted(Event *); |
297 | void eventDeleted(); | 297 | void eventDeleted(); |
298 | 298 | ||
299 | void todoAdded(Todo *); | 299 | void todoAdded(Todo *); |
300 | void todoChanged(Todo *); | 300 | void todoChanged(Todo *); |
301 | void todoToBeDeleted(Todo *); | 301 | void todoToBeDeleted(Todo *); |
302 | void todoDeleted(); | 302 | void todoDeleted(); |
303 | 303 | ||
304 | void updateView(const QDate &start, const QDate &end); | 304 | void updateView(const QDate &start, const QDate &end); |
305 | void updateView(); | 305 | void updateView(); |
306 | 306 | ||
307 | /** Full update of visible todo views */ | 307 | /** Full update of visible todo views */ |
308 | void updateTodoViews(); | 308 | void updateTodoViews(); |
309 | 309 | ||
310 | void updateUnmanagedViews(); | 310 | void updateUnmanagedViews(); |
311 | 311 | ||
312 | /** cut the current appointment to the clipboard */ | 312 | /** cut the current appointment to the clipboard */ |
313 | void edit_cut(); | 313 | void edit_cut(); |
314 | 314 | ||
315 | /** copy the current appointment(s) to the clipboard */ | 315 | /** copy the current appointment(s) to the clipboard */ |
316 | void edit_copy(); | 316 | void edit_copy(); |
317 | 317 | ||
318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
319 | void edit_paste(); | 319 | void edit_paste(); |
320 | 320 | ||
321 | /** edit viewing and configuration options. */ | 321 | /** edit viewing and configuration options. */ |
322 | void edit_options(); | 322 | void edit_options(); |
323 | /** | 323 | /** |
324 | Functions for printing, previewing a print, and setting up printing | 324 | Functions for printing, previewing a print, and setting up printing |
325 | parameters. | 325 | parameters. |
326 | */ | 326 | */ |
327 | void print(); | 327 | void print(); |
328 | void printSetup(); | 328 | void printSetup(); |
329 | void printPreview(); | 329 | void printPreview(); |
330 | 330 | ||
331 | /** Export as iCalendar file */ | 331 | /** Export as iCalendar file */ |
332 | void exportICalendar(); | 332 | void exportICalendar(); |
333 | 333 | ||
334 | /** Export as vCalendar file */ | 334 | /** Export as vCalendar file */ |
335 | bool exportVCalendar( QString fn); | 335 | bool exportVCalendar( QString fn); |
336 | 336 | ||
337 | /** pop up a dialog to show an existing appointment. */ | 337 | /** pop up a dialog to show an existing appointment. */ |
338 | void appointment_show(); | 338 | void appointment_show(); |
339 | /** | 339 | /** |
340 | * pop up an Appointment Dialog to edit an existing appointment.Get | 340 | * pop up an Appointment Dialog to edit an existing appointment.Get |
341 | * information on the appointment from the list of unique IDs that is | 341 | * information on the appointment from the list of unique IDs that is |
342 | * currently in the View, called currIds. | 342 | * currently in the View, called currIds. |
343 | */ | 343 | */ |
344 | void appointment_edit(); | 344 | void appointment_edit(); |
345 | /** | 345 | /** |
346 | * pop up dialog confirming deletion of currently selected event in the | 346 | * pop up dialog confirming deletion of currently selected event in the |
347 | * View. | 347 | * View. |
348 | */ | 348 | */ |
349 | void appointment_delete(); | 349 | void appointment_delete(); |
350 | 350 | ||
351 | /** mails the currently selected event to a particular user as a vCalendar | 351 | /** mails the currently selected event to a particular user as a vCalendar |
352 | attachment. */ | 352 | attachment. */ |
353 | void action_mail(); | 353 | void action_mail(); |
354 | 354 | ||
355 | /* frees a subtodo from it's relation */ | 355 | /* frees a subtodo from it's relation */ |
356 | void todo_unsub( Todo * ); | 356 | void todo_unsub( Todo * ); |
357 | void todo_resub( Todo * parent, Todo * sub ); | ||
357 | 358 | ||
358 | /** Take ownership of selected event. */ | 359 | /** Take ownership of selected event. */ |
359 | void takeOverEvent(); | 360 | void takeOverEvent(); |
360 | 361 | ||
361 | /** Take ownership of all events in calendar. */ | 362 | /** Take ownership of all events in calendar. */ |
362 | void takeOverCalendar(); | 363 | void takeOverCalendar(); |
363 | 364 | ||
364 | /** query whether or not the calendar is "dirty". */ | 365 | /** query whether or not the calendar is "dirty". */ |
365 | bool isModified(); | 366 | bool isModified(); |
366 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
367 | void setModified(bool modified=true); | 368 | void setModified(bool modified=true); |
368 | 369 | ||
369 | /** query if the calendar is read-only. */ | 370 | /** query if the calendar is read-only. */ |
370 | bool isReadOnly(); | 371 | bool isReadOnly(); |
371 | /** set state of calendar to read-only */ | 372 | /** set state of calendar to read-only */ |
372 | void setReadOnly(bool readOnly=true); | 373 | void setReadOnly(bool readOnly=true); |
373 | 374 | ||
374 | void eventUpdated(Incidence *); | 375 | void eventUpdated(Incidence *); |
375 | 376 | ||
376 | /* iTIP scheduling actions */ | 377 | /* iTIP scheduling actions */ |
377 | void schedule_publish(Incidence *incidence = 0); | 378 | void schedule_publish(Incidence *incidence = 0); |
378 | void schedule_request(Incidence *incidence = 0); | 379 | void schedule_request(Incidence *incidence = 0); |
379 | void schedule_refresh(Incidence *incidence = 0); | 380 | void schedule_refresh(Incidence *incidence = 0); |
380 | void schedule_cancel(Incidence *incidence = 0); | 381 | void schedule_cancel(Incidence *incidence = 0); |
381 | void schedule_add(Incidence *incidence = 0); | 382 | void schedule_add(Incidence *incidence = 0); |
382 | void schedule_reply(Incidence *incidence = 0); | 383 | void schedule_reply(Incidence *incidence = 0); |
383 | void schedule_counter(Incidence *incidence = 0); | 384 | void schedule_counter(Incidence *incidence = 0); |
384 | void schedule_declinecounter(Incidence *incidence = 0); | 385 | void schedule_declinecounter(Incidence *incidence = 0); |
385 | void schedule_publish_freebusy(int daysToPublish = 30); | 386 | void schedule_publish_freebusy(int daysToPublish = 30); |
386 | 387 | ||
387 | void openAddressbook(); | 388 | void openAddressbook(); |
388 | 389 | ||
389 | void editFilters(); | 390 | void editFilters(); |
390 | void toggleFilerEnabled(); | 391 | void toggleFilerEnabled(); |
391 | QPtrList<CalFilter> filters(); | 392 | QPtrList<CalFilter> filters(); |
392 | void toggleFilter(); | 393 | void toggleFilter(); |
393 | void showFilter(bool visible); | 394 | void showFilter(bool visible); |
394 | void updateFilter(); | 395 | void updateFilter(); |
395 | void filterEdited(); | 396 | void filterEdited(); |
396 | void selectFilter( int ); | 397 | void selectFilter( int ); |
397 | KOFilterView *filterView(); | 398 | KOFilterView *filterView(); |
398 | 399 | ||
399 | void showIntro(); | 400 | void showIntro(); |
400 | 401 | ||
401 | /** Move the curdatepient view date to today */ | 402 | /** Move the curdatepient view date to today */ |
402 | void goToday(); | 403 | void goToday(); |
403 | 404 | ||
404 | /** Move to the next date(s) in the current view */ | 405 | /** Move to the next date(s) in the current view */ |
405 | void goNext(); | 406 | void goNext(); |
406 | 407 | ||
407 | /** Move to the previous date(s) in the current view */ | 408 | /** Move to the previous date(s) in the current view */ |
408 | void goPrevious(); | 409 | void goPrevious(); |
409 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
410 | void goNextMonth(); | 411 | void goNextMonth(); |
411 | 412 | ||
412 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
413 | void goPreviousMonth(); | 414 | void goPreviousMonth(); |
414 | 415 | ||
415 | void toggleExpand(); | 416 | void toggleExpand(); |
416 | void toggleDateNavigatorWidget(); | 417 | void toggleDateNavigatorWidget(); |
417 | void toggleAllDaySize(); | 418 | void toggleAllDaySize(); |
418 | void dialogClosing(Incidence *); | 419 | void dialogClosing(Incidence *); |
419 | 420 | ||
420 | /** Look for new messages in the inbox */ | 421 | /** Look for new messages in the inbox */ |
421 | void lookForIncomingMessages(); | 422 | void lookForIncomingMessages(); |
422 | /** Look for new messages in the outbox */ | 423 | /** Look for new messages in the outbox */ |
423 | void lookForOutgoingMessages(); | 424 | void lookForOutgoingMessages(); |
424 | 425 | ||
425 | void processMainViewSelection( Incidence * ); | 426 | void processMainViewSelection( Incidence * ); |
426 | void processTodoListSelection( Incidence * ); | 427 | void processTodoListSelection( Incidence * ); |
427 | 428 | ||
428 | void processIncidenceSelection( Incidence * ); | 429 | void processIncidenceSelection( Incidence * ); |
429 | 430 | ||
430 | void purgeCompleted(); | 431 | void purgeCompleted(); |
431 | bool removeCompletedSubTodos( Todo* ); | 432 | bool removeCompletedSubTodos( Todo* ); |
432 | void slotCalendarChanged(); | 433 | void slotCalendarChanged(); |
433 | bool importBday(); | 434 | bool importBday(); |
434 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
435 | bool importQtopia( const QString &categoriesFile, | 436 | bool importQtopia( const QString &categoriesFile, |
436 | const QString &datebookFile, | 437 | const QString &datebookFile, |
437 | const QString &tasklistFile ); | 438 | const QString &tasklistFile ); |
438 | void syncExternal( int mode ); | 439 | void syncExternal( int mode ); |
439 | void slotSelectPickerDate( QDate ) ; | 440 | void slotSelectPickerDate( QDate ) ; |
440 | void showDatePicker( ) ; | 441 | void showDatePicker( ) ; |
441 | void moveIncidence(Incidence *) ; | 442 | void moveIncidence(Incidence *) ; |
442 | void beamIncidence(Incidence *) ; | 443 | void beamIncidence(Incidence *) ; |
443 | void beamCalendar() ; | 444 | void beamCalendar() ; |
444 | void beamFilteredCalendar() ; | 445 | void beamFilteredCalendar() ; |
445 | void beamIncidenceList(QPtrList<Incidence>) ; | 446 | void beamIncidenceList(QPtrList<Incidence>) ; |
446 | void manageCategories(); | 447 | void manageCategories(); |
447 | int addCategories(); | 448 | int addCategories(); |
448 | void removeCategories(); | 449 | void removeCategories(); |
449 | void setSyncDevice( QString ); | 450 | void setSyncDevice( QString ); |
450 | void setSyncName( QString ); | 451 | void setSyncName( QString ); |
451 | protected slots: | 452 | protected slots: |
452 | void timerAlarm(); | 453 | void timerAlarm(); |
453 | void suspendAlarm(); | 454 | void suspendAlarm(); |
454 | void beamDone( Ir *ir ); | 455 | void beamDone( Ir *ir ); |
455 | /** Select a view or adapt the current view to display the specified dates. */ | 456 | /** Select a view or adapt the current view to display the specified dates. */ |
456 | void showDates( const KCal::DateList & ); | 457 | void showDates( const KCal::DateList & ); |
457 | void selectWeekNum ( int ); | 458 | void selectWeekNum ( int ); |
458 | 459 | ||
459 | public: | 460 | public: |
460 | // show a standard warning | 461 | // show a standard warning |
461 | // returns KMsgBox::yesNoCancel() | 462 | // returns KMsgBox::yesNoCancel() |
462 | int msgCalModified(); | 463 | int msgCalModified(); |
463 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
464 | 465 | ||
465 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
466 | void setSyncManager(KSyncManager* manager); | 467 | void setSyncManager(KSyncManager* manager); |
467 | void setLoadedFileVersion(QDateTime); | 468 | void setLoadedFileVersion(QDateTime); |
468 | bool checkFileVersion(QString fn); | 469 | bool checkFileVersion(QString fn); |
469 | bool checkFileChanged(QString fn); | 470 | bool checkFileChanged(QString fn); |
470 | Event* getLastSyncEvent(); | 471 | Event* getLastSyncEvent(); |
471 | /** Adapt navigation units correpsonding to step size of navigation of the | 472 | /** Adapt navigation units correpsonding to step size of navigation of the |
472 | * current view. | 473 | * current view. |
473 | */ | 474 | */ |
474 | void adaptNavigationUnits(); | 475 | void adaptNavigationUnits(); |
475 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 476 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
476 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 477 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
477 | //Attendee* getYourAttendee(Event *event); | 478 | //Attendee* getYourAttendee(Event *event); |
478 | protected: | 479 | protected: |
479 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 480 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
480 | 481 | ||
481 | // returns KMsgBox::OKCandel() | 482 | // returns KMsgBox::OKCandel() |
482 | int msgItemDelete(); | 483 | int msgItemDelete(); |
483 | void showEventEditor(); | 484 | void showEventEditor(); |
484 | void showTodoEditor(); | 485 | void showTodoEditor(); |
485 | void writeLocale(); | 486 | void writeLocale(); |
486 | Todo *selectedTodo(); | 487 | Todo *selectedTodo(); |
487 | 488 | ||
488 | private: | 489 | private: |
489 | KSyncManager* mSyncManager; | 490 | KSyncManager* mSyncManager; |
490 | AlarmDialog * mAlarmDialog; | 491 | AlarmDialog * mAlarmDialog; |
491 | QString mAlarmNotification; | 492 | QString mAlarmNotification; |
492 | QString mSuspendAlarmNotification; | 493 | QString mSuspendAlarmNotification; |
493 | QTimer* mSuspendTimer; | 494 | QTimer* mSuspendTimer; |
494 | QTimer* mAlarmTimer; | 495 | QTimer* mAlarmTimer; |
495 | QTimer* mRecheckAlarmTimer; | 496 | QTimer* mRecheckAlarmTimer; |
496 | void computeAlarm( QString ); | 497 | void computeAlarm( QString ); |
497 | void startAlarm( QString, QString ); | 498 | void startAlarm( QString, QString ); |
498 | void setSyncEventsReadOnly(); | 499 | void setSyncEventsReadOnly(); |
499 | 500 | ||
500 | QDateTime loadedFileVersion; | 501 | QDateTime loadedFileVersion; |
501 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 502 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
502 | void checkExternalId( Incidence * inc ); | 503 | void checkExternalId( Incidence * inc ); |
503 | int mGlobalSyncMode; | 504 | int mGlobalSyncMode; |
504 | QString mCurrentSyncDevice; | 505 | QString mCurrentSyncDevice; |
505 | QString mCurrentSyncName; | 506 | QString mCurrentSyncName; |
506 | KOBeamPrefs* beamDialog; | 507 | KOBeamPrefs* beamDialog; |
507 | void init(); | 508 | void init(); |
508 | int mDatePickerMode; | 509 | int mDatePickerMode; |
509 | bool mFlagEditDescription; | 510 | bool mFlagEditDescription; |
510 | QDateTime mLastCalendarSync; | 511 | QDateTime mLastCalendarSync; |
511 | void createPrinter(); | 512 | void createPrinter(); |
512 | 513 | ||
513 | void calendarModified( bool, Calendar * ); | 514 | void calendarModified( bool, Calendar * ); |
514 | 515 | ||
515 | CalPrinter *mCalPrinter; | 516 | CalPrinter *mCalPrinter; |
516 | 517 | ||
517 | QSplitter *mPanner; | 518 | QSplitter *mPanner; |
518 | QSplitter *mLeftSplitter; | 519 | QSplitter *mLeftSplitter; |
519 | QWidget *mLeftFrame; | 520 | QWidget *mLeftFrame; |
520 | QWidgetStack *mRightFrame; | 521 | QWidgetStack *mRightFrame; |
521 | 522 | ||
522 | KDatePicker* mDatePicker; | 523 | KDatePicker* mDatePicker; |
523 | QVBox* mDateFrame; | 524 | QVBox* mDateFrame; |
524 | NavigatorBar *mNavigatorBar; | 525 | NavigatorBar *mNavigatorBar; |
525 | 526 | ||
526 | KDateNavigator *mDateNavigator; // widget showing small month view. | 527 | KDateNavigator *mDateNavigator; // widget showing small month view. |
527 | 528 | ||
528 | KOFilterView *mFilterView; | 529 | KOFilterView *mFilterView; |
529 | 530 | ||
530 | ResourceView *mResourceView; | 531 | ResourceView *mResourceView; |
531 | 532 | ||
532 | // calendar object for this viewing instance | 533 | // calendar object for this viewing instance |
533 | Calendar *mCalendar; | 534 | Calendar *mCalendar; |
534 | 535 | ||
535 | CalendarResourceManager *mResourceManager; | 536 | CalendarResourceManager *mResourceManager; |
536 | 537 | ||
537 | FileStorage *mStorage; | 538 | FileStorage *mStorage; |
538 | 539 | ||
539 | DateNavigator *mNavigator; | 540 | DateNavigator *mNavigator; |
540 | 541 | ||
541 | KOViewManager *mViewManager; | 542 | KOViewManager *mViewManager; |
542 | KODialogManager *mDialogManager; | 543 | KODialogManager *mDialogManager; |
543 | 544 | ||
544 | // Calendar filters | 545 | // Calendar filters |
545 | QPtrList<CalFilter> mFilters; | 546 | QPtrList<CalFilter> mFilters; |
546 | 547 | ||
547 | // various housekeeping variables. | 548 | // various housekeeping variables. |
548 | bool mModified; // flag indicating if calendar is modified | 549 | bool mModified; // flag indicating if calendar is modified |
549 | bool mReadOnly; // flag indicating if calendar is read-only | 550 | bool mReadOnly; // flag indicating if calendar is read-only |
550 | QDate mSaveSingleDate; | 551 | QDate mSaveSingleDate; |
551 | 552 | ||
552 | Incidence *mSelectedIncidence; | 553 | Incidence *mSelectedIncidence; |
553 | Incidence *mMoveIncidence; | 554 | Incidence *mMoveIncidence; |
554 | KOTodoView *mTodoList; | 555 | KOTodoView *mTodoList; |
555 | KOEventEditor * mEventEditor; | 556 | KOEventEditor * mEventEditor; |
556 | KOTodoEditor * mTodoEditor; | 557 | KOTodoEditor * mTodoEditor; |
557 | KOEventViewerDialog * mEventViewerDialog; | 558 | KOEventViewerDialog * mEventViewerDialog; |
558 | void keyPressEvent ( QKeyEvent *e) ; | 559 | void keyPressEvent ( QKeyEvent *e) ; |
559 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 560 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
560 | }; | 561 | }; |
561 | 562 | ||
562 | 563 | ||
563 | class CalendarViewVisitor : public Incidence::Visitor | 564 | class CalendarViewVisitor : public Incidence::Visitor |
564 | { | 565 | { |
565 | public: | 566 | public: |
566 | CalendarViewVisitor() : mView( 0 ) {} | 567 | CalendarViewVisitor() : mView( 0 ) {} |
567 | 568 | ||
568 | bool act( Incidence *incidence, CalendarView *view ) | 569 | bool act( Incidence *incidence, CalendarView *view ) |
569 | { | 570 | { |
570 | mView = view; | 571 | mView = view; |
571 | return incidence->accept( *this ); | 572 | return incidence->accept( *this ); |
572 | } | 573 | } |
573 | 574 | ||
574 | protected: | 575 | protected: |
575 | CalendarView *mView; | 576 | CalendarView *mView; |
576 | }; | 577 | }; |
577 | 578 | ||
578 | class ShowIncidenceVisitor : public CalendarViewVisitor | 579 | class ShowIncidenceVisitor : public CalendarViewVisitor |
579 | { | 580 | { |
580 | protected: | 581 | protected: |
581 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 582 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
582 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 583 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
583 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 584 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
584 | }; | 585 | }; |
585 | 586 | ||
586 | class EditIncidenceVisitor : public CalendarViewVisitor | 587 | class EditIncidenceVisitor : public CalendarViewVisitor |
587 | { | 588 | { |
588 | protected: | 589 | protected: |
589 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 590 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
590 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 591 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
591 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 592 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
592 | }; | 593 | }; |
593 | 594 | ||
594 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 595 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
595 | { | 596 | { |
596 | protected: | 597 | protected: |
597 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 598 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
598 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 599 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
599 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 600 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
600 | }; | 601 | }; |
601 | 602 | ||
602 | #endif | 603 | #endif |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index ca5eadd..a8143a0 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1036 +1,1116 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 147 | i18n("Cannot move To-Do to itself or a child of itself"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | |||
214 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
215 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
216 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
217 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
218 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
219 | mMousePressed = false; | 220 | mMousePressed = false; |
220 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
221 | if (item) { | 222 | if (item) { |
222 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
223 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | if (vd->drag()) { | 227 | if (vd->drag()) { |
227 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
228 | } | 229 | } |
229 | /* | 230 | /* |
230 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
231 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
232 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
233 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
234 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
235 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
236 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
237 | */ | 238 | */ |
238 | } | 239 | } |
239 | } | 240 | } |
240 | #endif | 241 | #endif |
241 | } | 242 | } |
242 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
243 | { | 244 | { |
244 | 245 | ||
245 | QListViewItem* cn; | 246 | QListViewItem* cn; |
246 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
247 | cn = currentItem(); | 248 | cn = currentItem(); |
248 | if ( cn ) { | 249 | if ( cn ) { |
249 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
250 | if ( ci ){ | 251 | if ( ci ){ |
251 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
252 | ci->setOn( false ); | 253 | ci->setOn( false ); |
253 | else | 254 | else |
254 | ci->setOn( true ); | 255 | ci->setOn( true ); |
255 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
256 | if ( cn ) { | 257 | if ( cn ) { |
257 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
258 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
259 | } | 260 | } |
260 | 261 | ||
261 | } | 262 | } |
262 | } | 263 | } |
263 | 264 | ||
264 | return; | 265 | return; |
265 | } | 266 | } |
266 | 267 | ||
267 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
268 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
269 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
270 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
271 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
272 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
273 | break; | 274 | break; |
274 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
275 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
276 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | ||
279 | return; | ||
277 | break; | 280 | break; |
278 | default: | 281 | default: |
279 | e->ignore(); | 282 | e->ignore(); |
280 | break; | 283 | break; |
281 | } | 284 | } |
282 | return; | 285 | return; |
283 | } | 286 | } |
284 | e->ignore(); | 287 | e->ignore(); |
285 | } | 288 | } |
286 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
287 | { | 290 | { |
288 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
289 | mMousePressed = false; | 292 | mMousePressed = false; |
290 | } | 293 | } |
291 | 294 | ||
292 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
293 | { | 296 | { |
294 | if (!e) return; | 297 | if (!e) return; |
295 | 298 | ||
296 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
297 | 300 | ||
298 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
299 | 302 | ||
300 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
301 | if (!item) return; | 304 | if (!item) return; |
302 | 305 | ||
303 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
304 | } | 307 | } |
305 | 308 | ||
306 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
307 | 310 | ||
308 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
309 | QLineEdit(parent) | 312 | QLineEdit(parent) |
310 | { | 313 | { |
311 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
312 | } | 315 | } |
313 | 316 | ||
314 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
315 | { | 318 | { |
316 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
317 | setText(""); | 320 | setText(""); |
318 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
319 | } | 322 | } |
320 | 323 | ||
321 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
322 | { | 325 | { |
323 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
324 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
325 | } | 328 | } |
326 | 329 | ||
327 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
328 | 331 | ||
329 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
330 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
331 | { | 334 | { |
332 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
333 | mName = QString ( name ); | 336 | mName = QString ( name ); |
334 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
335 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
336 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
337 | 340 | ||
338 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
339 | 342 | ||
340 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
341 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
342 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
343 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
344 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
345 | 348 | ||
346 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
347 | 350 | ||
348 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
349 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
350 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
351 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
352 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
353 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
354 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
355 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
356 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
357 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
358 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
359 | #if 0 | 362 | #if 0 |
360 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
361 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
362 | #endif | 365 | #endif |
363 | 366 | ||
364 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
365 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
366 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
367 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
368 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
369 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
370 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
371 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
374 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
375 | #if 0 | 378 | #if 0 |
376 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
377 | #endif | 380 | #endif |
378 | 381 | ||
379 | mPriorityPopupMenu = new QPopupMenu(this); | 382 | mPriorityPopupMenu = new QPopupMenu(this); |
380 | for (int i = 1; i <= 5; i++) { | 383 | for (int i = 1; i <= 5; i++) { |
381 | QString label = QString ("%1").arg (i); | 384 | QString label = QString ("%1").arg (i); |
382 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
383 | } | 386 | } |
384 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
385 | 388 | ||
386 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
387 | for (int i = 0; i <= 100; i+=20) { | 390 | for (int i = 0; i <= 100; i+=20) { |
388 | QString label = QString ("%1 %").arg (i); | 391 | QString label = QString ("%1 %").arg (i); |
389 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
390 | } | 393 | } |
391 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
392 | 395 | ||
393 | 396 | ||
394 | 397 | ||
395 | mItemPopupMenu = new QPopupMenu(this); | 398 | mItemPopupMenu = new QPopupMenu(this); |
396 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 399 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
397 | SLOT (showTodo())); | 400 | SLOT (showTodo())); |
398 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
399 | SLOT (editTodo())); | 402 | SLOT (editTodo())); |
400 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 403 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
401 | SLOT (deleteTodo())); | 404 | SLOT (deleteTodo())); |
402 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
403 | SLOT (cloneTodo())); | 406 | SLOT (cloneTodo())); |
404 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 407 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
405 | SLOT (moveTodo())); | 408 | SLOT (moveTodo())); |
406 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
407 | SLOT (beamTodo())); | 410 | SLOT (beamTodo())); |
408 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
409 | SLOT (cancelTodo())); | 412 | SLOT (cancelTodo())); |
410 | mItemPopupMenu->insertSeparator(); | 413 | mItemPopupMenu->insertSeparator(); |
411 | 414 | ||
412 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
413 | SLOT (newTodo())); | 416 | SLOT (newTodo())); |
414 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
415 | SLOT (newSubTodo())); | 418 | SLOT (newSubTodo())); |
416 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
417 | SLOT (unparentTodo())); | 420 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | ||
422 | SLOT (reparentTodo()),0,22); | ||
418 | mItemPopupMenu->insertSeparator(); | 423 | mItemPopupMenu->insertSeparator(); |
419 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
420 | this, SLOT( purgeCompleted() ) ); | 425 | this, SLOT( purgeCompleted() ) ); |
421 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
422 | this, SLOT( toggleCompleted() ),0, 33 ); | 427 | this, SLOT( toggleCompleted() ),0, 33 ); |
423 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
424 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 429 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
425 | 430 | ||
426 | mPopupMenu = new QPopupMenu(this); | 431 | mPopupMenu = new QPopupMenu(this); |
427 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
428 | SLOT (newTodo()),0,1); | 433 | SLOT (newTodo()),0,1); |
429 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
430 | this, SLOT(purgeCompleted()),0,2); | 435 | this, SLOT(purgeCompleted()),0,2); |
431 | mPopupMenu->insertItem(i18n("Show Completed"), | 436 | mPopupMenu->insertItem(i18n("Show Completed"), |
432 | this, SLOT( toggleCompleted() ),0,3 ); | 437 | this, SLOT( toggleCompleted() ),0,3 ); |
433 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
434 | this, SLOT( toggleQuickTodo() ),0,4 ); | 439 | this, SLOT( toggleQuickTodo() ),0,4 ); |
435 | mDocPrefs = new DocPrefs( name ); | 440 | mDocPrefs = new DocPrefs( name ); |
436 | 441 | ||
437 | mPopupMenu->setCheckable( true ); | 442 | mPopupMenu->setCheckable( true ); |
438 | mItemPopupMenu->setCheckable( true ); | 443 | mItemPopupMenu->setCheckable( true ); |
439 | // Double clicking conflicts with opening/closing the subtree | 444 | // Double clicking conflicts with opening/closing the subtree |
440 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
441 | SLOT( editItem( QListViewItem *) ) ); | 446 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | ||
442 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
443 | const QPoint &,int ) ), | 449 | const QPoint &,int ) ), |
444 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | ||
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | ||
453 | const QPoint &,int ) ), | ||
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | ||
445 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
446 | SLOT( itemClicked( QListViewItem * ) ) ); | 456 | SLOT( itemClicked( QListViewItem * ) ) ); |
447 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
448 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
449 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
450 | SLOT( updateView() ) ); | 460 | SLOT( updateView() ) ); |
451 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
452 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 462 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
453 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
454 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 464 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
455 | 465 | ||
456 | #if 0 | 466 | #if 0 |
457 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
458 | SLOT(selectionChanged(QListViewItem *))); | 468 | SLOT(selectionChanged(QListViewItem *))); |
459 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
460 | SLOT(selectionChanged(QListViewItem *))); | 470 | SLOT(selectionChanged(QListViewItem *))); |
461 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
462 | SLOT(selectionChanged(QListViewItem *))); | 472 | SLOT(selectionChanged(QListViewItem *))); |
463 | #endif | 473 | #endif |
464 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 474 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
465 | SLOT( processSelectionChange() ) ); | 475 | SLOT( processSelectionChange() ) ); |
466 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 476 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
467 | SLOT( addQuickTodo() ) ); | 477 | SLOT( addQuickTodo() ) ); |
468 | // if ( QApplication::desktop()->width() < 480 ) { | 478 | // if ( QApplication::desktop()->width() < 480 ) { |
469 | // setNarrow(); | 479 | // setNarrow(); |
470 | // mTodoListView->setColumnWidth( 0, 100 ); | 480 | // mTodoListView->setColumnWidth( 0, 100 ); |
471 | 481 | ||
472 | // } | 482 | // } |
473 | 483 | ||
474 | } | 484 | } |
475 | 485 | ||
476 | KOTodoView::~KOTodoView() | 486 | KOTodoView::~KOTodoView() |
477 | { | 487 | { |
478 | delete mDocPrefs; | 488 | delete mDocPrefs; |
479 | } | 489 | } |
480 | 490 | ||
481 | void KOTodoView::jumpToDate () | 491 | void KOTodoView::jumpToDate () |
482 | { | 492 | { |
483 | // if (mActiveItem) { | 493 | // if (mActiveItem) { |
484 | // mActiveItem->todo()); | 494 | // mActiveItem->todo()); |
485 | // if ( mActiveItem->todo()->hasDueDate() ) | 495 | // if ( mActiveItem->todo()->hasDueDate() ) |
486 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
487 | } | 497 | } |
488 | 498 | ||
489 | void KOTodoView::setNarrow() | 499 | void KOTodoView::setNarrow() |
490 | { | 500 | { |
491 | //mTodoListView->setColumnWidth( 0, 120 ); | 501 | //mTodoListView->setColumnWidth( 0, 120 ); |
492 | mTodoListView->setColumnWidth( 1, 35 ); | 502 | mTodoListView->setColumnWidth( 1, 35 ); |
493 | mTodoListView->setColumnWidth( 2, 40 ); | 503 | mTodoListView->setColumnWidth( 2, 40 ); |
494 | mTodoListView->setColumnWidth( 3, 80 ); | 504 | mTodoListView->setColumnWidth( 3, 80 ); |
495 | mTodoListView->setColumnWidth( 4, 40 ); | 505 | mTodoListView->setColumnWidth( 4, 40 ); |
496 | mTodoListView->setColumnWidth( 5, 90 ); | 506 | mTodoListView->setColumnWidth( 5, 90 ); |
497 | 507 | ||
498 | } | 508 | } |
499 | void KOTodoView::updateView() | 509 | void KOTodoView::updateView() |
500 | { | 510 | { |
501 | 511 | ||
502 | if ( mBlockUpdate ) { | 512 | if ( mBlockUpdate ) { |
503 | //qDebug("blocked "); | 513 | //qDebug("blocked "); |
504 | return; | 514 | return; |
505 | } | 515 | } |
506 | //qDebug("update "); | 516 | //qDebug("update "); |
507 | // kdDebug() << "KOTodoView::updateView()" << endl; | 517 | // kdDebug() << "KOTodoView::updateView()" << endl; |
508 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 518 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
509 | mTodoListView->clear(); | 519 | mTodoListView->clear(); |
510 | if ( mName == "todolistsmall" ) { | 520 | if ( mName == "todolistsmall" ) { |
511 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
512 | int ps = fo.pointSize() -2; | 522 | int ps = fo.pointSize() -2; |
513 | if ( ps > 12 ) | 523 | if ( ps > 12 ) |
514 | ps -= 2; | 524 | ps -= 2; |
515 | fo.setPointSize( ps ); | 525 | fo.setPointSize( ps ); |
516 | } | 526 | } |
517 | } | 527 | } |
518 | 528 | ||
519 | mTodoListView->setFont( fo ); | 529 | mTodoListView->setFont( fo ); |
520 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
521 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 531 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
522 | QPtrList<Todo> todoList = calendar()->todos(); | 532 | QPtrList<Todo> todoList = calendar()->todos(); |
523 | 533 | ||
524 | /* | 534 | /* |
525 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
526 | Event *t; | 536 | Event *t; |
527 | for(t = todoList.first(); t; t = todoList.next()) { | 537 | for(t = todoList.first(); t; t = todoList.next()) { |
528 | kdDebug() << " " << t->getSummary() << endl; | 538 | kdDebug() << " " << t->getSummary() << endl; |
529 | 539 | ||
530 | if (t->getRelatedTo()) { | 540 | if (t->getRelatedTo()) { |
531 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
532 | } | 542 | } |
533 | 543 | ||
534 | QPtrList<Event> l = t->getRelations(); | 544 | QPtrList<Event> l = t->getRelations(); |
535 | Event *c; | 545 | Event *c; |
536 | for(c=l.first();c;c=l.next()) { | 546 | for(c=l.first();c;c=l.next()) { |
537 | kdDebug() << " - relation: " << c->getSummary() << endl; | 547 | kdDebug() << " - relation: " << c->getSummary() << endl; |
538 | } | 548 | } |
539 | } | 549 | } |
540 | */ | 550 | */ |
541 | 551 | ||
542 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 552 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
543 | // specific order of events. That means that we have to generate parent items | 553 | // specific order of events. That means that we have to generate parent items |
544 | // recursively for proper hierarchical display of Todos. | 554 | // recursively for proper hierarchical display of Todos. |
545 | mTodoMap.clear(); | 555 | mTodoMap.clear(); |
546 | Todo *todo; | 556 | Todo *todo; |
547 | todo = todoList.first();// todo; todo = todoList.next()) { | 557 | todo = todoList.first();// todo; todo = todoList.next()) { |
548 | while ( todo ) { | 558 | while ( todo ) { |
549 | bool next = true; | 559 | bool next = true; |
550 | // qDebug("todo %s ", todo->summary().latin1()); | 560 | // qDebug("todo %s ", todo->summary().latin1()); |
551 | Incidence *incidence = todo->relatedTo(); | 561 | Incidence *incidence = todo->relatedTo(); |
552 | while ( incidence ) { | 562 | while ( incidence ) { |
553 | if ( incidence->type() == "Todo") { | 563 | if ( incidence->type() == "Todo") { |
554 | //qDebug("related %s ",incidence->summary().latin1() ); | 564 | //qDebug("related %s ",incidence->summary().latin1() ); |
555 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 565 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
556 | //qDebug("related not found "); | 566 | //qDebug("related not found "); |
557 | todoList.remove( ); | 567 | todoList.remove( ); |
558 | todo = todoList.current(); | 568 | todo = todoList.current(); |
559 | next = false; | 569 | next = false; |
560 | incidence = 0; | 570 | incidence = 0; |
561 | 571 | ||
562 | } else { | 572 | } else { |
563 | //qDebug("related found "); | 573 | //qDebug("related found "); |
564 | incidence = incidence->relatedTo(); | 574 | incidence = incidence->relatedTo(); |
565 | } | 575 | } |
566 | } else | 576 | } else |
567 | incidence = 0; | 577 | incidence = 0; |
568 | } | 578 | } |
569 | if ( next ) | 579 | if ( next ) |
570 | todo = todoList.next(); | 580 | todo = todoList.next(); |
571 | } | 581 | } |
572 | // qDebug("again .... "); | 582 | // qDebug("again .... "); |
573 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 583 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
574 | 584 | ||
575 | // qDebug("yytodo %s ", todo->summary().latin1()); | 585 | // qDebug("yytodo %s ", todo->summary().latin1()); |
576 | // } | 586 | // } |
577 | //qDebug("for "); | 587 | //qDebug("for "); |
578 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 588 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
579 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) | 589 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) |
580 | { | 590 | { |
581 | insertTodoItem(todo); | 591 | insertTodoItem(todo); |
582 | } | 592 | } |
583 | } | 593 | } |
584 | //qDebug("for end "); | 594 | //qDebug("for end "); |
585 | // Restore opened/closed state | 595 | // Restore opened/closed state |
586 | mTodoListView->blockSignals( true ); | 596 | mTodoListView->blockSignals( true ); |
587 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 597 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
588 | mTodoListView->blockSignals( false ); | 598 | mTodoListView->blockSignals( false ); |
589 | mTodoListView->setFocus(); | 599 | mTodoListView->setFocus(); |
590 | processSelectionChange(); | 600 | processSelectionChange(); |
591 | } | 601 | } |
592 | 602 | ||
593 | void KOTodoView::restoreItemState( QListViewItem *item ) | 603 | void KOTodoView::restoreItemState( QListViewItem *item ) |
594 | { | 604 | { |
595 | while( item ) { | 605 | while( item ) { |
596 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 606 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
597 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 607 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
598 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 608 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
599 | item = item->nextSibling(); | 609 | item = item->nextSibling(); |
600 | } | 610 | } |
601 | } | 611 | } |
602 | 612 | ||
603 | 613 | ||
604 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 614 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
605 | KOTodoView::insertTodoItem(Todo *todo) | 615 | KOTodoView::insertTodoItem(Todo *todo) |
606 | { | 616 | { |
607 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 617 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
608 | // TODO: Check, if dynmaic cast is necessary | 618 | // TODO: Check, if dynmaic cast is necessary |
609 | 619 | ||
610 | 620 | ||
611 | Incidence *incidence = todo->relatedTo(); | 621 | Incidence *incidence = todo->relatedTo(); |
612 | if (incidence && incidence->type() == "Todo") { | 622 | if (incidence && incidence->type() == "Todo") { |
613 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 623 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
614 | 624 | ||
615 | // kdDebug() << " has Related" << endl; | 625 | // kdDebug() << " has Related" << endl; |
616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 626 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
617 | itemIterator = mTodoMap.find(relatedTodo); | 627 | itemIterator = mTodoMap.find(relatedTodo); |
618 | if (itemIterator == mTodoMap.end()) { | 628 | if (itemIterator == mTodoMap.end()) { |
619 | // kdDebug() << " related not yet in list" << endl; | 629 | // kdDebug() << " related not yet in list" << endl; |
620 | itemIterator = insertTodoItem (relatedTodo); | 630 | itemIterator = insertTodoItem (relatedTodo); |
621 | } | 631 | } |
622 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 632 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
623 | // and one into the map. Sure finding is more easy but why? -zecke | 633 | // and one into the map. Sure finding is more easy but why? -zecke |
624 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 634 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
625 | return mTodoMap.insert(todo,todoItem); | 635 | return mTodoMap.insert(todo,todoItem); |
626 | } else { | 636 | } else { |
627 | // kdDebug() << " no Related" << endl; | 637 | // kdDebug() << " no Related" << endl; |
628 | // see above -zecke | 638 | // see above -zecke |
629 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 639 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
630 | return mTodoMap.insert(todo,todoItem); | 640 | return mTodoMap.insert(todo,todoItem); |
631 | } | 641 | } |
632 | } | 642 | } |
633 | 643 | ||
634 | 644 | ||
635 | void KOTodoView::updateConfig() | 645 | void KOTodoView::updateConfig() |
636 | { | 646 | { |
637 | updateView(); | 647 | updateView(); |
638 | mTodoListView->repaintContents(); | 648 | mTodoListView->repaintContents(); |
639 | } | 649 | } |
640 | 650 | ||
641 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 651 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
642 | { | 652 | { |
643 | QPtrList<Incidence> selected; | 653 | QPtrList<Incidence> selected; |
644 | 654 | ||
645 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 655 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
646 | // if (!item) item = mActiveItem; | 656 | // if (!item) item = mActiveItem; |
647 | if (item) selected.append(item->todo()); | 657 | if (item) selected.append(item->todo()); |
648 | 658 | ||
649 | return selected; | 659 | return selected; |
650 | } | 660 | } |
651 | 661 | ||
652 | QPtrList<Todo> KOTodoView::selectedTodos() | 662 | QPtrList<Todo> KOTodoView::selectedTodos() |
653 | { | 663 | { |
654 | QPtrList<Todo> selected; | 664 | QPtrList<Todo> selected; |
655 | 665 | ||
656 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 666 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
657 | // if (!item) item = mActiveItem; | 667 | // if (!item) item = mActiveItem; |
658 | if (item) selected.append(item->todo()); | 668 | if (item) selected.append(item->todo()); |
659 | 669 | ||
660 | return selected; | 670 | return selected; |
661 | } | 671 | } |
662 | 672 | ||
663 | void KOTodoView::changeEventDisplay(Event *, int) | 673 | void KOTodoView::changeEventDisplay(Event *, int) |
664 | { | 674 | { |
665 | updateView(); | 675 | updateView(); |
666 | } | 676 | } |
667 | 677 | ||
668 | void KOTodoView::showDates(const QDate &, const QDate &) | 678 | void KOTodoView::showDates(const QDate &, const QDate &) |
669 | { | 679 | { |
670 | } | 680 | } |
671 | 681 | ||
672 | void KOTodoView::showEvents(QPtrList<Event>) | 682 | void KOTodoView::showEvents(QPtrList<Event>) |
673 | { | 683 | { |
674 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 684 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
675 | } | 685 | } |
676 | 686 | ||
677 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 687 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
678 | const QDate &td) | 688 | const QDate &td) |
679 | { | 689 | { |
680 | #ifndef KORG_NOPRINTER | 690 | #ifndef KORG_NOPRINTER |
681 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 691 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
682 | #endif | 692 | #endif |
683 | } | 693 | } |
684 | 694 | ||
685 | void KOTodoView::editItem(QListViewItem *item ) | 695 | void KOTodoView::editItem(QListViewItem *item ) |
686 | { | 696 | { |
687 | // qDebug("editItem(QListViewItem *item ) "); | 697 | // qDebug("editItem(QListViewItem *item ) "); |
688 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 698 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
689 | } | 699 | } |
690 | 700 | ||
691 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 701 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
692 | { | 702 | { |
693 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 703 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
694 | } | 704 | } |
695 | 705 | ||
696 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 706 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
697 | { | 707 | { |
698 | |||
699 | mActiveItem = (KOTodoViewItem *)item; | 708 | mActiveItem = (KOTodoViewItem *)item; |
700 | if (item) { | 709 | if (item) { |
701 | switch (column){ | 710 | switch (column){ |
702 | case 1: | 711 | case 1: |
703 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 712 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
704 | case 2: | 713 | case 2: |
705 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 714 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
706 | case 3: | 715 | case 3: |
707 | moveTodo(); | 716 | moveTodo(); |
708 | break; | 717 | break; |
709 | case 6: | 718 | case 6: |
710 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 719 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
711 | default: | 720 | default: |
712 | mItemPopupMenu->popup(QCursor::pos()); | 721 | mItemPopupMenu->popup(QCursor::pos()); |
713 | } | 722 | } |
714 | } else mPopupMenu->popup(QCursor::pos()); | 723 | } else mPopupMenu->popup(QCursor::pos()); |
715 | } | 724 | } |
716 | void KOTodoView::newTodo() | 725 | void KOTodoView::newTodo() |
717 | { | 726 | { |
718 | emit newTodoSignal(); | 727 | emit newTodoSignal(); |
719 | } | 728 | } |
720 | 729 | ||
721 | void KOTodoView::newSubTodo() | 730 | void KOTodoView::newSubTodo() |
722 | { | 731 | { |
723 | if (mActiveItem) { | 732 | if (mActiveItem) { |
724 | emit newSubTodoSignal(mActiveItem->todo()); | 733 | emit newSubTodoSignal(mActiveItem->todo()); |
725 | } | 734 | } |
726 | } | 735 | } |
727 | void KOTodoView::unparentTodo() | 736 | void KOTodoView::unparentTodo() |
728 | { | 737 | { |
729 | if (mActiveItem) { | 738 | if (mActiveItem) { |
730 | emit unparentTodoSignal(mActiveItem->todo()); | 739 | emit unparentTodoSignal(mActiveItem->todo()); |
731 | } | 740 | } |
732 | } | 741 | } |
742 | |||
743 | void KOTodoView::reparentTodo() | ||
744 | { | ||
745 | if (mActiveItem) { | ||
746 | qDebug("KOTodoView::reparentTodo() "); | ||
747 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | ||
748 | pendingSubtodo = mActiveItem; | ||
749 | } | ||
750 | } | ||
733 | void KOTodoView::editTodo() | 751 | void KOTodoView::editTodo() |
734 | { | 752 | { |
735 | if (mActiveItem) { | 753 | if (mActiveItem) { |
736 | emit editTodoSignal(mActiveItem->todo()); | 754 | emit editTodoSignal(mActiveItem->todo()); |
737 | } | 755 | } |
738 | } | 756 | } |
739 | void KOTodoView::cloneTodo() | 757 | void KOTodoView::cloneTodo() |
740 | { | 758 | { |
741 | if (mActiveItem) { | 759 | if (mActiveItem) { |
742 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 760 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
743 | } | 761 | } |
744 | } | 762 | } |
745 | void KOTodoView::cancelTodo() | 763 | void KOTodoView::cancelTodo() |
746 | { | 764 | { |
747 | if (mActiveItem) { | 765 | if (mActiveItem) { |
748 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 766 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
749 | } | 767 | } |
750 | } | 768 | } |
751 | void KOTodoView::moveTodo() | 769 | void KOTodoView::moveTodo() |
752 | { | 770 | { |
753 | if (mActiveItem) { | 771 | if (mActiveItem) { |
754 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 772 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
755 | } | 773 | } |
756 | } | 774 | } |
757 | void KOTodoView::beamTodo() | 775 | void KOTodoView::beamTodo() |
758 | { | 776 | { |
759 | if (mActiveItem) { | 777 | if (mActiveItem) { |
760 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 778 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
761 | } | 779 | } |
762 | } | 780 | } |
763 | 781 | ||
764 | 782 | ||
765 | void KOTodoView::showTodo() | 783 | void KOTodoView::showTodo() |
766 | { | 784 | { |
767 | if (mActiveItem) { | 785 | if (mActiveItem) { |
768 | emit showTodoSignal(mActiveItem->todo()); | 786 | emit showTodoSignal(mActiveItem->todo()); |
769 | } | 787 | } |
770 | } | 788 | } |
771 | 789 | ||
772 | void KOTodoView::deleteTodo() | 790 | void KOTodoView::deleteTodo() |
773 | { | 791 | { |
774 | if (mActiveItem) { | 792 | if (mActiveItem) { |
775 | if (mActiveItem->childCount()) { | 793 | if (mActiveItem->childCount()) { |
776 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), | 794 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), |
777 | i18n("Delete To-Do")); | 795 | i18n("Delete To-Do")); |
778 | } else { | 796 | } else { |
779 | emit deleteTodoSignal(mActiveItem->todo()); | 797 | emit deleteTodoSignal(mActiveItem->todo()); |
780 | } | 798 | } |
781 | } | 799 | } |
782 | } | 800 | } |
783 | 801 | ||
784 | void KOTodoView::setNewPriority(int index) | 802 | void KOTodoView::setNewPriority(int index) |
785 | { | 803 | { |
786 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 804 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
787 | mActiveItem->todo()->setPriority(mPriority[index]); | 805 | mActiveItem->todo()->setPriority(mPriority[index]); |
788 | mActiveItem->construct(); | 806 | mActiveItem->construct(); |
789 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 807 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
790 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 808 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
791 | } | 809 | } |
792 | } | 810 | } |
793 | 811 | ||
794 | void KOTodoView::setNewPercentage(int index) | 812 | void KOTodoView::setNewPercentage(int index) |
795 | { | 813 | { |
796 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 814 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
797 | if (mPercentage[index] == 100) { | 815 | if (mPercentage[index] == 100) { |
798 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 816 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
799 | } else { | 817 | } else { |
800 | mActiveItem->todo()->setCompleted(false); | 818 | mActiveItem->todo()->setCompleted(false); |
801 | } | 819 | } |
802 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 820 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
803 | mActiveItem->construct(); | 821 | mActiveItem->construct(); |
804 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 822 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
805 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 823 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
806 | } | 824 | } |
807 | } | 825 | } |
808 | 826 | ||
809 | 827 | ||
810 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 828 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
811 | { | 829 | { |
812 | QPopupMenu* tempMenu = new QPopupMenu (this); | 830 | QPopupMenu* tempMenu = new QPopupMenu (this); |
813 | QStringList checkedCategories = todoItem->todo()->categories (); | 831 | QStringList checkedCategories = todoItem->todo()->categories (); |
814 | 832 | ||
815 | tempMenu->setCheckable (true); | 833 | tempMenu->setCheckable (true); |
816 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 834 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
817 | it != KOPrefs::instance()->mCustomCategories.end (); | 835 | it != KOPrefs::instance()->mCustomCategories.end (); |
818 | ++it) { | 836 | ++it) { |
819 | int index = tempMenu->insertItem (*it); | 837 | int index = tempMenu->insertItem (*it); |
820 | mCategory[index] = *it; | 838 | mCategory[index] = *it; |
821 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 839 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
822 | } | 840 | } |
823 | 841 | ||
824 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 842 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
825 | return tempMenu; | 843 | return tempMenu; |
826 | 844 | ||
827 | 845 | ||
828 | } | 846 | } |
829 | void KOTodoView::changedCategories(int index) | 847 | void KOTodoView::changedCategories(int index) |
830 | { | 848 | { |
831 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 849 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
832 | QStringList categories = mActiveItem->todo()->categories (); | 850 | QStringList categories = mActiveItem->todo()->categories (); |
833 | if (categories.find (mCategory[index]) != categories.end ()) | 851 | if (categories.find (mCategory[index]) != categories.end ()) |
834 | categories.remove (mCategory[index]); | 852 | categories.remove (mCategory[index]); |
835 | else | 853 | else |
836 | categories.insert (categories.end(), mCategory[index]); | 854 | categories.insert (categories.end(), mCategory[index]); |
837 | categories.sort (); | 855 | categories.sort (); |
838 | mActiveItem->todo()->setCategories (categories); | 856 | mActiveItem->todo()->setCategories (categories); |
839 | mActiveItem->construct(); | 857 | mActiveItem->construct(); |
840 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 858 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
841 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 859 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
842 | } | 860 | } |
843 | } | 861 | } |
844 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 862 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
845 | { | 863 | { |
864 | if ( pendingSubtodo != 0 ) { | ||
865 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | ||
866 | } | ||
867 | pendingSubtodo = 0; | ||
846 | if (!item) { | 868 | if (!item) { |
847 | newTodo(); | 869 | newTodo(); |
848 | return; | 870 | return; |
849 | } | 871 | } |
850 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 872 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
851 | editItem( item ); | 873 | editItem( item ); |
852 | else | 874 | else |
853 | showItem( item , QPoint(), 0 ); | 875 | showItem( item , QPoint(), 0 ); |
854 | } | 876 | } |
855 | void KOTodoView::itemClicked(QListViewItem *item) | 877 | void KOTodoView::itemClicked(QListViewItem *item) |
856 | { | 878 | { |
879 | |||
857 | if (!item) { | 880 | if (!item) { |
881 | if ( pendingSubtodo != 0 ) { | ||
882 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | ||
883 | } | ||
884 | pendingSubtodo = 0; | ||
858 | return; | 885 | return; |
859 | } | 886 | } |
860 | |||
861 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 887 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
888 | if ( pendingSubtodo != 0 ) { | ||
889 | bool allowReparent = true; | ||
890 | QListViewItem *par = item; | ||
891 | while ( par ) { | ||
892 | if ( par == pendingSubtodo ) { | ||
893 | allowReparent = false; | ||
894 | break; | ||
895 | } | ||
896 | par = par->parent(); | ||
897 | } | ||
898 | if ( !allowReparent ) { | ||
899 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | ||
900 | qDebug("Recursive reparenting not possible "); | ||
901 | pendingSubtodo = 0; | ||
902 | } else { | ||
903 | Todo* newParent = todoItem->todo(); | ||
904 | Todo* newSub = pendingSubtodo->todo(); | ||
905 | pendingSubtodo = 0; | ||
906 | emit reparentTodoSignal( newParent,newSub ); | ||
907 | return; | ||
908 | } | ||
909 | } | ||
862 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 910 | int completed = todoItem->todo()->isCompleted(); // Completed or not? |
863 | 911 | ||
864 | if (todoItem->isOn()) { | 912 | if (todoItem->isOn()) { |
865 | if (!completed) { | 913 | if (!completed) { |
866 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 914 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
867 | } | 915 | } |
868 | } else { | 916 | } else { |
869 | if (completed) { | 917 | if (completed) { |
870 | todoItem->todo()->setCompleted(false); | 918 | todoItem->todo()->setCompleted(false); |
871 | } | 919 | } |
872 | } | 920 | } |
873 | } | 921 | } |
874 | 922 | ||
875 | void KOTodoView::setDocumentId( const QString &id ) | 923 | void KOTodoView::setDocumentId( const QString &id ) |
876 | { | 924 | { |
877 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 925 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
878 | 926 | ||
879 | mDocPrefs->setDoc( id ); | 927 | mDocPrefs->setDoc( id ); |
880 | } | 928 | } |
881 | 929 | ||
882 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 930 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
883 | { | 931 | { |
884 | if (!item) return; | 932 | if (!item) return; |
885 | 933 | ||
886 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 934 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
887 | 935 | ||
888 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 936 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
889 | 937 | ||
890 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 938 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
891 | } | 939 | } |
892 | 940 | ||
893 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 941 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
894 | { | 942 | { |
895 | mTodoListView->saveLayout(config,group); | 943 | mTodoListView->saveLayout(config,group); |
896 | } | 944 | } |
897 | 945 | ||
898 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 946 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
899 | { | 947 | { |
900 | mTodoListView->restoreLayout(config,group); | 948 | mTodoListView->restoreLayout(config,group); |
901 | } | 949 | } |
902 | 950 | ||
903 | void KOTodoView::processSelectionChange() | 951 | void KOTodoView::processSelectionChange() |
904 | { | 952 | { |
905 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 953 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
906 | 954 | ||
907 | KOTodoViewItem *item = | 955 | KOTodoViewItem *item = |
908 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 956 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
909 | 957 | ||
910 | if ( !item ) { | 958 | if ( !item ) { |
911 | emit incidenceSelected( 0 ); | 959 | emit incidenceSelected( 0 ); |
912 | } else { | 960 | } else { |
913 | emit incidenceSelected( item->todo() ); | 961 | emit incidenceSelected( item->todo() ); |
914 | } | 962 | } |
915 | } | 963 | } |
916 | 964 | ||
917 | void KOTodoView::modified(bool b) | 965 | void KOTodoView::modified(bool b) |
918 | { | 966 | { |
919 | emit isModified(b); | 967 | emit isModified(b); |
920 | } | 968 | } |
921 | void KOTodoView::setTodoModified( Todo* todo ) | 969 | void KOTodoView::setTodoModified( Todo* todo ) |
922 | { | 970 | { |
923 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 971 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
924 | } | 972 | } |
925 | void KOTodoView::clearSelection() | 973 | void KOTodoView::clearSelection() |
926 | { | 974 | { |
927 | mTodoListView->selectAll( false ); | 975 | mTodoListView->selectAll( false ); |
928 | } | 976 | } |
929 | 977 | ||
930 | void KOTodoView::purgeCompleted() | 978 | void KOTodoView::purgeCompleted() |
931 | { | 979 | { |
932 | emit purgeCompletedSignal(); | 980 | emit purgeCompletedSignal(); |
933 | } | 981 | } |
934 | void KOTodoView::toggleQuickTodo() | 982 | void KOTodoView::toggleQuickTodo() |
935 | { | 983 | { |
936 | if ( mQuickAdd->isVisible() ) { | 984 | if ( mQuickAdd->isVisible() ) { |
937 | mQuickAdd->hide(); | 985 | mQuickAdd->hide(); |
938 | KOPrefs::instance()->mEnableQuickTodo = false; | 986 | KOPrefs::instance()->mEnableQuickTodo = false; |
939 | } | 987 | } |
940 | else { | 988 | else { |
941 | mQuickAdd->show(); | 989 | mQuickAdd->show(); |
942 | KOPrefs::instance()->mEnableQuickTodo = true; | 990 | KOPrefs::instance()->mEnableQuickTodo = true; |
943 | } | 991 | } |
944 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 992 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
945 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 993 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
946 | } | 994 | } |
947 | void KOTodoView::toggleCompleted() | 995 | void KOTodoView::toggleCompleted() |
948 | { | 996 | { |
949 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 997 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
950 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 998 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
951 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 999 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
952 | updateView(); | 1000 | updateView(); |
953 | } | 1001 | } |
954 | 1002 | ||
955 | void KOTodoView::addQuickTodo() | 1003 | void KOTodoView::addQuickTodo() |
956 | { | 1004 | { |
957 | Todo *todo = new Todo(); | 1005 | Todo *todo = new Todo(); |
958 | todo->setSummary(mQuickAdd->text()); | 1006 | todo->setSummary(mQuickAdd->text()); |
959 | todo->setOrganizer(KOPrefs::instance()->email()); | 1007 | todo->setOrganizer(KOPrefs::instance()->email()); |
960 | CalFilter * cf = mCalendar->filter(); | 1008 | CalFilter * cf = mCalendar->filter(); |
961 | if ( cf ) { | 1009 | if ( cf ) { |
962 | if ( cf->isEnabled()&& cf->showCategories()) { | 1010 | if ( cf->isEnabled()&& cf->showCategories()) { |
963 | todo->setCategories(cf->categoryList()); | 1011 | todo->setCategories(cf->categoryList()); |
964 | } | 1012 | } |
965 | if ( cf->isEnabled() ) | 1013 | if ( cf->isEnabled() ) |
966 | todo->setSecrecy( cf->getSecrecy()); | 1014 | todo->setSecrecy( cf->getSecrecy()); |
967 | } | 1015 | } |
968 | mCalendar->addTodo(todo); | 1016 | mCalendar->addTodo(todo); |
969 | mQuickAdd->setText(""); | 1017 | mQuickAdd->setText(""); |
970 | todoModified (todo, KOGlobals::EVENTADDED ); | 1018 | todoModified (todo, KOGlobals::EVENTADDED ); |
971 | updateView(); | 1019 | updateView(); |
972 | } | 1020 | } |
973 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1021 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
974 | { | 1022 | { |
975 | // e->ignore(); | 1023 | // e->ignore(); |
976 | //return; | 1024 | //return; |
1025 | //qDebug("KOTodoView::keyPressEvent "); | ||
977 | switch ( e->key() ) { | 1026 | switch ( e->key() ) { |
978 | case Qt::Key_Down: | 1027 | case Qt::Key_Down: |
979 | case Qt::Key_Up: | 1028 | case Qt::Key_Up: |
980 | QWidget::keyPressEvent ( e ); | 1029 | QWidget::keyPressEvent ( e ); |
981 | break; | 1030 | break; |
982 | 1031 | ||
983 | case Qt::Key_Q: | 1032 | case Qt::Key_Q: |
984 | toggleQuickTodo(); | 1033 | toggleQuickTodo(); |
985 | break; | 1034 | break; |
986 | 1035 | case Qt::Key_U: | |
1036 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1037 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1038 | unparentTodo(); | ||
1039 | e->accept(); | ||
1040 | } else | ||
1041 | e->ignore(); | ||
1042 | break; | ||
1043 | case Qt::Key_S: | ||
1044 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1045 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1046 | reparentTodo(); | ||
1047 | e->accept(); | ||
1048 | } else | ||
1049 | e->ignore(); | ||
1050 | break; | ||
1051 | case Qt::Key_P: | ||
1052 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1053 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1054 | if ( pendingSubtodo ) | ||
1055 | itemClicked(mActiveItem); | ||
1056 | e->accept(); | ||
1057 | } else | ||
1058 | e->ignore(); | ||
1059 | break; | ||
1060 | case Qt::Key_Escape: | ||
1061 | if ( pendingSubtodo ) { | ||
1062 | itemClicked(0); | ||
1063 | e->accept(); | ||
1064 | } else | ||
1065 | e->ignore(); | ||
1066 | break; | ||
987 | default: | 1067 | default: |
988 | e->ignore(); | 1068 | e->ignore(); |
989 | } | 1069 | } |
990 | 1070 | ||
991 | if ( true ) { | 1071 | if ( true ) { |
992 | if ( e->key() == Qt::Key_I ) { | 1072 | if ( e->key() == Qt::Key_I ) { |
993 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1073 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
994 | if ( cn ) { | 1074 | if ( cn ) { |
995 | mActiveItem = cn; | 1075 | mActiveItem = cn; |
996 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1076 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
997 | if ( ci ){ | 1077 | if ( ci ){ |
998 | showTodo(); | 1078 | showTodo(); |
999 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1079 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1000 | if ( cn ) { | 1080 | if ( cn ) { |
1001 | mTodoListView->setCurrentItem ( cn ); | 1081 | mTodoListView->setCurrentItem ( cn ); |
1002 | mTodoListView->ensureItemVisible ( cn ); | 1082 | mTodoListView->ensureItemVisible ( cn ); |
1003 | } | 1083 | } |
1004 | 1084 | ||
1005 | } | 1085 | } |
1006 | } | 1086 | } |
1007 | e->accept(); | 1087 | e->accept(); |
1008 | 1088 | ||
1009 | } | 1089 | } |
1010 | 1090 | ||
1011 | } | 1091 | } |
1012 | 1092 | ||
1013 | } | 1093 | } |
1014 | void KOTodoView::updateTodo( Todo * t, int type ) | 1094 | void KOTodoView::updateTodo( Todo * t, int type ) |
1015 | { | 1095 | { |
1016 | if ( mBlockUpdate) | 1096 | if ( mBlockUpdate) |
1017 | return; | 1097 | return; |
1018 | 1098 | ||
1019 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1099 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1020 | itemIterator = mTodoMap.find(t); | 1100 | itemIterator = mTodoMap.find(t); |
1021 | if (itemIterator != mTodoMap.end()) { | 1101 | if (itemIterator != mTodoMap.end()) { |
1022 | (*itemIterator)->construct(); | 1102 | (*itemIterator)->construct(); |
1023 | } else { | 1103 | } else { |
1024 | if ( type == KOGlobals::EVENTADDED ) { | 1104 | if ( type == KOGlobals::EVENTADDED ) { |
1025 | insertTodoItem( t ); | 1105 | insertTodoItem( t ); |
1026 | } | 1106 | } |
1027 | } | 1107 | } |
1028 | 1108 | ||
1029 | } | 1109 | } |
1030 | 1110 | ||
1031 | void KOTodoView::todoModified(Todo * t , int p ) | 1111 | void KOTodoView::todoModified(Todo * t , int p ) |
1032 | { | 1112 | { |
1033 | mBlockUpdate = true; | 1113 | mBlockUpdate = true; |
1034 | emit todoModifiedSignal ( t, p ); | 1114 | emit todoModifiedSignal ( t, p ); |
1035 | mBlockUpdate = false; | 1115 | mBlockUpdate = false; |
1036 | } | 1116 | } |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 6bf0203..0c08677 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -1,231 +1,234 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOTODOVIEW_H | 23 | #ifndef KOTODOVIEW_H |
24 | #define KOTODOVIEW_H | 24 | #define KOTODOVIEW_H |
25 | 25 | ||
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qmap.h> | 34 | #include <qmap.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <klistview.h> | 36 | #include <klistview.h> |
37 | 37 | ||
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | 40 | ||
41 | #include <korganizer/baseview.h> | 41 | #include <korganizer/baseview.h> |
42 | 42 | ||
43 | #include "kotodoviewitem.h" | 43 | #include "kotodoviewitem.h" |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include "koglobals.h" | 45 | #include "koglobals.h" |
46 | 46 | ||
47 | class QDragEnterEvent; | 47 | class QDragEnterEvent; |
48 | class QDragMoveEvent; | 48 | class QDragMoveEvent; |
49 | class QDragLeaveEvent; | 49 | class QDragLeaveEvent; |
50 | class QDropEvent; | 50 | class QDropEvent; |
51 | 51 | ||
52 | class DocPrefs; | 52 | class DocPrefs; |
53 | 53 | ||
54 | class KOTodoListView : public KListView | 54 | class KOTodoListView : public KListView |
55 | { | 55 | { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 58 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
59 | virtual ~KOTodoListView() {} | 59 | virtual ~KOTodoListView() {} |
60 | 60 | ||
61 | signals: | 61 | signals: |
62 | void todoDropped(Todo *); | 62 | void todoDropped(Todo *); |
63 | void double_Clicked(QListViewItem *item); | 63 | void double_Clicked(QListViewItem *item); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | void contentsDragEnterEvent(QDragEnterEvent *); | 66 | void contentsDragEnterEvent(QDragEnterEvent *); |
67 | void contentsDragMoveEvent(QDragMoveEvent *); | 67 | void contentsDragMoveEvent(QDragMoveEvent *); |
68 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 68 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
69 | void contentsDropEvent(QDropEvent *); | 69 | void contentsDropEvent(QDropEvent *); |
70 | 70 | ||
71 | void contentsMousePressEvent(QMouseEvent *); | 71 | void contentsMousePressEvent(QMouseEvent *); |
72 | void contentsMouseMoveEvent(QMouseEvent *); | 72 | void contentsMouseMoveEvent(QMouseEvent *); |
73 | void contentsMouseReleaseEvent(QMouseEvent *); | 73 | void contentsMouseReleaseEvent(QMouseEvent *); |
74 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 74 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
75 | 75 | ||
76 | private: | 76 | private: |
77 | QString mName; | 77 | QString mName; |
78 | Calendar *mCalendar; | 78 | Calendar *mCalendar; |
79 | QPoint mPressPos; | 79 | QPoint mPressPos; |
80 | bool mMousePressed; | 80 | bool mMousePressed; |
81 | QListViewItem *mOldCurrent; | 81 | QListViewItem *mOldCurrent; |
82 | void keyPressEvent ( QKeyEvent * ) ; | 82 | void keyPressEvent ( QKeyEvent * ) ; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | /** | 86 | /** |
87 | This is the line-edit on top of the todoview for fast addition of new todos | 87 | This is the line-edit on top of the todoview for fast addition of new todos |
88 | */ | 88 | */ |
89 | class KOQuickTodo : public QLineEdit | 89 | class KOQuickTodo : public QLineEdit |
90 | { | 90 | { |
91 | public: | 91 | public: |
92 | KOQuickTodo(QWidget *parent=0); | 92 | KOQuickTodo(QWidget *parent=0); |
93 | protected: | 93 | protected: |
94 | void focusInEvent(QFocusEvent *ev); | 94 | void focusInEvent(QFocusEvent *ev); |
95 | void focusOutEvent(QFocusEvent *ev); | 95 | void focusOutEvent(QFocusEvent *ev); |
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | /** | 99 | /** |
100 | This class provides a multi-column list view of todo events. | 100 | This class provides a multi-column list view of todo events. |
101 | 101 | ||
102 | @short multi-column list view of todo events. | 102 | @short multi-column list view of todo events. |
103 | @author Cornelius Schumacher <schumacher@kde.org> | 103 | @author Cornelius Schumacher <schumacher@kde.org> |
104 | */ | 104 | */ |
105 | class KOTodoView : public KOrg::BaseView | 105 | class KOTodoView : public KOrg::BaseView |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); | 109 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); |
110 | ~KOTodoView(); | 110 | ~KOTodoView(); |
111 | 111 | ||
112 | QPtrList<Incidence> selectedIncidences(); | 112 | QPtrList<Incidence> selectedIncidences(); |
113 | QPtrList<Todo> selectedTodos(); | 113 | QPtrList<Todo> selectedTodos(); |
114 | 114 | ||
115 | DateList selectedDates() | 115 | DateList selectedDates() |
116 | {DateList q; | 116 | {DateList q; |
117 | return q;} | 117 | return q;} |
118 | 118 | ||
119 | /** Return number of shown dates. TodoView does not show dates, */ | 119 | /** Return number of shown dates. TodoView does not show dates, */ |
120 | int currentDateCount() { return 0; } | 120 | int currentDateCount() { return 0; } |
121 | void setNarrow(); | 121 | void setNarrow(); |
122 | 122 | ||
123 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); | 123 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); |
124 | 124 | ||
125 | void setDocumentId( const QString & ); | 125 | void setDocumentId( const QString & ); |
126 | 126 | ||
127 | void saveLayout(KConfig *config, const QString &group) const; | 127 | void saveLayout(KConfig *config, const QString &group) const; |
128 | void restoreLayout(KConfig *config, const QString &group); | 128 | void restoreLayout(KConfig *config, const QString &group); |
129 | /** Create a popup menu to set categories */ | 129 | /** Create a popup menu to set categories */ |
130 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); | 130 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); |
131 | 131 | ||
132 | public slots: | 132 | public slots: |
133 | void updateView(); | 133 | void updateView(); |
134 | void updateConfig(); | 134 | void updateConfig(); |
135 | 135 | ||
136 | void changeEventDisplay(Event *, int); | 136 | void changeEventDisplay(Event *, int); |
137 | 137 | ||
138 | void showDates(const QDate &start, const QDate &end); | 138 | void showDates(const QDate &start, const QDate &end); |
139 | void showEvents(QPtrList<Event> eventList); | 139 | void showEvents(QPtrList<Event> eventList); |
140 | 140 | ||
141 | void clearSelection(); | 141 | void clearSelection(); |
142 | void jumpToDate (); | 142 | void jumpToDate (); |
143 | 143 | ||
144 | void editItem(QListViewItem *item); | 144 | void editItem(QListViewItem *item); |
145 | void showItem(QListViewItem *item,const QPoint &,int); | 145 | void showItem(QListViewItem *item,const QPoint &,int); |
146 | void popupMenu(QListViewItem *item,const QPoint &,int); | 146 | void popupMenu(QListViewItem *item,const QPoint &,int); |
147 | void newTodo(); | 147 | void newTodo(); |
148 | void newSubTodo(); | 148 | void newSubTodo(); |
149 | void unparentTodo(); | 149 | void unparentTodo(); |
150 | void reparentTodo(); | ||
150 | void showTodo(); | 151 | void showTodo(); |
151 | void editTodo(); | 152 | void editTodo(); |
152 | void cloneTodo(); | 153 | void cloneTodo(); |
153 | void cancelTodo(); | 154 | void cancelTodo(); |
154 | void moveTodo(); | 155 | void moveTodo(); |
155 | void beamTodo(); | 156 | void beamTodo(); |
156 | void deleteTodo(); | 157 | void deleteTodo(); |
157 | 158 | ||
158 | void setNewPriority(int); | 159 | void setNewPriority(int); |
159 | void setNewPercentage(int); | 160 | void setNewPercentage(int); |
160 | void changedCategories(int); | 161 | void changedCategories(int); |
161 | 162 | ||
162 | void purgeCompleted(); | 163 | void purgeCompleted(); |
163 | void toggleCompleted(); | 164 | void toggleCompleted(); |
164 | void toggleQuickTodo(); | 165 | void toggleQuickTodo(); |
165 | void updateTodo( Todo *, int ); | 166 | void updateTodo( Todo *, int ); |
166 | 167 | ||
167 | void itemClicked(QListViewItem *); | 168 | void itemClicked(QListViewItem *); |
168 | void itemStateChanged(QListViewItem *); | 169 | void itemStateChanged(QListViewItem *); |
169 | void modified(bool); | 170 | void modified(bool); |
170 | void itemDoubleClicked(QListViewItem *item); | 171 | void itemDoubleClicked(QListViewItem *item); |
171 | 172 | ||
172 | signals: | 173 | signals: |
173 | void newTodoSignal(); | 174 | void newTodoSignal(); |
174 | void newSubTodoSignal(Todo *); | 175 | void newSubTodoSignal(Todo *); |
175 | void unparentTodoSignal(Todo *); | 176 | void unparentTodoSignal(Todo *); |
177 | void reparentTodoSignal( Todo *,Todo * ); | ||
176 | void showTodoSignal(Todo *); | 178 | void showTodoSignal(Todo *); |
177 | 179 | ||
178 | void editTodoSignal(Todo *); | 180 | void editTodoSignal(Todo *); |
179 | void deleteTodoSignal(Todo *); | 181 | void deleteTodoSignal(Todo *); |
180 | void todoModifiedSignal (Todo *, int); | 182 | void todoModifiedSignal (Todo *, int); |
181 | 183 | ||
182 | void isModified(bool); | 184 | void isModified(bool); |
183 | void cloneTodoSignal( Incidence * ); | 185 | void cloneTodoSignal( Incidence * ); |
184 | void cancelTodoSignal( Incidence * ); | 186 | void cancelTodoSignal( Incidence * ); |
185 | void moveTodoSignal( Incidence * ); | 187 | void moveTodoSignal( Incidence * ); |
186 | void beamTodoSignal( Incidence * ); | 188 | void beamTodoSignal( Incidence * ); |
187 | void purgeCompletedSignal(); | 189 | void purgeCompletedSignal(); |
188 | 190 | ||
189 | protected slots: | 191 | protected slots: |
190 | void processSelectionChange(); | 192 | void processSelectionChange(); |
191 | void addQuickTodo(); | 193 | void addQuickTodo(); |
192 | 194 | ||
193 | private: | 195 | private: |
194 | /* | 196 | /* |
195 | * the TodoEditor approach is rather unscaling in the long | 197 | * the TodoEditor approach is rather unscaling in the long |
196 | * run. | 198 | * run. |
197 | * Korganizer keeps it in memory and we need to update | 199 | * Korganizer keeps it in memory and we need to update |
198 | * 1. make KOTodoViewItem a QObject again? | 200 | * 1. make KOTodoViewItem a QObject again? |
199 | * 2. add a public method for setting one todo modified? | 201 | * 2. add a public method for setting one todo modified? |
200 | * 3. add a private method for setting a todo modified + friend here? | 202 | * 3. add a private method for setting a todo modified + friend here? |
201 | * -- zecke 2002-07-08 | 203 | * -- zecke 2002-07-08 |
202 | */ | 204 | */ |
203 | friend class KOTodoViewItem; | 205 | friend class KOTodoViewItem; |
204 | void setTodoModified( Todo* ); | 206 | void setTodoModified( Todo* ); |
205 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 207 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
206 | void restoreItemState( QListViewItem * ); | 208 | void restoreItemState( QListViewItem * ); |
207 | 209 | ||
208 | KOTodoListView *mTodoListView; | 210 | KOTodoListView *mTodoListView; |
209 | QPopupMenu *mItemPopupMenu; | 211 | QPopupMenu *mItemPopupMenu; |
210 | QPopupMenu *mPopupMenu; | 212 | QPopupMenu *mPopupMenu; |
211 | QPopupMenu *mPriorityPopupMenu; | 213 | QPopupMenu *mPriorityPopupMenu; |
212 | QPopupMenu *mPercentageCompletedPopupMenu; | 214 | QPopupMenu *mPercentageCompletedPopupMenu; |
213 | QPopupMenu *mCategoryPopupMenu; | 215 | QPopupMenu *mCategoryPopupMenu; |
214 | 216 | ||
215 | QMap<int, int> mPercentage; | 217 | QMap<int, int> mPercentage; |
216 | QMap<int, int> mPriority; | 218 | QMap<int, int> mPriority; |
217 | QMap<int, QString> mCategory; | 219 | QMap<int, QString> mCategory; |
218 | KOTodoViewItem *mActiveItem; | 220 | KOTodoViewItem *mActiveItem; |
219 | 221 | ||
220 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 222 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
221 | QString mName; | 223 | QString mName; |
222 | 224 | ||
223 | DocPrefs *mDocPrefs; | 225 | DocPrefs *mDocPrefs; |
224 | QString mCurrentDoc; | 226 | QString mCurrentDoc; |
225 | KOQuickTodo *mQuickAdd; | 227 | KOQuickTodo *mQuickAdd; |
226 | bool mBlockUpdate; | 228 | bool mBlockUpdate; |
227 | void todoModified(Todo *, int ); | 229 | void todoModified(Todo *, int ); |
228 | void keyPressEvent ( QKeyEvent * ) ; | 230 | void keyPressEvent ( QKeyEvent * ) ; |
231 | KOTodoViewItem * pendingSubtodo; | ||
229 | }; | 232 | }; |
230 | 233 | ||
231 | #endif | 234 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 8e6cc53..391f98c 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,575 +1,577 @@ | |||
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 "calendarview.h" | 35 | #include "calendarview.h" |
36 | #include "datenavigator.h" | 36 | #include "datenavigator.h" |
37 | #include "kotodoview.h" | 37 | #include "kotodoview.h" |
38 | #include "koagendaview.h" | 38 | #include "koagendaview.h" |
39 | #include "kodialogmanager.h" | 39 | #include "kodialogmanager.h" |
40 | #include "komonthview.h" | 40 | #include "komonthview.h" |
41 | #include "kolistview.h" | 41 | #include "kolistview.h" |
42 | #include "kowhatsnextview.h" | 42 | #include "kowhatsnextview.h" |
43 | #include "kojournalview.h" | 43 | #include "kojournalview.h" |
44 | #include "kotimespanview.h" | 44 | #include "kotimespanview.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "navigatorbar.h" | 46 | #include "navigatorbar.h" |
47 | 47 | ||
48 | #include "koviewmanager.h" | 48 | #include "koviewmanager.h" |
49 | //extern bool externFlagMonthviewBlockPainting; | 49 | //extern bool externFlagMonthviewBlockPainting; |
50 | 50 | ||
51 | //bool globalFlagBlockPainting = false; | 51 | //bool globalFlagBlockPainting = false; |
52 | int globalFlagBlockAgenda = 0; | 52 | int globalFlagBlockAgenda = 0; |
53 | int globalFlagBlockLabel = 0; | 53 | int globalFlagBlockLabel = 0; |
54 | int globalFlagBlockAgendaItemPaint = 1; | 54 | int globalFlagBlockAgendaItemPaint = 1; |
55 | int globalFlagBlockAgendaItemUpdate = 1; | 55 | int globalFlagBlockAgendaItemUpdate = 1; |
56 | 56 | ||
57 | 57 | ||
58 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 58 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
59 | QObject(), mMainView( mainView ) | 59 | QObject(), mMainView( mainView ) |
60 | { | 60 | { |
61 | mCurrentView = 0; | 61 | mCurrentView = 0; |
62 | 62 | ||
63 | mWhatsNextView = 0; | 63 | mWhatsNextView = 0; |
64 | mTodoView = 0; | 64 | mTodoView = 0; |
65 | mAgendaView = 0; | 65 | mAgendaView = 0; |
66 | mMonthView = 0; | 66 | mMonthView = 0; |
67 | mListView = 0; | 67 | mListView = 0; |
68 | mJournalView = 0; | 68 | mJournalView = 0; |
69 | mTimeSpanView = 0; | 69 | mTimeSpanView = 0; |
70 | mCurrentAgendaView = 0 ; | 70 | mCurrentAgendaView = 0 ; |
71 | mFlagShowNextxDays = false; | 71 | mFlagShowNextxDays = false; |
72 | } | 72 | } |
73 | 73 | ||
74 | KOViewManager::~KOViewManager() | 74 | KOViewManager::~KOViewManager() |
75 | { | 75 | { |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | KOrg::BaseView *KOViewManager::currentView() | 79 | KOrg::BaseView *KOViewManager::currentView() |
80 | { | 80 | { |
81 | return mCurrentView; | 81 | return mCurrentView; |
82 | } | 82 | } |
83 | 83 | ||
84 | void KOViewManager::readSettings(KConfig *config) | 84 | void KOViewManager::readSettings(KConfig *config) |
85 | { | 85 | { |
86 | config->setGroup("General"); | 86 | config->setGroup("General"); |
87 | QString view = config->readEntry("Current View"); | 87 | QString view = config->readEntry("Current View"); |
88 | if (view == "WhatsNext") showWhatsNextView(); | 88 | if (view == "WhatsNext") showWhatsNextView(); |
89 | else if (view == "Month") showMonthView(); | 89 | else if (view == "Month") showMonthView(); |
90 | else if (view == "List") showListView(); | 90 | else if (view == "List") showListView(); |
91 | else if (view == "Journal") showJournalView(); | 91 | else if (view == "Journal") showJournalView(); |
92 | else if (view == "TimeSpan") showTimeSpanView(); | 92 | else if (view == "TimeSpan") showTimeSpanView(); |
93 | else if (view == "Todo") showTodoView(); | 93 | else if (view == "Todo") showTodoView(); |
94 | else { | 94 | else { |
95 | showAgendaView(); | 95 | showAgendaView(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void KOViewManager::writeSettings(KConfig *config) | 99 | void KOViewManager::writeSettings(KConfig *config) |
100 | { | 100 | { |
101 | config->setGroup("General"); | 101 | config->setGroup("General"); |
102 | 102 | ||
103 | QString view; | 103 | QString view; |
104 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 104 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
105 | else if (mCurrentView == mMonthView) view = "Month"; | 105 | else if (mCurrentView == mMonthView) view = "Month"; |
106 | else if (mCurrentView == mListView) view = "List"; | 106 | else if (mCurrentView == mListView) view = "List"; |
107 | else if (mCurrentView == mJournalView) view = "Journal"; | 107 | else if (mCurrentView == mJournalView) view = "Journal"; |
108 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 108 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
109 | else if (mCurrentView == mTodoView) view = "Todo"; | 109 | else if (mCurrentView == mTodoView) view = "Todo"; |
110 | else view = "Agenda"; | 110 | else view = "Agenda"; |
111 | 111 | ||
112 | config->writeEntry("Current View",view); | 112 | config->writeEntry("Current View",view); |
113 | 113 | ||
114 | if (mAgendaView) { | 114 | if (mAgendaView) { |
115 | mAgendaView->writeSettings(config); | 115 | mAgendaView->writeSettings(config); |
116 | } | 116 | } |
117 | if (mTimeSpanView) { | 117 | if (mTimeSpanView) { |
118 | mTimeSpanView->writeSettings(config); | 118 | mTimeSpanView->writeSettings(config); |
119 | } | 119 | } |
120 | if (mListView) { | 120 | if (mListView) { |
121 | mListView->writeSettings(config); | 121 | mListView->writeSettings(config); |
122 | } | 122 | } |
123 | if (mTodoView) { | 123 | if (mTodoView) { |
124 | mTodoView->saveLayout(config,"Todo View"); | 124 | mTodoView->saveLayout(config,"Todo View"); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 128 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
129 | { | 129 | { |
130 | 130 | ||
131 | //mFlagShowNextxDays = false; | 131 | //mFlagShowNextxDays = false; |
132 | //if(view == mCurrentView) return; | 132 | //if(view == mCurrentView) return; |
133 | if ( view == 0 ) { | 133 | if ( view == 0 ) { |
134 | view = mCurrentView; | 134 | view = mCurrentView; |
135 | if ( view == 0 ) | 135 | if ( view == 0 ) |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | bool full = fullScreen; | 138 | bool full = fullScreen; |
139 | if(view == mCurrentView && view != mWhatsNextView ) { | 139 | if(view == mCurrentView && view != mWhatsNextView ) { |
140 | if ( mCurrentAgendaView < 0 ) | 140 | if ( mCurrentAgendaView < 0 ) |
141 | return; | 141 | return; |
142 | full = mMainView->leftFrame()->isVisible(); | 142 | full = mMainView->leftFrame()->isVisible(); |
143 | } else { | 143 | } else { |
144 | mCurrentView = view; | 144 | mCurrentView = view; |
145 | 145 | ||
146 | // bool full = fullScreen; | 146 | // bool full = fullScreen; |
147 | bool isFull = !mMainView->leftFrame()->isVisible(); | 147 | bool isFull = !mMainView->leftFrame()->isVisible(); |
148 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 148 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
149 | full = true; | 149 | full = true; |
150 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 150 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
151 | full = false; | 151 | full = false; |
152 | } | 152 | } |
153 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 153 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
154 | raiseCurrentView( full ); | 154 | raiseCurrentView( full ); |
155 | mMainView->processIncidenceSelection( 0 ); | 155 | mMainView->processIncidenceSelection( 0 ); |
156 | mMainView->updateView(); | 156 | mMainView->updateView(); |
157 | mMainView->adaptNavigationUnits(); | 157 | mMainView->adaptNavigationUnits(); |
158 | } | 158 | } |
159 | 159 | ||
160 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 160 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
161 | { | 161 | { |
162 | //qDebug("raiseCurrentView "); | 162 | //qDebug("raiseCurrentView "); |
163 | mCurrentAgendaView = 0; | 163 | mCurrentAgendaView = 0; |
164 | int wid = mMainView->width() ; | 164 | int wid = mMainView->width() ; |
165 | int hei = mMainView->height(); | 165 | int hei = mMainView->height(); |
166 | if ( mCurrentView == mMonthView ) { | 166 | if ( mCurrentView == mMonthView ) { |
167 | mMainView->navigatorBar()->show(); | 167 | mMainView->navigatorBar()->show(); |
168 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 168 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
169 | //mMainView->navigatorBar()->hide(); | 169 | //mMainView->navigatorBar()->hide(); |
170 | } else { | 170 | } else { |
171 | mMainView->navigatorBar()->hide(); | 171 | mMainView->navigatorBar()->hide(); |
172 | } | 172 | } |
173 | if ( fullScreen ) { | 173 | if ( fullScreen ) { |
174 | mMainView->leftFrame()->hide(); | 174 | mMainView->leftFrame()->hide(); |
175 | } else { | 175 | } else { |
176 | mMainView->leftFrame()->show(); | 176 | mMainView->leftFrame()->show(); |
177 | if ( KOPrefs::instance()->mVerticalScreen ) | 177 | if ( KOPrefs::instance()->mVerticalScreen ) |
178 | hei -= mMainView->leftFrame()->height(); | 178 | hei -= mMainView->leftFrame()->height(); |
179 | else | 179 | else |
180 | wid -= mMainView->leftFrame()->width(); | 180 | wid -= mMainView->leftFrame()->width(); |
181 | } | 181 | } |
182 | 182 | ||
183 | if ( globalFlagBlockAgenda == 5 ) { | 183 | if ( globalFlagBlockAgenda == 5 ) { |
184 | globalFlagBlockAgenda = 4; | 184 | globalFlagBlockAgenda = 4; |
185 | globalFlagBlockAgendaItemPaint = 1; | 185 | globalFlagBlockAgendaItemPaint = 1; |
186 | } | 186 | } |
187 | mMainView->viewStack()->raiseWidget(mCurrentView); | 187 | mMainView->viewStack()->raiseWidget(mCurrentView); |
188 | if ( globalFlagBlockAgenda == 4 ) { | 188 | if ( globalFlagBlockAgenda == 4 ) { |
189 | if ( mCurrentView == mAgendaView ) { | 189 | if ( mCurrentView == mAgendaView ) { |
190 | //globalFlagBlockAgenda =1 ; | 190 | //globalFlagBlockAgenda =1 ; |
191 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 191 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
192 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 192 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
193 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 193 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
194 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 194 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
195 | qApp->processEvents(); | 195 | qApp->processEvents(); |
196 | //qDebug("qApp->processEvents() "); | 196 | //qDebug("qApp->processEvents() "); |
197 | globalFlagBlockAgenda = 0; | 197 | globalFlagBlockAgenda = 0; |
198 | mAgendaView->repaintAgenda(); | 198 | mAgendaView->repaintAgenda(); |
199 | 199 | ||
200 | } | 200 | } |
201 | globalFlagBlockAgenda = 0; | 201 | globalFlagBlockAgenda = 0; |
202 | } | 202 | } |
203 | //qDebug("raiseCurrentView ende "); | 203 | //qDebug("raiseCurrentView ende "); |
204 | } | 204 | } |
205 | 205 | ||
206 | void KOViewManager::updateView() | 206 | void KOViewManager::updateView() |
207 | { | 207 | { |
208 | // qDebug("KOViewManager::updateView() "); | 208 | // qDebug("KOViewManager::updateView() "); |
209 | // if we are updating mTodoView, we get endless recursion | 209 | // if we are updating mTodoView, we get endless recursion |
210 | if ( mTodoView == mCurrentView ) | 210 | if ( mTodoView == mCurrentView ) |
211 | return; | 211 | return; |
212 | if ( mCurrentView ) mCurrentView->updateView(); | 212 | if ( mCurrentView ) mCurrentView->updateView(); |
213 | 213 | ||
214 | } | 214 | } |
215 | 215 | ||
216 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 216 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
217 | { | 217 | { |
218 | // kdDebug() << "KOViewManager::updateView()" << endl; | 218 | // kdDebug() << "KOViewManager::updateView()" << endl; |
219 | 219 | ||
220 | if (mCurrentView) mCurrentView->showDates(start, end); | 220 | if (mCurrentView) mCurrentView->showDates(start, end); |
221 | 221 | ||
222 | if (mTodoView) mTodoView->updateView(); | 222 | if (mTodoView) mTodoView->updateView(); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void KOViewManager::updateWNview() | 226 | void KOViewManager::updateWNview() |
227 | { | 227 | { |
228 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 228 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
229 | mWhatsNextView->updateView(); | 229 | mWhatsNextView->updateView(); |
230 | 230 | ||
231 | } | 231 | } |
232 | void KOViewManager::showWhatsNextView() | 232 | void KOViewManager::showWhatsNextView() |
233 | { | 233 | { |
234 | if (!mWhatsNextView) { | 234 | if (!mWhatsNextView) { |
235 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 235 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
236 | "KOViewManager::WhatsNextView"); | 236 | "KOViewManager::WhatsNextView"); |
237 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 237 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
238 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 238 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
239 | addView(mWhatsNextView); | 239 | addView(mWhatsNextView); |
240 | } | 240 | } |
241 | globalFlagBlockAgenda = 1; | 241 | globalFlagBlockAgenda = 1; |
242 | showView(mWhatsNextView, true ); | 242 | showView(mWhatsNextView, true ); |
243 | //mWhatsNextView->updateView(); | 243 | //mWhatsNextView->updateView(); |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | void KOViewManager::showListView() | 247 | void KOViewManager::showListView() |
248 | { | 248 | { |
249 | if (!mListView) { | 249 | if (!mListView) { |
250 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 250 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
251 | addView(mListView); | 251 | addView(mListView); |
252 | 252 | ||
253 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 253 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
254 | mMainView, SLOT(showIncidence(Incidence *))); | 254 | mMainView, SLOT(showIncidence(Incidence *))); |
255 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 255 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
256 | mMainView, SLOT(editIncidence(Incidence *))); | 256 | mMainView, SLOT(editIncidence(Incidence *))); |
257 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 257 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
258 | mMainView, SLOT(deleteIncidence(Incidence *))); | 258 | mMainView, SLOT(deleteIncidence(Incidence *))); |
259 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 259 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
260 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 260 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
261 | connect( mListView, SIGNAL( signalNewEvent() ), | 261 | connect( mListView, SIGNAL( signalNewEvent() ), |
262 | mMainView, SLOT( newEvent() ) ); | 262 | mMainView, SLOT( newEvent() ) ); |
263 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 263 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
264 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 264 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
265 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 265 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
266 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 266 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
267 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 267 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
268 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 268 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
269 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 269 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
270 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 270 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
271 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 271 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
272 | } | 272 | } |
273 | // bool temp = mFlagShowNextxDays; | 273 | // bool temp = mFlagShowNextxDays; |
274 | //globalFlagBlockPainting = true; | 274 | //globalFlagBlockPainting = true; |
275 | globalFlagBlockAgenda = 1; | 275 | globalFlagBlockAgenda = 1; |
276 | if ( KOPrefs::instance()->mListViewMonthTimespan ) | 276 | if ( KOPrefs::instance()->mListViewMonthTimespan ) |
277 | mMainView->dateNavigator()->selectMonth(); | 277 | mMainView->dateNavigator()->selectMonth(); |
278 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 278 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
279 | //mFlagShowNextxDays = temp; | 279 | //mFlagShowNextxDays = temp; |
280 | } | 280 | } |
281 | 281 | ||
282 | void KOViewManager::showAgendaView( bool fullScreen ) | 282 | void KOViewManager::showAgendaView( bool fullScreen ) |
283 | { | 283 | { |
284 | 284 | ||
285 | mMainView->dialogManager()->hideSearchDialog(); | 285 | mMainView->dialogManager()->hideSearchDialog(); |
286 | // qDebug("KOViewManager::showAgendaView "); | 286 | // qDebug("KOViewManager::showAgendaView "); |
287 | bool full; | 287 | bool full; |
288 | full = fullScreen; | 288 | full = fullScreen; |
289 | if (!mAgendaView) { | 289 | if (!mAgendaView) { |
290 | full = false; | 290 | full = false; |
291 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 291 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
292 | addView(mAgendaView); | 292 | addView(mAgendaView); |
293 | #ifndef DESKTOP_VERSION | 293 | #ifndef DESKTOP_VERSION |
294 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 294 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
295 | #endif | 295 | #endif |
296 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 296 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
297 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 297 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
298 | 298 | ||
299 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 299 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
300 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 300 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
301 | mMainView, SLOT(newEvent(QDateTime))); | 301 | mMainView, SLOT(newEvent(QDateTime))); |
302 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 302 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
303 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 303 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
304 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 304 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
305 | mMainView, SLOT(newEvent(QDate))); | 305 | mMainView, SLOT(newEvent(QDate))); |
306 | 306 | ||
307 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 307 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
308 | mMainView, SLOT(editIncidence(Incidence *))); | 308 | mMainView, SLOT(editIncidence(Incidence *))); |
309 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 309 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
310 | mMainView, SLOT(showIncidence(Incidence *))); | 310 | mMainView, SLOT(showIncidence(Incidence *))); |
311 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 311 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
312 | mMainView, SLOT(deleteIncidence(Incidence *))); | 312 | mMainView, SLOT(deleteIncidence(Incidence *))); |
313 | 313 | ||
314 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 314 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
316 | 316 | ||
317 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 317 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
318 | mMainView, SLOT( toggleExpand() ) ); | 318 | mMainView, SLOT( toggleExpand() ) ); |
319 | 319 | ||
320 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 320 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
321 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 321 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
322 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 322 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
323 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 323 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
324 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 324 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
325 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 325 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
326 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 326 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
327 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 327 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
328 | SLOT( updateTodo( Todo *, int ) ) ); | 328 | SLOT( updateTodo( Todo *, int ) ) ); |
329 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 329 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
330 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 330 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
331 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 331 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
332 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 332 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
333 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 333 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
334 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 334 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
335 | mAgendaView->readSettings(); | 335 | mAgendaView->readSettings(); |
336 | mAgendaView->updateConfig(); | 336 | mAgendaView->updateConfig(); |
337 | } | 337 | } |
338 | 338 | ||
339 | showView( mAgendaView, full); | 339 | showView( mAgendaView, full); |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | void KOViewManager::showDayView() | 343 | void KOViewManager::showDayView() |
344 | { | 344 | { |
345 | mFlagShowNextxDays = false; | 345 | mFlagShowNextxDays = false; |
346 | globalFlagBlockLabel = 1; | 346 | globalFlagBlockLabel = 1; |
347 | globalFlagBlockAgenda = 1; | 347 | globalFlagBlockAgenda = 1; |
348 | if ( mCurrentAgendaView != 1 ) | 348 | if ( mCurrentAgendaView != 1 ) |
349 | mCurrentAgendaView = -1; | 349 | mCurrentAgendaView = -1; |
350 | showAgendaView(); | 350 | showAgendaView(); |
351 | qApp->processEvents(); | 351 | qApp->processEvents(); |
352 | globalFlagBlockAgenda = 2; | 352 | globalFlagBlockAgenda = 2; |
353 | globalFlagBlockLabel = 0; | 353 | globalFlagBlockLabel = 0; |
354 | mMainView->dateNavigator()->selectDates( 1 ); | 354 | mMainView->dateNavigator()->selectDates( 1 ); |
355 | mCurrentAgendaView = 1 ; | 355 | mCurrentAgendaView = 1 ; |
356 | 356 | ||
357 | } | 357 | } |
358 | 358 | ||
359 | void KOViewManager::showWorkWeekView() | 359 | void KOViewManager::showWorkWeekView() |
360 | { | 360 | { |
361 | mFlagShowNextxDays = false; | 361 | mFlagShowNextxDays = false; |
362 | globalFlagBlockAgenda = 1; | 362 | globalFlagBlockAgenda = 1; |
363 | globalFlagBlockLabel = 1; | 363 | globalFlagBlockLabel = 1; |
364 | if ( mCurrentAgendaView != 5 ) | 364 | if ( mCurrentAgendaView != 5 ) |
365 | mCurrentAgendaView = -1; | 365 | mCurrentAgendaView = -1; |
366 | showAgendaView(); | 366 | showAgendaView(); |
367 | qApp->processEvents(); | 367 | qApp->processEvents(); |
368 | globalFlagBlockAgenda = 2; | 368 | globalFlagBlockAgenda = 2; |
369 | globalFlagBlockLabel = 0; | 369 | globalFlagBlockLabel = 0; |
370 | mMainView->dateNavigator()->selectWorkWeek(); | 370 | mMainView->dateNavigator()->selectWorkWeek(); |
371 | mCurrentAgendaView = 5 ; | 371 | mCurrentAgendaView = 5 ; |
372 | 372 | ||
373 | } | 373 | } |
374 | 374 | ||
375 | void KOViewManager::showWeekView() | 375 | void KOViewManager::showWeekView() |
376 | { | 376 | { |
377 | /* | 377 | /* |
378 | globalFlagBlockAgenda = 2; | 378 | globalFlagBlockAgenda = 2; |
379 | qDebug("4globalFlagBlockAgenda = 2; "); | 379 | qDebug("4globalFlagBlockAgenda = 2; "); |
380 | //globalFlagBlockPainting = true; | 380 | //globalFlagBlockPainting = true; |
381 | mMainView->dateNavigator()->selectWeek(); | 381 | mMainView->dateNavigator()->selectWeek(); |
382 | showAgendaView(); | 382 | showAgendaView(); |
383 | */ | 383 | */ |
384 | 384 | ||
385 | 385 | ||
386 | mFlagShowNextxDays = false; | 386 | mFlagShowNextxDays = false; |
387 | globalFlagBlockAgenda = 1; | 387 | globalFlagBlockAgenda = 1; |
388 | globalFlagBlockLabel = 1; | 388 | globalFlagBlockLabel = 1; |
389 | if ( mCurrentAgendaView != 7 ) | 389 | if ( mCurrentAgendaView != 7 ) |
390 | mCurrentAgendaView = -1; | 390 | mCurrentAgendaView = -1; |
391 | showAgendaView(); | 391 | showAgendaView(); |
392 | qApp->processEvents(); | 392 | qApp->processEvents(); |
393 | globalFlagBlockAgenda = 2; | 393 | globalFlagBlockAgenda = 2; |
394 | globalFlagBlockLabel = 0; | 394 | globalFlagBlockLabel = 0; |
395 | mMainView->dateNavigator()->selectWeek(); | 395 | mMainView->dateNavigator()->selectWeek(); |
396 | mCurrentAgendaView = 7 ; | 396 | mCurrentAgendaView = 7 ; |
397 | } | 397 | } |
398 | 398 | ||
399 | void KOViewManager::showNextXView() | 399 | void KOViewManager::showNextXView() |
400 | { | 400 | { |
401 | 401 | ||
402 | globalFlagBlockAgenda = 1; | 402 | globalFlagBlockAgenda = 1; |
403 | if ( mCurrentAgendaView != 3 ) | 403 | if ( mCurrentAgendaView != 3 ) |
404 | mCurrentAgendaView = -1; | 404 | mCurrentAgendaView = -1; |
405 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 405 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
406 | globalFlagBlockAgenda = 2; | 406 | globalFlagBlockAgenda = 2; |
407 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 407 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
408 | KOPrefs::instance()->mNextXDays ); | 408 | KOPrefs::instance()->mNextXDays ); |
409 | mFlagShowNextxDays = true; | 409 | mFlagShowNextxDays = true; |
410 | mCurrentAgendaView = 3 ; | 410 | mCurrentAgendaView = 3 ; |
411 | } | 411 | } |
412 | bool KOViewManager::showsNextDays() | 412 | bool KOViewManager::showsNextDays() |
413 | { | 413 | { |
414 | return mFlagShowNextxDays; | 414 | return mFlagShowNextxDays; |
415 | } | 415 | } |
416 | void KOViewManager::showMonthView() | 416 | void KOViewManager::showMonthView() |
417 | { | 417 | { |
418 | if (!mMonthView) { | 418 | if (!mMonthView) { |
419 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 419 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
420 | 420 | ||
421 | addView(mMonthView); | 421 | addView(mMonthView); |
422 | // mMonthView->show(); | 422 | // mMonthView->show(); |
423 | // SIGNALS/SLOTS FOR MONTH VIEW | 423 | // SIGNALS/SLOTS FOR MONTH VIEW |
424 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 424 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
425 | mMainView, SLOT(newEvent(QDateTime))); | 425 | mMainView, SLOT(newEvent(QDateTime))); |
426 | 426 | ||
427 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 427 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
428 | mMainView, SLOT(showIncidence(Incidence *))); | 428 | mMainView, SLOT(showIncidence(Incidence *))); |
429 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 429 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
430 | mMainView, SLOT(editIncidence(Incidence *))); | 430 | mMainView, SLOT(editIncidence(Incidence *))); |
431 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 431 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
432 | mMainView, SLOT(deleteIncidence(Incidence *))); | 432 | mMainView, SLOT(deleteIncidence(Incidence *))); |
433 | 433 | ||
434 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 434 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
435 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 435 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
436 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 436 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
437 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 437 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
438 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 438 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
439 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 439 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
440 | 440 | ||
441 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 441 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
442 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 442 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
443 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 443 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
444 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 444 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
445 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 445 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
446 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 446 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
447 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 447 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
448 | mMonthView->updateConfig(); | 448 | mMonthView->updateConfig(); |
449 | } | 449 | } |
450 | 450 | ||
451 | globalFlagBlockAgenda = 1; | 451 | globalFlagBlockAgenda = 1; |
452 | //mFlagShowNextxDays = false; | 452 | //mFlagShowNextxDays = false; |
453 | // if(mMonthView == mCurrentView) return; | 453 | // if(mMonthView == mCurrentView) return; |
454 | mMainView->dateNavigator()->selectMonth(); | 454 | mMainView->dateNavigator()->selectMonth(); |
455 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 455 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
456 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 456 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
457 | 457 | ||
458 | showView(mMonthView, true ); | 458 | showView(mMonthView, true ); |
459 | 459 | ||
460 | } | 460 | } |
461 | 461 | ||
462 | void KOViewManager::showTodoView() | 462 | void KOViewManager::showTodoView() |
463 | { | 463 | { |
464 | //mFlagShowNextxDays = false; | 464 | //mFlagShowNextxDays = false; |
465 | if ( !mTodoView ) { | 465 | if ( !mTodoView ) { |
466 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 466 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
467 | "KOViewManager::TodoView" ); | 467 | "KOViewManager::TodoView" ); |
468 | 468 | ||
469 | addView( mTodoView ); | 469 | addView( mTodoView ); |
470 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 470 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
471 | 471 | ||
472 | // SIGNALS/SLOTS FOR TODO VIEW | 472 | // SIGNALS/SLOTS FOR TODO VIEW |
473 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 473 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
474 | mMainView, SLOT( newTodo() ) ); | 474 | mMainView, SLOT( newTodo() ) ); |
475 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 475 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
476 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 476 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
477 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 477 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
478 | mMainView, SLOT( showTodo( Todo * ) ) ); | 478 | mMainView, SLOT( showTodo( Todo * ) ) ); |
479 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 479 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
480 | mMainView, SLOT( editTodo( Todo * ) ) ); | 480 | mMainView, SLOT( editTodo( Todo * ) ) ); |
481 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 481 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
482 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 482 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
483 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 483 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
484 | mMainView, SLOT( purgeCompleted() ) ); | 484 | mMainView, SLOT( purgeCompleted() ) ); |
485 | 485 | ||
486 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 486 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
487 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 487 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
488 | 488 | ||
489 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 489 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
490 | SLOT( updateConfig() ) ); | 490 | SLOT( updateConfig() ) ); |
491 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 491 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
492 | SLOT( updateTodo( Todo *, int ) ) ); | 492 | SLOT( updateTodo( Todo *, int ) ) ); |
493 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 493 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
494 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 494 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
495 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 495 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
496 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 496 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
497 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 497 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
498 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 498 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
499 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 499 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
500 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 500 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
501 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | ||
502 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | ||
501 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 503 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
502 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 504 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
503 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 505 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
504 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 506 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
505 | KConfig *config = KOGlobals::config(); | 507 | KConfig *config = KOGlobals::config(); |
506 | mTodoView->restoreLayout(config,"Todo View"); | 508 | mTodoView->restoreLayout(config,"Todo View"); |
507 | } | 509 | } |
508 | 510 | ||
509 | globalFlagBlockAgenda = 1; | 511 | globalFlagBlockAgenda = 1; |
510 | showView( mTodoView, true ); | 512 | showView( mTodoView, true ); |
511 | 513 | ||
512 | } | 514 | } |
513 | 515 | ||
514 | void KOViewManager::showJournalView() | 516 | void KOViewManager::showJournalView() |
515 | { | 517 | { |
516 | //mFlagShowNextxDays = false; | 518 | //mFlagShowNextxDays = false; |
517 | if (!mJournalView) { | 519 | if (!mJournalView) { |
518 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 520 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
519 | "KOViewManager::JournalView"); | 521 | "KOViewManager::JournalView"); |
520 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 522 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
521 | SLOT( updateConfig() ) ); | 523 | SLOT( updateConfig() ) ); |
522 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 524 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
523 | addView(mJournalView); | 525 | addView(mJournalView); |
524 | } | 526 | } |
525 | 527 | ||
526 | showView(mJournalView); | 528 | showView(mJournalView); |
527 | } | 529 | } |
528 | 530 | ||
529 | void KOViewManager::showTimeSpanView() | 531 | void KOViewManager::showTimeSpanView() |
530 | { | 532 | { |
531 | //mFlagShowNextxDays = false; | 533 | //mFlagShowNextxDays = false; |
532 | if (!mTimeSpanView) { | 534 | if (!mTimeSpanView) { |
533 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 535 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
534 | "KOViewManager::TimeSpanView"); | 536 | "KOViewManager::TimeSpanView"); |
535 | addView(mTimeSpanView); | 537 | addView(mTimeSpanView); |
536 | 538 | ||
537 | mTimeSpanView->readSettings(); | 539 | mTimeSpanView->readSettings(); |
538 | } | 540 | } |
539 | 541 | ||
540 | showView(mTimeSpanView); | 542 | showView(mTimeSpanView); |
541 | } | 543 | } |
542 | 544 | ||
543 | Incidence *KOViewManager::currentSelection() | 545 | Incidence *KOViewManager::currentSelection() |
544 | { | 546 | { |
545 | if (!mCurrentView) return 0; | 547 | if (!mCurrentView) return 0; |
546 | if ( mCurrentView == mListView ) { | 548 | if ( mCurrentView == mListView ) { |
547 | if ( mListView->currentItem() ) | 549 | if ( mListView->currentItem() ) |
548 | return mListView->currentItem(); | 550 | return mListView->currentItem(); |
549 | } | 551 | } |
550 | return mCurrentView->selectedIncidences().first(); | 552 | return mCurrentView->selectedIncidences().first(); |
551 | } | 553 | } |
552 | 554 | ||
553 | QDate KOViewManager::currentSelectionDate() | 555 | QDate KOViewManager::currentSelectionDate() |
554 | { | 556 | { |
555 | QDate qd; | 557 | QDate qd; |
556 | if (mCurrentView) { | 558 | if (mCurrentView) { |
557 | DateList qvl = mCurrentView->selectedDates(); | 559 | DateList qvl = mCurrentView->selectedDates(); |
558 | if (!qvl.isEmpty()) qd = qvl.first(); | 560 | if (!qvl.isEmpty()) qd = qvl.first(); |
559 | } | 561 | } |
560 | return qd; | 562 | return qd; |
561 | } | 563 | } |
562 | 564 | ||
563 | void KOViewManager::addView(KOrg::BaseView *view) | 565 | void KOViewManager::addView(KOrg::BaseView *view) |
564 | { | 566 | { |
565 | #if QT_VERSION >= 300 | 567 | #if QT_VERSION >= 300 |
566 | mMainView->viewStack()->addWidget( view ); | 568 | mMainView->viewStack()->addWidget( view ); |
567 | #else | 569 | #else |
568 | mMainView->viewStack()->addWidget( view, 1 ); | 570 | mMainView->viewStack()->addWidget( view, 1 ); |
569 | #endif | 571 | #endif |
570 | } | 572 | } |
571 | 573 | ||
572 | void KOViewManager::setDocumentId( const QString &id ) | 574 | void KOViewManager::setDocumentId( const QString &id ) |
573 | { | 575 | { |
574 | if (mTodoView) mTodoView->setDocumentId( id ); | 576 | if (mTodoView) mTodoView->setDocumentId( id ); |
575 | } | 577 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 8daacc7..06470b8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1822 +1,1825 @@ | |||
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 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | 129 | ||
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mClosed = false; | 133 | mClosed = false; |
134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
135 | QString confFile = locateLocal("config","korganizerrc"); | 135 | QString confFile = locateLocal("config","korganizerrc"); |
136 | QFileInfo finf ( confFile ); | 136 | QFileInfo finf ( confFile ); |
137 | bool showWarning = !finf.exists(); | 137 | bool showWarning = !finf.exists(); |
138 | setIcon(SmallIcon( "ko24" ) ); | 138 | setIcon(SmallIcon( "ko24" ) ); |
139 | mBlockAtStartup = true; | 139 | mBlockAtStartup = true; |
140 | mFlagKeyPressed = false; | 140 | mFlagKeyPressed = false; |
141 | setCaption("KOrganizer/Pi"); | 141 | setCaption("KOrganizer/Pi"); |
142 | KOPrefs *p = KOPrefs::instance(); | 142 | KOPrefs *p = KOPrefs::instance(); |
143 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 143 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
144 | if ( p->mHourSize > 18 ) | 144 | if ( p->mHourSize > 18 ) |
145 | p->mHourSize = 18; | 145 | p->mHourSize = 18; |
146 | QMainWindow::ToolBarDock tbd; | 146 | QMainWindow::ToolBarDock tbd; |
147 | if ( p->mToolBarHor ) { | 147 | if ( p->mToolBarHor ) { |
148 | if ( p->mToolBarUp ) | 148 | if ( p->mToolBarUp ) |
149 | tbd = Bottom; | 149 | tbd = Bottom; |
150 | else | 150 | else |
151 | tbd = Top; | 151 | tbd = Top; |
152 | } | 152 | } |
153 | else { | 153 | else { |
154 | if ( p->mToolBarUp ) | 154 | if ( p->mToolBarUp ) |
155 | tbd = Right; | 155 | tbd = Right; |
156 | else | 156 | else |
157 | tbd = Left; | 157 | tbd = Left; |
158 | } | 158 | } |
159 | if ( KOPrefs::instance()->mUseAppColors ) | 159 | if ( KOPrefs::instance()->mUseAppColors ) |
160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
161 | globalFlagBlockStartup = 1; | 161 | globalFlagBlockStartup = 1; |
162 | iconToolBar = new QPEToolBar( this ); | 162 | iconToolBar = new QPEToolBar( this ); |
163 | addToolBar (iconToolBar , tbd ); | 163 | addToolBar (iconToolBar , tbd ); |
164 | mCalendarModifiedFlag = false; | 164 | mCalendarModifiedFlag = false; |
165 | 165 | ||
166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
167 | splash->setAlignment ( AlignCenter ); | 167 | splash->setAlignment ( AlignCenter ); |
168 | setCentralWidget( splash ); | 168 | setCentralWidget( splash ); |
169 | #ifndef DESKTOP_VERSION | 169 | #ifndef DESKTOP_VERSION |
170 | showMaximized(); | 170 | showMaximized(); |
171 | #endif | 171 | #endif |
172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
173 | setDefaultPreferences(); | 173 | setDefaultPreferences(); |
174 | mCalendar = new CalendarLocal(); | 174 | mCalendar = new CalendarLocal(); |
175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
176 | mView->hide(); | 176 | mView->hide(); |
177 | //mView->resize(splash->size() ); | 177 | //mView->resize(splash->size() ); |
178 | initActions(); | 178 | initActions(); |
179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
180 | mSyncManager->setBlockSave(false); | 180 | mSyncManager->setBlockSave(false); |
181 | mView->setSyncManager(mSyncManager); | 181 | mView->setSyncManager(mSyncManager); |
182 | #ifndef DESKTOP_VERSION | 182 | #ifndef DESKTOP_VERSION |
183 | iconToolBar->show(); | 183 | iconToolBar->show(); |
184 | qApp->processEvents(); | 184 | qApp->processEvents(); |
185 | #endif | 185 | #endif |
186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
187 | int vh = height() ; | 187 | int vh = height() ; |
188 | int vw = width(); | 188 | int vw = width(); |
189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
191 | vh -= iconToolBar->height(); | 191 | vh -= iconToolBar->height(); |
192 | } else { | 192 | } else { |
193 | vw -= iconToolBar->height(); | 193 | vw -= iconToolBar->height(); |
194 | } | 194 | } |
195 | //mView->setMaximumSize( splash->size() ); | 195 | //mView->setMaximumSize( splash->size() ); |
196 | //mView->resize( splash->size() ); | 196 | //mView->resize( splash->size() ); |
197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
198 | mView->readSettings(); | 198 | mView->readSettings(); |
199 | bool newFile = false; | 199 | bool newFile = false; |
200 | if( !QFile::exists( defaultFileName() ) ) { | 200 | if( !QFile::exists( defaultFileName() ) ) { |
201 | QFileInfo finfo ( defaultFileName() ); | 201 | QFileInfo finfo ( defaultFileName() ); |
202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
203 | qDebug("oldfile %s ", oldFile.latin1()); | 203 | qDebug("oldfile %s ", oldFile.latin1()); |
204 | 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"; | 204 | 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"; |
205 | finfo.setFile( oldFile ); | 205 | finfo.setFile( oldFile ); |
206 | if (finfo.exists() ) { | 206 | if (finfo.exists() ) { |
207 | KMessageBox::information( this, message); | 207 | KMessageBox::information( this, message); |
208 | mView->openCalendar( oldFile ); | 208 | mView->openCalendar( oldFile ); |
209 | qApp->processEvents(); | 209 | qApp->processEvents(); |
210 | } else { | 210 | } else { |
211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
212 | finfo.setFile( oldFile ); | 212 | finfo.setFile( oldFile ); |
213 | if (finfo.exists() ) { | 213 | if (finfo.exists() ) { |
214 | KMessageBox::information( this, message); | 214 | KMessageBox::information( this, message); |
215 | mView->openCalendar( oldFile ); | 215 | mView->openCalendar( oldFile ); |
216 | qApp->processEvents(); | 216 | qApp->processEvents(); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | mView->saveCalendar( defaultFileName() ); | 219 | mView->saveCalendar( defaultFileName() ); |
220 | newFile = true; | 220 | newFile = true; |
221 | } | 221 | } |
222 | 222 | ||
223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
224 | mView->openCalendar( defaultFileName() ); | 224 | mView->openCalendar( defaultFileName() ); |
225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
227 | 227 | ||
228 | if ( KOPrefs::instance()->mLanguageChanged ) { | 228 | if ( KOPrefs::instance()->mLanguageChanged ) { |
229 | KOPrefs::instance()->setCategoryDefaults(); | 229 | KOPrefs::instance()->setCategoryDefaults(); |
230 | int count = mView->addCategories(); | 230 | int count = mView->addCategories(); |
231 | KOPrefs::instance()->mLanguageChanged = false; | 231 | KOPrefs::instance()->mLanguageChanged = false; |
232 | } | 232 | } |
233 | processIncidenceSelection( 0 ); | 233 | processIncidenceSelection( 0 ); |
234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
235 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 235 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
237 | SLOT( slotModifiedChanged( bool ) ) ); | 237 | SLOT( slotModifiedChanged( bool ) ) ); |
238 | 238 | ||
239 | 239 | ||
240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
241 | mView->setModified( false ); | 241 | mView->setModified( false ); |
242 | mBlockAtStartup = false; | 242 | mBlockAtStartup = false; |
243 | mView->setModified( false ); | 243 | mView->setModified( false ); |
244 | setCentralWidget( mView ); | 244 | setCentralWidget( mView ); |
245 | globalFlagBlockStartup = 0; | 245 | globalFlagBlockStartup = 0; |
246 | mView->show(); | 246 | mView->show(); |
247 | delete splash; | 247 | delete splash; |
248 | if ( newFile ) | 248 | if ( newFile ) |
249 | mView->updateConfig(); | 249 | mView->updateConfig(); |
250 | // qApp->processEvents(); | 250 | // qApp->processEvents(); |
251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
252 | //fillSyncMenu(); | 252 | //fillSyncMenu(); |
253 | 253 | ||
254 | 254 | ||
255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
258 | mSyncManager->setDefaultFileName( defaultFileName()); | 258 | mSyncManager->setDefaultFileName( defaultFileName()); |
259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
260 | mSyncManager->fillSyncMenu(); | 260 | mSyncManager->fillSyncMenu(); |
261 | 261 | ||
262 | 262 | ||
263 | 263 | ||
264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
265 | if ( showWarning ) { | 265 | if ( showWarning ) { |
266 | KMessageBox::information( this, | 266 | KMessageBox::information( this, |
267 | "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"); | 267 | "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"); |
268 | qApp->processEvents(); | 268 | qApp->processEvents(); |
269 | mView->dialogManager()->showSyncOptions(); | 269 | mView->dialogManager()->showSyncOptions(); |
270 | } | 270 | } |
271 | 271 | ||
272 | //US listen for result adressed from Ka/Pi | 272 | //US listen for result adressed from Ka/Pi |
273 | #ifndef DESKTOP_VERSION | 273 | #ifndef DESKTOP_VERSION |
274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
275 | #endif | 275 | #endif |
276 | 276 | ||
277 | } | 277 | } |
278 | MainWindow::~MainWindow() | 278 | MainWindow::~MainWindow() |
279 | { | 279 | { |
280 | //qDebug("MainWindow::~MainWindow() "); | 280 | //qDebug("MainWindow::~MainWindow() "); |
281 | //save toolbar location | 281 | //save toolbar location |
282 | delete mCalendar; | 282 | delete mCalendar; |
283 | delete mSyncManager; | 283 | delete mSyncManager; |
284 | 284 | ||
285 | 285 | ||
286 | } | 286 | } |
287 | void MainWindow::showMaximized () | 287 | void MainWindow::showMaximized () |
288 | { | 288 | { |
289 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
290 | if ( ! globalFlagBlockStartup ) | 290 | if ( ! globalFlagBlockStartup ) |
291 | if ( mClosed ) | 291 | if ( mClosed ) |
292 | mView->goToday(); | 292 | mView->goToday(); |
293 | #endif | 293 | #endif |
294 | QWidget::showMaximized () ; | 294 | QWidget::showMaximized () ; |
295 | mClosed = false; | 295 | mClosed = false; |
296 | } | 296 | } |
297 | void MainWindow::closeEvent( QCloseEvent* ce ) | 297 | void MainWindow::closeEvent( QCloseEvent* ce ) |
298 | { | 298 | { |
299 | 299 | ||
300 | 300 | ||
301 | 301 | ||
302 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 302 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
303 | saveOnClose(); | 303 | saveOnClose(); |
304 | mClosed = true; | 304 | mClosed = true; |
305 | ce->accept(); | 305 | ce->accept(); |
306 | return; | 306 | return; |
307 | 307 | ||
308 | } | 308 | } |
309 | 309 | ||
310 | switch( QMessageBox::information( this, "KO/Pi", | 310 | switch( QMessageBox::information( this, "KO/Pi", |
311 | i18n("Do you really want\nto close KO/Pi?"), | 311 | i18n("Do you really want\nto close KO/Pi?"), |
312 | i18n("Close"), i18n("No"), | 312 | i18n("Close"), i18n("No"), |
313 | 0, 0 ) ) { | 313 | 0, 0 ) ) { |
314 | case 0: | 314 | case 0: |
315 | saveOnClose(); | 315 | saveOnClose(); |
316 | mClosed = true; | 316 | mClosed = true; |
317 | ce->accept(); | 317 | ce->accept(); |
318 | break; | 318 | break; |
319 | case 1: | 319 | case 1: |
320 | ce->ignore(); | 320 | ce->ignore(); |
321 | break; | 321 | break; |
322 | case 2: | 322 | case 2: |
323 | 323 | ||
324 | default: | 324 | default: |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
332 | { | 332 | { |
333 | QDataStream stream( data, IO_ReadOnly ); | 333 | QDataStream stream( data, IO_ReadOnly ); |
334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
335 | //QString datamess; | 335 | //QString datamess; |
336 | //qDebug("message "); | 336 | //qDebug("message "); |
337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
338 | 338 | ||
339 | if ( cmsg == "setDocument(QString)" ) { | 339 | if ( cmsg == "setDocument(QString)" ) { |
340 | QDataStream stream( data, IO_ReadOnly ); | 340 | QDataStream stream( data, IO_ReadOnly ); |
341 | QString fileName; | 341 | QString fileName; |
342 | stream >> fileName; | 342 | stream >> fileName; |
343 | //qDebug("filename %s ", fileName.latin1()); | 343 | //qDebug("filename %s ", fileName.latin1()); |
344 | showMaximized(); | 344 | showMaximized(); |
345 | raise(); | 345 | raise(); |
346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
347 | mSyncManager->slotSyncMenu( 1002 ); | 347 | mSyncManager->slotSyncMenu( 1002 ); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | if ( cmsg == "-writeFile" ) { | 351 | if ( cmsg == "-writeFile" ) { |
352 | // I made from the "-writeFile" an "-writeAlarm" | 352 | // I made from the "-writeFile" an "-writeAlarm" |
353 | mView->viewManager()->showWhatsNextView(); | 353 | mView->viewManager()->showWhatsNextView(); |
354 | mCalendar->checkAlarmForIncidence( 0, true); | 354 | mCalendar->checkAlarmForIncidence( 0, true); |
355 | showMaximized(); | 355 | showMaximized(); |
356 | raise(); | 356 | raise(); |
357 | return; | 357 | return; |
358 | 358 | ||
359 | } | 359 | } |
360 | if ( cmsg == "-writeFileSilent" ) { | 360 | if ( cmsg == "-writeFileSilent" ) { |
361 | // I made from the "-writeFile" an "-writeAlarm" | 361 | // I made from the "-writeFile" an "-writeAlarm" |
362 | // mView->viewManager()->showWhatsNextView(); | 362 | // mView->viewManager()->showWhatsNextView(); |
363 | mCalendar->checkAlarmForIncidence( 0, true); | 363 | mCalendar->checkAlarmForIncidence( 0, true); |
364 | //showMaximized(); | 364 | //showMaximized(); |
365 | //raise(); | 365 | //raise(); |
366 | hide(); | 366 | hide(); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | if ( cmsg == "-newCountdown" ) { | 369 | if ( cmsg == "-newCountdown" ) { |
370 | qDebug("newCountdown "); | 370 | qDebug("newCountdown "); |
371 | 371 | ||
372 | } | 372 | } |
373 | QString msg ; | 373 | QString msg ; |
374 | QString allmsg = cmsg; | 374 | QString allmsg = cmsg; |
375 | while ( allmsg.length() > 0 ) { | 375 | while ( allmsg.length() > 0 ) { |
376 | int nextC = allmsg.find( "-", 1 ); | 376 | int nextC = allmsg.find( "-", 1 ); |
377 | if ( nextC == -1 ) { | 377 | if ( nextC == -1 ) { |
378 | msg = allmsg; | 378 | msg = allmsg; |
379 | allmsg = ""; | 379 | allmsg = ""; |
380 | } else{ | 380 | } else{ |
381 | msg = allmsg.left( nextC ); | 381 | msg = allmsg.left( nextC ); |
382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
383 | } | 383 | } |
384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
385 | if ( msg == "-newEvent" ) { | 385 | if ( msg == "-newEvent" ) { |
386 | mView->newEvent(); | 386 | mView->newEvent(); |
387 | } | 387 | } |
388 | if ( msg == "-newTodo" ) { | 388 | if ( msg == "-newTodo" ) { |
389 | mView->newTodo(); | 389 | mView->newTodo(); |
390 | 390 | ||
391 | } | 391 | } |
392 | if ( msg == "-showWN" ) { | 392 | if ( msg == "-showWN" ) { |
393 | mView->viewManager()->showWhatsNextView(); | 393 | mView->viewManager()->showWhatsNextView(); |
394 | } | 394 | } |
395 | if ( msg == "-showTodo" ) { | 395 | if ( msg == "-showTodo" ) { |
396 | mView->viewManager()->showTodoView(); | 396 | mView->viewManager()->showTodoView(); |
397 | } | 397 | } |
398 | if ( msg == "-showList" ) { | 398 | if ( msg == "-showList" ) { |
399 | mView->viewManager()->showListView(); | 399 | mView->viewManager()->showListView(); |
400 | } | 400 | } |
401 | else if ( msg == "-showDay" ) { | 401 | else if ( msg == "-showDay" ) { |
402 | mView->viewManager()->showDayView(); | 402 | mView->viewManager()->showDayView(); |
403 | } | 403 | } |
404 | else if ( msg == "-showWWeek" ) { | 404 | else if ( msg == "-showWWeek" ) { |
405 | mView->viewManager()->showWorkWeekView(); | 405 | mView->viewManager()->showWorkWeekView(); |
406 | } | 406 | } |
407 | else if ( msg == "-ringSync" ) { | 407 | else if ( msg == "-ringSync" ) { |
408 | mSyncManager->multiSync( false ); | 408 | mSyncManager->multiSync( false ); |
409 | } | 409 | } |
410 | else if ( msg == "-showWeek" ) { | 410 | else if ( msg == "-showWeek" ) { |
411 | mView->viewManager()->showWeekView(); | 411 | mView->viewManager()->showWeekView(); |
412 | } | 412 | } |
413 | else if ( msg == "-showTodo" ) { | 413 | else if ( msg == "-showTodo" ) { |
414 | mView->viewManager()->showTodoView(); | 414 | mView->viewManager()->showTodoView(); |
415 | } | 415 | } |
416 | else if ( msg == "-showJournal" ) { | 416 | else if ( msg == "-showJournal" ) { |
417 | mView->dateNavigator()->selectDates( 1 ); | 417 | mView->dateNavigator()->selectDates( 1 ); |
418 | mView->dateNavigator()->selectToday(); | 418 | mView->dateNavigator()->selectToday(); |
419 | mView->viewManager()->showJournalView(); | 419 | mView->viewManager()->showJournalView(); |
420 | } | 420 | } |
421 | else if ( msg == "-showKO" ) { | 421 | else if ( msg == "-showKO" ) { |
422 | mView->viewManager()->showNextXView(); | 422 | mView->viewManager()->showNextXView(); |
423 | } | 423 | } |
424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
425 | mView->viewManager()->showWhatsNextView(); | 425 | mView->viewManager()->showWhatsNextView(); |
426 | } | 426 | } |
427 | else if ( msg == "-showNextXView" ) { | 427 | else if ( msg == "-showNextXView" ) { |
428 | mView->viewManager()->showNextXView(); | 428 | mView->viewManager()->showNextXView(); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | } | 432 | } |
433 | 433 | ||
434 | showMaximized(); | 434 | showMaximized(); |
435 | raise(); | 435 | raise(); |
436 | } | 436 | } |
437 | 437 | ||
438 | QPixmap MainWindow::loadPixmap( QString name ) | 438 | QPixmap MainWindow::loadPixmap( QString name ) |
439 | { | 439 | { |
440 | return SmallIcon( name ); | 440 | return SmallIcon( name ); |
441 | 441 | ||
442 | } | 442 | } |
443 | void MainWindow::initActions() | 443 | void MainWindow::initActions() |
444 | { | 444 | { |
445 | //KOPrefs::instance()->mShowFullMenu | 445 | //KOPrefs::instance()->mShowFullMenu |
446 | iconToolBar->clear(); | 446 | iconToolBar->clear(); |
447 | KOPrefs *p = KOPrefs::instance(); | 447 | KOPrefs *p = KOPrefs::instance(); |
448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
449 | 449 | ||
450 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 450 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
451 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 451 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
452 | QPopupMenu *importMenu = new QPopupMenu( this ); | 452 | QPopupMenu *importMenu = new QPopupMenu( this ); |
453 | selectFilterMenu = new QPopupMenu( this ); | 453 | selectFilterMenu = new QPopupMenu( this ); |
454 | selectFilterMenu->setCheckable( true ); | 454 | selectFilterMenu->setCheckable( true ); |
455 | syncMenu = new QPopupMenu( this ); | 455 | syncMenu = new QPopupMenu( this ); |
456 | configureAgendaMenu = new QPopupMenu( this ); | 456 | configureAgendaMenu = new QPopupMenu( this ); |
457 | configureToolBarMenu = new QPopupMenu( this ); | 457 | configureToolBarMenu = new QPopupMenu( this ); |
458 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 458 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
459 | if ( KOPrefs::instance()->mShowFullMenu ) { | 459 | if ( KOPrefs::instance()->mShowFullMenu ) { |
460 | QMenuBar *menuBar1; | 460 | QMenuBar *menuBar1; |
461 | menuBar1 = menuBar(); | 461 | menuBar1 = menuBar(); |
462 | menuBar1->insertItem( i18n("File"), importMenu ); | 462 | menuBar1->insertItem( i18n("File"), importMenu ); |
463 | menuBar1->insertItem( i18n("View"), viewMenu ); | 463 | menuBar1->insertItem( i18n("View"), viewMenu ); |
464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
469 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 469 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
470 | } else { | 470 | } else { |
471 | QPEMenuBar *menuBar1; | 471 | QPEMenuBar *menuBar1; |
472 | menuBar1 = new QPEMenuBar( iconToolBar ); | 472 | menuBar1 = new QPEMenuBar( iconToolBar ); |
473 | QPopupMenu *menuBar = new QPopupMenu( this ); | 473 | QPopupMenu *menuBar = new QPopupMenu( this ); |
474 | menuBar1->insertItem( i18n("ME"), menuBar); | 474 | menuBar1->insertItem( i18n("ME"), menuBar); |
475 | menuBar->insertItem( i18n("File"), importMenu ); | 475 | menuBar->insertItem( i18n("File"), importMenu ); |
476 | menuBar->insertItem( i18n("View"), viewMenu ); | 476 | menuBar->insertItem( i18n("View"), viewMenu ); |
477 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 477 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
478 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 478 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
479 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 479 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
480 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 480 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
481 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 481 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
482 | menuBar->insertItem( i18n("Help"), helpMenu ); | 482 | menuBar->insertItem( i18n("Help"), helpMenu ); |
483 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 483 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
484 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 484 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
485 | } | 485 | } |
486 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 486 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
487 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 487 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
488 | 488 | ||
489 | // ****************** | 489 | // ****************** |
490 | QAction *action; | 490 | QAction *action; |
491 | QIconSet icon; | 491 | QIconSet icon; |
492 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 492 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
493 | configureToolBarMenu->setCheckable( true ); | 493 | configureToolBarMenu->setCheckable( true ); |
494 | 494 | ||
495 | QString pathString = ""; | 495 | QString pathString = ""; |
496 | if ( !p->mToolBarMiniIcons ) { | 496 | if ( !p->mToolBarMiniIcons ) { |
497 | if ( QApplication::desktop()->width() < 480 ) | 497 | if ( QApplication::desktop()->width() < 480 ) |
498 | pathString += "icons16/"; | 498 | pathString += "icons16/"; |
499 | } else | 499 | } else |
500 | pathString += "iconsmini/"; | 500 | pathString += "iconsmini/"; |
501 | configureAgendaMenu->setCheckable( true ); | 501 | configureAgendaMenu->setCheckable( true ); |
502 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 502 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
503 | configureAgendaMenu->insertSeparator(); | 503 | configureAgendaMenu->insertSeparator(); |
504 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 504 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
505 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 505 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
506 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 506 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
507 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 507 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
508 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 508 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
509 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 509 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
510 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 510 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
511 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 511 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
512 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 512 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
513 | 513 | ||
514 | icon = loadPixmap( pathString + "configure" ); | 514 | icon = loadPixmap( pathString + "configure" ); |
515 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 515 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
516 | action->addTo( actionMenu ); | 516 | action->addTo( actionMenu ); |
517 | connect( action, SIGNAL( activated() ), | 517 | connect( action, SIGNAL( activated() ), |
518 | mView, SLOT( edit_options() ) ); | 518 | mView, SLOT( edit_options() ) ); |
519 | actionMenu->insertSeparator(); | 519 | actionMenu->insertSeparator(); |
520 | icon = loadPixmap( pathString + "newevent" ); | 520 | icon = loadPixmap( pathString + "newevent" ); |
521 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 521 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
522 | configureToolBarMenu->insertSeparator(); | 522 | configureToolBarMenu->insertSeparator(); |
523 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 523 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
524 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 524 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
525 | ne_action->addTo( actionMenu ); | 525 | ne_action->addTo( actionMenu ); |
526 | connect( ne_action, SIGNAL( activated() ), | 526 | connect( ne_action, SIGNAL( activated() ), |
527 | mView, SLOT( newEvent() ) ); | 527 | mView, SLOT( newEvent() ) ); |
528 | icon = loadPixmap( pathString + "newtodo" ); | 528 | icon = loadPixmap( pathString + "newtodo" ); |
529 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 529 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
530 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 530 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
531 | nt_action->addTo( actionMenu ); | 531 | nt_action->addTo( actionMenu ); |
532 | connect( nt_action, SIGNAL( activated() ), | 532 | connect( nt_action, SIGNAL( activated() ), |
533 | mView, SLOT( newTodo() ) ); | 533 | mView, SLOT( newTodo() ) ); |
534 | icon = loadPixmap( pathString + "navi" ); | 534 | icon = loadPixmap( pathString + "navi" ); |
535 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 535 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
536 | action->addTo( viewMenu ); | 536 | action->addTo( viewMenu ); |
537 | connect( action, SIGNAL( activated() ), | 537 | connect( action, SIGNAL( activated() ), |
538 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 538 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
539 | icon = loadPixmap( pathString + "filter" ); | 539 | icon = loadPixmap( pathString + "filter" ); |
540 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 540 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
541 | action->addTo( viewMenu ); | 541 | action->addTo( viewMenu ); |
542 | connect( action, SIGNAL( activated() ), | 542 | connect( action, SIGNAL( activated() ), |
543 | mView, SLOT( toggleFilter() ) ); | 543 | mView, SLOT( toggleFilter() ) ); |
544 | 544 | ||
545 | 545 | ||
546 | viewMenu->insertSeparator(); | 546 | viewMenu->insertSeparator(); |
547 | icon = loadPixmap( pathString + "picker" ); | 547 | icon = loadPixmap( pathString + "picker" ); |
548 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 548 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
549 | action->addTo( viewMenu ); | 549 | action->addTo( viewMenu ); |
550 | connect( action, SIGNAL( activated() ), | 550 | connect( action, SIGNAL( activated() ), |
551 | mView, SLOT( showDatePicker() ) ); | 551 | mView, SLOT( showDatePicker() ) ); |
552 | action->addTo( iconToolBar ); | 552 | action->addTo( iconToolBar ); |
553 | viewMenu->insertSeparator(); | 553 | viewMenu->insertSeparator(); |
554 | icon = loadPixmap( pathString + "list" ); | 554 | icon = loadPixmap( pathString + "list" ); |
555 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 555 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
556 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 556 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
557 | showlist_action->addTo( viewMenu ); | 557 | showlist_action->addTo( viewMenu ); |
558 | connect( showlist_action, SIGNAL( activated() ), | 558 | connect( showlist_action, SIGNAL( activated() ), |
559 | mView->viewManager(), SLOT( showListView() ) ); | 559 | mView->viewManager(), SLOT( showListView() ) ); |
560 | 560 | ||
561 | 561 | ||
562 | icon = loadPixmap( pathString + "day" ); | 562 | icon = loadPixmap( pathString + "day" ); |
563 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 563 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
564 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 564 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
565 | day1_action->addTo( viewMenu ); | 565 | day1_action->addTo( viewMenu ); |
566 | // action->addTo( toolBar ); | 566 | // action->addTo( toolBar ); |
567 | connect( day1_action, SIGNAL( activated() ), | 567 | connect( day1_action, SIGNAL( activated() ), |
568 | mView->viewManager(), SLOT( showDayView() ) ); | 568 | mView->viewManager(), SLOT( showDayView() ) ); |
569 | 569 | ||
570 | icon = loadPixmap( pathString + "workweek" ); | 570 | icon = loadPixmap( pathString + "workweek" ); |
571 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 571 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
572 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 572 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
573 | day5_action->addTo( viewMenu ); | 573 | day5_action->addTo( viewMenu ); |
574 | connect( day5_action, SIGNAL( activated() ), | 574 | connect( day5_action, SIGNAL( activated() ), |
575 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 575 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
576 | 576 | ||
577 | icon = loadPixmap( pathString + "week" ); | 577 | icon = loadPixmap( pathString + "week" ); |
578 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 578 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
579 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 579 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
580 | day7_action->addTo( viewMenu ); | 580 | day7_action->addTo( viewMenu ); |
581 | connect( day7_action, SIGNAL( activated() ), | 581 | connect( day7_action, SIGNAL( activated() ), |
582 | mView->viewManager(), SLOT( showWeekView() ) ); | 582 | mView->viewManager(), SLOT( showWeekView() ) ); |
583 | 583 | ||
584 | icon = loadPixmap( pathString + "month" ); | 584 | icon = loadPixmap( pathString + "month" ); |
585 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 585 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
586 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 586 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
587 | month_action->addTo( viewMenu ); | 587 | month_action->addTo( viewMenu ); |
588 | connect( month_action, SIGNAL( activated() ), | 588 | connect( month_action, SIGNAL( activated() ), |
589 | mView->viewManager(), SLOT( showMonthView() ) ); | 589 | mView->viewManager(), SLOT( showMonthView() ) ); |
590 | 590 | ||
591 | icon = loadPixmap( pathString + "todo" ); | 591 | icon = loadPixmap( pathString + "todo" ); |
592 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 592 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
593 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 593 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
594 | todoview_action->addTo( viewMenu ); | 594 | todoview_action->addTo( viewMenu ); |
595 | connect( todoview_action, SIGNAL( activated() ), | 595 | connect( todoview_action, SIGNAL( activated() ), |
596 | mView->viewManager(), SLOT( showTodoView() ) ); | 596 | mView->viewManager(), SLOT( showTodoView() ) ); |
597 | 597 | ||
598 | icon = loadPixmap( pathString + "journal" ); | 598 | icon = loadPixmap( pathString + "journal" ); |
599 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 599 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
600 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 600 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
601 | viewjournal_action->addTo( viewMenu ); | 601 | viewjournal_action->addTo( viewMenu ); |
602 | connect( viewjournal_action, SIGNAL( activated() ), | 602 | connect( viewjournal_action, SIGNAL( activated() ), |
603 | mView->viewManager(), SLOT( showJournalView() ) ); | 603 | mView->viewManager(), SLOT( showJournalView() ) ); |
604 | 604 | ||
605 | icon = loadPixmap( pathString + "xdays" ); | 605 | icon = loadPixmap( pathString + "xdays" ); |
606 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 606 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
607 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 607 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
608 | xdays_action->addTo( viewMenu ); | 608 | xdays_action->addTo( viewMenu ); |
609 | connect( xdays_action, SIGNAL( activated() ), | 609 | connect( xdays_action, SIGNAL( activated() ), |
610 | mView->viewManager(), SLOT( showNextXView() ) ); | 610 | mView->viewManager(), SLOT( showNextXView() ) ); |
611 | 611 | ||
612 | icon = loadPixmap( pathString + "whatsnext" ); | 612 | icon = loadPixmap( pathString + "whatsnext" ); |
613 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 613 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
614 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 614 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
615 | whatsnext_action->addTo( viewMenu ); | 615 | whatsnext_action->addTo( viewMenu ); |
616 | connect( whatsnext_action, SIGNAL( activated() ), | 616 | connect( whatsnext_action, SIGNAL( activated() ), |
617 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 617 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
618 | 618 | ||
619 | #if 0 | 619 | #if 0 |
620 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 620 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
621 | action->addTo( viewMenu ); | 621 | action->addTo( viewMenu ); |
622 | connect( action, SIGNAL( activated() ), | 622 | connect( action, SIGNAL( activated() ), |
623 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 623 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
624 | #endif | 624 | #endif |
625 | 625 | ||
626 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 626 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
627 | this ); | 627 | this ); |
628 | mNewSubTodoAction->addTo( actionMenu ); | 628 | mNewSubTodoAction->addTo( actionMenu ); |
629 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 629 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
630 | mView, SLOT( newSubTodo() ) ); | 630 | mView, SLOT( newSubTodo() ) ); |
631 | 631 | ||
632 | actionMenu->insertSeparator(); | 632 | actionMenu->insertSeparator(); |
633 | 633 | ||
634 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 634 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
635 | mShowAction->addTo( actionMenu ); | 635 | mShowAction->addTo( actionMenu ); |
636 | connect( mShowAction, SIGNAL( activated() ), | 636 | connect( mShowAction, SIGNAL( activated() ), |
637 | mView, SLOT( showIncidence() ) ); | 637 | mView, SLOT( showIncidence() ) ); |
638 | 638 | ||
639 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 639 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
640 | mEditAction->addTo( actionMenu ); | 640 | mEditAction->addTo( actionMenu ); |
641 | connect( mEditAction, SIGNAL( activated() ), | 641 | connect( mEditAction, SIGNAL( activated() ), |
642 | mView, SLOT( editIncidence() ) ); | 642 | mView, SLOT( editIncidence() ) ); |
643 | 643 | ||
644 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 644 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
645 | mDeleteAction->addTo( actionMenu ); | 645 | mDeleteAction->addTo( actionMenu ); |
646 | connect( mDeleteAction, SIGNAL( activated() ), | 646 | connect( mDeleteAction, SIGNAL( activated() ), |
647 | mView, SLOT( deleteIncidence() ) ); | 647 | mView, SLOT( deleteIncidence() ) ); |
648 | 648 | ||
649 | 649 | ||
650 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 650 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
651 | mCloneAction->addTo( actionMenu ); | 651 | mCloneAction->addTo( actionMenu ); |
652 | connect( mCloneAction, SIGNAL( activated() ), | 652 | connect( mCloneAction, SIGNAL( activated() ), |
653 | mView, SLOT( cloneIncidence() ) ); | 653 | mView, SLOT( cloneIncidence() ) ); |
654 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 654 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
655 | mMoveAction->addTo( actionMenu ); | 655 | mMoveAction->addTo( actionMenu ); |
656 | connect( mMoveAction, SIGNAL( activated() ), | 656 | connect( mMoveAction, SIGNAL( activated() ), |
657 | mView, SLOT( moveIncidence() ) ); | 657 | mView, SLOT( moveIncidence() ) ); |
658 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 658 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
659 | mBeamAction->addTo( actionMenu ); | 659 | mBeamAction->addTo( actionMenu ); |
660 | connect( mBeamAction, SIGNAL( activated() ), | 660 | connect( mBeamAction, SIGNAL( activated() ), |
661 | mView, SLOT( beamIncidence() ) ); | 661 | mView, SLOT( beamIncidence() ) ); |
662 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 662 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
663 | mCancelAction->addTo( actionMenu ); | 663 | mCancelAction->addTo( actionMenu ); |
664 | connect( mCancelAction, SIGNAL( activated() ), | 664 | connect( mCancelAction, SIGNAL( activated() ), |
665 | mView, SLOT( toggleCancelIncidence() ) ); | 665 | mView, SLOT( toggleCancelIncidence() ) ); |
666 | 666 | ||
667 | actionMenu->insertSeparator(); | 667 | actionMenu->insertSeparator(); |
668 | 668 | ||
669 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 669 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
670 | this ); | 670 | this ); |
671 | action->addTo( actionMenu ); | 671 | action->addTo( actionMenu ); |
672 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 672 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
673 | 673 | ||
674 | icon = loadPixmap( pathString + "search" ); | 674 | icon = loadPixmap( pathString + "search" ); |
675 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 675 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
676 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 676 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
677 | search_action->addTo( actionMenu ); | 677 | search_action->addTo( actionMenu ); |
678 | connect( search_action, SIGNAL( activated() ), | 678 | connect( search_action, SIGNAL( activated() ), |
679 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 679 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
680 | 680 | ||
681 | icon = loadPixmap( pathString + "today" ); | 681 | icon = loadPixmap( pathString + "today" ); |
682 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 682 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
683 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 683 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
684 | today_action->addTo( actionMenu ); | 684 | today_action->addTo( actionMenu ); |
685 | connect( today_action, SIGNAL( activated() ), | 685 | connect( today_action, SIGNAL( activated() ), |
686 | mView, SLOT( goToday() ) ); | 686 | mView, SLOT( goToday() ) ); |
687 | 687 | ||
688 | if ( KOPrefs::instance()->mShowFullMenu ) { | 688 | if ( KOPrefs::instance()->mShowFullMenu ) { |
689 | actionMenu->insertSeparator(); | 689 | actionMenu->insertSeparator(); |
690 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 690 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
691 | 691 | ||
692 | } | 692 | } |
693 | // actionMenu->insertSeparator(); | 693 | // actionMenu->insertSeparator(); |
694 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 694 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
695 | this ); | 695 | this ); |
696 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
697 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
698 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 698 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
699 | this ); | 699 | this ); |
700 | action->addTo( importMenu ); | 700 | action->addTo( importMenu ); |
701 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 701 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
702 | importMenu->insertSeparator(); | 702 | importMenu->insertSeparator(); |
703 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 703 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
704 | this ); | 704 | this ); |
705 | action->addTo( importMenu ); | 705 | action->addTo( importMenu ); |
706 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 706 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
707 | #ifndef DESKTOP_VERSION | 707 | #ifndef DESKTOP_VERSION |
708 | importMenu->insertSeparator(); | 708 | importMenu->insertSeparator(); |
709 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 709 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
710 | this ); | 710 | this ); |
711 | action->addTo( importMenu ); | 711 | action->addTo( importMenu ); |
712 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 712 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
713 | #else | 713 | #else |
714 | #ifdef _WIN32_ | 714 | #ifdef _WIN32_ |
715 | importMenu->insertSeparator(); | 715 | importMenu->insertSeparator(); |
716 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 716 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
717 | this ); | 717 | this ); |
718 | action->addTo( importMenu ); | 718 | action->addTo( importMenu ); |
719 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 719 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
720 | #endif | 720 | #endif |
721 | #endif | 721 | #endif |
722 | 722 | ||
723 | importMenu->insertSeparator(); | 723 | importMenu->insertSeparator(); |
724 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 724 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
725 | this ); | 725 | this ); |
726 | action->addTo( importMenu ); | 726 | action->addTo( importMenu ); |
727 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 727 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
728 | 728 | ||
729 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 729 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
730 | this ); | 730 | this ); |
731 | action->addTo( importMenu ); | 731 | action->addTo( importMenu ); |
732 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 732 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
733 | 733 | ||
734 | importMenu->insertSeparator(); | 734 | importMenu->insertSeparator(); |
735 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 735 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
736 | this ); | 736 | this ); |
737 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 737 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
738 | 738 | ||
739 | 739 | ||
740 | //LR | 740 | //LR |
741 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 741 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
742 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 742 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
743 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 743 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
744 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 744 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
745 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 745 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
746 | 746 | ||
747 | importMenu->insertSeparator(); | 747 | importMenu->insertSeparator(); |
748 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 748 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
749 | this ); | 749 | this ); |
750 | action->addTo( importMenu ); | 750 | action->addTo( importMenu ); |
751 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 751 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
752 | #ifndef DESKTOP_VERSION | 752 | #ifndef DESKTOP_VERSION |
753 | importMenu->insertSeparator(); | 753 | importMenu->insertSeparator(); |
754 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 754 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
755 | this ); | 755 | this ); |
756 | action->addTo( importMenu ); | 756 | action->addTo( importMenu ); |
757 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 757 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
758 | 758 | ||
759 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 759 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
760 | this ); | 760 | this ); |
761 | action->addTo( importMenu ); | 761 | action->addTo( importMenu ); |
762 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 762 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
763 | #else | 763 | #else |
764 | importMenu->insertSeparator(); | 764 | importMenu->insertSeparator(); |
765 | icon = loadPixmap( pathString + "print" ); | 765 | icon = loadPixmap( pathString + "print" ); |
766 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 766 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
767 | action->addTo( importMenu ); | 767 | action->addTo( importMenu ); |
768 | connect( action, SIGNAL( activated() ), | 768 | connect( action, SIGNAL( activated() ), |
769 | this, SLOT( printCal() ) ); | 769 | this, SLOT( printCal() ) ); |
770 | 770 | ||
771 | icon = loadPixmap( pathString + "print" ); | 771 | icon = loadPixmap( pathString + "print" ); |
772 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 772 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
773 | action->addTo( importMenu ); | 773 | action->addTo( importMenu ); |
774 | connect( action, SIGNAL( activated() ), | 774 | connect( action, SIGNAL( activated() ), |
775 | this, SLOT( printSel() ) ); | 775 | this, SLOT( printSel() ) ); |
776 | #endif | 776 | #endif |
777 | importMenu->insertSeparator(); | 777 | importMenu->insertSeparator(); |
778 | action = new QAction( "beam all", i18n("Save"), 0, | 778 | action = new QAction( "beam all", i18n("Save"), 0, |
779 | this ); | 779 | this ); |
780 | action->addTo( importMenu ); | 780 | action->addTo( importMenu ); |
781 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 781 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
782 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 782 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
783 | this ); | 783 | this ); |
784 | action->addTo( importMenu ); | 784 | action->addTo( importMenu ); |
785 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 785 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
786 | 786 | ||
787 | //menuBar->insertItem( "Configure",configureMenu ); | 787 | //menuBar->insertItem( "Configure",configureMenu ); |
788 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 788 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
789 | icon = loadPixmap( "korganizer/korganizer" ); | 789 | icon = loadPixmap( "korganizer/korganizer" ); |
790 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 790 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
791 | action->addTo( helpMenu ); | 791 | action->addTo( helpMenu ); |
792 | connect( action, SIGNAL( activated() ), | 792 | connect( action, SIGNAL( activated() ), |
793 | SLOT( keyBindings() ) ); | 793 | SLOT( keyBindings() ) ); |
794 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 794 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
795 | action->addTo( helpMenu ); | 795 | action->addTo( helpMenu ); |
796 | connect( action, SIGNAL( activated() ), | 796 | connect( action, SIGNAL( activated() ), |
797 | SLOT( features() ) ); | 797 | SLOT( features() ) ); |
798 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 798 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
799 | action->addTo( helpMenu ); | 799 | action->addTo( helpMenu ); |
800 | connect( action, SIGNAL( activated() ), | 800 | connect( action, SIGNAL( activated() ), |
801 | SLOT( aboutAutoSaving() ) ); | 801 | SLOT( aboutAutoSaving() ) ); |
802 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 802 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
803 | action->addTo( helpMenu ); | 803 | action->addTo( helpMenu ); |
804 | connect( action, SIGNAL( activated() ), | 804 | connect( action, SIGNAL( activated() ), |
805 | SLOT( aboutKnownBugs() ) ); | 805 | SLOT( aboutKnownBugs() ) ); |
806 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 806 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
807 | action->addTo( helpMenu ); | 807 | action->addTo( helpMenu ); |
808 | connect( action, SIGNAL( activated() ), | 808 | connect( action, SIGNAL( activated() ), |
809 | SLOT( usertrans() ) ); | 809 | SLOT( usertrans() ) ); |
810 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 810 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
811 | action->addTo( helpMenu ); | 811 | action->addTo( helpMenu ); |
812 | connect( action, SIGNAL( activated() ), | 812 | connect( action, SIGNAL( activated() ), |
813 | SLOT( synchowto() ) ); | 813 | SLOT( synchowto() ) ); |
814 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 814 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
815 | action->addTo( helpMenu ); | 815 | action->addTo( helpMenu ); |
816 | connect( action, SIGNAL( activated() ), | 816 | connect( action, SIGNAL( activated() ), |
817 | SLOT( whatsNew() ) ); | 817 | SLOT( whatsNew() ) ); |
818 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 818 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
819 | action->addTo( helpMenu ); | 819 | action->addTo( helpMenu ); |
820 | connect( action, SIGNAL( activated() ), | 820 | connect( action, SIGNAL( activated() ), |
821 | SLOT( faq() ) ); | 821 | SLOT( faq() ) ); |
822 | 822 | ||
823 | 823 | ||
824 | action = new QAction( "about", i18n("About..."), 0, this ); | 824 | action = new QAction( "about", i18n("About..."), 0, this ); |
825 | action->addTo( helpMenu ); | 825 | action->addTo( helpMenu ); |
826 | connect( action, SIGNAL( activated() ), | 826 | connect( action, SIGNAL( activated() ), |
827 | SLOT( about() ) ); | 827 | SLOT( about() ) ); |
828 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 828 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
829 | action->addTo( helpMenu ); | 829 | action->addTo( helpMenu ); |
830 | connect( action, SIGNAL( activated() ), | 830 | connect( action, SIGNAL( activated() ), |
831 | SLOT( licence() ) ); | 831 | SLOT( licence() ) ); |
832 | //menuBar->insertSeparator(); | 832 | //menuBar->insertSeparator(); |
833 | 833 | ||
834 | // ****************************************************** | 834 | // ****************************************************** |
835 | // menubar icons | 835 | // menubar icons |
836 | 836 | ||
837 | 837 | ||
838 | iconToolBar->setHorizontalStretchable (true ); | 838 | iconToolBar->setHorizontalStretchable (true ); |
839 | //menuBar->insertItem( iconToolBar ); | 839 | //menuBar->insertItem( iconToolBar ); |
840 | //xdays_action | 840 | //xdays_action |
841 | if (p-> mShowIconNewEvent) | 841 | if (p-> mShowIconNewEvent) |
842 | ne_action->addTo( iconToolBar ); | 842 | ne_action->addTo( iconToolBar ); |
843 | if (p->mShowIconNewTodo ) | 843 | if (p->mShowIconNewTodo ) |
844 | nt_action->addTo( iconToolBar ); | 844 | nt_action->addTo( iconToolBar ); |
845 | if (p-> mShowIconSearch) | 845 | if (p-> mShowIconSearch) |
846 | search_action->addTo( iconToolBar ); | 846 | search_action->addTo( iconToolBar ); |
847 | if (p-> mShowIconNext) | 847 | if (p-> mShowIconNext) |
848 | whatsnext_action->addTo( iconToolBar ); | 848 | whatsnext_action->addTo( iconToolBar ); |
849 | if (p-> mShowIconNextDays) | 849 | if (p-> mShowIconNextDays) |
850 | xdays_action->addTo( iconToolBar ); | 850 | xdays_action->addTo( iconToolBar ); |
851 | if (p-> mShowIconList) | 851 | if (p-> mShowIconList) |
852 | showlist_action->addTo( iconToolBar ); | 852 | showlist_action->addTo( iconToolBar ); |
853 | if (p-> mShowIconDay1) | 853 | if (p-> mShowIconDay1) |
854 | day1_action->addTo( iconToolBar ); | 854 | day1_action->addTo( iconToolBar ); |
855 | if (p-> mShowIconDay5) | 855 | if (p-> mShowIconDay5) |
856 | day5_action->addTo( iconToolBar ); | 856 | day5_action->addTo( iconToolBar ); |
857 | if (p-> mShowIconDay7) | 857 | if (p-> mShowIconDay7) |
858 | day7_action->addTo( iconToolBar ); | 858 | day7_action->addTo( iconToolBar ); |
859 | if (p-> mShowIconMonth) | 859 | if (p-> mShowIconMonth) |
860 | month_action->addTo( iconToolBar ); | 860 | month_action->addTo( iconToolBar ); |
861 | if (p-> mShowIconTodoview) | 861 | if (p-> mShowIconTodoview) |
862 | todoview_action->addTo( iconToolBar ); | 862 | todoview_action->addTo( iconToolBar ); |
863 | if (p-> mShowIconJournal) | 863 | if (p-> mShowIconJournal) |
864 | viewjournal_action->addTo( iconToolBar ); | 864 | viewjournal_action->addTo( iconToolBar ); |
865 | icon = loadPixmap( pathString + "2leftarrowB" ); | 865 | icon = loadPixmap( pathString + "2leftarrowB" ); |
866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
867 | if (p-> mShowIconBackFast) { | 867 | if (p-> mShowIconBackFast) { |
868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
869 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
870 | mView, SLOT( goPreviousMonth() ) ); | 870 | mView, SLOT( goPreviousMonth() ) ); |
871 | action->addTo( iconToolBar ); | 871 | action->addTo( iconToolBar ); |
872 | } | 872 | } |
873 | icon = loadPixmap( pathString + "1leftarrowB" ); | 873 | icon = loadPixmap( pathString + "1leftarrowB" ); |
874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
875 | if (p-> mShowIconBack) { | 875 | if (p-> mShowIconBack) { |
876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
877 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
878 | mView, SLOT( goPrevious() ) ); | 878 | mView, SLOT( goPrevious() ) ); |
879 | action->addTo( iconToolBar ); | 879 | action->addTo( iconToolBar ); |
880 | } | 880 | } |
881 | if (p-> mShowIconToday) | 881 | if (p-> mShowIconToday) |
882 | today_action->addTo( iconToolBar ); | 882 | today_action->addTo( iconToolBar ); |
883 | icon = loadPixmap( pathString + "1rightarrowB" ); | 883 | icon = loadPixmap( pathString + "1rightarrowB" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
885 | if (p-> mShowIconForward) { | 885 | if (p-> mShowIconForward) { |
886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
887 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( goNext() ) ); | 888 | mView, SLOT( goNext() ) ); |
889 | action->addTo( iconToolBar ); | 889 | action->addTo( iconToolBar ); |
890 | } | 890 | } |
891 | icon = loadPixmap( pathString + "2rightarrowB" ); | 891 | icon = loadPixmap( pathString + "2rightarrowB" ); |
892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
893 | if (p-> mShowIconForwardFast) { | 893 | if (p-> mShowIconForwardFast) { |
894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
895 | connect( action, SIGNAL( activated() ), | 895 | connect( action, SIGNAL( activated() ), |
896 | mView, SLOT( goNextMonth() ) ); | 896 | mView, SLOT( goNextMonth() ) ); |
897 | action->addTo( iconToolBar ); | 897 | action->addTo( iconToolBar ); |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
902 | 902 | ||
903 | if (p-> mShowIconNewEvent) | 903 | if (p-> mShowIconNewEvent) |
904 | configureToolBarMenu->setItemChecked( 10, true ); | 904 | configureToolBarMenu->setItemChecked( 10, true ); |
905 | if (p->mShowIconNewTodo ) | 905 | if (p->mShowIconNewTodo ) |
906 | configureToolBarMenu->setItemChecked( 20, true ); | 906 | configureToolBarMenu->setItemChecked( 20, true ); |
907 | if (p-> mShowIconSearch) | 907 | if (p-> mShowIconSearch) |
908 | configureToolBarMenu->setItemChecked( 120, true ); | 908 | configureToolBarMenu->setItemChecked( 120, true ); |
909 | if (p-> mShowIconList) | 909 | if (p-> mShowIconList) |
910 | configureToolBarMenu->setItemChecked( 30, true ); | 910 | configureToolBarMenu->setItemChecked( 30, true ); |
911 | if (p-> mShowIconDay1) | 911 | if (p-> mShowIconDay1) |
912 | configureToolBarMenu->setItemChecked( 40, true ); | 912 | configureToolBarMenu->setItemChecked( 40, true ); |
913 | if (p-> mShowIconDay5) | 913 | if (p-> mShowIconDay5) |
914 | configureToolBarMenu->setItemChecked( 50, true ); | 914 | configureToolBarMenu->setItemChecked( 50, true ); |
915 | if (p-> mShowIconDay7) | 915 | if (p-> mShowIconDay7) |
916 | configureToolBarMenu->setItemChecked( 60, true ); | 916 | configureToolBarMenu->setItemChecked( 60, true ); |
917 | if (p-> mShowIconMonth) | 917 | if (p-> mShowIconMonth) |
918 | configureToolBarMenu->setItemChecked( 70, true ); | 918 | configureToolBarMenu->setItemChecked( 70, true ); |
919 | if (p-> mShowIconTodoview) | 919 | if (p-> mShowIconTodoview) |
920 | configureToolBarMenu->setItemChecked( 80, true ); | 920 | configureToolBarMenu->setItemChecked( 80, true ); |
921 | if (p-> mShowIconBackFast) | 921 | if (p-> mShowIconBackFast) |
922 | configureToolBarMenu->setItemChecked( 200, true ); | 922 | configureToolBarMenu->setItemChecked( 200, true ); |
923 | if (p-> mShowIconBack) | 923 | if (p-> mShowIconBack) |
924 | configureToolBarMenu->setItemChecked( 210, true ); | 924 | configureToolBarMenu->setItemChecked( 210, true ); |
925 | if (p-> mShowIconToday) | 925 | if (p-> mShowIconToday) |
926 | configureToolBarMenu->setItemChecked( 130, true ); | 926 | configureToolBarMenu->setItemChecked( 130, true ); |
927 | if (p-> mShowIconForward) | 927 | if (p-> mShowIconForward) |
928 | configureToolBarMenu->setItemChecked( 220, true ); | 928 | configureToolBarMenu->setItemChecked( 220, true ); |
929 | if (p-> mShowIconForwardFast) | 929 | if (p-> mShowIconForwardFast) |
930 | configureToolBarMenu->setItemChecked( 230, true ); | 930 | configureToolBarMenu->setItemChecked( 230, true ); |
931 | if (p-> mShowIconNextDays) | 931 | if (p-> mShowIconNextDays) |
932 | configureToolBarMenu->setItemChecked( 100, true ); | 932 | configureToolBarMenu->setItemChecked( 100, true ); |
933 | if (p-> mShowIconNext) | 933 | if (p-> mShowIconNext) |
934 | configureToolBarMenu->setItemChecked( 110, true ); | 934 | configureToolBarMenu->setItemChecked( 110, true ); |
935 | if (p-> mShowIconJournal) | 935 | if (p-> mShowIconJournal) |
936 | configureToolBarMenu->setItemChecked( 90, true ); | 936 | configureToolBarMenu->setItemChecked( 90, true ); |
937 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
938 | configureToolBarMenu->setItemChecked( 300, true ); | 938 | configureToolBarMenu->setItemChecked( 300, true ); |
939 | 939 | ||
940 | QLabel* dummy = new QLabel( iconToolBar ); | 940 | QLabel* dummy = new QLabel( iconToolBar ); |
941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
942 | if (!p-> mShowIconStretch) | 942 | if (!p-> mShowIconStretch) |
943 | iconToolBar->setStretchableWidget ( dummy ) ; | 943 | iconToolBar->setStretchableWidget ( dummy ) ; |
944 | else | 944 | else |
945 | configureToolBarMenu->setItemChecked( 5, true ); | 945 | configureToolBarMenu->setItemChecked( 5, true ); |
946 | if (p-> mShowIconWhatsThis) | 946 | if (p-> mShowIconWhatsThis) |
947 | QWhatsThis::whatsThisButton ( iconToolBar ); | 947 | QWhatsThis::whatsThisButton ( iconToolBar ); |
948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
949 | configureAgenda( p->mHourSize ); | 949 | configureAgenda( p->mHourSize ); |
950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
951 | } | 951 | } |
952 | 952 | ||
953 | void MainWindow::exportToPhone( int mode ) | 953 | void MainWindow::exportToPhone( int mode ) |
954 | { | 954 | { |
955 | 955 | ||
956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
958 | KOex2phonePrefs ex2phone; | 958 | KOex2phonePrefs ex2phone; |
959 | 959 | ||
960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
963 | if ( mode == 1 ) | 963 | if ( mode == 1 ) |
964 | ex2phone.setCaption(i18n("Export complete calendar")); | 964 | ex2phone.setCaption(i18n("Export complete calendar")); |
965 | if ( mode == 2 ) | 965 | if ( mode == 2 ) |
966 | ex2phone.setCaption(i18n("Export filtered calendar")); | 966 | ex2phone.setCaption(i18n("Export filtered calendar")); |
967 | 967 | ||
968 | if ( !ex2phone.exec() ) { | 968 | if ( !ex2phone.exec() ) { |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
974 | 974 | ||
975 | int inFuture = 0; | 975 | int inFuture = 0; |
976 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 976 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
978 | QPtrList<Incidence> delSel; | 978 | QPtrList<Incidence> delSel; |
979 | if ( mode == 1 ) | 979 | if ( mode == 1 ) |
980 | delSel = mCalendar->rawIncidences(); | 980 | delSel = mCalendar->rawIncidences(); |
981 | if ( mode == 2 ) | 981 | if ( mode == 2 ) |
982 | delSel = mCalendar->incidences(); | 982 | delSel = mCalendar->incidences(); |
983 | CalendarLocal* cal = new CalendarLocal(); | 983 | CalendarLocal* cal = new CalendarLocal(); |
984 | cal->setLocalTime(); | 984 | cal->setLocalTime(); |
985 | Incidence *incidence = delSel.first(); | 985 | Incidence *incidence = delSel.first(); |
986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
988 | while ( incidence ) { | 988 | while ( incidence ) { |
989 | if ( incidence->type() != "Journal" ) { | 989 | if ( incidence->type() != "Journal" ) { |
990 | bool add = true; | 990 | bool add = true; |
991 | if ( inFuture ) { | 991 | if ( inFuture ) { |
992 | QDateTime dt; | 992 | QDateTime dt; |
993 | if ( incidence->type() == "Todo" ) { | 993 | if ( incidence->type() == "Todo" ) { |
994 | Todo * t = (Todo*)incidence; | 994 | Todo * t = (Todo*)incidence; |
995 | if ( t->hasDueDate() ) | 995 | if ( t->hasDueDate() ) |
996 | dt = t->dtDue(); | 996 | dt = t->dtDue(); |
997 | else | 997 | else |
998 | dt = cur.addSecs( 62 ); | 998 | dt = cur.addSecs( 62 ); |
999 | } | 999 | } |
1000 | else { | 1000 | else { |
1001 | bool ok; | 1001 | bool ok; |
1002 | dt = incidence->getNextOccurence( cur, &ok ); | 1002 | dt = incidence->getNextOccurence( cur, &ok ); |
1003 | if ( !ok ) | 1003 | if ( !ok ) |
1004 | dt = cur.addSecs( -62 ); | 1004 | dt = cur.addSecs( -62 ); |
1005 | } | 1005 | } |
1006 | if ( dt < cur || dt > end ) { | 1006 | if ( dt < cur || dt > end ) { |
1007 | add = false; | 1007 | add = false; |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | if ( add ) { | 1010 | if ( add ) { |
1011 | Incidence *in = incidence->clone(); | 1011 | Incidence *in = incidence->clone(); |
1012 | cal->addIncidence( in ); | 1012 | cal->addIncidence( in ); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | incidence = delSel.next(); | 1015 | incidence = delSel.next(); |
1016 | } | 1016 | } |
1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1020 | 1020 | ||
1021 | setCaption( i18n("Writing to phone...")); | 1021 | setCaption( i18n("Writing to phone...")); |
1022 | if ( PhoneFormat::writeToPhone( cal ) ) | 1022 | if ( PhoneFormat::writeToPhone( cal ) ) |
1023 | setCaption( i18n("Export to phone successful!")); | 1023 | setCaption( i18n("Export to phone successful!")); |
1024 | else | 1024 | else |
1025 | setCaption( i18n("Error exporting to phone!")); | 1025 | setCaption( i18n("Error exporting to phone!")); |
1026 | delete cal; | 1026 | delete cal; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | 1029 | ||
1030 | void MainWindow::setDefaultPreferences() | 1030 | void MainWindow::setDefaultPreferences() |
1031 | { | 1031 | { |
1032 | KOPrefs *p = KOPrefs::instance(); | 1032 | KOPrefs *p = KOPrefs::instance(); |
1033 | 1033 | ||
1034 | p->mCompactDialogs = true; | 1034 | p->mCompactDialogs = true; |
1035 | p->mConfirm = true; | 1035 | p->mConfirm = true; |
1036 | // p->mEnableQuickTodo = false; | 1036 | // p->mEnableQuickTodo = false; |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | QString MainWindow::resourcePath() | 1040 | QString MainWindow::resourcePath() |
1041 | { | 1041 | { |
1042 | return KGlobal::iconLoader()->iconPath(); | 1042 | return KGlobal::iconLoader()->iconPath(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void MainWindow::displayText( QString text ,QString cap ) | 1045 | void MainWindow::displayText( QString text ,QString cap ) |
1046 | { | 1046 | { |
1047 | QDialog dia( this, "name", true ); ; | 1047 | QDialog dia( this, "name", true ); ; |
1048 | dia.setCaption( cap ); | 1048 | dia.setCaption( cap ); |
1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1050 | lay->setSpacing( 3 ); | 1050 | lay->setSpacing( 3 ); |
1051 | lay->setMargin( 3 ); | 1051 | lay->setMargin( 3 ); |
1052 | QTextBrowser tb ( &dia ); | 1052 | QTextBrowser tb ( &dia ); |
1053 | lay->addWidget( &tb ); | 1053 | lay->addWidget( &tb ); |
1054 | tb.setText( text ); | 1054 | tb.setText( text ); |
1055 | #ifdef DESKTOP_VERSION | 1055 | #ifdef DESKTOP_VERSION |
1056 | dia.resize( 640, 480); | 1056 | dia.resize( 640, 480); |
1057 | #else | 1057 | #else |
1058 | dia.showMaximized(); | 1058 | dia.showMaximized(); |
1059 | #endif | 1059 | #endif |
1060 | dia.exec(); | 1060 | dia.exec(); |
1061 | } | 1061 | } |
1062 | void MainWindow::displayFile( QString fn, QString cap ) | 1062 | void MainWindow::displayFile( QString fn, QString cap ) |
1063 | { | 1063 | { |
1064 | QString fileName = resourcePath() + fn; | 1064 | QString fileName = resourcePath() + fn; |
1065 | QString text; | 1065 | QString text; |
1066 | QFile file( fileName ); | 1066 | QFile file( fileName ); |
1067 | if (!file.open( IO_ReadOnly ) ) { | 1067 | if (!file.open( IO_ReadOnly ) ) { |
1068 | return ; | 1068 | return ; |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | QTextStream ts( &file ); | 1071 | QTextStream ts( &file ); |
1072 | text = ts.read(); | 1072 | text = ts.read(); |
1073 | file.close(); | 1073 | file.close(); |
1074 | displayText( text, cap); | 1074 | displayText( text, cap); |
1075 | } | 1075 | } |
1076 | void MainWindow::features() | 1076 | void MainWindow::features() |
1077 | { | 1077 | { |
1078 | 1078 | ||
1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void MainWindow::usertrans() | 1082 | void MainWindow::usertrans() |
1083 | { | 1083 | { |
1084 | 1084 | ||
1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void MainWindow::synchowto() | 1088 | void MainWindow::synchowto() |
1089 | { | 1089 | { |
1090 | 1090 | ||
1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1092 | } | 1092 | } |
1093 | void MainWindow::faq() | 1093 | void MainWindow::faq() |
1094 | { | 1094 | { |
1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | void MainWindow::whatsNew() | 1098 | void MainWindow::whatsNew() |
1099 | { | 1099 | { |
1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1101 | 1101 | ||
1102 | } | 1102 | } |
1103 | void MainWindow::licence() | 1103 | void MainWindow::licence() |
1104 | { | 1104 | { |
1105 | KApplication::showLicence(); | 1105 | KApplication::showLicence(); |
1106 | 1106 | ||
1107 | } | 1107 | } |
1108 | void MainWindow::about() | 1108 | void MainWindow::about() |
1109 | { | 1109 | { |
1110 | QString version; | 1110 | QString version; |
1111 | #include <../version> | 1111 | #include <../version> |
1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1113 | i18n("KOrganizer/Platform-independent\n") + | 1113 | i18n("KOrganizer/Platform-independent\n") + |
1114 | "(KO/Pi) " + version + " - " + | 1114 | "(KO/Pi) " + version + " - " + |
1115 | 1115 | ||
1116 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1117 | i18n("Desktop Edition\n") + | 1117 | i18n("Desktop Edition\n") + |
1118 | #else | 1118 | #else |
1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1120 | #endif | 1120 | #endif |
1121 | 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") ); | 1121 | 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") ); |
1122 | } | 1122 | } |
1123 | void MainWindow::keyBindings() | 1123 | void MainWindow::keyBindings() |
1124 | { | 1124 | { |
1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1149 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1149 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1150 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | ||
1151 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | ||
1152 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | ||
1150 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1151 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1152 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1153 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1154 | i18n("<p><h3>In list view:</h3></p>\n") + | 1157 | i18n("<p><h3>In list view:</h3></p>\n") + |
1155 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1156 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1157 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1158 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1159 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1160 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1161 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1162 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1163 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1164 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1167 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1165 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1166 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1167 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1168 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1169 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1170 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1171 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1172 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1173 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1174 | displayText( text, cap); | 1177 | displayText( text, cap); |
1175 | 1178 | ||
1176 | } | 1179 | } |
1177 | void MainWindow::aboutAutoSaving() | 1180 | void MainWindow::aboutAutoSaving() |
1178 | { | 1181 | { |
1179 | QMessageBox* msg; | 1182 | QMessageBox* msg; |
1180 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1181 | 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, | 1184 | 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, |
1182 | QMessageBox::Ok, | 1185 | QMessageBox::Ok, |
1183 | QMessageBox::NoButton, | 1186 | QMessageBox::NoButton, |
1184 | QMessageBox::NoButton); | 1187 | QMessageBox::NoButton); |
1185 | msg->exec(); | 1188 | msg->exec(); |
1186 | delete msg; | 1189 | delete msg; |
1187 | 1190 | ||
1188 | 1191 | ||
1189 | } | 1192 | } |
1190 | void MainWindow::aboutKnownBugs() | 1193 | void MainWindow::aboutKnownBugs() |
1191 | { | 1194 | { |
1192 | QMessageBox* msg; | 1195 | QMessageBox* msg; |
1193 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1194 | 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")+ | 1197 | 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")+ |
1195 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1196 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1197 | i18n("\nor report them in the bugtracker on\n") + | 1200 | i18n("\nor report them in the bugtracker on\n") + |
1198 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1199 | QMessageBox::NoIcon, | 1202 | QMessageBox::NoIcon, |
1200 | QMessageBox::Ok, | 1203 | QMessageBox::Ok, |
1201 | QMessageBox::NoButton, | 1204 | QMessageBox::NoButton, |
1202 | QMessageBox::NoButton); | 1205 | QMessageBox::NoButton); |
1203 | msg->exec(); | 1206 | msg->exec(); |
1204 | delete msg; | 1207 | delete msg; |
1205 | 1208 | ||
1206 | } | 1209 | } |
1207 | 1210 | ||
1208 | QString MainWindow::defaultFileName() | 1211 | QString MainWindow::defaultFileName() |
1209 | { | 1212 | { |
1210 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1211 | } | 1214 | } |
1212 | QString MainWindow::syncFileName() | 1215 | QString MainWindow::syncFileName() |
1213 | { | 1216 | { |
1214 | #ifdef _WIN32_ | 1217 | #ifdef _WIN32_ |
1215 | return locateLocal( "tmp", "synccalendar.ics" ); | 1218 | return locateLocal( "tmp", "synccalendar.ics" ); |
1216 | #else | 1219 | #else |
1217 | return QString( "/tmp/kopitempfile.ics" ); | 1220 | return QString( "/tmp/kopitempfile.ics" ); |
1218 | #endif | 1221 | #endif |
1219 | } | 1222 | } |
1220 | 1223 | ||
1221 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1224 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1222 | { | 1225 | { |
1223 | if ( !incidence ) { | 1226 | if ( !incidence ) { |
1224 | enableIncidenceActions( false ); | 1227 | enableIncidenceActions( false ); |
1225 | 1228 | ||
1226 | mNewSubTodoAction->setEnabled( false ); | 1229 | mNewSubTodoAction->setEnabled( false ); |
1227 | setCaptionToDates(); | 1230 | setCaptionToDates(); |
1228 | return; | 1231 | return; |
1229 | 1232 | ||
1230 | } | 1233 | } |
1231 | 1234 | ||
1232 | //KGlobal::locale()->formatDateTime(nextA, true); | 1235 | //KGlobal::locale()->formatDateTime(nextA, true); |
1233 | QString startString = ""; | 1236 | QString startString = ""; |
1234 | if ( incidence->type() != "Todo" ) { | 1237 | if ( incidence->type() != "Todo" ) { |
1235 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1238 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1236 | if ( incidence->doesFloat() ) { | 1239 | if ( incidence->doesFloat() ) { |
1237 | startString += ": "+incidence->dtStartDateStr( true ); | 1240 | startString += ": "+incidence->dtStartDateStr( true ); |
1238 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1241 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1239 | 1242 | ||
1240 | } else { | 1243 | } else { |
1241 | startString = ": "+incidence->dtStartStr(true); | 1244 | startString = ": "+incidence->dtStartStr(true); |
1242 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1245 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1243 | 1246 | ||
1244 | } | 1247 | } |
1245 | 1248 | ||
1246 | } else { | 1249 | } else { |
1247 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1250 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1248 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1251 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1249 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1252 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1250 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1253 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1251 | } | 1254 | } |
1252 | 1255 | ||
1253 | } | 1256 | } |
1254 | else | 1257 | else |
1255 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1258 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1256 | if ( !incidence->location().isEmpty() ) | 1259 | if ( !incidence->location().isEmpty() ) |
1257 | startString += " (" +incidence->location()+")"; | 1260 | startString += " (" +incidence->location()+")"; |
1258 | setCaption( incidence->summary()+startString); | 1261 | setCaption( incidence->summary()+startString); |
1259 | 1262 | ||
1260 | enableIncidenceActions( true ); | 1263 | enableIncidenceActions( true ); |
1261 | 1264 | ||
1262 | if ( incidence->type() == "Event" ) { | 1265 | if ( incidence->type() == "Event" ) { |
1263 | mShowAction->setText( i18n("Show Event...") ); | 1266 | mShowAction->setText( i18n("Show Event...") ); |
1264 | mEditAction->setText( i18n("Edit Event...") ); | 1267 | mEditAction->setText( i18n("Edit Event...") ); |
1265 | mDeleteAction->setText( i18n("Delete Event...") ); | 1268 | mDeleteAction->setText( i18n("Delete Event...") ); |
1266 | 1269 | ||
1267 | mNewSubTodoAction->setEnabled( false ); | 1270 | mNewSubTodoAction->setEnabled( false ); |
1268 | } else if ( incidence->type() == "Todo" ) { | 1271 | } else if ( incidence->type() == "Todo" ) { |
1269 | mShowAction->setText( i18n("Show Todo...") ); | 1272 | mShowAction->setText( i18n("Show Todo...") ); |
1270 | mEditAction->setText( i18n("Edit Todo...") ); | 1273 | mEditAction->setText( i18n("Edit Todo...") ); |
1271 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1274 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1272 | 1275 | ||
1273 | mNewSubTodoAction->setEnabled( true ); | 1276 | mNewSubTodoAction->setEnabled( true ); |
1274 | } else { | 1277 | } else { |
1275 | mShowAction->setText( i18n("Show...") ); | 1278 | mShowAction->setText( i18n("Show...") ); |
1276 | mShowAction->setText( i18n("Edit...") ); | 1279 | mShowAction->setText( i18n("Edit...") ); |
1277 | mShowAction->setText( i18n("Delete...") ); | 1280 | mShowAction->setText( i18n("Delete...") ); |
1278 | 1281 | ||
1279 | mNewSubTodoAction->setEnabled( false ); | 1282 | mNewSubTodoAction->setEnabled( false ); |
1280 | } | 1283 | } |
1281 | } | 1284 | } |
1282 | 1285 | ||
1283 | void MainWindow::enableIncidenceActions( bool enabled ) | 1286 | void MainWindow::enableIncidenceActions( bool enabled ) |
1284 | { | 1287 | { |
1285 | mShowAction->setEnabled( enabled ); | 1288 | mShowAction->setEnabled( enabled ); |
1286 | mEditAction->setEnabled( enabled ); | 1289 | mEditAction->setEnabled( enabled ); |
1287 | mDeleteAction->setEnabled( enabled ); | 1290 | mDeleteAction->setEnabled( enabled ); |
1288 | 1291 | ||
1289 | mCloneAction->setEnabled( enabled ); | 1292 | mCloneAction->setEnabled( enabled ); |
1290 | mMoveAction->setEnabled( enabled ); | 1293 | mMoveAction->setEnabled( enabled ); |
1291 | mBeamAction->setEnabled( enabled ); | 1294 | mBeamAction->setEnabled( enabled ); |
1292 | mCancelAction->setEnabled( enabled ); | 1295 | mCancelAction->setEnabled( enabled ); |
1293 | } | 1296 | } |
1294 | 1297 | ||
1295 | void MainWindow::importOL() | 1298 | void MainWindow::importOL() |
1296 | { | 1299 | { |
1297 | #ifdef _WIN32_ | 1300 | #ifdef _WIN32_ |
1298 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1301 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1299 | id->exec(); | 1302 | id->exec(); |
1300 | delete id; | 1303 | delete id; |
1301 | mView->updateView(); | 1304 | mView->updateView(); |
1302 | #endif | 1305 | #endif |
1303 | } | 1306 | } |
1304 | void MainWindow::importBday() | 1307 | void MainWindow::importBday() |
1305 | { | 1308 | { |
1306 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1309 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1307 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1310 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1308 | i18n("Import!"), i18n("Cancel"), 0, | 1311 | i18n("Import!"), i18n("Cancel"), 0, |
1309 | 0, 1 ); | 1312 | 0, 1 ); |
1310 | if ( result == 0 ) { | 1313 | if ( result == 0 ) { |
1311 | mView->importBday(); | 1314 | mView->importBday(); |
1312 | 1315 | ||
1313 | } | 1316 | } |
1314 | 1317 | ||
1315 | 1318 | ||
1316 | } | 1319 | } |
1317 | void MainWindow::importQtopia() | 1320 | void MainWindow::importQtopia() |
1318 | { | 1321 | { |
1319 | #ifndef DESKTOP_VERSION | 1322 | #ifndef DESKTOP_VERSION |
1320 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1323 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1321 | 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"), | 1324 | 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"), |
1322 | i18n("Import!"), i18n("Cancel"), 0, | 1325 | i18n("Import!"), i18n("Cancel"), 0, |
1323 | 0, 1 ); | 1326 | 0, 1 ); |
1324 | if ( result == 0 ) { | 1327 | if ( result == 0 ) { |
1325 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1328 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1326 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1329 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1327 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1330 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1328 | mView->importQtopia( categories, datebook, todolist ); | 1331 | mView->importQtopia( categories, datebook, todolist ); |
1329 | } | 1332 | } |
1330 | #else | 1333 | #else |
1331 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1334 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1332 | i18n("Not supported \non desktop!\n"), | 1335 | i18n("Not supported \non desktop!\n"), |
1333 | i18n("Ok"), i18n("Cancel"), 0, | 1336 | i18n("Ok"), i18n("Cancel"), 0, |
1334 | 0, 1 ); | 1337 | 0, 1 ); |
1335 | 1338 | ||
1336 | #endif | 1339 | #endif |
1337 | } | 1340 | } |
1338 | 1341 | ||
1339 | void MainWindow::saveOnClose() | 1342 | void MainWindow::saveOnClose() |
1340 | { | 1343 | { |
1341 | KOPrefs *p = KOPrefs::instance(); | 1344 | KOPrefs *p = KOPrefs::instance(); |
1342 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1345 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1343 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1346 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1344 | iconToolBar->y() > height()/2; | 1347 | iconToolBar->y() > height()/2; |
1345 | mView->writeSettings(); | 1348 | mView->writeSettings(); |
1346 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1349 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1347 | save(); | 1350 | save(); |
1348 | } | 1351 | } |
1349 | void MainWindow::slotModifiedChanged( bool changed ) | 1352 | void MainWindow::slotModifiedChanged( bool changed ) |
1350 | { | 1353 | { |
1351 | if ( mBlockAtStartup ) | 1354 | if ( mBlockAtStartup ) |
1352 | return; | 1355 | return; |
1353 | int msec; | 1356 | int msec; |
1354 | // we store the changes after 1 minute, | 1357 | // we store the changes after 1 minute, |
1355 | // and for safety reasons after 10 minutes again | 1358 | // and for safety reasons after 10 minutes again |
1356 | if ( !mSyncManager->blockSave() ) | 1359 | if ( !mSyncManager->blockSave() ) |
1357 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1360 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1358 | else | 1361 | else |
1359 | msec = 1000 * 600; | 1362 | msec = 1000 * 600; |
1360 | mSaveTimer.start( msec, true ); // 1 minute | 1363 | mSaveTimer.start( msec, true ); // 1 minute |
1361 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1364 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1362 | mCalendarModifiedFlag = true; | 1365 | mCalendarModifiedFlag = true; |
1363 | } | 1366 | } |
1364 | void MainWindow::save() | 1367 | void MainWindow::save() |
1365 | { | 1368 | { |
1366 | if ( mSyncManager->blockSave() ) | 1369 | if ( mSyncManager->blockSave() ) |
1367 | return; | 1370 | return; |
1368 | mSyncManager->setBlockSave(true); | 1371 | mSyncManager->setBlockSave(true); |
1369 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1372 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1370 | 1373 | ||
1371 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1374 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1372 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1375 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1373 | qDebug("KO: Start saving data to file!"); | 1376 | qDebug("KO: Start saving data to file!"); |
1374 | mView->saveCalendar( defaultFileName() ); | 1377 | mView->saveCalendar( defaultFileName() ); |
1375 | 1378 | ||
1376 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1379 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1377 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1380 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1378 | QString savemes; | 1381 | QString savemes; |
1379 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1382 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1380 | setCaption(savemes); | 1383 | setCaption(savemes); |
1381 | } else | 1384 | } else |
1382 | setCaption(i18n("Saving cancelled!")); | 1385 | setCaption(i18n("Saving cancelled!")); |
1383 | mCalendarModifiedFlag = false; | 1386 | mCalendarModifiedFlag = false; |
1384 | mSyncManager->setBlockSave( false ); | 1387 | mSyncManager->setBlockSave( false ); |
1385 | } | 1388 | } |
1386 | 1389 | ||
1387 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1390 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1388 | { | 1391 | { |
1389 | if ( !e->isAutoRepeat() ) { | 1392 | if ( !e->isAutoRepeat() ) { |
1390 | mFlagKeyPressed = false; | 1393 | mFlagKeyPressed = false; |
1391 | } | 1394 | } |
1392 | } | 1395 | } |
1393 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1396 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1394 | { | 1397 | { |
1395 | qApp->processEvents(); | 1398 | qApp->processEvents(); |
1396 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1399 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1397 | e->ignore(); | 1400 | e->ignore(); |
1398 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1401 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1399 | return; | 1402 | return; |
1400 | } | 1403 | } |
1401 | if (! e->isAutoRepeat() ) | 1404 | if (! e->isAutoRepeat() ) |
1402 | mFlagKeyPressed = true; | 1405 | mFlagKeyPressed = true; |
1403 | KOPrefs *p = KOPrefs::instance(); | 1406 | KOPrefs *p = KOPrefs::instance(); |
1404 | bool showSelectedDates = false; | 1407 | bool showSelectedDates = false; |
1405 | int size; | 1408 | int size; |
1406 | int pro = 0; | 1409 | int pro = 0; |
1407 | //qDebug("MainWindow::keyPressEvent "); | 1410 | //qDebug("MainWindow::keyPressEvent "); |
1408 | switch ( e->key() ) { | 1411 | switch ( e->key() ) { |
1409 | case Qt::Key_Right: | 1412 | case Qt::Key_Right: |
1410 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1413 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1411 | mView->goNextMonth(); | 1414 | mView->goNextMonth(); |
1412 | else | 1415 | else |
1413 | mView->goNext(); | 1416 | mView->goNext(); |
1414 | showSelectedDates = true; | 1417 | showSelectedDates = true; |
1415 | break; | 1418 | break; |
1416 | case Qt::Key_Left: | 1419 | case Qt::Key_Left: |
1417 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1420 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1418 | mView->goPreviousMonth(); | 1421 | mView->goPreviousMonth(); |
1419 | else | 1422 | else |
1420 | mView->goPrevious(); | 1423 | mView->goPrevious(); |
1421 | showSelectedDates = true; | 1424 | showSelectedDates = true; |
1422 | break; | 1425 | break; |
1423 | case Qt::Key_Down: | 1426 | case Qt::Key_Down: |
1424 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1427 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1425 | break; | 1428 | break; |
1426 | case Qt::Key_Up: | 1429 | case Qt::Key_Up: |
1427 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1430 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1428 | break; | 1431 | break; |
1429 | case Qt::Key_I: | 1432 | case Qt::Key_I: |
1430 | mView->showIncidence(); | 1433 | mView->showIncidence(); |
1431 | break; | 1434 | break; |
1432 | case Qt::Key_Delete: | 1435 | case Qt::Key_Delete: |
1433 | case Qt::Key_Backspace: | 1436 | case Qt::Key_Backspace: |
1434 | mView->deleteIncidence(); | 1437 | mView->deleteIncidence(); |
1435 | break; | 1438 | break; |
1436 | case Qt::Key_D: | 1439 | case Qt::Key_D: |
1437 | mView->viewManager()->showDayView(); | 1440 | mView->viewManager()->showDayView(); |
1438 | showSelectedDates = true; | 1441 | showSelectedDates = true; |
1439 | break; | 1442 | break; |
1440 | case Qt::Key_O: | 1443 | case Qt::Key_O: |
1441 | mView->toggleFilerEnabled( ); | 1444 | mView->toggleFilerEnabled( ); |
1442 | break; | 1445 | break; |
1443 | case Qt::Key_0: | 1446 | case Qt::Key_0: |
1444 | case Qt::Key_1: | 1447 | case Qt::Key_1: |
1445 | case Qt::Key_2: | 1448 | case Qt::Key_2: |
1446 | case Qt::Key_3: | 1449 | case Qt::Key_3: |
1447 | case Qt::Key_4: | 1450 | case Qt::Key_4: |
1448 | case Qt::Key_5: | 1451 | case Qt::Key_5: |
1449 | case Qt::Key_6: | 1452 | case Qt::Key_6: |
1450 | case Qt::Key_7: | 1453 | case Qt::Key_7: |
1451 | case Qt::Key_8: | 1454 | case Qt::Key_8: |
1452 | case Qt::Key_9: | 1455 | case Qt::Key_9: |
1453 | pro = e->key()-48; | 1456 | pro = e->key()-48; |
1454 | if ( pro == 0 ) | 1457 | if ( pro == 0 ) |
1455 | pro = 10; | 1458 | pro = 10; |
1456 | if ( e->state() == Qt::ControlButton) | 1459 | if ( e->state() == Qt::ControlButton) |
1457 | pro += 10; | 1460 | pro += 10; |
1458 | break; | 1461 | break; |
1459 | case Qt::Key_M: | 1462 | case Qt::Key_M: |
1460 | mView->viewManager()->showMonthView(); | 1463 | mView->viewManager()->showMonthView(); |
1461 | showSelectedDates = true; | 1464 | showSelectedDates = true; |
1462 | break; | 1465 | break; |
1463 | case Qt::Key_Insert: | 1466 | case Qt::Key_Insert: |
1464 | mView->newEvent(); | 1467 | mView->newEvent(); |
1465 | break; | 1468 | break; |
1466 | case Qt::Key_S : | 1469 | case Qt::Key_S : |
1467 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1470 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1468 | mView->newSubTodo(); | 1471 | mView->newSubTodo(); |
1469 | else | 1472 | else |
1470 | mView->dialogManager()->showSearchDialog(); | 1473 | mView->dialogManager()->showSearchDialog(); |
1471 | break; | 1474 | break; |
1472 | case Qt::Key_Y : | 1475 | case Qt::Key_Y : |
1473 | case Qt::Key_Z : | 1476 | case Qt::Key_Z : |
1474 | mView->viewManager()->showWorkWeekView(); | 1477 | mView->viewManager()->showWorkWeekView(); |
1475 | showSelectedDates = true; | 1478 | showSelectedDates = true; |
1476 | break; | 1479 | break; |
1477 | case Qt::Key_U : | 1480 | case Qt::Key_U : |
1478 | mView->viewManager()->showWeekView(); | 1481 | mView->viewManager()->showWeekView(); |
1479 | showSelectedDates = true; | 1482 | showSelectedDates = true; |
1480 | break; | 1483 | break; |
1481 | case Qt::Key_H : | 1484 | case Qt::Key_H : |
1482 | keyBindings(); | 1485 | keyBindings(); |
1483 | break; | 1486 | break; |
1484 | case Qt::Key_W: | 1487 | case Qt::Key_W: |
1485 | mView->viewManager()->showWhatsNextView(); | 1488 | mView->viewManager()->showWhatsNextView(); |
1486 | break; | 1489 | break; |
1487 | case Qt::Key_L: | 1490 | case Qt::Key_L: |
1488 | mView->viewManager()->showListView(); | 1491 | mView->viewManager()->showListView(); |
1489 | break; | 1492 | break; |
1490 | case Qt::Key_N: | 1493 | case Qt::Key_N: |
1491 | mView->viewManager()->showNextXView(); | 1494 | mView->viewManager()->showNextXView(); |
1492 | showSelectedDates = true; | 1495 | showSelectedDates = true; |
1493 | break; | 1496 | break; |
1494 | case Qt::Key_V: | 1497 | case Qt::Key_V: |
1495 | mView->viewManager()->showTodoView(); | 1498 | mView->viewManager()->showTodoView(); |
1496 | break; | 1499 | break; |
1497 | case Qt::Key_C: | 1500 | case Qt::Key_C: |
1498 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1501 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1499 | break; | 1502 | break; |
1500 | case Qt::Key_P: | 1503 | case Qt::Key_P: |
1501 | mView->showDatePicker( ); | 1504 | mView->showDatePicker( ); |
1502 | break; | 1505 | break; |
1503 | case Qt::Key_F: | 1506 | case Qt::Key_F: |
1504 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1505 | mView->editFilters(); | 1508 | mView->editFilters(); |
1506 | else | 1509 | else |
1507 | mView->toggleFilter(); | 1510 | mView->toggleFilter(); |
1508 | break; | 1511 | break; |
1509 | case Qt::Key_X: | 1512 | case Qt::Key_X: |
1510 | mView->toggleDateNavigatorWidget(); | 1513 | mView->toggleDateNavigatorWidget(); |
1511 | break; | 1514 | break; |
1512 | case Qt::Key_Space: | 1515 | case Qt::Key_Space: |
1513 | mView->toggleExpand(); | 1516 | mView->toggleExpand(); |
1514 | break; | 1517 | break; |
1515 | case Qt::Key_A: | 1518 | case Qt::Key_A: |
1516 | mView->toggleAllDaySize(); | 1519 | mView->toggleAllDaySize(); |
1517 | break; | 1520 | break; |
1518 | case Qt::Key_T: | 1521 | case Qt::Key_T: |
1519 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1522 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1520 | mView->newTodo(); | 1523 | mView->newTodo(); |
1521 | else { | 1524 | else { |
1522 | mView->goToday(); | 1525 | mView->goToday(); |
1523 | showSelectedDates = true; | 1526 | showSelectedDates = true; |
1524 | } | 1527 | } |
1525 | break; | 1528 | break; |
1526 | case Qt::Key_J: | 1529 | case Qt::Key_J: |
1527 | mView->viewManager()->showJournalView(); | 1530 | mView->viewManager()->showJournalView(); |
1528 | break; | 1531 | break; |
1529 | case Qt::Key_B: | 1532 | case Qt::Key_B: |
1530 | mView->editIncidenceDescription();; | 1533 | mView->editIncidenceDescription();; |
1531 | break; | 1534 | break; |
1532 | // case Qt::Key_Return: | 1535 | // case Qt::Key_Return: |
1533 | case Qt::Key_E: | 1536 | case Qt::Key_E: |
1534 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1537 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1535 | mView->newEvent(); | 1538 | mView->newEvent(); |
1536 | else | 1539 | else |
1537 | mView->editIncidence(); | 1540 | mView->editIncidence(); |
1538 | break; | 1541 | break; |
1539 | case Qt::Key_Plus: | 1542 | case Qt::Key_Plus: |
1540 | size = p->mHourSize +2; | 1543 | size = p->mHourSize +2; |
1541 | if ( size <= 18 ) | 1544 | if ( size <= 18 ) |
1542 | configureAgenda( size ); | 1545 | configureAgenda( size ); |
1543 | break; | 1546 | break; |
1544 | case Qt::Key_Minus: | 1547 | case Qt::Key_Minus: |
1545 | size = p->mHourSize - 2; | 1548 | size = p->mHourSize - 2; |
1546 | if ( size >= 4 ) | 1549 | if ( size >= 4 ) |
1547 | configureAgenda( size ); | 1550 | configureAgenda( size ); |
1548 | break; | 1551 | break; |
1549 | 1552 | ||
1550 | 1553 | ||
1551 | default: | 1554 | default: |
1552 | e->ignore(); | 1555 | e->ignore(); |
1553 | } | 1556 | } |
1554 | if ( pro > 0 ) { | 1557 | if ( pro > 0 ) { |
1555 | mView->selectFilter( pro-1 ); | 1558 | mView->selectFilter( pro-1 ); |
1556 | } | 1559 | } |
1557 | if ( showSelectedDates ) { | 1560 | if ( showSelectedDates ) { |
1558 | ;// setCaptionToDates(); | 1561 | ;// setCaptionToDates(); |
1559 | } | 1562 | } |
1560 | 1563 | ||
1561 | } | 1564 | } |
1562 | 1565 | ||
1563 | void MainWindow::fillFilterMenu() | 1566 | void MainWindow::fillFilterMenu() |
1564 | { | 1567 | { |
1565 | selectFilterMenu->clear(); | 1568 | selectFilterMenu->clear(); |
1566 | bool disable = false; | 1569 | bool disable = false; |
1567 | if ( mView->filterView()->filtersEnabled() ) { | 1570 | if ( mView->filterView()->filtersEnabled() ) { |
1568 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1571 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1569 | } | 1572 | } |
1570 | else { | 1573 | else { |
1571 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1574 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1572 | disable = true; | 1575 | disable = true; |
1573 | } | 1576 | } |
1574 | selectFilterMenu->insertSeparator(); | 1577 | selectFilterMenu->insertSeparator(); |
1575 | QPtrList<CalFilter> fili = mView->filters(); | 1578 | QPtrList<CalFilter> fili = mView->filters(); |
1576 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1579 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1577 | CalFilter *filter = fili.first(); | 1580 | CalFilter *filter = fili.first(); |
1578 | int iii = 1; | 1581 | int iii = 1; |
1579 | while(filter) { | 1582 | while(filter) { |
1580 | selectFilterMenu->insertItem( filter->name(), iii ); | 1583 | selectFilterMenu->insertItem( filter->name(), iii ); |
1581 | if ( filter == curfilter) | 1584 | if ( filter == curfilter) |
1582 | selectFilterMenu->setItemChecked( iii, true ); | 1585 | selectFilterMenu->setItemChecked( iii, true ); |
1583 | if ( disable ) | 1586 | if ( disable ) |
1584 | selectFilterMenu->setItemEnabled( iii, false ); | 1587 | selectFilterMenu->setItemEnabled( iii, false ); |
1585 | filter = fili.next(); | 1588 | filter = fili.next(); |
1586 | ++iii; | 1589 | ++iii; |
1587 | } | 1590 | } |
1588 | } | 1591 | } |
1589 | void MainWindow::selectFilter( int fil ) | 1592 | void MainWindow::selectFilter( int fil ) |
1590 | { | 1593 | { |
1591 | if ( fil == 0 ) { | 1594 | if ( fil == 0 ) { |
1592 | mView->toggleFilerEnabled( ); | 1595 | mView->toggleFilerEnabled( ); |
1593 | } else { | 1596 | } else { |
1594 | mView->selectFilter( fil-1 ); | 1597 | mView->selectFilter( fil-1 ); |
1595 | } | 1598 | } |
1596 | } | 1599 | } |
1597 | void MainWindow::configureToolBar( int item ) | 1600 | void MainWindow::configureToolBar( int item ) |
1598 | { | 1601 | { |
1599 | 1602 | ||
1600 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1603 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1601 | KOPrefs *p = KOPrefs::instance(); | 1604 | KOPrefs *p = KOPrefs::instance(); |
1602 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1605 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1603 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1606 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1604 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1607 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1605 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1608 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1606 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1609 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1607 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1610 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1608 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1611 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1609 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1612 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1610 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1613 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1611 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1614 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1612 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1615 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1613 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1616 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1614 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1617 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1615 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1618 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1616 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1619 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1617 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1620 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1618 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1621 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1619 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1622 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1620 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1623 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1621 | // initActions(); | 1624 | // initActions(); |
1622 | } | 1625 | } |
1623 | 1626 | ||
1624 | void MainWindow::setCaptionToDates() | 1627 | void MainWindow::setCaptionToDates() |
1625 | { | 1628 | { |
1626 | QString selDates; | 1629 | QString selDates; |
1627 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1630 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1628 | if (mView->startDate() < mView->endDate() ) | 1631 | if (mView->startDate() < mView->endDate() ) |
1629 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1632 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1630 | setCaption( i18n("Dates: ") + selDates ); | 1633 | setCaption( i18n("Dates: ") + selDates ); |
1631 | 1634 | ||
1632 | } | 1635 | } |
1633 | // parameter item == 0: reinit | 1636 | // parameter item == 0: reinit |
1634 | void MainWindow::configureAgenda( int item ) | 1637 | void MainWindow::configureAgenda( int item ) |
1635 | { | 1638 | { |
1636 | 1639 | ||
1637 | KOPrefs *p = KOPrefs::instance(); | 1640 | KOPrefs *p = KOPrefs::instance(); |
1638 | 1641 | ||
1639 | int i; | 1642 | int i; |
1640 | if ( item == 1 ) { | 1643 | if ( item == 1 ) { |
1641 | mView->toggleAllDaySize(); | 1644 | mView->toggleAllDaySize(); |
1642 | return; | 1645 | return; |
1643 | } | 1646 | } |
1644 | // do not allow 4 for widgets higher than 480 | 1647 | // do not allow 4 for widgets higher than 480 |
1645 | // if ( QApplication::desktop()->height() > 480 ) { | 1648 | // if ( QApplication::desktop()->height() > 480 ) { |
1646 | // if ( item == 4 ) | 1649 | // if ( item == 4 ) |
1647 | // item = 6; | 1650 | // item = 6; |
1648 | // } | 1651 | // } |
1649 | for ( i = 4; i <= 18; i= i+2 ) | 1652 | for ( i = 4; i <= 18; i= i+2 ) |
1650 | configureAgendaMenu->setItemChecked( i, false ); | 1653 | configureAgendaMenu->setItemChecked( i, false ); |
1651 | configureAgendaMenu->setItemChecked( item, true ); | 1654 | configureAgendaMenu->setItemChecked( item, true ); |
1652 | if ( p->mHourSize == item ) | 1655 | if ( p->mHourSize == item ) |
1653 | return; | 1656 | return; |
1654 | p->mHourSize=item; | 1657 | p->mHourSize=item; |
1655 | mView->viewManager()->agendaView()->updateConfig(); | 1658 | mView->viewManager()->agendaView()->updateConfig(); |
1656 | } | 1659 | } |
1657 | 1660 | ||
1658 | void MainWindow::saveCalendar() | 1661 | void MainWindow::saveCalendar() |
1659 | { | 1662 | { |
1660 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1663 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1661 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1664 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1662 | 1665 | ||
1663 | if ( fn == "" ) | 1666 | if ( fn == "" ) |
1664 | return; | 1667 | return; |
1665 | QFileInfo info; | 1668 | QFileInfo info; |
1666 | info.setFile( fn ); | 1669 | info.setFile( fn ); |
1667 | QString mes; | 1670 | QString mes; |
1668 | bool createbup = true; | 1671 | bool createbup = true; |
1669 | if ( info. exists() ) { | 1672 | if ( info. exists() ) { |
1670 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1673 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1671 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1674 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1672 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1675 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1673 | 0, 1 ); | 1676 | 0, 1 ); |
1674 | if ( result != 0 ) { | 1677 | if ( result != 0 ) { |
1675 | createbup = false; | 1678 | createbup = false; |
1676 | } | 1679 | } |
1677 | } | 1680 | } |
1678 | if ( createbup ) { | 1681 | if ( createbup ) { |
1679 | mView->saveCalendar( fn ); | 1682 | mView->saveCalendar( fn ); |
1680 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1683 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1681 | KOPrefs::instance()->mLastSaveFile = fn; | 1684 | KOPrefs::instance()->mLastSaveFile = fn; |
1682 | setCaption(mes); | 1685 | setCaption(mes); |
1683 | } | 1686 | } |
1684 | } | 1687 | } |
1685 | void MainWindow::loadCalendar() | 1688 | void MainWindow::loadCalendar() |
1686 | { | 1689 | { |
1687 | 1690 | ||
1688 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1691 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1689 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1692 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1690 | 1693 | ||
1691 | if ( fn == "" ) | 1694 | if ( fn == "" ) |
1692 | return; | 1695 | return; |
1693 | QFileInfo info; | 1696 | QFileInfo info; |
1694 | info.setFile( fn ); | 1697 | info.setFile( fn ); |
1695 | QString mess; | 1698 | QString mess; |
1696 | bool loadbup = true; | 1699 | bool loadbup = true; |
1697 | if ( info. exists() ) { | 1700 | if ( info. exists() ) { |
1698 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1701 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1699 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1702 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1700 | mess, | 1703 | mess, |
1701 | i18n("Load!"), i18n("Cancel"), 0, | 1704 | i18n("Load!"), i18n("Cancel"), 0, |
1702 | 0, 1 ); | 1705 | 0, 1 ); |
1703 | if ( result != 0 ) { | 1706 | if ( result != 0 ) { |
1704 | loadbup = false; | 1707 | loadbup = false; |
1705 | } | 1708 | } |
1706 | } else { | 1709 | } else { |
1707 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1710 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1708 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1711 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1709 | 0, 1 ); | 1712 | 0, 1 ); |
1710 | 1713 | ||
1711 | return; | 1714 | return; |
1712 | } | 1715 | } |
1713 | if ( loadbup ) { | 1716 | if ( loadbup ) { |
1714 | mView->openCalendar( fn ); | 1717 | mView->openCalendar( fn ); |
1715 | KOPrefs::instance()->mLastLoadFile = fn; | 1718 | KOPrefs::instance()->mLastLoadFile = fn; |
1716 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1719 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1717 | setCaption(mess); | 1720 | setCaption(mess); |
1718 | } | 1721 | } |
1719 | 1722 | ||
1720 | } | 1723 | } |
1721 | void MainWindow::quickImportIcal() | 1724 | void MainWindow::quickImportIcal() |
1722 | { | 1725 | { |
1723 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1726 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1724 | } | 1727 | } |
1725 | void MainWindow::importFile( QString fn, bool quick ) | 1728 | void MainWindow::importFile( QString fn, bool quick ) |
1726 | { | 1729 | { |
1727 | QFileInfo info; | 1730 | QFileInfo info; |
1728 | info.setFile( fn ); | 1731 | info.setFile( fn ); |
1729 | QString mess; | 1732 | QString mess; |
1730 | bool loadbup = true; | 1733 | bool loadbup = true; |
1731 | if ( !info. exists() ) { | 1734 | if ( !info. exists() ) { |
1732 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1735 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1733 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1736 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1734 | mess ); | 1737 | mess ); |
1735 | return; | 1738 | return; |
1736 | } | 1739 | } |
1737 | int result = 0; | 1740 | int result = 0; |
1738 | if ( !quick ) { | 1741 | if ( !quick ) { |
1739 | 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 )); | 1742 | 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 )); |
1740 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1743 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1741 | mess, | 1744 | mess, |
1742 | "Import", "Cancel", 0, | 1745 | "Import", "Cancel", 0, |
1743 | 0, 1 ); | 1746 | 0, 1 ); |
1744 | } | 1747 | } |
1745 | if ( result == 0 ) { | 1748 | if ( result == 0 ) { |
1746 | if ( mView->openCalendar( fn, true )) { | 1749 | if ( mView->openCalendar( fn, true )) { |
1747 | KOPrefs::instance()->mLastImportFile = fn; | 1750 | KOPrefs::instance()->mLastImportFile = fn; |
1748 | setCaption(i18n("Imported file successfully")); | 1751 | setCaption(i18n("Imported file successfully")); |
1749 | } else { | 1752 | } else { |
1750 | setCaption(i18n("Error importing file")); | 1753 | setCaption(i18n("Error importing file")); |
1751 | } | 1754 | } |
1752 | } | 1755 | } |
1753 | } | 1756 | } |
1754 | 1757 | ||
1755 | void MainWindow::importIcal() | 1758 | void MainWindow::importIcal() |
1756 | { | 1759 | { |
1757 | 1760 | ||
1758 | QString fn =KOPrefs::instance()->mLastImportFile; | 1761 | QString fn =KOPrefs::instance()->mLastImportFile; |
1759 | 1762 | ||
1760 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1763 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1761 | if ( fn == "" ) | 1764 | if ( fn == "" ) |
1762 | return; | 1765 | return; |
1763 | importFile( fn, true ); | 1766 | importFile( fn, true ); |
1764 | 1767 | ||
1765 | } | 1768 | } |
1766 | 1769 | ||
1767 | void MainWindow::exportVCalendar() | 1770 | void MainWindow::exportVCalendar() |
1768 | { | 1771 | { |
1769 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1772 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1770 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1773 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1771 | if ( fn == "" ) | 1774 | if ( fn == "" ) |
1772 | return; | 1775 | return; |
1773 | QFileInfo info; | 1776 | QFileInfo info; |
1774 | info.setFile( fn ); | 1777 | info.setFile( fn ); |
1775 | QString mes; | 1778 | QString mes; |
1776 | bool createbup = true; | 1779 | bool createbup = true; |
1777 | if ( info. exists() ) { | 1780 | if ( info. exists() ) { |
1778 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1781 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1779 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1782 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1780 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1783 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1781 | 0, 1 ); | 1784 | 0, 1 ); |
1782 | if ( result != 0 ) { | 1785 | if ( result != 0 ) { |
1783 | createbup = false; | 1786 | createbup = false; |
1784 | } | 1787 | } |
1785 | } | 1788 | } |
1786 | if ( createbup ) { | 1789 | if ( createbup ) { |
1787 | if ( mView->exportVCalendar( fn ) ) { | 1790 | if ( mView->exportVCalendar( fn ) ) { |
1788 | KOPrefs::instance()->mLastVcalFile = fn; | 1791 | KOPrefs::instance()->mLastVcalFile = fn; |
1789 | if ( fn.length() > 20 ) | 1792 | if ( fn.length() > 20 ) |
1790 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1793 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1791 | else | 1794 | else |
1792 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1795 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1793 | setCaption(mes); | 1796 | setCaption(mes); |
1794 | } | 1797 | } |
1795 | } | 1798 | } |
1796 | 1799 | ||
1797 | } | 1800 | } |
1798 | 1801 | ||
1799 | void MainWindow::syncFileRequest() | 1802 | void MainWindow::syncFileRequest() |
1800 | { | 1803 | { |
1801 | save(); | 1804 | save(); |
1802 | } | 1805 | } |
1803 | void MainWindow::getFile( bool success ) | 1806 | void MainWindow::getFile( bool success ) |
1804 | { | 1807 | { |
1805 | if ( ! success ) { | 1808 | if ( ! success ) { |
1806 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1809 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1807 | return; | 1810 | return; |
1808 | } | 1811 | } |
1809 | mView->openCalendar( defaultFileName() ); | 1812 | mView->openCalendar( defaultFileName() ); |
1810 | setCaption( i18n("Pi-Sync successful!") ); | 1813 | setCaption( i18n("Pi-Sync successful!") ); |
1811 | } | 1814 | } |
1812 | 1815 | ||
1813 | void MainWindow::printSel( ) | 1816 | void MainWindow::printSel( ) |
1814 | { | 1817 | { |
1815 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1818 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1816 | } | 1819 | } |
1817 | 1820 | ||
1818 | void MainWindow::printCal() | 1821 | void MainWindow::printCal() |
1819 | { | 1822 | { |
1820 | mView->print();//mCp->showDialog(); | 1823 | mView->print();//mCp->showDialog(); |
1821 | } | 1824 | } |
1822 | 1825 | ||
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 2856f2d..6477d11 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -1,2191 +1,2192 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> |
3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> | 3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> |
4 | Copyright (C) 2000 Peter Putzer | 4 | Copyright (C) 2000 Peter Putzer |
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 version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
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 <qdragobject.h> | 21 | #include <qdragobject.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qheader.h> | 23 | #include <qheader.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qstyle.h> | 26 | #include <qstyle.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | 28 | ||
29 | #include <kglobalsettings.h> | 29 | #include <kglobalsettings.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | //US #include <kcursor.h> | 32 | //US #include <kcursor.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | //US #include <kipc.h> | 34 | //US #include <kipc.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #ifdef _WIN32_ | 36 | #ifdef _WIN32_ |
37 | #define Q_WS_QWS | 37 | #define Q_WS_QWS |
38 | #endif | 38 | #endif |
39 | #ifndef _WIN32_ | 39 | #ifndef _WIN32_ |
40 | #define private public | 40 | #define private public |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #undef private | 42 | #undef private |
43 | #endif | 43 | #endif |
44 | #include "klistview.h" | 44 | #include "klistview.h" |
45 | //US #include "klistviewlineedit.h" | 45 | //US #include "klistviewlineedit.h" |
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qpe/qpeapplication.h> | 47 | #include <qpe/qpeapplication.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | // /*US | 50 | // /*US |
51 | class KListView::Tooltip : public QToolTip | 51 | class KListView::Tooltip : public QToolTip |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); | 54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); |
55 | virtual ~Tooltip () {} | 55 | virtual ~Tooltip () {} |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | // */ | 58 | // */ |
59 | /** | 59 | /** |
60 | * Reimplemented from QToolTip for internal reasons. | 60 | * Reimplemented from QToolTip for internal reasons. |
61 | */ | 61 | */ |
62 | // /*US | 62 | // /*US |
63 | virtual void maybeTip (const QPoint&); | 63 | virtual void maybeTip (const QPoint&); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | KListView* mParent; | 66 | KListView* mParent; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) | 69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) |
70 | : QToolTip (parent, group), | 70 | : QToolTip (parent, group), |
71 | mParent (parent) | 71 | mParent (parent) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KListView::Tooltip::maybeTip (const QPoint&) | 75 | void KListView::Tooltip::maybeTip (const QPoint&) |
76 | { | 76 | { |
77 | // FIXME | 77 | // FIXME |
78 | } | 78 | } |
79 | // */ | 79 | // */ |
80 | 80 | ||
81 | class KListView::KListViewPrivate | 81 | class KListView::KListViewPrivate |
82 | { | 82 | { |
83 | public: | 83 | public: |
84 | KListViewPrivate (KListView* listview) | 84 | KListViewPrivate (KListView* listview) |
85 | : pCurrentItem (0L), | 85 | : pCurrentItem (0L), |
86 | autoSelectDelay(1), | 86 | autoSelectDelay(1), |
87 | //US dragDelay (KGlobalSettings::dndEventDelay()), | 87 | //US dragDelay (KGlobalSettings::dndEventDelay()), |
88 | 88 | ||
89 | dragDelay (10), | 89 | dragDelay (10), |
90 | //US editor (new KListViewLineEdit (listview)), | 90 | //US editor (new KListViewLineEdit (listview)), |
91 | cursorInExecuteArea(false), | 91 | cursorInExecuteArea(false), |
92 | bUseSingle(false), | 92 | bUseSingle(false), |
93 | bChangeCursorOverItem(false), | 93 | bChangeCursorOverItem(false), |
94 | itemsMovable (true), | 94 | itemsMovable (true), |
95 | selectedBySimpleMove(false), | 95 | selectedBySimpleMove(false), |
96 | selectedUsingMouse(false), | 96 | selectedUsingMouse(false), |
97 | showContextMenusOnPress(true), | 97 | showContextMenusOnPress(true), |
98 | itemsRenameable (false), | 98 | itemsRenameable (false), |
99 | validDrag (false), | 99 | validDrag (false), |
100 | dragEnabled (false), | 100 | dragEnabled (false), |
101 | autoOpen (true), | 101 | autoOpen (true), |
102 | dropVisualizer (true), | 102 | dropVisualizer (true), |
103 | dropHighlighter (false), | 103 | dropHighlighter (false), |
104 | createChildren (true), | 104 | createChildren (true), |
105 | pressedOnSelected (false), | 105 | pressedOnSelected (false), |
106 | wasShiftEvent (false), | 106 | wasShiftEvent (false), |
107 | fullWidth (false), | 107 | fullWidth (false), |
108 | sortAscending(true), | 108 | sortAscending(true), |
109 | tabRename(true), | 109 | tabRename(true), |
110 | sortColumn(0), | 110 | sortColumn(0), |
111 | selectionDirection(0), | 111 | selectionDirection(0), |
112 | tooltipColumn (0), | 112 | tooltipColumn (0), |
113 | selectionMode (Single), | 113 | selectionMode (Single), |
114 | //US contextMenuKey (KGlobalSettings::contextMenuKey()), | 114 | //US contextMenuKey (KGlobalSettings::contextMenuKey()), |
115 | //US showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), | 115 | //US showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), |
116 | mDropVisualizerWidth (4) | 116 | mDropVisualizerWidth (4) |
117 | { | 117 | { |
118 | renameable += 0; | 118 | renameable += 0; |
119 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); | 119 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); |
120 | } | 120 | } |
121 | 121 | ||
122 | ~KListViewPrivate () | 122 | ~KListViewPrivate () |
123 | { | 123 | { |
124 | //US delete editor; | 124 | //US delete editor; |
125 | } | 125 | } |
126 | 126 | ||
127 | QListViewItem* pCurrentItem; | 127 | QListViewItem* pCurrentItem; |
128 | 128 | ||
129 | QTimer autoSelect; | 129 | QTimer autoSelect; |
130 | int autoSelectDelay; | 130 | int autoSelectDelay; |
131 | 131 | ||
132 | QTimer dragExpand; | 132 | QTimer dragExpand; |
133 | QListViewItem* dragOverItem; | 133 | QListViewItem* dragOverItem; |
134 | QPoint dragOverPoint; | 134 | QPoint dragOverPoint; |
135 | 135 | ||
136 | QPoint startDragPos; | 136 | QPoint startDragPos; |
137 | int dragDelay; | 137 | int dragDelay; |
138 | 138 | ||
139 | //US KListViewLineEdit *editor; | 139 | //US KListViewLineEdit *editor; |
140 | QValueList<int> renameable; | 140 | QValueList<int> renameable; |
141 | 141 | ||
142 | bool cursorInExecuteArea:1; | 142 | bool cursorInExecuteArea:1; |
143 | bool bUseSingle:1; | 143 | bool bUseSingle:1; |
144 | bool bChangeCursorOverItem:1; | 144 | bool bChangeCursorOverItem:1; |
145 | bool itemsMovable:1; | 145 | bool itemsMovable:1; |
146 | bool selectedBySimpleMove : 1; | 146 | bool selectedBySimpleMove : 1; |
147 | bool selectedUsingMouse:1; | 147 | bool selectedUsingMouse:1; |
148 | bool itemsRenameable:1; | 148 | bool itemsRenameable:1; |
149 | bool validDrag:1; | 149 | bool validDrag:1; |
150 | bool dragEnabled:1; | 150 | bool dragEnabled:1; |
151 | bool autoOpen:1; | 151 | bool autoOpen:1; |
152 | bool dropVisualizer:1; | 152 | bool dropVisualizer:1; |
153 | bool dropHighlighter:1; | 153 | bool dropHighlighter:1; |
154 | bool createChildren:1; | 154 | bool createChildren:1; |
155 | bool pressedOnSelected:1; | 155 | bool pressedOnSelected:1; |
156 | bool wasShiftEvent:1; | 156 | bool wasShiftEvent:1; |
157 | bool fullWidth:1; | 157 | bool fullWidth:1; |
158 | bool sortAscending:1; | 158 | bool sortAscending:1; |
159 | bool tabRename:1; | 159 | bool tabRename:1; |
160 | 160 | ||
161 | int sortColumn; | 161 | int sortColumn; |
162 | 162 | ||
163 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX | 163 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX |
164 | int selectionDirection; | 164 | int selectionDirection; |
165 | int tooltipColumn; | 165 | int tooltipColumn; |
166 | 166 | ||
167 | SelectionModeExt selectionMode; | 167 | SelectionModeExt selectionMode; |
168 | int contextMenuKey; | 168 | int contextMenuKey; |
169 | bool showContextMenusOnPress; | 169 | bool showContextMenusOnPress; |
170 | 170 | ||
171 | QRect mOldDropVisualizer; | 171 | QRect mOldDropVisualizer; |
172 | int mDropVisualizerWidth; | 172 | int mDropVisualizerWidth; |
173 | QRect mOldDropHighlighter; | 173 | QRect mOldDropHighlighter; |
174 | QListViewItem *afterItemDrop; | 174 | QListViewItem *afterItemDrop; |
175 | QListViewItem *parentItemDrop; | 175 | QListViewItem *parentItemDrop; |
176 | 176 | ||
177 | QColor alternateBackground; | 177 | QColor alternateBackground; |
178 | }; | 178 | }; |
179 | 179 | ||
180 | /*US | 180 | /*US |
181 | KListViewLineEdit::KListViewLineEdit(KListView *parent) | 181 | KListViewLineEdit::KListViewLineEdit(KListView *parent) |
182 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) | 182 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) |
183 | { | 183 | { |
184 | setFrame( false ); | 184 | setFrame( false ); |
185 | hide(); | 185 | hide(); |
186 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); | 186 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); |
187 | } | 187 | } |
188 | 188 | ||
189 | KListViewLineEdit::~KListViewLineEdit() | 189 | KListViewLineEdit::~KListViewLineEdit() |
190 | { | 190 | { |
191 | } | 191 | } |
192 | 192 | ||
193 | void KListViewLineEdit::load(QListViewItem *i, int c) | 193 | void KListViewLineEdit::load(QListViewItem *i, int c) |
194 | { | 194 | { |
195 | item=i; | 195 | item=i; |
196 | col=c; | 196 | col=c; |
197 | 197 | ||
198 | QRect rect(p->itemRect(i)); | 198 | QRect rect(p->itemRect(i)); |
199 | setText(item->text(c)); | 199 | setText(item->text(c)); |
200 | 200 | ||
201 | int fieldX = rect.x() - 1; | 201 | int fieldX = rect.x() - 1; |
202 | int fieldW = p->columnWidth(col) + 2; | 202 | int fieldW = p->columnWidth(col) + 2; |
203 | 203 | ||
204 | int pos = p->header()->mapToIndex(col); | 204 | int pos = p->header()->mapToIndex(col); |
205 | for ( int index = 0; index < pos; index++ ) | 205 | for ( int index = 0; index < pos; index++ ) |
206 | fieldX += p->columnWidth( p->header()->mapToSection( index )); | 206 | fieldX += p->columnWidth( p->header()->mapToSection( index )); |
207 | 207 | ||
208 | if ( col == 0 ) { | 208 | if ( col == 0 ) { |
209 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); | 209 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); |
210 | d *= p->treeStepSize(); | 210 | d *= p->treeStepSize(); |
211 | fieldX += d; | 211 | fieldX += d; |
212 | fieldW -= d; | 212 | fieldW -= d; |
213 | } | 213 | } |
214 | 214 | ||
215 | if ( i->pixmap( col ) ) {// add width of pixmap | 215 | if ( i->pixmap( col ) ) {// add width of pixmap |
216 | int d = i->pixmap( col )->width(); | 216 | int d = i->pixmap( col )->width(); |
217 | fieldX += d; | 217 | fieldX += d; |
218 | fieldW -= d; | 218 | fieldW -= d; |
219 | } | 219 | } |
220 | 220 | ||
221 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); | 221 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); |
222 | show(); | 222 | show(); |
223 | setFocus(); | 223 | setFocus(); |
224 | } | 224 | } |
225 | */ | 225 | */ |
226 | /*Helper functions to for | 226 | /*Helper functions to for |
227 | *tabOrderedRename functionality. | 227 | *tabOrderedRename functionality. |
228 | */ | 228 | */ |
229 | 229 | ||
230 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 230 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) |
231 | { | 231 | { |
232 | if (pi) | 232 | if (pi) |
233 | { | 233 | { |
234 | //Find the next renameable column in the current row | 234 | //Find the next renameable column in the current row |
235 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) | 235 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) |
236 | if (pl->isRenameable(start)) | 236 | if (pl->isRenameable(start)) |
237 | return start; | 237 | return start; |
238 | } | 238 | } |
239 | 239 | ||
240 | return -1; | 240 | return -1; |
241 | } | 241 | } |
242 | 242 | ||
243 | static QListViewItem *prevItem (QListViewItem *pi) | 243 | static QListViewItem *prevItem (QListViewItem *pi) |
244 | { | 244 | { |
245 | QListViewItem *pa = pi->itemAbove(); | 245 | QListViewItem *pa = pi->itemAbove(); |
246 | 246 | ||
247 | /*Does what the QListViewItem::previousSibling() | 247 | /*Does what the QListViewItem::previousSibling() |
248 | *of my dreams would do. | 248 | *of my dreams would do. |
249 | */ | 249 | */ |
250 | if (pa && pa->parent() == pi->parent()) | 250 | if (pa && pa->parent() == pi->parent()) |
251 | return pa; | 251 | return pa; |
252 | 252 | ||
253 | return NULL; | 253 | return NULL; |
254 | } | 254 | } |
255 | 255 | ||
256 | static QListViewItem *lastQChild (QListViewItem *pi) | 256 | static QListViewItem *lastQChild (QListViewItem *pi) |
257 | { | 257 | { |
258 | if (pi) | 258 | if (pi) |
259 | { | 259 | { |
260 | /*Since there's no QListViewItem::lastChild(). | 260 | /*Since there's no QListViewItem::lastChild(). |
261 | *This finds the last sibling for the given | 261 | *This finds the last sibling for the given |
262 | *item. | 262 | *item. |
263 | */ | 263 | */ |
264 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) | 264 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) |
265 | pi = pt; | 265 | pi = pt; |
266 | } | 266 | } |
267 | 267 | ||
268 | return pi; | 268 | return pi; |
269 | } | 269 | } |
270 | /*US | 270 | /*US |
271 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 271 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) |
272 | { | 272 | { |
273 | const int ncols = p->columns(); | 273 | const int ncols = p->columns(); |
274 | const int dir = forward ? +1 : -1; | 274 | const int dir = forward ? +1 : -1; |
275 | const int restart = forward ? 0 : (ncols - 1); | 275 | const int restart = forward ? 0 : (ncols - 1); |
276 | QListViewItem *top = (pitem && pitem->parent()) | 276 | QListViewItem *top = (pitem && pitem->parent()) |
277 | ? pitem->parent()->firstChild() | 277 | ? pitem->parent()->firstChild() |
278 | : p->firstChild(); | 278 | : p->firstChild(); |
279 | QListViewItem *pi = pitem; | 279 | QListViewItem *pi = pitem; |
280 | 280 | ||
281 | terminate(); //Save current changes | 281 | terminate(); //Save current changes |
282 | 282 | ||
283 | do | 283 | do |
284 | { | 284 | { |
285 | */ | 285 | */ |
286 | /*Check the rest of the current row for an editable column, | 286 | /*Check the rest of the current row for an editable column, |
287 | *if that fails, check the entire next/previous row. The | 287 | *if that fails, check the entire next/previous row. The |
288 | *last case goes back to the first item in the current branch | 288 | *last case goes back to the first item in the current branch |
289 | *or the last item in the current branch depending on the | 289 | *or the last item in the current branch depending on the |
290 | *direction. | 290 | *direction. |
291 | */ | 291 | */ |
292 | /*US | 292 | /*US |
293 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || | 293 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || |
294 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || | 294 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || |
295 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) | 295 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) |
296 | { | 296 | { |
297 | if (pi) | 297 | if (pi) |
298 | { | 298 | { |
299 | p->setCurrentItem(pi); //Calls terminate | 299 | p->setCurrentItem(pi); //Calls terminate |
300 | p->rename(pi, column); | 300 | p->rename(pi, column); |
301 | */ | 301 | */ |
302 | /*Some listviews may override rename() to | 302 | /*Some listviews may override rename() to |
303 | *prevent certain items from being renamed, | 303 | *prevent certain items from being renamed, |
304 | *if this is done, [m_]item will be NULL | 304 | *if this is done, [m_]item will be NULL |
305 | *after the rename() call... try again. | 305 | *after the rename() call... try again. |
306 | */ | 306 | */ |
307 | /*US | 307 | /*US |
308 | if (!item) | 308 | if (!item) |
309 | continue; | 309 | continue; |
310 | 310 | ||
311 | break; | 311 | break; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | while (pi && !item); | 315 | while (pi && !item); |
316 | } | 316 | } |
317 | */ | 317 | */ |
318 | 318 | ||
319 | /*US | 319 | /*US |
320 | #ifdef KeyPress | 320 | #ifdef KeyPress |
321 | #undef KeyPress | 321 | #undef KeyPress |
322 | #endif | 322 | #endif |
323 | 323 | ||
324 | bool KListViewLineEdit::event (QEvent *pe) | 324 | bool KListViewLineEdit::event (QEvent *pe) |
325 | { | 325 | { |
326 | if (pe->type() == QEvent::KeyPress) | 326 | if (pe->type() == QEvent::KeyPress) |
327 | { | 327 | { |
328 | QKeyEvent *k = (QKeyEvent *) pe; | 328 | QKeyEvent *k = (QKeyEvent *) pe; |
329 | 329 | ||
330 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && | 330 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && |
331 | p->tabOrderedRenaming() && p->itemsRenameable() && | 331 | p->tabOrderedRenaming() && p->itemsRenameable() && |
332 | !(k->state() & ControlButton || k->state() & AltButton)) | 332 | !(k->state() & ControlButton || k->state() & AltButton)) |
333 | { | 333 | { |
334 | selectNextCell(item, col, | 334 | selectNextCell(item, col, |
335 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); | 335 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); |
336 | return true; | 336 | return true; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | return KLineEdit::event(pe); | 340 | return KLineEdit::event(pe); |
341 | } | 341 | } |
342 | 342 | ||
343 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 343 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) |
344 | { | 344 | { |
345 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) | 345 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) |
346 | terminate(true); | 346 | terminate(true); |
347 | else if(e->key() == Qt::Key_Escape) | 347 | else if(e->key() == Qt::Key_Escape) |
348 | terminate(false); | 348 | terminate(false); |
349 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) | 349 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) |
350 | { | 350 | { |
351 | terminate(true); | 351 | terminate(true); |
352 | KLineEdit::keyPressEvent(e); | 352 | KLineEdit::keyPressEvent(e); |
353 | } | 353 | } |
354 | else | 354 | else |
355 | KLineEdit::keyPressEvent(e); | 355 | KLineEdit::keyPressEvent(e); |
356 | } | 356 | } |
357 | 357 | ||
358 | void KListViewLineEdit::terminate() | 358 | void KListViewLineEdit::terminate() |
359 | { | 359 | { |
360 | terminate(true); | 360 | terminate(true); |
361 | } | 361 | } |
362 | 362 | ||
363 | void KListViewLineEdit::terminate(bool commit) | 363 | void KListViewLineEdit::terminate(bool commit) |
364 | { | 364 | { |
365 | if ( item ) | 365 | if ( item ) |
366 | { | 366 | { |
367 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 367 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
368 | if (commit) | 368 | if (commit) |
369 | item->setText(col, text()); | 369 | item->setText(col, text()); |
370 | int c=col; | 370 | int c=col; |
371 | QListViewItem *i=item; | 371 | QListViewItem *i=item; |
372 | col=0; | 372 | col=0; |
373 | item=0; | 373 | item=0; |
374 | hide(); // will call focusOutEvent, that's why we set item=0 before | 374 | hide(); // will call focusOutEvent, that's why we set item=0 before |
375 | emit done(i,c); | 375 | emit done(i,c); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 379 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
380 | { | 380 | { |
381 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 381 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
382 | // Don't let a RMB close the editor | 382 | // Don't let a RMB close the editor |
383 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 383 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
384 | terminate(true); | 384 | terminate(true); |
385 | } | 385 | } |
386 | 386 | ||
387 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 387 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
388 | { | 388 | { |
389 | KLineEdit::paintEvent( e ); | 389 | KLineEdit::paintEvent( e ); |
390 | 390 | ||
391 | if ( !frame() ) { | 391 | if ( !frame() ) { |
392 | QPainter p( this ); | 392 | QPainter p( this ); |
393 | p.setClipRegion( e->region() ); | 393 | p.setClipRegion( e->region() ); |
394 | p.drawRect( rect() ); | 394 | p.drawRect( rect() ); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // selection changed -> terminate. As our "item" can be already deleted, | 398 | // selection changed -> terminate. As our "item" can be already deleted, |
399 | // we can't call terminate(false), because that would emit done() with | 399 | // we can't call terminate(false), because that would emit done() with |
400 | // a dangling pointer to "item". | 400 | // a dangling pointer to "item". |
401 | void KListViewLineEdit::slotSelectionChanged() | 401 | void KListViewLineEdit::slotSelectionChanged() |
402 | { | 402 | { |
403 | item = 0; | 403 | item = 0; |
404 | col = 0; | 404 | col = 0; |
405 | hide(); | 405 | hide(); |
406 | } | 406 | } |
407 | */ | 407 | */ |
408 | 408 | ||
409 | KListView::KListView( QWidget *parent, const char *name ) | 409 | KListView::KListView( QWidget *parent, const char *name ) |
410 | : QListView( parent, name ), | 410 | : QListView( parent, name ), |
411 | d (new KListViewPrivate (this)) | 411 | d (new KListViewPrivate (this)) |
412 | { | 412 | { |
413 | #ifndef DESKTOP_VERSION | 413 | #ifndef DESKTOP_VERSION |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 415 | #endif |
416 | //US setDragAutoScroll(true); | 416 | //US setDragAutoScroll(true); |
417 | 417 | ||
418 | connect( this, SIGNAL( onViewport() ), | 418 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 419 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 422 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 423 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 424 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 425 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 426 | this, SLOT(cleanItemHighlighter())); |
427 | 427 | ||
428 | /*US | 428 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 430 | ||
431 | if (kapp) | 431 | if (kapp) |
432 | { | 432 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 435 | } |
436 | */ | 436 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 437 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 438 | ||
439 | 439 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 440 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 441 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 442 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 443 | this, SLOT( slotDragExpand() ) ); |
444 | 444 | ||
445 | // context menu handling | 445 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 446 | if (d->showContextMenusOnPress) |
447 | { | 447 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 455 | } |
456 | 456 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 459 | ||
460 | 460 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 461 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 462 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | d->alternateBackground = QColor(240, 240, 240); | 463 | d->alternateBackground = QColor(240, 240, 240); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | 467 | ||
468 | KListView::~KListView() | 468 | KListView::~KListView() |
469 | { | 469 | { |
470 | delete d; | 470 | delete d; |
471 | } | 471 | } |
472 | 472 | ||
473 | bool KListView::isExecuteArea( const QPoint& point ) | 473 | bool KListView::isExecuteArea( const QPoint& point ) |
474 | { | 474 | { |
475 | if ( itemAt( point ) ) | 475 | if ( itemAt( point ) ) |
476 | return isExecuteArea( point.x() ); | 476 | return isExecuteArea( point.x() ); |
477 | 477 | ||
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | 480 | ||
481 | bool KListView::isExecuteArea( int x ) | 481 | bool KListView::isExecuteArea( int x ) |
482 | { | 482 | { |
483 | if( allColumnsShowFocus() ) | 483 | if( allColumnsShowFocus() ) |
484 | return true; | 484 | return true; |
485 | else { | 485 | else { |
486 | int offset = 0; | 486 | int offset = 0; |
487 | int width = columnWidth( 0 ); | 487 | int width = columnWidth( 0 ); |
488 | int pos = header()->mapToIndex( 0 ); | 488 | int pos = header()->mapToIndex( 0 ); |
489 | 489 | ||
490 | for ( int index = 0; index < pos; index++ ) | 490 | for ( int index = 0; index < pos; index++ ) |
491 | offset += columnWidth( header()->mapToSection( index ) ); | 491 | offset += columnWidth( header()->mapToSection( index ) ); |
492 | 492 | ||
493 | x += contentsX(); // in case of a horizontal scrollbar | 493 | x += contentsX(); // in case of a horizontal scrollbar |
494 | return ( x > offset && x < ( offset + width ) ); | 494 | return ( x > offset && x < ( offset + width ) ); |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | void KListView::slotOnItem( QListViewItem *item ) | 498 | void KListView::slotOnItem( QListViewItem *item ) |
499 | { | 499 | { |
500 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 500 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
501 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 501 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
502 | d->autoSelect.start( d->autoSelectDelay, true ); | 502 | d->autoSelect.start( d->autoSelectDelay, true ); |
503 | d->pCurrentItem = item; | 503 | d->pCurrentItem = item; |
504 | } | 504 | } |
505 | } | 505 | } |
506 | 506 | ||
507 | void KListView::slotOnViewport() | 507 | void KListView::slotOnViewport() |
508 | { | 508 | { |
509 | if ( d->bChangeCursorOverItem ) | 509 | if ( d->bChangeCursorOverItem ) |
510 | viewport()->unsetCursor(); | 510 | viewport()->unsetCursor(); |
511 | 511 | ||
512 | d->autoSelect.stop(); | 512 | d->autoSelect.stop(); |
513 | d->pCurrentItem = 0L; | 513 | d->pCurrentItem = 0L; |
514 | } | 514 | } |
515 | 515 | ||
516 | void KListView::slotSettingsChanged(int category) | 516 | void KListView::slotSettingsChanged(int category) |
517 | { | 517 | { |
518 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 518 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
519 | /*US | 519 | /*US |
520 | 520 | ||
521 | switch (category) | 521 | switch (category) |
522 | { | 522 | { |
523 | case KApplication::SETTINGS_MOUSE: | 523 | case KApplication::SETTINGS_MOUSE: |
524 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 524 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
525 | d->bUseSingle = KGlobalSettings::singleClick(); | 525 | d->bUseSingle = KGlobalSettings::singleClick(); |
526 | 526 | ||
527 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 527 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
528 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 528 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
529 | 529 | ||
530 | if( d->bUseSingle ) | 530 | if( d->bUseSingle ) |
531 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 531 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
532 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 532 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
533 | 533 | ||
534 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 534 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
535 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 535 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
536 | 536 | ||
537 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 537 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
538 | viewport()->unsetCursor(); | 538 | viewport()->unsetCursor(); |
539 | 539 | ||
540 | break; | 540 | break; |
541 | 541 | ||
542 | case KApplication::SETTINGS_POPUPMENU: | 542 | case KApplication::SETTINGS_POPUPMENU: |
543 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 543 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
544 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 544 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
545 | 545 | ||
546 | if (d->showContextMenusOnPress) | 546 | if (d->showContextMenusOnPress) |
547 | { | 547 | { |
548 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 548 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
549 | 549 | ||
550 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 550 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
551 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 551 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
552 | } | 552 | } |
553 | else | 553 | else |
554 | { | 554 | { |
555 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 555 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
556 | 556 | ||
557 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 557 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
558 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 558 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
559 | } | 559 | } |
560 | break; | 560 | break; |
561 | 561 | ||
562 | default: | 562 | default: |
563 | break; | 563 | break; |
564 | } | 564 | } |
565 | */ | 565 | */ |
566 | 566 | ||
567 | if( d->bUseSingle ) | 567 | if( d->bUseSingle ) |
568 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 568 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
569 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 569 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
570 | 570 | ||
571 | } | 571 | } |
572 | 572 | ||
573 | void KListView::slotAutoSelect() | 573 | void KListView::slotAutoSelect() |
574 | { | 574 | { |
575 | // check that the item still exists | 575 | // check that the item still exists |
576 | if( itemIndex( d->pCurrentItem ) == -1 ) | 576 | if( itemIndex( d->pCurrentItem ) == -1 ) |
577 | return; | 577 | return; |
578 | 578 | ||
579 | if (!isActiveWindow()) | 579 | if (!isActiveWindow()) |
580 | { | 580 | { |
581 | d->autoSelect.stop(); | 581 | d->autoSelect.stop(); |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | 584 | ||
585 | //Give this widget the keyboard focus. | 585 | //Give this widget the keyboard focus. |
586 | if( !hasFocus() ) | 586 | if( !hasFocus() ) |
587 | setFocus(); | 587 | setFocus(); |
588 | 588 | ||
589 | QListViewItem* previousItem = currentItem(); | 589 | QListViewItem* previousItem = currentItem(); |
590 | setCurrentItem( d->pCurrentItem ); | 590 | setCurrentItem( d->pCurrentItem ); |
591 | 591 | ||
592 | #if 0 | 592 | #if 0 |
593 | #ifndef Q_WS_QWS | 593 | #ifndef Q_WS_QWS |
594 | // FIXME(E): Implement for Qt Embedded | 594 | // FIXME(E): Implement for Qt Embedded |
595 | if( d->pCurrentItem ) { | 595 | if( d->pCurrentItem ) { |
596 | //Shift pressed? | 596 | //Shift pressed? |
597 | if( (keybstate & ShiftMask) ) { | 597 | if( (keybstate & ShiftMask) ) { |
598 | bool block = signalsBlocked(); | 598 | bool block = signalsBlocked(); |
599 | blockSignals( true ); | 599 | blockSignals( true ); |
600 | 600 | ||
601 | //No Ctrl? Then clear before! | 601 | //No Ctrl? Then clear before! |
602 | if( !(keybstate & ControlMask) ) | 602 | if( !(keybstate & ControlMask) ) |
603 | clearSelection(); | 603 | clearSelection(); |
604 | 604 | ||
605 | bool select = !d->pCurrentItem->isSelected(); | 605 | bool select = !d->pCurrentItem->isSelected(); |
606 | bool update = viewport()->isUpdatesEnabled(); | 606 | bool update = viewport()->isUpdatesEnabled(); |
607 | viewport()->setUpdatesEnabled( false ); | 607 | viewport()->setUpdatesEnabled( false ); |
608 | 608 | ||
609 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 609 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
610 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 610 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
611 | for ( ; lit.current(); ++lit ) { | 611 | for ( ; lit.current(); ++lit ) { |
612 | if ( down && lit.current() == d->pCurrentItem ) { | 612 | if ( down && lit.current() == d->pCurrentItem ) { |
613 | d->pCurrentItem->setSelected( select ); | 613 | d->pCurrentItem->setSelected( select ); |
614 | break; | 614 | break; |
615 | } | 615 | } |
616 | if ( !down && lit.current() == previousItem ) { | 616 | if ( !down && lit.current() == previousItem ) { |
617 | previousItem->setSelected( select ); | 617 | previousItem->setSelected( select ); |
618 | break; | 618 | break; |
619 | } | 619 | } |
620 | lit.current()->setSelected( select ); | 620 | lit.current()->setSelected( select ); |
621 | } | 621 | } |
622 | 622 | ||
623 | blockSignals( block ); | 623 | blockSignals( block ); |
624 | viewport()->setUpdatesEnabled( update ); | 624 | viewport()->setUpdatesEnabled( update ); |
625 | triggerUpdate(); | 625 | triggerUpdate(); |
626 | 626 | ||
627 | emit selectionChanged(); | 627 | emit selectionChanged(); |
628 | 628 | ||
629 | if( selectionMode() == QListView::Single ) | 629 | if( selectionMode() == QListView::Single ) |
630 | emit selectionChanged( d->pCurrentItem ); | 630 | emit selectionChanged( d->pCurrentItem ); |
631 | } | 631 | } |
632 | else if( (keybstate & ControlMask) ) | 632 | else if( (keybstate & ControlMask) ) |
633 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 633 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
634 | else { | 634 | else { |
635 | bool block = signalsBlocked(); | 635 | bool block = signalsBlocked(); |
636 | blockSignals( true ); | 636 | blockSignals( true ); |
637 | 637 | ||
638 | if( !d->pCurrentItem->isSelected() ) | 638 | if( !d->pCurrentItem->isSelected() ) |
639 | clearSelection(); | 639 | clearSelection(); |
640 | 640 | ||
641 | blockSignals( block ); | 641 | blockSignals( block ); |
642 | 642 | ||
643 | setSelected( d->pCurrentItem, true ); | 643 | setSelected( d->pCurrentItem, true ); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | else | 646 | else |
647 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 647 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
648 | #endif | 648 | #endif |
649 | #endif | 649 | #endif |
650 | } | 650 | } |
651 | 651 | ||
652 | void KListView::slotHeaderChanged() | 652 | void KListView::slotHeaderChanged() |
653 | { | 653 | { |
654 | if (d->fullWidth && columns()) | 654 | if (d->fullWidth && columns()) |
655 | { | 655 | { |
656 | int w = 0; | 656 | int w = 0; |
657 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 657 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
658 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 658 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) | 662 | void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) |
663 | { | 663 | { |
664 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 664 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
665 | 665 | ||
666 | // Double click mode ? | 666 | // Double click mode ? |
667 | if ( !d->bUseSingle ) | 667 | if ( !d->bUseSingle ) |
668 | { | 668 | { |
669 | emit executed( item ); | 669 | emit executed( item ); |
670 | emit executed( item, pos, c ); | 670 | emit executed( item, pos, c ); |
671 | } | 671 | } |
672 | else | 672 | else |
673 | { | 673 | { |
674 | #if 0 | 674 | #if 0 |
675 | #ifndef Q_WS_QWS | 675 | #ifndef Q_WS_QWS |
676 | // FIXME(E): Implement for Qt Embedded | 676 | // FIXME(E): Implement for Qt Embedded |
677 | Window root; | 677 | Window root; |
678 | Window child; | 678 | Window child; |
679 | int root_x, root_y, win_x, win_y; | 679 | int root_x, root_y, win_x, win_y; |
680 | uint keybstate; | 680 | uint keybstate; |
681 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, | 681 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, |
682 | &root_x, &root_y, &win_x, &win_y, &keybstate ); | 682 | &root_x, &root_y, &win_x, &win_y, &keybstate ); |
683 | 683 | ||
684 | d->autoSelect.stop(); | 684 | d->autoSelect.stop(); |
685 | 685 | ||
686 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 686 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
687 | if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 687 | if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { |
688 | emit executed( item ); | 688 | emit executed( item ); |
689 | emit executed( item, pos, c ); | 689 | emit executed( item, pos, c ); |
690 | } | 690 | } |
691 | #endif | 691 | #endif |
692 | #endif | 692 | #endif |
693 | } | 693 | } |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | void KListView::focusInEvent( QFocusEvent *fe ) | 697 | void KListView::focusInEvent( QFocusEvent *fe ) |
698 | { | 698 | { |
699 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 699 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
700 | QListView::focusInEvent( fe ); | 700 | QListView::focusInEvent( fe ); |
701 | if ((d->selectedBySimpleMove) | 701 | if ((d->selectedBySimpleMove) |
702 | && (d->selectionMode == FileManager) | 702 | && (d->selectionMode == FileManager) |
703 | && (fe->reason()!=QFocusEvent::Popup) | 703 | && (fe->reason()!=QFocusEvent::Popup) |
704 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 704 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
705 | && (currentItem()!=0)) | 705 | && (currentItem()!=0)) |
706 | { | 706 | { |
707 | currentItem()->setSelected(true); | 707 | currentItem()->setSelected(true); |
708 | currentItem()->repaint(); | 708 | currentItem()->repaint(); |
709 | emit selectionChanged(); | 709 | emit selectionChanged(); |
710 | }; | 710 | }; |
711 | } | 711 | } |
712 | 712 | ||
713 | void KListView::focusOutEvent( QFocusEvent *fe ) | 713 | void KListView::focusOutEvent( QFocusEvent *fe ) |
714 | { | 714 | { |
715 | cleanDropVisualizer(); | 715 | cleanDropVisualizer(); |
716 | cleanItemHighlighter(); | 716 | cleanItemHighlighter(); |
717 | 717 | ||
718 | d->autoSelect.stop(); | 718 | d->autoSelect.stop(); |
719 | 719 | ||
720 | if ((d->selectedBySimpleMove) | 720 | if ((d->selectedBySimpleMove) |
721 | && (d->selectionMode == FileManager) | 721 | && (d->selectionMode == FileManager) |
722 | && (fe->reason()!=QFocusEvent::Popup) | 722 | && (fe->reason()!=QFocusEvent::Popup) |
723 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 723 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
724 | && (currentItem()!=0) | 724 | && (currentItem()!=0) |
725 | /*US && (!d->editor->isVisible()) */ | 725 | /*US && (!d->editor->isVisible()) */ |
726 | ) | 726 | ) |
727 | { | 727 | { |
728 | currentItem()->setSelected(false); | 728 | currentItem()->setSelected(false); |
729 | currentItem()->repaint(); | 729 | currentItem()->repaint(); |
730 | emit selectionChanged(); | 730 | emit selectionChanged(); |
731 | }; | 731 | }; |
732 | 732 | ||
733 | QListView::focusOutEvent( fe ); | 733 | QListView::focusOutEvent( fe ); |
734 | } | 734 | } |
735 | 735 | ||
736 | void KListView::leaveEvent( QEvent *e ) | 736 | void KListView::leaveEvent( QEvent *e ) |
737 | { | 737 | { |
738 | d->autoSelect.stop(); | 738 | d->autoSelect.stop(); |
739 | 739 | ||
740 | QListView::leaveEvent( e ); | 740 | QListView::leaveEvent( e ); |
741 | } | 741 | } |
742 | 742 | ||
743 | bool KListView::event( QEvent *e ) | 743 | bool KListView::event( QEvent *e ) |
744 | { | 744 | { |
745 | if (e->type() == QEvent::ApplicationPaletteChange) { | 745 | if (e->type() == QEvent::ApplicationPaletteChange) { |
746 | qDebug("KListView::event make alternate color configurable"); | 746 | qDebug("KListView::event make alternate color configurable"); |
747 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); | 747 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); |
748 | d->alternateBackground = QColor(240, 240, 240); | 748 | d->alternateBackground = QColor(240, 240, 240); |
749 | } | 749 | } |
750 | 750 | ||
751 | return QListView::event(e); | 751 | return QListView::event(e); |
752 | } | 752 | } |
753 | 753 | ||
754 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 754 | void KListView::contentsMousePressEvent( QMouseEvent *e ) |
755 | { | 755 | { |
756 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) | 756 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) |
757 | { | 757 | { |
758 | bool block = signalsBlocked(); | 758 | bool block = signalsBlocked(); |
759 | blockSignals( true ); | 759 | blockSignals( true ); |
760 | 760 | ||
761 | clearSelection(); | 761 | clearSelection(); |
762 | 762 | ||
763 | blockSignals( block ); | 763 | blockSignals( block ); |
764 | } | 764 | } |
765 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) | 765 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) |
766 | { | 766 | { |
767 | d->selectedBySimpleMove=false; | 767 | d->selectedBySimpleMove=false; |
768 | d->selectedUsingMouse=true; | 768 | d->selectedUsingMouse=true; |
769 | if (currentItem()!=0) | 769 | if (currentItem()!=0) |
770 | { | 770 | { |
771 | currentItem()->setSelected(false); | 771 | currentItem()->setSelected(false); |
772 | currentItem()->repaint(); | 772 | currentItem()->repaint(); |
773 | // emit selectionChanged(); | 773 | // emit selectionChanged(); |
774 | }; | 774 | }; |
775 | }; | 775 | }; |
776 | 776 | ||
777 | QPoint p( contentsToViewport( e->pos() ) ); | 777 | QPoint p( contentsToViewport( e->pos() ) ); |
778 | QListViewItem *at = itemAt (p); | 778 | QListViewItem *at = itemAt (p); |
779 | 779 | ||
780 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 780 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
781 | bool rootDecoClicked = at | 781 | bool rootDecoClicked = at |
782 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 782 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
783 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 783 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
784 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 784 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
785 | 785 | ||
786 | if (e->button() == LeftButton && !rootDecoClicked) | 786 | if (e->button() == LeftButton && !rootDecoClicked) |
787 | { | 787 | { |
788 | //Start a drag | 788 | //Start a drag |
789 | d->startDragPos = e->pos(); | 789 | d->startDragPos = e->pos(); |
790 | 790 | ||
791 | if (at) | 791 | if (at) |
792 | { | 792 | { |
793 | d->validDrag = true; | 793 | d->validDrag = true; |
794 | d->pressedOnSelected = at->isSelected(); | 794 | d->pressedOnSelected = at->isSelected(); |
795 | } | 795 | } |
796 | } | 796 | } |
797 | 797 | ||
798 | QListView::contentsMousePressEvent( e ); | 798 | QListView::contentsMousePressEvent( e ); |
799 | } | 799 | } |
800 | 800 | ||
801 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 801 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
802 | { | 802 | { |
803 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 803 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
804 | QListView::contentsMouseMoveEvent (e); | 804 | QListView::contentsMouseMoveEvent (e); |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | 807 | ||
808 | QPoint vp = contentsToViewport(e->pos()); | 808 | QPoint vp = contentsToViewport(e->pos()); |
809 | QListViewItem *item = itemAt( vp ); | 809 | QListViewItem *item = itemAt( vp ); |
810 | 810 | ||
811 | //do we process cursor changes at all? | 811 | //do we process cursor changes at all? |
812 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 812 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
813 | { | 813 | { |
814 | //Cursor moved on a new item or in/out the execute area | 814 | //Cursor moved on a new item or in/out the execute area |
815 | if( (item != d->pCurrentItem) || | 815 | if( (item != d->pCurrentItem) || |
816 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 816 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
817 | { | 817 | { |
818 | d->cursorInExecuteArea = isExecuteArea(vp); | 818 | d->cursorInExecuteArea = isExecuteArea(vp); |
819 | qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 819 | qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
820 | /*US | 820 | /*US |
821 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 821 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
822 | viewport()->setCursor( KCursor::handCursor() ); | 822 | viewport()->setCursor( KCursor::handCursor() ); |
823 | else //cursor moved out of execute area | 823 | else //cursor moved out of execute area |
824 | viewport()->unsetCursor(); | 824 | viewport()->unsetCursor(); |
825 | */ | 825 | */ |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | bool dragOn = dragEnabled(); | 829 | bool dragOn = dragEnabled(); |
830 | QPoint newPos = e->pos(); | 830 | QPoint newPos = e->pos(); |
831 | if (dragOn && d->validDrag && | 831 | if (dragOn && d->validDrag && |
832 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 832 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
833 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 833 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
834 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 834 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
835 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 835 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
836 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 836 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
837 | { | 837 | { |
838 | QListView::contentsMouseReleaseEvent( 0 ); | 838 | QListView::contentsMouseReleaseEvent( 0 ); |
839 | startDrag(); | 839 | startDrag(); |
840 | d->startDragPos = QPoint(); | 840 | d->startDragPos = QPoint(); |
841 | d->validDrag = false; | 841 | d->validDrag = false; |
842 | } | 842 | } |
843 | } | 843 | } |
844 | 844 | ||
845 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | 845 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) |
846 | { | 846 | { |
847 | if (e->button() == LeftButton) | 847 | if (e->button() == LeftButton) |
848 | { | 848 | { |
849 | // If the row was already selected, maybe we want to start an in-place editing | 849 | // If the row was already selected, maybe we want to start an in-place editing |
850 | if ( d->pressedOnSelected && itemsRenameable() ) | 850 | if ( d->pressedOnSelected && itemsRenameable() ) |
851 | { | 851 | { |
852 | QPoint p( contentsToViewport( e->pos() ) ); | 852 | QPoint p( contentsToViewport( e->pos() ) ); |
853 | QListViewItem *at = itemAt (p); | 853 | QListViewItem *at = itemAt (p); |
854 | if ( at ) | 854 | if ( at ) |
855 | { | 855 | { |
856 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 856 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
857 | bool rootDecoClicked = | 857 | bool rootDecoClicked = |
858 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 858 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
859 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 859 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
860 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 860 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
861 | 861 | ||
862 | if (!rootDecoClicked) | 862 | if (!rootDecoClicked) |
863 | { | 863 | { |
864 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); | 864 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); |
865 | if ( d->renameable.contains(col) ) | 865 | if ( d->renameable.contains(col) ) |
866 | rename(at, col); | 866 | rename(at, col); |
867 | } | 867 | } |
868 | } | 868 | } |
869 | } | 869 | } |
870 | 870 | ||
871 | d->pressedOnSelected = false; | 871 | d->pressedOnSelected = false; |
872 | d->validDrag = false; | 872 | d->validDrag = false; |
873 | d->startDragPos = QPoint(); | 873 | d->startDragPos = QPoint(); |
874 | } | 874 | } |
875 | QListView::contentsMouseReleaseEvent( e ); | 875 | QListView::contentsMouseReleaseEvent( e ); |
876 | } | 876 | } |
877 | 877 | ||
878 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | 878 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) |
879 | { | 879 | { |
880 | // We don't want to call the parent method because it does setOpen, | 880 | // We don't want to call the parent method because it does setOpen, |
881 | // whereas we don't do it in single click mode... (David) | 881 | // whereas we don't do it in single click mode... (David) |
882 | //QListView::contentsMouseDoubleClickEvent( e ); | 882 | //QListView::contentsMouseDoubleClickEvent( e ); |
883 | 883 | ||
884 | QPoint vp = contentsToViewport(e->pos()); | 884 | QPoint vp = contentsToViewport(e->pos()); |
885 | QListViewItem *item = itemAt( vp ); | 885 | QListViewItem *item = itemAt( vp ); |
886 | emit QListView::doubleClicked( item ); // we do it now | 886 | emit QListView::doubleClicked( item ); // we do it now |
887 | 887 | ||
888 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; | 888 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; |
889 | 889 | ||
890 | if( item ) { | 890 | if( item ) { |
891 | emit doubleClicked( item, e->globalPos(), col ); | 891 | emit doubleClicked( item, e->globalPos(), col ); |
892 | 892 | ||
893 | if( (e->button() == LeftButton) && !d->bUseSingle ) | 893 | if( (e->button() == LeftButton) && !d->bUseSingle ) |
894 | emitExecute( item, e->globalPos(), col ); | 894 | emitExecute( item, e->globalPos(), col ); |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) | 898 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) |
899 | { | 899 | { |
900 | if( (btn == LeftButton) && item ) | 900 | if( (btn == LeftButton) && item ) |
901 | emitExecute(item, pos, c); | 901 | emitExecute(item, pos, c); |
902 | } | 902 | } |
903 | 903 | ||
904 | void KListView::contentsDropEvent(QDropEvent* e) | 904 | void KListView::contentsDropEvent(QDropEvent* e) |
905 | { | 905 | { |
906 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 906 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
907 | /*US | 907 | /*US |
908 | cleanDropVisualizer(); | 908 | cleanDropVisualizer(); |
909 | cleanItemHighlighter(); | 909 | cleanItemHighlighter(); |
910 | d->dragExpand.stop(); | 910 | d->dragExpand.stop(); |
911 | 911 | ||
912 | if (acceptDrag (e)) | 912 | if (acceptDrag (e)) |
913 | { | 913 | { |
914 | e->acceptAction(); | 914 | e->acceptAction(); |
915 | QListViewItem *afterme; | 915 | QListViewItem *afterme; |
916 | QListViewItem *parent; | 916 | QListViewItem *parent; |
917 | findDrop(e->pos(), parent, afterme); | 917 | findDrop(e->pos(), parent, afterme); |
918 | 918 | ||
919 | if (e->source() == viewport() && itemsMovable()) | 919 | if (e->source() == viewport() && itemsMovable()) |
920 | movableDropEvent(parent, afterme); | 920 | movableDropEvent(parent, afterme); |
921 | else | 921 | else |
922 | { | 922 | { |
923 | 923 | ||
924 | emit dropped(e, afterme); | 924 | emit dropped(e, afterme); |
925 | emit dropped(this, e, afterme); | 925 | emit dropped(this, e, afterme); |
926 | emit dropped(e, parent, afterme); | 926 | emit dropped(e, parent, afterme); |
927 | emit dropped(this, e, parent, afterme); | 927 | emit dropped(this, e, parent, afterme); |
928 | 928 | ||
929 | } | 929 | } |
930 | } | 930 | } |
931 | */ | 931 | */ |
932 | 932 | ||
933 | } | 933 | } |
934 | 934 | ||
935 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) | 935 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) |
936 | { | 936 | { |
937 | QPtrList<QListViewItem> items, afterFirsts, afterNows; | 937 | QPtrList<QListViewItem> items, afterFirsts, afterNows; |
938 | QListViewItem *current=currentItem(); | 938 | QListViewItem *current=currentItem(); |
939 | bool hasMoved=false; | 939 | bool hasMoved=false; |
940 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) | 940 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) |
941 | { | 941 | { |
942 | iNext=i->itemBelow(); | 942 | iNext=i->itemBelow(); |
943 | if (!i->isSelected()) | 943 | if (!i->isSelected()) |
944 | continue; | 944 | continue; |
945 | 945 | ||
946 | // don't drop an item after itself, or else | 946 | // don't drop an item after itself, or else |
947 | // it moves to the top of the list | 947 | // it moves to the top of the list |
948 | if (i==afterme) | 948 | if (i==afterme) |
949 | continue; | 949 | continue; |
950 | 950 | ||
951 | i->setSelected(false); | 951 | i->setSelected(false); |
952 | 952 | ||
953 | QListViewItem *afterFirst = i->itemAbove(); | 953 | QListViewItem *afterFirst = i->itemAbove(); |
954 | 954 | ||
955 | if (!hasMoved) | 955 | if (!hasMoved) |
956 | { | 956 | { |
957 | emit aboutToMove(); | 957 | emit aboutToMove(); |
958 | hasMoved=true; | 958 | hasMoved=true; |
959 | } | 959 | } |
960 | 960 | ||
961 | moveItem(i, parent, afterme); | 961 | moveItem(i, parent, afterme); |
962 | 962 | ||
963 | // ###### This should include the new parent !!! -> KDE 3.0 | 963 | // ###### This should include the new parent !!! -> KDE 3.0 |
964 | // If you need this right now, have a look at keditbookmarks. | 964 | // If you need this right now, have a look at keditbookmarks. |
965 | emit moved(i, afterFirst, afterme); | 965 | emit moved(i, afterFirst, afterme); |
966 | 966 | ||
967 | items.append (i); | 967 | items.append (i); |
968 | afterFirsts.append (afterFirst); | 968 | afterFirsts.append (afterFirst); |
969 | afterNows.append (afterme); | 969 | afterNows.append (afterme); |
970 | 970 | ||
971 | afterme = i; | 971 | afterme = i; |
972 | } | 972 | } |
973 | clearSelection(); | 973 | clearSelection(); |
974 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) | 974 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) |
975 | i->setSelected(true); | 975 | i->setSelected(true); |
976 | if (current) | 976 | if (current) |
977 | setCurrentItem(current); | 977 | setCurrentItem(current); |
978 | 978 | ||
979 | emit moved(items,afterFirsts,afterNows); | 979 | emit moved(items,afterFirsts,afterNows); |
980 | 980 | ||
981 | if (firstChild()) | 981 | if (firstChild()) |
982 | emit moved(); | 982 | emit moved(); |
983 | } | 983 | } |
984 | 984 | ||
985 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) | 985 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) |
986 | { | 986 | { |
987 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 987 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
988 | /*US | 988 | /*US |
989 | if (acceptDrag(event)) | 989 | if (acceptDrag(event)) |
990 | { | 990 | { |
991 | event->acceptAction(); | 991 | event->acceptAction(); |
992 | //Clean up the view | 992 | //Clean up the view |
993 | 993 | ||
994 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); | 994 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); |
995 | QPoint vp = contentsToViewport( event->pos() ); | 995 | QPoint vp = contentsToViewport( event->pos() ); |
996 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; | 996 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; |
997 | 997 | ||
998 | if ( item != d->dragOverItem ) | 998 | if ( item != d->dragOverItem ) |
999 | { | 999 | { |
1000 | d->dragExpand.stop(); | 1000 | d->dragExpand.stop(); |
1001 | d->dragOverItem = item; | 1001 | d->dragOverItem = item; |
1002 | d->dragOverPoint = vp; | 1002 | d->dragOverPoint = vp; |
1003 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) | 1003 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) |
1004 | d->dragExpand.start( QApplication::startDragTime(), true ); | 1004 | d->dragExpand.start( QApplication::startDragTime(), true ); |
1005 | } | 1005 | } |
1006 | if (dropVisualizer()) | 1006 | if (dropVisualizer()) |
1007 | { | 1007 | { |
1008 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); | 1008 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); |
1009 | if (tmpRect != d->mOldDropVisualizer) | 1009 | if (tmpRect != d->mOldDropVisualizer) |
1010 | { | 1010 | { |
1011 | cleanDropVisualizer(); | 1011 | cleanDropVisualizer(); |
1012 | d->mOldDropVisualizer=tmpRect; | 1012 | d->mOldDropVisualizer=tmpRect; |
1013 | viewport()->repaint(tmpRect); | 1013 | viewport()->repaint(tmpRect); |
1014 | } | 1014 | } |
1015 | } | 1015 | } |
1016 | if (dropHighlighter()) | 1016 | if (dropHighlighter()) |
1017 | { | 1017 | { |
1018 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); | 1018 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); |
1019 | if (tmpRect != d->mOldDropHighlighter) | 1019 | if (tmpRect != d->mOldDropHighlighter) |
1020 | { | 1020 | { |
1021 | cleanItemHighlighter(); | 1021 | cleanItemHighlighter(); |
1022 | d->mOldDropHighlighter=tmpRect; | 1022 | d->mOldDropHighlighter=tmpRect; |
1023 | viewport()->repaint(tmpRect); | 1023 | viewport()->repaint(tmpRect); |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | else | 1027 | else |
1028 | event->ignore(); | 1028 | event->ignore(); |
1029 | */ | 1029 | */ |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void KListView::slotDragExpand() | 1032 | void KListView::slotDragExpand() |
1033 | { | 1033 | { |
1034 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) | 1034 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) |
1035 | d->dragOverItem->setOpen( true ); | 1035 | d->dragOverItem->setOpen( true ); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) | 1038 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) |
1039 | { | 1039 | { |
1040 | d->dragExpand.stop(); | 1040 | d->dragExpand.stop(); |
1041 | cleanDropVisualizer(); | 1041 | cleanDropVisualizer(); |
1042 | cleanItemHighlighter(); | 1042 | cleanItemHighlighter(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void KListView::cleanDropVisualizer() | 1045 | void KListView::cleanDropVisualizer() |
1046 | { | 1046 | { |
1047 | if (d->mOldDropVisualizer.isValid()) | 1047 | if (d->mOldDropVisualizer.isValid()) |
1048 | { | 1048 | { |
1049 | QRect rect=d->mOldDropVisualizer; | 1049 | QRect rect=d->mOldDropVisualizer; |
1050 | d->mOldDropVisualizer = QRect(); | 1050 | d->mOldDropVisualizer = QRect(); |
1051 | viewport()->repaint(rect, true); | 1051 | viewport()->repaint(rect, true); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | int KListView::depthToPixels( int depth ) | 1055 | int KListView::depthToPixels( int depth ) |
1056 | { | 1056 | { |
1057 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); | 1057 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) | 1060 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) |
1061 | { | 1061 | { |
1062 | QPoint p (contentsToViewport(pos)); | 1062 | QPoint p (contentsToViewport(pos)); |
1063 | 1063 | ||
1064 | // Get the position to put it in | 1064 | // Get the position to put it in |
1065 | QListViewItem *atpos = itemAt(p); | 1065 | QListViewItem *atpos = itemAt(p); |
1066 | 1066 | ||
1067 | QListViewItem *above; | 1067 | QListViewItem *above; |
1068 | if (!atpos) // put it at the end | 1068 | if (!atpos) // put it at the end |
1069 | above = lastItem(); | 1069 | above = lastItem(); |
1070 | else | 1070 | else |
1071 | { | 1071 | { |
1072 | // Get the closest item before us ('atpos' or the one above, if any) | 1072 | // Get the closest item before us ('atpos' or the one above, if any) |
1073 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) | 1073 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) |
1074 | above = atpos->itemAbove(); | 1074 | above = atpos->itemAbove(); |
1075 | else | 1075 | else |
1076 | above = atpos; | 1076 | above = atpos; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | if (above) | 1079 | if (above) |
1080 | { | 1080 | { |
1081 | // Now, we know we want to go after "above". But as a child or as a sibling ? | 1081 | // Now, we know we want to go after "above". But as a child or as a sibling ? |
1082 | // We have to ask the "above" item if it accepts children. | 1082 | // We have to ask the "above" item if it accepts children. |
1083 | if (above->isExpandable()) | 1083 | if (above->isExpandable()) |
1084 | { | 1084 | { |
1085 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children | 1085 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children |
1086 | if (p.x() >= depthToPixels( above->depth() + 1 ) || | 1086 | if (p.x() >= depthToPixels( above->depth() + 1 ) || |
1087 | (above->isOpen() && above->childCount() > 0) ) | 1087 | (above->isOpen() && above->childCount() > 0) ) |
1088 | { | 1088 | { |
1089 | parent = above; | 1089 | parent = above; |
1090 | after = 0L; | 1090 | after = 0L; |
1091 | return; | 1091 | return; |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | // Ok, there's one more level of complexity. We may want to become a new | 1095 | // Ok, there's one more level of complexity. We may want to become a new |
1096 | // sibling, but of an upper-level group, rather than the "above" item | 1096 | // sibling, but of an upper-level group, rather than the "above" item |
1097 | QListViewItem * betterAbove = above->parent(); | 1097 | QListViewItem * betterAbove = above->parent(); |
1098 | QListViewItem * last = above; | 1098 | QListViewItem * last = above; |
1099 | while ( betterAbove ) | 1099 | while ( betterAbove ) |
1100 | { | 1100 | { |
1101 | // We are allowed to become a sibling of "betterAbove" only if we are | 1101 | // We are allowed to become a sibling of "betterAbove" only if we are |
1102 | // after its last child | 1102 | // after its last child |
1103 | if ( last->nextSibling() == 0 ) | 1103 | if ( last->nextSibling() == 0 ) |
1104 | { | 1104 | { |
1105 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) | 1105 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) |
1106 | above = betterAbove; // store this one, but don't stop yet, there may be a better one | 1106 | above = betterAbove; // store this one, but don't stop yet, there may be a better one |
1107 | else | 1107 | else |
1108 | break; // not enough on the left, so stop | 1108 | break; // not enough on the left, so stop |
1109 | last = betterAbove; | 1109 | last = betterAbove; |
1110 | betterAbove = betterAbove->parent(); // up one level | 1110 | betterAbove = betterAbove->parent(); // up one level |
1111 | } else | 1111 | } else |
1112 | break; // we're among the child of betterAbove, not after the last one | 1112 | break; // we're among the child of betterAbove, not after the last one |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | // set as sibling | 1115 | // set as sibling |
1116 | after = above; | 1116 | after = above; |
1117 | parent = after ? after->parent() : 0L ; | 1117 | parent = after ? after->parent() : 0L ; |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | QListViewItem* KListView::lastChild () const | 1120 | QListViewItem* KListView::lastChild () const |
1121 | { | 1121 | { |
1122 | QListViewItem* lastchild = firstChild(); | 1122 | QListViewItem* lastchild = firstChild(); |
1123 | 1123 | ||
1124 | if (lastchild) | 1124 | if (lastchild) |
1125 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); | 1125 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); |
1126 | 1126 | ||
1127 | return lastchild; | 1127 | return lastchild; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | QListViewItem *KListView::lastItem() const | 1130 | QListViewItem *KListView::lastItem() const |
1131 | { | 1131 | { |
1132 | QListViewItem* last = lastChild(); | 1132 | QListViewItem* last = lastChild(); |
1133 | 1133 | ||
1134 | for (QListViewItemIterator it (last); it.current(); ++it) | 1134 | for (QListViewItemIterator it (last); it.current(); ++it) |
1135 | last = it.current(); | 1135 | last = it.current(); |
1136 | 1136 | ||
1137 | return last; | 1137 | return last; |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | KLineEdit *KListView::renameLineEdit() const | 1140 | KLineEdit *KListView::renameLineEdit() const |
1141 | { | 1141 | { |
1142 | //US return d->editor; | 1142 | //US return d->editor; |
1143 | qDebug("KListView::renameLineEdit returns 0. Might crash"); | 1143 | qDebug("KListView::renameLineEdit returns 0. Might crash"); |
1144 | return 0; | 1144 | return 0; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | void KListView::startDrag() | 1147 | void KListView::startDrag() |
1148 | { | 1148 | { |
1149 | qDebug("KListView::startDrag drag&drop not supported yet."); | 1149 | qDebug("KListView::startDrag drag&drop not supported yet."); |
1150 | /*US | 1150 | /*US |
1151 | QDragObject *drag = dragObject(); | 1151 | QDragObject *drag = dragObject(); |
1152 | 1152 | ||
1153 | if (!drag) | 1153 | if (!drag) |
1154 | return; | 1154 | return; |
1155 | 1155 | ||
1156 | if (drag->drag() && drag->target() != viewport()) | 1156 | if (drag->drag() && drag->target() != viewport()) |
1157 | emit moved(); | 1157 | emit moved(); |
1158 | */ | 1158 | */ |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | QDragObject *KListView::dragObject() | 1161 | QDragObject *KListView::dragObject() |
1162 | { | 1162 | { |
1163 | if (!currentItem()) | 1163 | if (!currentItem()) |
1164 | return 0; | 1164 | return 0; |
1165 | 1165 | ||
1166 | return new QStoredDrag("application/x-qlistviewitem", viewport()); | 1166 | return new QStoredDrag("application/x-qlistviewitem", viewport()); |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | void KListView::setItemsMovable(bool b) | 1169 | void KListView::setItemsMovable(bool b) |
1170 | { | 1170 | { |
1171 | d->itemsMovable=b; | 1171 | d->itemsMovable=b; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | bool KListView::itemsMovable() const | 1174 | bool KListView::itemsMovable() const |
1175 | { | 1175 | { |
1176 | return d->itemsMovable; | 1176 | return d->itemsMovable; |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | void KListView::setItemsRenameable(bool b) | 1179 | void KListView::setItemsRenameable(bool b) |
1180 | { | 1180 | { |
1181 | d->itemsRenameable=b; | 1181 | d->itemsRenameable=b; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | bool KListView::itemsRenameable() const | 1184 | bool KListView::itemsRenameable() const |
1185 | { | 1185 | { |
1186 | return d->itemsRenameable; | 1186 | return d->itemsRenameable; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | 1189 | ||
1190 | void KListView::setDragEnabled(bool b) | 1190 | void KListView::setDragEnabled(bool b) |
1191 | { | 1191 | { |
1192 | d->dragEnabled=b; | 1192 | d->dragEnabled=b; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | bool KListView::dragEnabled() const | 1195 | bool KListView::dragEnabled() const |
1196 | { | 1196 | { |
1197 | return d->dragEnabled; | 1197 | return d->dragEnabled; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | void KListView::setAutoOpen(bool b) | 1200 | void KListView::setAutoOpen(bool b) |
1201 | { | 1201 | { |
1202 | d->autoOpen=b; | 1202 | d->autoOpen=b; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | bool KListView::autoOpen() const | 1205 | bool KListView::autoOpen() const |
1206 | { | 1206 | { |
1207 | return d->autoOpen; | 1207 | return d->autoOpen; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | bool KListView::dropVisualizer() const | 1210 | bool KListView::dropVisualizer() const |
1211 | { | 1211 | { |
1212 | return d->dropVisualizer; | 1212 | return d->dropVisualizer; |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void KListView::setDropVisualizer(bool b) | 1215 | void KListView::setDropVisualizer(bool b) |
1216 | { | 1216 | { |
1217 | d->dropVisualizer=b; | 1217 | d->dropVisualizer=b; |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | QPtrList<QListViewItem> KListView::selectedItems() const | 1220 | QPtrList<QListViewItem> KListView::selectedItems() const |
1221 | { | 1221 | { |
1222 | QPtrList<QListViewItem> list; | 1222 | QPtrList<QListViewItem> list; |
1223 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) | 1223 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) |
1224 | if (i->isSelected()) list.append(i); | 1224 | if (i->isSelected()) list.append(i); |
1225 | return list; | 1225 | return list; |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | 1228 | ||
1229 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) | 1229 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) |
1230 | { | 1230 | { |
1231 | // sanity check - don't move a item into it's own child structure | 1231 | // sanity check - don't move a item into it's own child structure |
1232 | QListViewItem *i = parent; | 1232 | QListViewItem *i = parent; |
1233 | while(i) | 1233 | while(i) |
1234 | { | 1234 | { |
1235 | if(i == item) | 1235 | if(i == item) |
1236 | return; | 1236 | return; |
1237 | i = i->parent(); | 1237 | i = i->parent(); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor | 1240 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor |
1241 | // in here, without ever deleting the item. | 1241 | // in here, without ever deleting the item. |
1242 | if (item->parent()) | 1242 | if (item->parent()) |
1243 | item->parent()->takeItem(item); | 1243 | item->parent()->takeItem(item); |
1244 | else | 1244 | else |
1245 | takeItem(item); | 1245 | takeItem(item); |
1246 | 1246 | ||
1247 | if (parent) | 1247 | if (parent) |
1248 | parent->insertItem(item); | 1248 | parent->insertItem(item); |
1249 | else | 1249 | else |
1250 | insertItem(item); | 1250 | insertItem(item); |
1251 | 1251 | ||
1252 | if (after) | 1252 | if (after) |
1253 | ;//item->moveToJustAfter(after); | 1253 | ;//item->moveToJustAfter(after); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) | 1256 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) |
1257 | { | 1257 | { |
1258 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); | 1258 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); |
1259 | /*US | 1259 | /*US |
1260 | if (acceptDrag (event)) | 1260 | if (acceptDrag (event)) |
1261 | event->accept(); | 1261 | event->accept(); |
1262 | */ | 1262 | */ |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void KListView::setDropVisualizerWidth (int w) | 1265 | void KListView::setDropVisualizerWidth (int w) |
1266 | { | 1266 | { |
1267 | d->mDropVisualizerWidth = w > 0 ? w : 1; | 1267 | d->mDropVisualizerWidth = w > 0 ? w : 1; |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, | 1270 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, |
1271 | QListViewItem *after) | 1271 | QListViewItem *after) |
1272 | { | 1272 | { |
1273 | QRect insertmarker; | 1273 | QRect insertmarker; |
1274 | 1274 | ||
1275 | if (!after && !parent) | 1275 | if (!after && !parent) |
1276 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); | 1276 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | int level = 0; | 1279 | int level = 0; |
1280 | if (after) | 1280 | if (after) |
1281 | { | 1281 | { |
1282 | QListViewItem* it = 0L; | 1282 | QListViewItem* it = 0L; |
1283 | if (after->isOpen()) | 1283 | if (after->isOpen()) |
1284 | { | 1284 | { |
1285 | // Look for the last child (recursively) | 1285 | // Look for the last child (recursively) |
1286 | it = after->firstChild(); | 1286 | it = after->firstChild(); |
1287 | if (it) | 1287 | if (it) |
1288 | while (it->nextSibling() || it->firstChild()) | 1288 | while (it->nextSibling() || it->firstChild()) |
1289 | if ( it->nextSibling() ) | 1289 | if ( it->nextSibling() ) |
1290 | it = it->nextSibling(); | 1290 | it = it->nextSibling(); |
1291 | else | 1291 | else |
1292 | it = it->firstChild(); | 1292 | it = it->firstChild(); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | insertmarker = itemRect (it ? it : after); | 1295 | insertmarker = itemRect (it ? it : after); |
1296 | level = after->depth(); | 1296 | level = after->depth(); |
1297 | } | 1297 | } |
1298 | else if (parent) | 1298 | else if (parent) |
1299 | { | 1299 | { |
1300 | insertmarker = itemRect (parent); | 1300 | insertmarker = itemRect (parent); |
1301 | level = parent->depth() + 1; | 1301 | level = parent->depth() + 1; |
1302 | } | 1302 | } |
1303 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); | 1303 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); |
1304 | insertmarker.setRight (viewport()->width()); | 1304 | insertmarker.setRight (viewport()->width()); |
1305 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); | 1305 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); |
1306 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); | 1306 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) | 1309 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) |
1310 | // Remove for KDE 3.0. | 1310 | // Remove for KDE 3.0. |
1311 | if (p) | 1311 | if (p) |
1312 | p->fillRect(insertmarker, Dense4Pattern); | 1312 | p->fillRect(insertmarker, Dense4Pattern); |
1313 | 1313 | ||
1314 | return insertmarker; | 1314 | return insertmarker; |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) | 1317 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) |
1318 | { | 1318 | { |
1319 | QRect r; | 1319 | QRect r; |
1320 | 1320 | ||
1321 | if (item) | 1321 | if (item) |
1322 | { | 1322 | { |
1323 | r = itemRect(item); | 1323 | r = itemRect(item); |
1324 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); | 1324 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); |
1325 | if (painter) { | 1325 | if (painter) { |
1326 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), | 1326 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), |
1327 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); | 1327 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); |
1328 | const QColor* pHighl = &(colorGroup().highlight()); | 1328 | const QColor* pHighl = &(colorGroup().highlight()); |
1329 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); | 1329 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); |
1330 | 1330 | ||
1331 | qDebug("KListView::drawItemHighlighter has to be verified"); | 1331 | qDebug("KListView::drawItemHighlighter has to be verified"); |
1332 | 1332 | ||
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | return r; | 1337 | return r; |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | void KListView::cleanItemHighlighter () | 1340 | void KListView::cleanItemHighlighter () |
1341 | { | 1341 | { |
1342 | if (d->mOldDropHighlighter.isValid()) | 1342 | if (d->mOldDropHighlighter.isValid()) |
1343 | { | 1343 | { |
1344 | QRect rect=d->mOldDropHighlighter; | 1344 | QRect rect=d->mOldDropHighlighter; |
1345 | d->mOldDropHighlighter = QRect(); | 1345 | d->mOldDropHighlighter = QRect(); |
1346 | viewport()->repaint(rect, true); | 1346 | viewport()->repaint(rect, true); |
1347 | } | 1347 | } |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | void KListView::rename(QListViewItem *item, int c) | 1350 | void KListView::rename(QListViewItem *item, int c) |
1351 | { | 1351 | { |
1352 | if (d->renameable.contains(c)) | 1352 | if (d->renameable.contains(c)) |
1353 | { | 1353 | { |
1354 | ensureItemVisible(item); | 1354 | ensureItemVisible(item); |
1355 | //US d->editor->load(item,c); | 1355 | //US d->editor->load(item,c); |
1356 | qDebug("KListView::rename has to be verified"); | 1356 | qDebug("KListView::rename has to be verified"); |
1357 | 1357 | ||
1358 | } | 1358 | } |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | bool KListView::isRenameable (int col) const | 1361 | bool KListView::isRenameable (int col) const |
1362 | { | 1362 | { |
1363 | return d->renameable.contains(col); | 1363 | return d->renameable.contains(col); |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KListView::setRenameable (int col, bool yesno) | 1366 | void KListView::setRenameable (int col, bool yesno) |
1367 | { | 1367 | { |
1368 | if (col>=header()->count()) return; | 1368 | if (col>=header()->count()) return; |
1369 | 1369 | ||
1370 | d->renameable.remove(col); | 1370 | d->renameable.remove(col); |
1371 | if (yesno && d->renameable.find(col)==d->renameable.end()) | 1371 | if (yesno && d->renameable.find(col)==d->renameable.end()) |
1372 | d->renameable+=col; | 1372 | d->renameable+=col; |
1373 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) | 1373 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) |
1374 | d->renameable.remove(col); | 1374 | d->renameable.remove(col); |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | void KListView::doneEditing(QListViewItem *item, int row) | 1377 | void KListView::doneEditing(QListViewItem *item, int row) |
1378 | { | 1378 | { |
1379 | emit itemRenamed(item, item->text(row), row); | 1379 | emit itemRenamed(item, item->text(row), row); |
1380 | emit itemRenamed(item); | 1380 | emit itemRenamed(item); |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool KListView::acceptDrag(QDropEvent* e) const | 1383 | bool KListView::acceptDrag(QDropEvent* e) const |
1384 | { | 1384 | { |
1385 | qDebug("KListView::acceptDrag drag&drop not supported yet"); | 1385 | qDebug("KListView::acceptDrag drag&drop not supported yet"); |
1386 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); | 1386 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); |
1387 | return false; | 1387 | return false; |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void KListView::setCreateChildren(bool b) | 1390 | void KListView::setCreateChildren(bool b) |
1391 | { | 1391 | { |
1392 | d->createChildren=b; | 1392 | d->createChildren=b; |
1393 | } | 1393 | } |
1394 | 1394 | ||
1395 | bool KListView::createChildren() const | 1395 | bool KListView::createChildren() const |
1396 | { | 1396 | { |
1397 | return d->createChildren; | 1397 | return d->createChildren; |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | 1400 | ||
1401 | int KListView::tooltipColumn() const | 1401 | int KListView::tooltipColumn() const |
1402 | { | 1402 | { |
1403 | return d->tooltipColumn; | 1403 | return d->tooltipColumn; |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | void KListView::setTooltipColumn(int column) | 1406 | void KListView::setTooltipColumn(int column) |
1407 | { | 1407 | { |
1408 | d->tooltipColumn=column; | 1408 | d->tooltipColumn=column; |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | void KListView::setDropHighlighter(bool b) | 1411 | void KListView::setDropHighlighter(bool b) |
1412 | { | 1412 | { |
1413 | d->dropHighlighter=b; | 1413 | d->dropHighlighter=b; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | bool KListView::dropHighlighter() const | 1416 | bool KListView::dropHighlighter() const |
1417 | { | 1417 | { |
1418 | return d->dropHighlighter; | 1418 | return d->dropHighlighter; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const | 1421 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const |
1422 | { | 1422 | { |
1423 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); | 1423 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | QString KListView::tooltip(QListViewItem *item, int column) const | 1426 | QString KListView::tooltip(QListViewItem *item, int column) const |
1427 | { | 1427 | { |
1428 | return item->text(column); | 1428 | return item->text(column); |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void KListView::setTabOrderedRenaming(bool b) | 1431 | void KListView::setTabOrderedRenaming(bool b) |
1432 | { | 1432 | { |
1433 | d->tabRename = b; | 1433 | d->tabRename = b; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | bool KListView::tabOrderedRenaming() const | 1436 | bool KListView::tabOrderedRenaming() const |
1437 | { | 1437 | { |
1438 | return d->tabRename; | 1438 | return d->tabRename; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | void KListView::keyPressEvent (QKeyEvent* e) | 1441 | void KListView::keyPressEvent (QKeyEvent* e) |
1442 | { | 1442 | { |
1443 | //don't we need a contextMenuModifier too ? (aleXXX) | 1443 | //don't we need a contextMenuModifier too ? (aleXXX) |
1444 | if (e->key() == d->contextMenuKey) | 1444 | if (e->key() == d->contextMenuKey) |
1445 | { | 1445 | { |
1446 | emit menuShortCutPressed (this, currentItem()); | 1446 | emit menuShortCutPressed (this, currentItem()); |
1447 | return; | 1447 | return; |
1448 | } | 1448 | } |
1449 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) | 1449 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) |
1450 | { | 1450 | { |
1451 | emit signalDelete ( ); | 1451 | emit signalDelete ( ); |
1452 | return; | 1452 | return; |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | if (d->selectionMode != FileManager) | 1455 | if (d->selectionMode != FileManager) |
1456 | QListView::keyPressEvent (e); | 1456 | QListView::keyPressEvent (e); |
1457 | else | 1457 | else |
1458 | fileManagerKeyPressEvent (e); | 1458 | fileManagerKeyPressEvent (e); |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | void KListView::activateAutomaticSelection() | 1461 | void KListView::activateAutomaticSelection() |
1462 | { | 1462 | { |
1463 | d->selectedBySimpleMove=true; | 1463 | d->selectedBySimpleMove=true; |
1464 | d->selectedUsingMouse=false; | 1464 | d->selectedUsingMouse=false; |
1465 | if (currentItem()!=0) | 1465 | if (currentItem()!=0) |
1466 | { | 1466 | { |
1467 | selectAll(false); | 1467 | selectAll(false); |
1468 | currentItem()->setSelected(true); | 1468 | currentItem()->setSelected(true); |
1469 | currentItem()->repaint(); | 1469 | currentItem()->repaint(); |
1470 | emit selectionChanged(); | 1470 | emit selectionChanged(); |
1471 | }; | 1471 | }; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void KListView::deactivateAutomaticSelection() | 1474 | void KListView::deactivateAutomaticSelection() |
1475 | { | 1475 | { |
1476 | d->selectedBySimpleMove=false; | 1476 | d->selectedBySimpleMove=false; |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | bool KListView::automaticSelection() const | 1479 | bool KListView::automaticSelection() const |
1480 | { | 1480 | { |
1481 | return d->selectedBySimpleMove; | 1481 | return d->selectedBySimpleMove; |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) | 1484 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) |
1485 | { | 1485 | { |
1486 | //don't care whether it's on the keypad or not | 1486 | //don't care whether it's on the keypad or not |
1487 | int e_state=(e->state() & ~Keypad); | 1487 | int e_state=(e->state() & ~Keypad); |
1488 | 1488 | ||
1489 | int oldSelectionDirection(d->selectionDirection); | 1489 | int oldSelectionDirection(d->selectionDirection); |
1490 | 1490 | ||
1491 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1491 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1492 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) | 1492 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) |
1493 | { | 1493 | { |
1494 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) | 1494 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) |
1495 | selectAll(FALSE); | 1495 | selectAll(FALSE); |
1496 | d->selectionDirection=0; | 1496 | d->selectionDirection=0; |
1497 | d->wasShiftEvent = (e_state == ShiftButton); | 1497 | d->wasShiftEvent = (e_state == ShiftButton); |
1498 | }; | 1498 | }; |
1499 | 1499 | ||
1500 | //d->wasShiftEvent = (e_state == ShiftButton); | 1500 | //d->wasShiftEvent = (e_state == ShiftButton); |
1501 | 1501 | ||
1502 | 1502 | ||
1503 | QListViewItem* item = currentItem(); | 1503 | QListViewItem* item = currentItem(); |
1504 | if (item==0) return; | 1504 | if (item==0) return; |
1505 | 1505 | ||
1506 | QListViewItem* repaintItem1 = item; | 1506 | QListViewItem* repaintItem1 = item; |
1507 | QListViewItem* repaintItem2 = 0L; | 1507 | QListViewItem* repaintItem2 = 0L; |
1508 | QListViewItem* visItem = 0L; | 1508 | QListViewItem* visItem = 0L; |
1509 | 1509 | ||
1510 | QListViewItem* nextItem = 0L; | 1510 | QListViewItem* nextItem = 0L; |
1511 | int items = 0; | 1511 | int items = 0; |
1512 | 1512 | ||
1513 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); | 1513 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); |
1514 | int selectedItems(0); | 1514 | int selectedItems(0); |
1515 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) | 1515 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) |
1516 | if (tmpItem->isSelected()) selectedItems++; | 1516 | if (tmpItem->isSelected()) selectedItems++; |
1517 | 1517 | ||
1518 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) | 1518 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) |
1519 | && (e_state==NoButton) | 1519 | && (e_state==NoButton) |
1520 | && ((e->key()==Key_Down) | 1520 | && ((e->key()==Key_Down) |
1521 | || (e->key()==Key_Up) | 1521 | || (e->key()==Key_Up) |
1522 | || (e->key()==Key_Next) | 1522 | || (e->key()==Key_Next) |
1523 | || (e->key()==Key_Prior) | 1523 | || (e->key()==Key_Prior) |
1524 | || (e->key()==Key_Home) | 1524 | || (e->key()==Key_Home) |
1525 | || (e->key()==Key_End))) | 1525 | || (e->key()==Key_End))) |
1526 | { | 1526 | { |
1527 | d->selectedBySimpleMove=true; | 1527 | d->selectedBySimpleMove=true; |
1528 | d->selectedUsingMouse=false; | 1528 | d->selectedUsingMouse=false; |
1529 | } | 1529 | } |
1530 | else if (selectedItems>1) | 1530 | else if (selectedItems>1) |
1531 | d->selectedBySimpleMove=false; | 1531 | d->selectedBySimpleMove=false; |
1532 | 1532 | ||
1533 | bool emitSelectionChanged(false); | 1533 | bool emitSelectionChanged(false); |
1534 | 1534 | ||
1535 | switch (e->key()) | 1535 | switch (e->key()) |
1536 | { | 1536 | { |
1537 | case Key_Escape: | 1537 | case Key_Escape: |
1538 | selectAll(FALSE); | 1538 | selectAll(FALSE); |
1539 | emitSelectionChanged=TRUE; | 1539 | emitSelectionChanged=TRUE; |
1540 | break; | 1540 | break; |
1541 | 1541 | ||
1542 | case Key_Space: | 1542 | case Key_Space: |
1543 | //toggle selection of current item | 1543 | //toggle selection of current item |
1544 | if (d->selectedBySimpleMove) | 1544 | if (d->selectedBySimpleMove) |
1545 | d->selectedBySimpleMove=false; | 1545 | d->selectedBySimpleMove=false; |
1546 | item->setSelected(!item->isSelected()); | 1546 | item->setSelected(!item->isSelected()); |
1547 | emitSelectionChanged=TRUE; | 1547 | emitSelectionChanged=TRUE; |
1548 | break; | 1548 | break; |
1549 | 1549 | ||
1550 | case Key_Insert: | 1550 | case Key_Insert: |
1551 | //toggle selection of current item and move to the next item | 1551 | //toggle selection of current item and move to the next item |
1552 | if (d->selectedBySimpleMove) | 1552 | if (d->selectedBySimpleMove) |
1553 | { | 1553 | { |
1554 | d->selectedBySimpleMove=false; | 1554 | d->selectedBySimpleMove=false; |
1555 | if (!item->isSelected()) item->setSelected(TRUE); | 1555 | if (!item->isSelected()) item->setSelected(TRUE); |
1556 | } | 1556 | } |
1557 | else | 1557 | else |
1558 | { | 1558 | { |
1559 | item->setSelected(!item->isSelected()); | 1559 | item->setSelected(!item->isSelected()); |
1560 | }; | 1560 | }; |
1561 | 1561 | ||
1562 | nextItem=item->itemBelow(); | 1562 | nextItem=item->itemBelow(); |
1563 | 1563 | ||
1564 | if (nextItem!=0) | 1564 | if (nextItem!=0) |
1565 | { | 1565 | { |
1566 | repaintItem2=nextItem; | 1566 | repaintItem2=nextItem; |
1567 | visItem=nextItem; | 1567 | visItem=nextItem; |
1568 | setCurrentItem(nextItem); | 1568 | setCurrentItem(nextItem); |
1569 | }; | 1569 | }; |
1570 | d->selectionDirection=1; | 1570 | d->selectionDirection=1; |
1571 | emitSelectionChanged=TRUE; | 1571 | emitSelectionChanged=TRUE; |
1572 | break; | 1572 | break; |
1573 | 1573 | ||
1574 | case Key_Down: | 1574 | case Key_Down: |
1575 | nextItem=item->itemBelow(); | 1575 | nextItem=item->itemBelow(); |
1576 | //toggle selection of current item and move to the next item | 1576 | //toggle selection of current item and move to the next item |
1577 | if (shiftOrCtrl) | 1577 | if (shiftOrCtrl) |
1578 | { | 1578 | { |
1579 | d->selectionDirection=1; | 1579 | d->selectionDirection=1; |
1580 | if (d->selectedBySimpleMove) | 1580 | if (d->selectedBySimpleMove) |
1581 | d->selectedBySimpleMove=false; | 1581 | d->selectedBySimpleMove=false; |
1582 | else | 1582 | else |
1583 | { | 1583 | { |
1584 | if (oldSelectionDirection!=-1) | 1584 | if (oldSelectionDirection!=-1) |
1585 | { | 1585 | { |
1586 | item->setSelected(!item->isSelected()); | 1586 | item->setSelected(!item->isSelected()); |
1587 | emitSelectionChanged=TRUE; | 1587 | emitSelectionChanged=TRUE; |
1588 | }; | 1588 | }; |
1589 | }; | 1589 | }; |
1590 | } | 1590 | } |
1591 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1591 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1592 | { | 1592 | { |
1593 | item->setSelected(false); | 1593 | item->setSelected(false); |
1594 | emitSelectionChanged=TRUE; | 1594 | emitSelectionChanged=TRUE; |
1595 | }; | 1595 | }; |
1596 | 1596 | ||
1597 | if (nextItem!=0) | 1597 | if (nextItem!=0) |
1598 | { | 1598 | { |
1599 | if (d->selectedBySimpleMove) | 1599 | if (d->selectedBySimpleMove) |
1600 | nextItem->setSelected(true); | 1600 | nextItem->setSelected(true); |
1601 | repaintItem2=nextItem; | 1601 | repaintItem2=nextItem; |
1602 | visItem=nextItem; | 1602 | visItem=nextItem; |
1603 | setCurrentItem(nextItem); | 1603 | setCurrentItem(nextItem); |
1604 | }; | 1604 | }; |
1605 | break; | 1605 | break; |
1606 | 1606 | ||
1607 | case Key_Up: | 1607 | case Key_Up: |
1608 | nextItem=item->itemAbove(); | 1608 | nextItem=item->itemAbove(); |
1609 | d->selectionDirection=-1; | 1609 | d->selectionDirection=-1; |
1610 | //move to the prev. item and toggle selection of this one | 1610 | //move to the prev. item and toggle selection of this one |
1611 | // => No, can't select the last item, with this. For symmetry, let's | 1611 | // => No, can't select the last item, with this. For symmetry, let's |
1612 | // toggle selection and THEN move up, just like we do in down (David) | 1612 | // toggle selection and THEN move up, just like we do in down (David) |
1613 | if (shiftOrCtrl) | 1613 | if (shiftOrCtrl) |
1614 | { | 1614 | { |
1615 | if (d->selectedBySimpleMove) | 1615 | if (d->selectedBySimpleMove) |
1616 | d->selectedBySimpleMove=false; | 1616 | d->selectedBySimpleMove=false; |
1617 | else | 1617 | else |
1618 | { | 1618 | { |
1619 | if (oldSelectionDirection!=1) | 1619 | if (oldSelectionDirection!=1) |
1620 | { | 1620 | { |
1621 | item->setSelected(!item->isSelected()); | 1621 | item->setSelected(!item->isSelected()); |
1622 | emitSelectionChanged=TRUE; | 1622 | emitSelectionChanged=TRUE; |
1623 | }; | 1623 | }; |
1624 | } | 1624 | } |
1625 | } | 1625 | } |
1626 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1626 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1627 | { | 1627 | { |
1628 | item->setSelected(false); | 1628 | item->setSelected(false); |
1629 | emitSelectionChanged=TRUE; | 1629 | emitSelectionChanged=TRUE; |
1630 | }; | 1630 | }; |
1631 | 1631 | ||
1632 | if (nextItem!=0) | 1632 | if (nextItem!=0) |
1633 | { | 1633 | { |
1634 | if (d->selectedBySimpleMove) | 1634 | if (d->selectedBySimpleMove) |
1635 | nextItem->setSelected(true); | 1635 | nextItem->setSelected(true); |
1636 | repaintItem2=nextItem; | 1636 | repaintItem2=nextItem; |
1637 | visItem=nextItem; | 1637 | visItem=nextItem; |
1638 | setCurrentItem(nextItem); | 1638 | setCurrentItem(nextItem); |
1639 | }; | 1639 | }; |
1640 | break; | 1640 | break; |
1641 | 1641 | ||
1642 | case Key_End: | 1642 | case Key_End: |
1643 | //move to the last item and toggle selection of all items inbetween | 1643 | //move to the last item and toggle selection of all items inbetween |
1644 | nextItem=item; | 1644 | nextItem=item; |
1645 | if (d->selectedBySimpleMove) | 1645 | if (d->selectedBySimpleMove) |
1646 | item->setSelected(false); | 1646 | item->setSelected(false); |
1647 | if (shiftOrCtrl) | 1647 | if (shiftOrCtrl) |
1648 | d->selectedBySimpleMove=false; | 1648 | d->selectedBySimpleMove=false; |
1649 | 1649 | ||
1650 | while(nextItem!=0) | 1650 | while(nextItem!=0) |
1651 | { | 1651 | { |
1652 | if (shiftOrCtrl) | 1652 | if (shiftOrCtrl) |
1653 | nextItem->setSelected(!nextItem->isSelected()); | 1653 | nextItem->setSelected(!nextItem->isSelected()); |
1654 | if (nextItem->itemBelow()==0) | 1654 | if (nextItem->itemBelow()==0) |
1655 | { | 1655 | { |
1656 | if (d->selectedBySimpleMove) | 1656 | if (d->selectedBySimpleMove) |
1657 | nextItem->setSelected(true); | 1657 | nextItem->setSelected(true); |
1658 | repaintItem2=nextItem; | 1658 | repaintItem2=nextItem; |
1659 | visItem=nextItem; | 1659 | visItem=nextItem; |
1660 | setCurrentItem(nextItem); | 1660 | setCurrentItem(nextItem); |
1661 | } | 1661 | } |
1662 | nextItem=nextItem->itemBelow(); | 1662 | nextItem=nextItem->itemBelow(); |
1663 | } | 1663 | } |
1664 | emitSelectionChanged=TRUE; | 1664 | emitSelectionChanged=TRUE; |
1665 | break; | 1665 | break; |
1666 | 1666 | ||
1667 | case Key_Home: | 1667 | case Key_Home: |
1668 | // move to the first item and toggle selection of all items inbetween | 1668 | // move to the first item and toggle selection of all items inbetween |
1669 | nextItem = firstChild(); | 1669 | nextItem = firstChild(); |
1670 | visItem = nextItem; | 1670 | visItem = nextItem; |
1671 | repaintItem2 = visItem; | 1671 | repaintItem2 = visItem; |
1672 | if (d->selectedBySimpleMove) | 1672 | if (d->selectedBySimpleMove) |
1673 | item->setSelected(false); | 1673 | item->setSelected(false); |
1674 | if (shiftOrCtrl) | 1674 | if (shiftOrCtrl) |
1675 | { | 1675 | { |
1676 | d->selectedBySimpleMove=false; | 1676 | d->selectedBySimpleMove=false; |
1677 | 1677 | ||
1678 | while ( nextItem != item ) | 1678 | while ( nextItem != item ) |
1679 | { | 1679 | { |
1680 | nextItem->setSelected( !nextItem->isSelected() ); | 1680 | nextItem->setSelected( !nextItem->isSelected() ); |
1681 | nextItem = nextItem->itemBelow(); | 1681 | nextItem = nextItem->itemBelow(); |
1682 | } | 1682 | } |
1683 | item->setSelected( !item->isSelected() ); | 1683 | item->setSelected( !item->isSelected() ); |
1684 | } | 1684 | } |
1685 | setCurrentItem( firstChild() ); | 1685 | setCurrentItem( firstChild() ); |
1686 | emitSelectionChanged=TRUE; | 1686 | emitSelectionChanged=TRUE; |
1687 | break; | 1687 | break; |
1688 | 1688 | ||
1689 | case Key_Next: | 1689 | case Key_Next: |
1690 | items=visibleHeight()/item->height(); | 1690 | items=visibleHeight()/item->height(); |
1691 | nextItem=item; | 1691 | nextItem=item; |
1692 | if (d->selectedBySimpleMove) | 1692 | if (d->selectedBySimpleMove) |
1693 | item->setSelected(false); | 1693 | item->setSelected(false); |
1694 | if (shiftOrCtrl) | 1694 | if (shiftOrCtrl) |
1695 | { | 1695 | { |
1696 | d->selectedBySimpleMove=false; | 1696 | d->selectedBySimpleMove=false; |
1697 | d->selectionDirection=1; | 1697 | d->selectionDirection=1; |
1698 | }; | 1698 | }; |
1699 | 1699 | ||
1700 | for (int i=0; i<items; i++) | 1700 | for (int i=0; i<items; i++) |
1701 | { | 1701 | { |
1702 | if (shiftOrCtrl) | 1702 | if (shiftOrCtrl) |
1703 | nextItem->setSelected(!nextItem->isSelected()); | 1703 | nextItem->setSelected(!nextItem->isSelected()); |
1704 | //the end | 1704 | //the end |
1705 | if ((i==items-1) || (nextItem->itemBelow()==0)) | 1705 | if ((i==items-1) || (nextItem->itemBelow()==0)) |
1706 | 1706 | ||
1707 | { | 1707 | { |
1708 | if (shiftOrCtrl) | 1708 | if (shiftOrCtrl) |
1709 | nextItem->setSelected(!nextItem->isSelected()); | 1709 | nextItem->setSelected(!nextItem->isSelected()); |
1710 | if (d->selectedBySimpleMove) | 1710 | if (d->selectedBySimpleMove) |
1711 | nextItem->setSelected(true); | 1711 | nextItem->setSelected(true); |
1712 | ensureItemVisible(nextItem); | 1712 | ensureItemVisible(nextItem); |
1713 | setCurrentItem(nextItem); | 1713 | setCurrentItem(nextItem); |
1714 | update(); | 1714 | update(); |
1715 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1715 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1716 | { | 1716 | { |
1717 | emit selectionChanged(); | 1717 | emit selectionChanged(); |
1718 | } | 1718 | } |
1719 | return; | 1719 | return; |
1720 | } | 1720 | } |
1721 | nextItem=nextItem->itemBelow(); | 1721 | nextItem=nextItem->itemBelow(); |
1722 | } | 1722 | } |
1723 | break; | 1723 | break; |
1724 | 1724 | ||
1725 | case Key_Prior: | 1725 | case Key_Prior: |
1726 | items=visibleHeight()/item->height(); | 1726 | items=visibleHeight()/item->height(); |
1727 | nextItem=item; | 1727 | nextItem=item; |
1728 | if (d->selectedBySimpleMove) | 1728 | if (d->selectedBySimpleMove) |
1729 | item->setSelected(false); | 1729 | item->setSelected(false); |
1730 | if (shiftOrCtrl) | 1730 | if (shiftOrCtrl) |
1731 | { | 1731 | { |
1732 | d->selectionDirection=-1; | 1732 | d->selectionDirection=-1; |
1733 | d->selectedBySimpleMove=false; | 1733 | d->selectedBySimpleMove=false; |
1734 | }; | 1734 | }; |
1735 | 1735 | ||
1736 | for (int i=0; i<items; i++) | 1736 | for (int i=0; i<items; i++) |
1737 | { | 1737 | { |
1738 | if ((nextItem!=item) &&(shiftOrCtrl)) | 1738 | if ((nextItem!=item) &&(shiftOrCtrl)) |
1739 | nextItem->setSelected(!nextItem->isSelected()); | 1739 | nextItem->setSelected(!nextItem->isSelected()); |
1740 | //the end | 1740 | //the end |
1741 | if ((i==items-1) || (nextItem->itemAbove()==0)) | 1741 | if ((i==items-1) || (nextItem->itemAbove()==0)) |
1742 | 1742 | ||
1743 | { | 1743 | { |
1744 | if (d->selectedBySimpleMove) | 1744 | if (d->selectedBySimpleMove) |
1745 | nextItem->setSelected(true); | 1745 | nextItem->setSelected(true); |
1746 | ensureItemVisible(nextItem); | 1746 | ensureItemVisible(nextItem); |
1747 | setCurrentItem(nextItem); | 1747 | setCurrentItem(nextItem); |
1748 | update(); | 1748 | update(); |
1749 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1749 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1750 | { | 1750 | { |
1751 | emit selectionChanged(); | 1751 | emit selectionChanged(); |
1752 | } | 1752 | } |
1753 | return; | 1753 | return; |
1754 | } | 1754 | } |
1755 | nextItem=nextItem->itemAbove(); | 1755 | nextItem=nextItem->itemAbove(); |
1756 | } | 1756 | } |
1757 | break; | 1757 | break; |
1758 | 1758 | ||
1759 | case Key_Minus: | 1759 | case Key_Minus: |
1760 | if ( item->isOpen() ) | 1760 | if ( item->isOpen() ) |
1761 | setOpen( item, FALSE ); | 1761 | setOpen( item, FALSE ); |
1762 | break; | 1762 | break; |
1763 | case Key_Plus: | 1763 | case Key_Plus: |
1764 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) | 1764 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) |
1765 | setOpen( item, TRUE ); | 1765 | setOpen( item, TRUE ); |
1766 | break; | 1766 | break; |
1767 | default: | 1767 | default: |
1768 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1768 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1769 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); | 1769 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); |
1770 | 1770 | ||
1771 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); | 1771 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); |
1772 | if (realKey && selectCurrentItem) | 1772 | if (realKey && selectCurrentItem) |
1773 | item->setSelected(false); | 1773 | item->setSelected(false); |
1774 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) | 1774 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) |
1775 | QListView::SelectionMode oldSelectionMode = selectionMode(); | 1775 | QListView::SelectionMode oldSelectionMode = selectionMode(); |
1776 | setSelectionMode (QListView::Multi); | 1776 | setSelectionMode (QListView::Multi); |
1777 | QListView::keyPressEvent (e); | 1777 | QListView::keyPressEvent (e); |
1778 | setSelectionMode (oldSelectionMode); | 1778 | setSelectionMode (oldSelectionMode); |
1779 | if (realKey && selectCurrentItem) | 1779 | if (realKey && selectCurrentItem) |
1780 | { | 1780 | { |
1781 | currentItem()->setSelected(true); | 1781 | currentItem()->setSelected(true); |
1782 | emitSelectionChanged=TRUE; | 1782 | emitSelectionChanged=TRUE; |
1783 | } | 1783 | } |
1784 | repaintItem2=currentItem(); | 1784 | repaintItem2=currentItem(); |
1785 | if (realKey) | 1785 | if (realKey) |
1786 | visItem=currentItem(); | 1786 | visItem=currentItem(); |
1787 | break; | 1787 | break; |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | if (visItem) | 1790 | if (visItem) |
1791 | ensureItemVisible(visItem); | 1791 | ensureItemVisible(visItem); |
1792 | 1792 | ||
1793 | QRect ir; | 1793 | QRect ir; |
1794 | if (repaintItem1) | 1794 | if (repaintItem1) |
1795 | ir = ir.unite( itemRect(repaintItem1) ); | 1795 | ir = ir.unite( itemRect(repaintItem1) ); |
1796 | if (repaintItem2) | 1796 | if (repaintItem2) |
1797 | ir = ir.unite( itemRect(repaintItem2) ); | 1797 | ir = ir.unite( itemRect(repaintItem2) ); |
1798 | 1798 | ||
1799 | if ( !ir.isEmpty() ) | 1799 | if ( !ir.isEmpty() ) |
1800 | { // rectangle to be repainted | 1800 | { // rectangle to be repainted |
1801 | if ( ir.x() < 0 ) | 1801 | if ( ir.x() < 0 ) |
1802 | ir.moveBy( -ir.x(), 0 ); | 1802 | ir.moveBy( -ir.x(), 0 ); |
1803 | viewport()->repaint( ir, FALSE ); | 1803 | viewport()->repaint( ir, FALSE ); |
1804 | } | 1804 | } |
1805 | /*if (repaintItem1) | 1805 | /*if (repaintItem1) |
1806 | repaintItem1->repaint(); | 1806 | repaintItem1->repaint(); |
1807 | if (repaintItem2) | 1807 | if (repaintItem2) |
1808 | repaintItem2->repaint();*/ | 1808 | repaintItem2->repaint();*/ |
1809 | update(); | 1809 | update(); |
1810 | if (emitSelectionChanged) | 1810 | if (emitSelectionChanged) |
1811 | emit selectionChanged(); | 1811 | emit selectionChanged(); |
1812 | } | 1812 | } |
1813 | 1813 | ||
1814 | void KListView::setSelectionModeExt (SelectionModeExt mode) | 1814 | void KListView::setSelectionModeExt (SelectionModeExt mode) |
1815 | { | 1815 | { |
1816 | d->selectionMode = mode; | 1816 | d->selectionMode = mode; |
1817 | 1817 | ||
1818 | switch (mode) | 1818 | switch (mode) |
1819 | { | 1819 | { |
1820 | case Single: | 1820 | case Single: |
1821 | case Multi: | 1821 | case Multi: |
1822 | case Extended: | 1822 | case Extended: |
1823 | case NoSelection: | 1823 | case NoSelection: |
1824 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); | 1824 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); |
1825 | break; | 1825 | break; |
1826 | 1826 | ||
1827 | case FileManager: | 1827 | case FileManager: |
1828 | setSelectionMode (QListView::Extended); | 1828 | setSelectionMode (QListView::Extended); |
1829 | break; | 1829 | break; |
1830 | 1830 | ||
1831 | default: | 1831 | default: |
1832 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; | 1832 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; |
1833 | break; | 1833 | break; |
1834 | } | 1834 | } |
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | KListView::SelectionModeExt KListView::selectionModeExt () const | 1837 | KListView::SelectionModeExt KListView::selectionModeExt () const |
1838 | { | 1838 | { |
1839 | return d->selectionMode; | 1839 | return d->selectionMode; |
1840 | } | 1840 | } |
1841 | 1841 | ||
1842 | int KListView::itemIndex( const QListViewItem *item ) const | 1842 | int KListView::itemIndex( const QListViewItem *item ) const |
1843 | { | 1843 | { |
1844 | if ( !item ) | 1844 | if ( !item ) |
1845 | return -1; | 1845 | return -1; |
1846 | 1846 | ||
1847 | if ( item == firstChild() ) | 1847 | if ( item == firstChild() ) |
1848 | return 0; | 1848 | return 0; |
1849 | else { | 1849 | else { |
1850 | QListViewItemIterator it(firstChild()); | 1850 | QListViewItemIterator it(firstChild()); |
1851 | uint j = 0; | 1851 | uint j = 0; |
1852 | for (; it.current() && it.current() != item; ++it, ++j ); | 1852 | for (; it.current() && it.current() != item; ++it, ++j ); |
1853 | 1853 | ||
1854 | if( !it.current() ) | 1854 | if( !it.current() ) |
1855 | return -1; | 1855 | return -1; |
1856 | 1856 | ||
1857 | return j; | 1857 | return j; |
1858 | } | 1858 | } |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | QListViewItem* KListView::itemAtIndex(int index) | 1861 | QListViewItem* KListView::itemAtIndex(int index) |
1862 | { | 1862 | { |
1863 | if (index<0) | 1863 | if (index<0) |
1864 | return 0; | 1864 | return 0; |
1865 | 1865 | ||
1866 | int j(0); | 1866 | int j(0); |
1867 | for (QListViewItemIterator it=firstChild(); it.current(); it++) | 1867 | for (QListViewItemIterator it=firstChild(); it.current(); it++) |
1868 | { | 1868 | { |
1869 | if (j==index) | 1869 | if (j==index) |
1870 | return it.current(); | 1870 | return it.current(); |
1871 | j++; | 1871 | j++; |
1872 | }; | 1872 | }; |
1873 | return 0; | 1873 | return 0; |
1874 | } | 1874 | } |
1875 | 1875 | ||
1876 | 1876 | ||
1877 | void KListView::emitContextMenu (KListView*, QListViewItem* i) | 1877 | void KListView::emitContextMenu (KListView*, QListViewItem* i) |
1878 | { | 1878 | { |
1879 | QPoint p; | 1879 | QPoint p; |
1880 | qDebug("KListView::emitContextMenu "); | 1880 | qDebug("KListView::emitContextMenu "); |
1881 | 1881 | ||
1882 | if (i) | 1882 | if (i) |
1883 | p = viewport()->mapToGlobal(itemRect(i).center()); | 1883 | p = viewport()->mapToGlobal(itemRect(i).center()); |
1884 | else | 1884 | else |
1885 | p = mapToGlobal(rect().center()); | 1885 | p = mapToGlobal(rect().center()); |
1886 | 1886 | ||
1887 | emit contextMenu (this, i, p); | 1887 | emit contextMenu (this, i, p); |
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int) | 1890 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) |
1891 | { | 1891 | { |
1892 | qDebug("KListView::emitContextMenu "); | 1892 | qDebug("KListView::emitContextMenu col"); |
1893 | emit contextMenu (this, i, p); | 1893 | emit contextRequest( i, p, col ); |
1894 | emit contextMenu (this, i, p); | ||
1894 | } | 1895 | } |
1895 | 1896 | ||
1896 | void KListView::setAcceptDrops (bool val) | 1897 | void KListView::setAcceptDrops (bool val) |
1897 | { | 1898 | { |
1898 | QListView::setAcceptDrops (val); | 1899 | QListView::setAcceptDrops (val); |
1899 | viewport()->setAcceptDrops (val); | 1900 | viewport()->setAcceptDrops (val); |
1900 | } | 1901 | } |
1901 | 1902 | ||
1902 | int KListView::dropVisualizerWidth () const | 1903 | int KListView::dropVisualizerWidth () const |
1903 | { | 1904 | { |
1904 | return d->mDropVisualizerWidth; | 1905 | return d->mDropVisualizerWidth; |
1905 | } | 1906 | } |
1906 | 1907 | ||
1907 | 1908 | ||
1908 | void KListView::viewportPaintEvent(QPaintEvent *e) | 1909 | void KListView::viewportPaintEvent(QPaintEvent *e) |
1909 | { | 1910 | { |
1910 | QListView::viewportPaintEvent(e); | 1911 | QListView::viewportPaintEvent(e); |
1911 | 1912 | ||
1912 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) | 1913 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) |
1913 | { | 1914 | { |
1914 | QPainter painter(viewport()); | 1915 | QPainter painter(viewport()); |
1915 | 1916 | ||
1916 | // This is where we actually draw the drop-visualizer | 1917 | // This is where we actually draw the drop-visualizer |
1917 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); | 1918 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); |
1918 | } | 1919 | } |
1919 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) | 1920 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) |
1920 | { | 1921 | { |
1921 | QPainter painter(viewport()); | 1922 | QPainter painter(viewport()); |
1922 | 1923 | ||
1923 | qDebug("KListView::viewportPaintEvent has to be verified"); | 1924 | qDebug("KListView::viewportPaintEvent has to be verified"); |
1924 | 1925 | ||
1925 | // This is where we actually draw the drop-highlighter | 1926 | // This is where we actually draw the drop-highlighter |
1926 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), | 1927 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), |
1927 | //US QStyle::Style_FocusAtBorder); | 1928 | //US QStyle::Style_FocusAtBorder); |
1928 | 1929 | ||
1929 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); | 1930 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); |
1930 | 1931 | ||
1931 | 1932 | ||
1932 | } | 1933 | } |
1933 | } | 1934 | } |
1934 | 1935 | ||
1935 | void KListView::setFullWidth() | 1936 | void KListView::setFullWidth() |
1936 | { | 1937 | { |
1937 | setFullWidth(true); | 1938 | setFullWidth(true); |
1938 | } | 1939 | } |
1939 | 1940 | ||
1940 | void KListView::setFullWidth(bool fullWidth) | 1941 | void KListView::setFullWidth(bool fullWidth) |
1941 | { | 1942 | { |
1942 | d->fullWidth = fullWidth; | 1943 | d->fullWidth = fullWidth; |
1943 | //US header()->setStretchEnabled(fullWidth, columns()-1); | 1944 | //US header()->setStretchEnabled(fullWidth, columns()-1); |
1944 | } | 1945 | } |
1945 | 1946 | ||
1946 | bool KListView::fullWidth() const | 1947 | bool KListView::fullWidth() const |
1947 | { | 1948 | { |
1948 | return d->fullWidth; | 1949 | return d->fullWidth; |
1949 | } | 1950 | } |
1950 | 1951 | ||
1951 | int KListView::addColumn(const QString& label, int width) | 1952 | int KListView::addColumn(const QString& label, int width) |
1952 | { | 1953 | { |
1953 | int result = QListView::addColumn(label, width); | 1954 | int result = QListView::addColumn(label, width); |
1954 | if (d->fullWidth) { | 1955 | if (d->fullWidth) { |
1955 | //US header()->setStretchEnabled(false, columns()-2); | 1956 | //US header()->setStretchEnabled(false, columns()-2); |
1956 | //US header()->setStretchEnabled(true, columns()-1); | 1957 | //US header()->setStretchEnabled(true, columns()-1); |
1957 | } | 1958 | } |
1958 | return result; | 1959 | return result; |
1959 | } | 1960 | } |
1960 | 1961 | ||
1961 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) | 1962 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) |
1962 | { | 1963 | { |
1963 | int result = QListView::addColumn(iconset, label, width); | 1964 | int result = QListView::addColumn(iconset, label, width); |
1964 | if (d->fullWidth) { | 1965 | if (d->fullWidth) { |
1965 | //US header()->setStretchEnabled(false, columns()-2); | 1966 | //US header()->setStretchEnabled(false, columns()-2); |
1966 | //US header()->setStretchEnabled(true, columns()-1); | 1967 | //US header()->setStretchEnabled(true, columns()-1); |
1967 | } | 1968 | } |
1968 | return result; | 1969 | return result; |
1969 | } | 1970 | } |
1970 | 1971 | ||
1971 | void KListView::removeColumn(int index) | 1972 | void KListView::removeColumn(int index) |
1972 | { | 1973 | { |
1973 | QListView::removeColumn(index); | 1974 | QListView::removeColumn(index); |
1974 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); | 1975 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); |
1975 | } | 1976 | } |
1976 | 1977 | ||
1977 | void KListView::viewportResizeEvent(QResizeEvent* e) | 1978 | void KListView::viewportResizeEvent(QResizeEvent* e) |
1978 | { | 1979 | { |
1979 | QListView::viewportResizeEvent(e); | 1980 | QListView::viewportResizeEvent(e); |
1980 | } | 1981 | } |
1981 | 1982 | ||
1982 | const QColor &KListView::alternateBackground() const | 1983 | const QColor &KListView::alternateBackground() const |
1983 | { | 1984 | { |
1984 | return d->alternateBackground; | 1985 | return d->alternateBackground; |
1985 | } | 1986 | } |
1986 | 1987 | ||
1987 | void KListView::setAlternateBackground(const QColor &c) | 1988 | void KListView::setAlternateBackground(const QColor &c) |
1988 | { | 1989 | { |
1989 | d->alternateBackground = c; | 1990 | d->alternateBackground = c; |
1990 | repaint(); | 1991 | repaint(); |
1991 | } | 1992 | } |
1992 | 1993 | ||
1993 | void KListView::saveLayout(KConfig *config, const QString &group) const | 1994 | void KListView::saveLayout(KConfig *config, const QString &group) const |
1994 | { | 1995 | { |
1995 | KConfigGroupSaver saver(config, group); | 1996 | KConfigGroupSaver saver(config, group); |
1996 | QStringList widths, order; | 1997 | QStringList widths, order; |
1997 | for (int i = 0; i < columns(); ++i) | 1998 | for (int i = 0; i < columns(); ++i) |
1998 | { | 1999 | { |
1999 | widths << QString::number(columnWidth(i)); | 2000 | widths << QString::number(columnWidth(i)); |
2000 | order << QString::number(header()->mapToIndex(i)); | 2001 | order << QString::number(header()->mapToIndex(i)); |
2001 | } | 2002 | } |
2002 | config->writeEntry("ColumnWidths", widths); | 2003 | config->writeEntry("ColumnWidths", widths); |
2003 | config->writeEntry("ColumnOrder", order); | 2004 | config->writeEntry("ColumnOrder", order); |
2004 | config->writeEntry("SortColumn", d->sortColumn); | 2005 | config->writeEntry("SortColumn", d->sortColumn); |
2005 | config->writeEntry("SortAscending", d->sortAscending); | 2006 | config->writeEntry("SortAscending", d->sortAscending); |
2006 | } | 2007 | } |
2007 | 2008 | ||
2008 | void KListView::restoreLayout(KConfig *config, const QString &group) | 2009 | void KListView::restoreLayout(KConfig *config, const QString &group) |
2009 | { | 2010 | { |
2010 | KConfigGroupSaver saver(config, group); | 2011 | KConfigGroupSaver saver(config, group); |
2011 | QStringList cols = config->readListEntry("ColumnWidths"); | 2012 | QStringList cols = config->readListEntry("ColumnWidths"); |
2012 | int i = 0; | 2013 | int i = 0; |
2013 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2014 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2014 | setColumnWidth(i++, (*it).toInt()); | 2015 | setColumnWidth(i++, (*it).toInt()); |
2015 | 2016 | ||
2016 | cols = config->readListEntry("ColumnOrder"); | 2017 | cols = config->readListEntry("ColumnOrder"); |
2017 | i = 0; | 2018 | i = 0; |
2018 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2019 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2019 | header()->moveSection(i++, (*it).toInt()); | 2020 | header()->moveSection(i++, (*it).toInt()); |
2020 | 2021 | ||
2021 | /*US I changed the following code, because hasKey is not available. | 2022 | /*US I changed the following code, because hasKey is not available. |
2022 | !!! check if my version is correct | 2023 | !!! check if my version is correct |
2023 | if (config->hasKey("SortColumn")) | 2024 | if (config->hasKey("SortColumn")) |
2024 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2025 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2025 | */ | 2026 | */ |
2026 | QStringList langLst = config->readListEntry( "SortColumn" ); | 2027 | QStringList langLst = config->readListEntry( "SortColumn" ); |
2027 | if (!langLst.isEmpty()) | 2028 | if (!langLst.isEmpty()) |
2028 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2029 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2029 | } | 2030 | } |
2030 | 2031 | ||
2031 | void KListView::setSorting(int column, bool ascending) | 2032 | void KListView::setSorting(int column, bool ascending) |
2032 | { | 2033 | { |
2033 | d->sortColumn = column; | 2034 | d->sortColumn = column; |
2034 | d->sortAscending = ascending; | 2035 | d->sortAscending = ascending; |
2035 | QListView::setSorting(column, ascending); | 2036 | QListView::setSorting(column, ascending); |
2036 | } | 2037 | } |
2037 | 2038 | ||
2038 | int KListView::columnSorted(void) const | 2039 | int KListView::columnSorted(void) const |
2039 | { | 2040 | { |
2040 | return d->sortColumn; | 2041 | return d->sortColumn; |
2041 | } | 2042 | } |
2042 | 2043 | ||
2043 | bool KListView::ascendingSort(void) const | 2044 | bool KListView::ascendingSort(void) const |
2044 | { | 2045 | { |
2045 | return d->sortAscending; | 2046 | return d->sortAscending; |
2046 | } | 2047 | } |
2047 | 2048 | ||
2048 | KListViewItem::KListViewItem(QListView *parent) | 2049 | KListViewItem::KListViewItem(QListView *parent) |
2049 | : QListViewItem(parent) | 2050 | : QListViewItem(parent) |
2050 | { | 2051 | { |
2051 | init(); | 2052 | init(); |
2052 | } | 2053 | } |
2053 | 2054 | ||
2054 | KListViewItem::KListViewItem(QListViewItem *parent) | 2055 | KListViewItem::KListViewItem(QListViewItem *parent) |
2055 | : QListViewItem(parent) | 2056 | : QListViewItem(parent) |
2056 | { | 2057 | { |
2057 | init(); | 2058 | init(); |
2058 | } | 2059 | } |
2059 | 2060 | ||
2060 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) | 2061 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) |
2061 | : QListViewItem(parent, after) | 2062 | : QListViewItem(parent, after) |
2062 | { | 2063 | { |
2063 | init(); | 2064 | init(); |
2064 | } | 2065 | } |
2065 | 2066 | ||
2066 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) | 2067 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) |
2067 | : QListViewItem(parent, after) | 2068 | : QListViewItem(parent, after) |
2068 | { | 2069 | { |
2069 | init(); | 2070 | init(); |
2070 | } | 2071 | } |
2071 | 2072 | ||
2072 | KListViewItem::KListViewItem(QListView *parent, | 2073 | KListViewItem::KListViewItem(QListView *parent, |
2073 | QString label1, QString label2, QString label3, QString label4, | 2074 | QString label1, QString label2, QString label3, QString label4, |
2074 | QString label5, QString label6, QString label7, QString label8) | 2075 | QString label5, QString label6, QString label7, QString label8) |
2075 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2076 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2076 | { | 2077 | { |
2077 | init(); | 2078 | init(); |
2078 | } | 2079 | } |
2079 | 2080 | ||
2080 | KListViewItem::KListViewItem(QListViewItem *parent, | 2081 | KListViewItem::KListViewItem(QListViewItem *parent, |
2081 | QString label1, QString label2, QString label3, QString label4, | 2082 | QString label1, QString label2, QString label3, QString label4, |
2082 | QString label5, QString label6, QString label7, QString label8) | 2083 | QString label5, QString label6, QString label7, QString label8) |
2083 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2084 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2084 | { | 2085 | { |
2085 | init(); | 2086 | init(); |
2086 | } | 2087 | } |
2087 | 2088 | ||
2088 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, | 2089 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, |
2089 | QString label1, QString label2, QString label3, QString label4, | 2090 | QString label1, QString label2, QString label3, QString label4, |
2090 | QString label5, QString label6, QString label7, QString label8) | 2091 | QString label5, QString label6, QString label7, QString label8) |
2091 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2092 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2092 | { | 2093 | { |
2093 | init(); | 2094 | init(); |
2094 | } | 2095 | } |
2095 | 2096 | ||
2096 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, | 2097 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, |
2097 | QString label1, QString label2, QString label3, QString label4, | 2098 | QString label1, QString label2, QString label3, QString label4, |
2098 | QString label5, QString label6, QString label7, QString label8) | 2099 | QString label5, QString label6, QString label7, QString label8) |
2099 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2100 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2100 | { | 2101 | { |
2101 | init(); | 2102 | init(); |
2102 | } | 2103 | } |
2103 | 2104 | ||
2104 | KListViewItem::~KListViewItem() | 2105 | KListViewItem::~KListViewItem() |
2105 | { | 2106 | { |
2106 | } | 2107 | } |
2107 | 2108 | ||
2108 | void KListViewItem::init() | 2109 | void KListViewItem::init() |
2109 | { | 2110 | { |
2110 | m_known = false; | 2111 | m_known = false; |
2111 | } | 2112 | } |
2112 | 2113 | ||
2113 | const QColor &KListViewItem::backgroundColor() | 2114 | const QColor &KListViewItem::backgroundColor() |
2114 | { | 2115 | { |
2115 | if (isAlternate()) | 2116 | if (isAlternate()) |
2116 | return static_cast< KListView* >(listView())->alternateBackground(); | 2117 | return static_cast< KListView* >(listView())->alternateBackground(); |
2117 | return listView()->viewport()->colorGroup().base(); | 2118 | return listView()->viewport()->colorGroup().base(); |
2118 | } | 2119 | } |
2119 | 2120 | ||
2120 | bool KListViewItem::isAlternate() | 2121 | bool KListViewItem::isAlternate() |
2121 | { | 2122 | { |
2122 | KListView *lv = static_cast<KListView *>(listView()); | 2123 | KListView *lv = static_cast<KListView *>(listView()); |
2123 | if (lv && lv->alternateBackground().isValid()) | 2124 | if (lv && lv->alternateBackground().isValid()) |
2124 | { | 2125 | { |
2125 | KListViewItem *above = 0; | 2126 | KListViewItem *above = 0; |
2126 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); | 2127 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); |
2127 | above = (KListViewItem *)(itemAbove()); | 2128 | above = (KListViewItem *)(itemAbove()); |
2128 | m_known = above ? above->m_known : true; | 2129 | m_known = above ? above->m_known : true; |
2129 | if (m_known) | 2130 | if (m_known) |
2130 | { | 2131 | { |
2131 | m_odd = above ? !above->m_odd : false; | 2132 | m_odd = above ? !above->m_odd : false; |
2132 | } | 2133 | } |
2133 | else | 2134 | else |
2134 | { | 2135 | { |
2135 | KListViewItem *item; | 2136 | KListViewItem *item; |
2136 | bool previous = true; | 2137 | bool previous = true; |
2137 | if (parent()) | 2138 | if (parent()) |
2138 | { | 2139 | { |
2139 | //US item = dynamic_cast<KListViewItem *>(parent()); | 2140 | //US item = dynamic_cast<KListViewItem *>(parent()); |
2140 | item = (KListViewItem *)(parent()); | 2141 | item = (KListViewItem *)(parent()); |
2141 | if (item) | 2142 | if (item) |
2142 | previous = item->m_odd; | 2143 | previous = item->m_odd; |
2143 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); | 2144 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); |
2144 | item = (KListViewItem *)(parent()->firstChild()); | 2145 | item = (KListViewItem *)(parent()->firstChild()); |
2145 | } | 2146 | } |
2146 | else | 2147 | else |
2147 | { | 2148 | { |
2148 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); | 2149 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); |
2149 | item = (KListViewItem *)(lv->firstChild()); | 2150 | item = (KListViewItem *)(lv->firstChild()); |
2150 | } | 2151 | } |
2151 | 2152 | ||
2152 | while(item) | 2153 | while(item) |
2153 | { | 2154 | { |
2154 | item->m_odd = previous = !previous; | 2155 | item->m_odd = previous = !previous; |
2155 | item->m_known = true; | 2156 | item->m_known = true; |
2156 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); | 2157 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); |
2157 | item = (KListViewItem *)(item->nextSibling()); | 2158 | item = (KListViewItem *)(item->nextSibling()); |
2158 | } | 2159 | } |
2159 | } | 2160 | } |
2160 | return m_odd; | 2161 | return m_odd; |
2161 | } | 2162 | } |
2162 | return false; | 2163 | return false; |
2163 | } | 2164 | } |
2164 | 2165 | ||
2165 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 2166 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
2166 | { | 2167 | { |
2167 | QColorGroup _cg = cg; | 2168 | QColorGroup _cg = cg; |
2168 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 2169 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
2169 | if (pm && !pm->isNull()) | 2170 | if (pm && !pm->isNull()) |
2170 | { | 2171 | { |
2171 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 2172 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
2172 | QPoint o = p->brushOrigin(); | 2173 | QPoint o = p->brushOrigin(); |
2173 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); | 2174 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); |
2174 | } | 2175 | } |
2175 | else if (isAlternate()) { | 2176 | else if (isAlternate()) { |
2176 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) | 2177 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) |
2177 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) | 2178 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) |
2178 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); | 2179 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); |
2179 | else | 2180 | else |
2180 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); | 2181 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); |
2181 | } | 2182 | } |
2182 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 2183 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
2183 | } | 2184 | } |
2184 | 2185 | ||
2185 | void KListView::virtual_hook( int, void* ) | 2186 | void KListView::virtual_hook( int, void* ) |
2186 | { /*BASE::virtual_hook( id, data );*/ } | 2187 | { /*BASE::virtual_hook( id, data );*/ } |
2187 | 2188 | ||
2188 | //US #include "klistview.moc" | 2189 | //US #include "klistview.moc" |
2189 | //US #include "klistviewlineedit.moc" | 2190 | //US #include "klistviewlineedit.moc" |
2190 | 2191 | ||
2191 | // vim: ts=2 sw=2 et | 2192 | // vim: ts=2 sw=2 et |
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h index f7d9f85..8d933f6 100644 --- a/microkde/kdeui/klistview.h +++ b/microkde/kdeui/klistview.h | |||
@@ -1,1033 +1,1034 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> |
3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> | 3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> |
4 | Copyright (C) 2000 Peter Putzer <putzer@kde.org> | 4 | Copyright (C) 2000 Peter Putzer <putzer@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 version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
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 KLISTVIEW_H | 20 | #ifndef KLISTVIEW_H |
21 | #define KLISTVIEW_H | 21 | #define KLISTVIEW_H |
22 | 22 | ||
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | 24 | ||
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | //US | 27 | //US |
28 | class QDropEvent; | 28 | class QDropEvent; |
29 | class QDragLeaveEvent; | 29 | class QDragLeaveEvent; |
30 | class QDragMoveEvent; | 30 | class QDragMoveEvent; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | 32 | ||
33 | class QDragObject; | 33 | class QDragObject; |
34 | class KConfig; | 34 | class KConfig; |
35 | class KLineEdit; | 35 | class KLineEdit; |
36 | /** | 36 | /** |
37 | * This Widget extends the functionality of QListView to honor the system | 37 | * This Widget extends the functionality of QListView to honor the system |
38 | * wide settings for Single Click/Double Click mode, AutoSelection and | 38 | * wide settings for Single Click/Double Click mode, AutoSelection and |
39 | * ChangeCursorOverLink (TM). | 39 | * ChangeCursorOverLink (TM). |
40 | * | 40 | * |
41 | * There is a new signal executed(). It gets connected to either | 41 | * There is a new signal executed(). It gets connected to either |
42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE | 42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE |
43 | * wide Single Click/Double Click settings. It is strongly recommended that | 43 | * wide Single Click/Double Click settings. It is strongly recommended that |
44 | * you use this signal instead of the above mentioned. This way you dont | 44 | * you use this signal instead of the above mentioned. This way you dont |
45 | * need to care about the current settings. | 45 | * need to care about the current settings. |
46 | * If you want to get informed when the user selects something connect to the | 46 | * If you want to get informed when the user selects something connect to the |
47 | * QListView::selectionChanged() signal. | 47 | * QListView::selectionChanged() signal. |
48 | * | 48 | * |
49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) | 49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) |
50 | * and connect it to a suitable slot. | 50 | * and connect it to a suitable slot. |
51 | * To see where you are dropping, @ref setDropVisualizer(true). | 51 | * To see where you are dropping, @ref setDropVisualizer(true). |
52 | * And also you'll need @ref acceptDrag(QDropEvent*) | 52 | * And also you'll need @ref acceptDrag(QDropEvent*) |
53 | * | 53 | * |
54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. | 54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. |
55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), | 55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), |
56 | * and @ref setDragEnabled(true). | 56 | * and @ref setDragEnabled(true). |
57 | * | 57 | * |
58 | * @version $Id$ | 58 | * @version $Id$ |
59 | */ | 59 | */ |
60 | class KListView : public QListView | 60 | class KListView : public QListView |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | Q_ENUMS( SelectionModeExt ) | 63 | Q_ENUMS( SelectionModeExt ) |
64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) | 64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) |
65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) | 65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) |
66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) | 66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) |
67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) | 67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) |
68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) | 68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) |
69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) | 69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) |
70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) | 70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) |
71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) | 71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) |
72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) | 72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) |
73 | 73 | ||
74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) | 74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) |
75 | 75 | ||
76 | public: | 76 | public: |
77 | /** | 77 | /** |
78 | * Possible selection modes. | 78 | * Possible selection modes. |
79 | * | 79 | * |
80 | * The first four correspond directly to QListView::SelectionMode, while | 80 | * The first four correspond directly to QListView::SelectionMode, while |
81 | * the FileManager selection mode is defined as follows: | 81 | * the FileManager selection mode is defined as follows: |
82 | * @li home: move to the first | 82 | * @li home: move to the first |
83 | * @li end: move to the last | 83 | * @li end: move to the last |
84 | * @li PgUp/PgDn: move one page up/down | 84 | * @li PgUp/PgDn: move one page up/down |
85 | * @li up/down: move one item up/down | 85 | * @li up/down: move one item up/down |
86 | * @li insert: toggle selection of current and move to the next | 86 | * @li insert: toggle selection of current and move to the next |
87 | * @li space: toggle selection of the current | 87 | * @li space: toggle selection of the current |
88 | * @li CTRL+up: move to the previous item and toggle selection of this one | 88 | * @li CTRL+up: move to the previous item and toggle selection of this one |
89 | * @li CTRL+down: toggle selection of the current item and move to the next | 89 | * @li CTRL+down: toggle selection of the current item and move to the next |
90 | * @li CTRL+end: toggle selection from (including) the current | 90 | * @li CTRL+end: toggle selection from (including) the current |
91 | * item to (including) the last item | 91 | * item to (including) the last item |
92 | * @li CTRL+home: toggle selection from (including) the current | 92 | * @li CTRL+home: toggle selection from (including) the current |
93 | * item to the (including) the first item | 93 | * item to the (including) the first item |
94 | * @li CTRL+PgDn: toggle selection from (including) the current | 94 | * @li CTRL+PgDn: toggle selection from (including) the current |
95 | * item to (excluding) the item one page down | 95 | * item to (excluding) the item one page down |
96 | * @li CTRL+PgUp: toggle selection from (excluding) the current | 96 | * @li CTRL+PgUp: toggle selection from (excluding) the current |
97 | * item to (including) the item one page up | 97 | * item to (including) the item one page up |
98 | * | 98 | * |
99 | * The combinations work the same with SHIFT instead of CTRL, except | 99 | * The combinations work the same with SHIFT instead of CTRL, except |
100 | * that if you start selecting something using SHIFT everything selected | 100 | * that if you start selecting something using SHIFT everything selected |
101 | * before will be deselected first. | 101 | * before will be deselected first. |
102 | * | 102 | * |
103 | * Additionally the current item is always selected automatically when | 103 | * Additionally the current item is always selected automatically when |
104 | * navigating using the keyboard, except other items were selected explicitely. | 104 | * navigating using the keyboard, except other items were selected explicitely. |
105 | * | 105 | * |
106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected | 106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected |
107 | */ | 107 | */ |
108 | enum SelectionModeExt { | 108 | enum SelectionModeExt { |
109 | Single = QListView::Single, | 109 | Single = QListView::Single, |
110 | Multi = QListView::Multi, | 110 | Multi = QListView::Multi, |
111 | Extended = QListView::Extended, | 111 | Extended = QListView::Extended, |
112 | NoSelection = QListView::NoSelection, | 112 | NoSelection = QListView::NoSelection, |
113 | FileManager | 113 | FileManager |
114 | }; | 114 | }; |
115 | void repaintContents( bool erase = true ) | 115 | void repaintContents( bool erase = true ) |
116 | { | 116 | { |
117 | QScrollView::repaintContents( contentsX(), contentsY(), | 117 | QScrollView::repaintContents( contentsX(), contentsY(), |
118 | visibleWidth(), visibleHeight(), erase ); | 118 | visibleWidth(), visibleHeight(), erase ); |
119 | }; | 119 | }; |
120 | /** | 120 | /** |
121 | * Constructor. | 121 | * Constructor. |
122 | * | 122 | * |
123 | * The parameters @p parent and @p name are handled by | 123 | * The parameters @p parent and @p name are handled by |
124 | * @ref QListView, as usual. | 124 | * @ref QListView, as usual. |
125 | */ | 125 | */ |
126 | KListView (QWidget *parent = 0, const char *name = 0); | 126 | KListView (QWidget *parent = 0, const char *name = 0); |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Destructor. | 129 | * Destructor. |
130 | */ | 130 | */ |
131 | virtual ~KListView(); | 131 | virtual ~KListView(); |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * Reimplemented for internal reasons. | 134 | * Reimplemented for internal reasons. |
135 | * Further reimplementations should call this function or else | 135 | * Further reimplementations should call this function or else |
136 | * some features may not work correctly. | 136 | * some features may not work correctly. |
137 | * | 137 | * |
138 | * The API is unaffected. | 138 | * The API is unaffected. |
139 | */ | 139 | */ |
140 | virtual void setAcceptDrops (bool); | 140 | virtual void setAcceptDrops (bool); |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * This function determines whether the given coordinates are within the | 143 | * This function determines whether the given coordinates are within the |
144 | * execute area. The execute area is the part of a @ref QListViewItem where mouse | 144 | * execute area. The execute area is the part of a @ref QListViewItem where mouse |
145 | * clicks or double clicks respectively generate a @ref #executed() signal. | 145 | * clicks or double clicks respectively generate a @ref #executed() signal. |
146 | * Depending on @ref QListView::allColumnsShowFocus() this is either the | 146 | * Depending on @ref QListView::allColumnsShowFocus() this is either the |
147 | * whole item or only the first column. | 147 | * whole item or only the first column. |
148 | * @return true if point is inside execute area of an item, false in all | 148 | * @return true if point is inside execute area of an item, false in all |
149 | * other cases including the case that it is over the viewport. | 149 | * other cases including the case that it is over the viewport. |
150 | */ | 150 | */ |
151 | virtual bool isExecuteArea( const QPoint& point ); | 151 | virtual bool isExecuteArea( const QPoint& point ); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Same thing, but from an x coordinate only. This only checks if x is in | 154 | * Same thing, but from an x coordinate only. This only checks if x is in |
155 | * the first column (if all columns don't show focus), without testing if | 155 | * the first column (if all columns don't show focus), without testing if |
156 | * the y coordinate is over an item or not. | 156 | * the y coordinate is over an item or not. |
157 | */ | 157 | */ |
158 | bool isExecuteArea( int x ); | 158 | bool isExecuteArea( int x ); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * @return a list containing the currently selected items. | 161 | * @return a list containing the currently selected items. |
162 | */ | 162 | */ |
163 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) | 163 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. | 166 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. |
167 | */ | 167 | */ |
168 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); | 168 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * @return the last item (not child!) of this listview. | 171 | * @return the last item (not child!) of this listview. |
172 | * | 172 | * |
173 | * @see lastChild() | 173 | * @see lastChild() |
174 | */ | 174 | */ |
175 | QListViewItem *lastItem() const; | 175 | QListViewItem *lastItem() const; |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * @return the last child of this listview. | 178 | * @return the last child of this listview. |
179 | * | 179 | * |
180 | * @see lastItem() | 180 | * @see lastItem() |
181 | */ | 181 | */ |
182 | QListViewItem* lastChild () const; | 182 | QListViewItem* lastChild () const; |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * @return the lineedit used for inline renaming. | 185 | * @return the lineedit used for inline renaming. |
186 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit | 186 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit |
187 | * | 187 | * |
188 | * @since 3.2 | 188 | * @since 3.2 |
189 | */ | 189 | */ |
190 | KLineEdit* renameLineEdit() const; | 190 | KLineEdit* renameLineEdit() const; |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * @returns if it is legal to move items in the list view. True by default. | 193 | * @returns if it is legal to move items in the list view. True by default. |
194 | * | 194 | * |
195 | * @see #setDragEnabled() | 195 | * @see #setDragEnabled() |
196 | * @see #setItemsMovable() | 196 | * @see #setItemsMovable() |
197 | */ | 197 | */ |
198 | bool itemsMovable() const; | 198 | bool itemsMovable() const; |
199 | 199 | ||
200 | /** | 200 | /** |
201 | * @return whether inplace-renaming has been enabled. False by default. | 201 | * @return whether inplace-renaming has been enabled. False by default. |
202 | * | 202 | * |
203 | * @see #setItemsRenameable() | 203 | * @see #setItemsRenameable() |
204 | */ | 204 | */ |
205 | bool itemsRenameable() const; | 205 | bool itemsRenameable() const; |
206 | 206 | ||
207 | /** | 207 | /** |
208 | * @return whether dragging is enabled. False by default. | 208 | * @return whether dragging is enabled. False by default. |
209 | * | 209 | * |
210 | * @see #setDragEnabled() | 210 | * @see #setDragEnabled() |
211 | */ | 211 | */ |
212 | bool dragEnabled() const; | 212 | bool dragEnabled() const; |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * @return true if AutoOpen is enabled (not implemented currently). | 215 | * @return true if AutoOpen is enabled (not implemented currently). |
216 | * | 216 | * |
217 | * @see #setAutoOpen() | 217 | * @see #setAutoOpen() |
218 | */ | 218 | */ |
219 | bool autoOpen() const; | 219 | bool autoOpen() const; |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * @return true if @p column is renamable. | 222 | * @return true if @p column is renamable. |
223 | * | 223 | * |
224 | * @see #setRenameable() | 224 | * @see #setRenameable() |
225 | */ | 225 | */ |
226 | bool isRenameable (int column) const; | 226 | bool isRenameable (int column) const; |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * @return true if drawing of the drop-visualizer has been enabled. True by default. | 229 | * @return true if drawing of the drop-visualizer has been enabled. True by default. |
230 | * | 230 | * |
231 | * @see #setDropVisualizer() | 231 | * @see #setDropVisualizer() |
232 | */ | 232 | */ |
233 | bool dropVisualizer() const; | 233 | bool dropVisualizer() const; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * @return the column for which tooltips are displayed (or -1 if none set). | 236 | * @return the column for which tooltips are displayed (or -1 if none set). |
237 | * | 237 | * |
238 | * @see #setTooltipColumn() | 238 | * @see #setTooltipColumn() |
239 | */ | 239 | */ |
240 | int tooltipColumn() const; | 240 | int tooltipColumn() const; |
241 | 241 | ||
242 | /** | 242 | /** |
243 | * For future expansions. | 243 | * For future expansions. |
244 | * | 244 | * |
245 | * Do not use. | 245 | * Do not use. |
246 | * @deprecated | 246 | * @deprecated |
247 | */ | 247 | */ |
248 | bool createChildren() const; | 248 | bool createChildren() const; |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * @return true if drawing of the drop-highlighter has been enabled. False by default. | 251 | * @return true if drawing of the drop-highlighter has been enabled. False by default. |
252 | * | 252 | * |
253 | * @see #setDropHighlighter() | 253 | * @see #setDropHighlighter() |
254 | */ | 254 | */ |
255 | bool dropHighlighter() const; | 255 | bool dropHighlighter() const; |
256 | 256 | ||
257 | /** | 257 | /** |
258 | * The dropVisualizerWidth defaults to 4. | 258 | * The dropVisualizerWidth defaults to 4. |
259 | * | 259 | * |
260 | * @see #setDropVisualizerWidth() | 260 | * @see #setDropVisualizerWidth() |
261 | * @return the current width of the drop-visualizer. | 261 | * @return the current width of the drop-visualizer. |
262 | */ | 262 | */ |
263 | int dropVisualizerWidth () const; | 263 | int dropVisualizerWidth () const; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * @return the "extended" selection mode of this listview. | 266 | * @return the "extended" selection mode of this listview. |
267 | * | 267 | * |
268 | * @see SelectionModeExt | 268 | * @see SelectionModeExt |
269 | * @see setSelectionModeExt | 269 | * @see setSelectionModeExt |
270 | */ | 270 | */ |
271 | SelectionModeExt selectionModeExt () const; | 271 | SelectionModeExt selectionModeExt () const; |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * Returns the index of @p item within the item tree or -1 if | 274 | * Returns the index of @p item within the item tree or -1 if |
275 | * @p item doesn't exist in this list view. This function takes | 275 | * @p item doesn't exist in this list view. This function takes |
276 | * all items into account not only the visible ones. | 276 | * all items into account not only the visible ones. |
277 | */ | 277 | */ |
278 | int itemIndex( const QListViewItem *item ) const; | 278 | int itemIndex( const QListViewItem *item ) const; |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Returns the item of @p index within the item tree or 0 if | 281 | * Returns the item of @p index within the item tree or 0 if |
282 | * @p index doesn't exist in this list view. This function takes | 282 | * @p index doesn't exist in this list view. This function takes |
283 | * all items into account not only the visible ones. | 283 | * all items into account not only the visible ones. |
284 | */ | 284 | */ |
285 | QListViewItem* itemAtIndex(int index); | 285 | QListViewItem* itemAtIndex(int index); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | * @deprecated | 288 | * @deprecated |
289 | * @see #setFullWidth() | 289 | * @see #setFullWidth() |
290 | */ | 290 | */ |
291 | void setFullWidth(); | 291 | void setFullWidth(); |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * Let the last column fit exactly all the available width. | 294 | * Let the last column fit exactly all the available width. |
295 | * | 295 | * |
296 | * @see #fullWidth() | 296 | * @see #fullWidth() |
297 | */ | 297 | */ |
298 | void setFullWidth(bool fullWidth); | 298 | void setFullWidth(bool fullWidth); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * Returns whether the last column is set to fit the available width. | 301 | * Returns whether the last column is set to fit the available width. |
302 | * | 302 | * |
303 | * @see #setFullWidth() | 303 | * @see #setFullWidth() |
304 | */ | 304 | */ |
305 | bool fullWidth() const; | 305 | bool fullWidth() const; |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Reimplemented for full width support | 308 | * Reimplemented for full width support |
309 | * | 309 | * |
310 | * @see #removeColumn() | 310 | * @see #removeColumn() |
311 | */ | 311 | */ |
312 | virtual int addColumn(const QString& label, int width = -1); | 312 | virtual int addColumn(const QString& label, int width = -1); |
313 | /** | 313 | /** |
314 | * Reimplemented for full width support | 314 | * Reimplemented for full width support |
315 | */ | 315 | */ |
316 | virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); | 316 | virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); |
317 | /** | 317 | /** |
318 | * Reimplemented for full width support | 318 | * Reimplemented for full width support |
319 | * | 319 | * |
320 | * @see #addColumn() | 320 | * @see #addColumn() |
321 | */ | 321 | */ |
322 | virtual void removeColumn(int index); | 322 | virtual void removeColumn(int index); |
323 | 323 | ||
324 | /** | 324 | /** |
325 | * sets the alternate background background color. | 325 | * sets the alternate background background color. |
326 | * This only has an effect if the items are KListViewItems | 326 | * This only has an effect if the items are KListViewItems |
327 | * | 327 | * |
328 | * @param c the color to use for every other item. Set to an invalid | 328 | * @param c the color to use for every other item. Set to an invalid |
329 | * colour to disable alternate colours. | 329 | * colour to disable alternate colours. |
330 | * | 330 | * |
331 | * @see #alternateBackground() | 331 | * @see #alternateBackground() |
332 | **/ | 332 | **/ |
333 | void setAlternateBackground(const QColor &c); | 333 | void setAlternateBackground(const QColor &c); |
334 | /** | 334 | /** |
335 | * @return the alternate background color | 335 | * @return the alternate background color |
336 | * | 336 | * |
337 | * @see #setAlternateBackground() | 337 | * @see #setAlternateBackground() |
338 | */ | 338 | */ |
339 | const QColor &alternateBackground() const; | 339 | const QColor &alternateBackground() const; |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * Saves the list view's layout (column widtsh, column order, sort column) | 342 | * Saves the list view's layout (column widtsh, column order, sort column) |
343 | * to a KConfig group | 343 | * to a KConfig group |
344 | * | 344 | * |
345 | * @param config the @ref KConfig object to write to | 345 | * @param config the @ref KConfig object to write to |
346 | * @param group the config group to use | 346 | * @param group the config group to use |
347 | */ | 347 | */ |
348 | void saveLayout(KConfig *config, const QString &group) const; | 348 | void saveLayout(KConfig *config, const QString &group) const; |
349 | /** | 349 | /** |
350 | * Reads the list view's layout from a KConfig group as stored with | 350 | * Reads the list view's layout from a KConfig group as stored with |
351 | * @ref #saveLayout | 351 | * @ref #saveLayout |
352 | * | 352 | * |
353 | * @param config the @ref KConfig object to read from | 353 | * @param config the @ref KConfig object to read from |
354 | * @param group the config group to use | 354 | * @param group the config group to use |
355 | */ | 355 | */ |
356 | void restoreLayout(KConfig *config, const QString &group); | 356 | void restoreLayout(KConfig *config, const QString &group); |
357 | /** | 357 | /** |
358 | * Reimplemented to remember the current sort column and order. | 358 | * Reimplemented to remember the current sort column and order. |
359 | * @param column is the column to be sorted, or -1 to sort in order of | 359 | * @param column is the column to be sorted, or -1 to sort in order of |
360 | * insertion | 360 | * insertion |
361 | * @param whether to sort ascending (or descending) | 361 | * @param whether to sort ascending (or descending) |
362 | */ | 362 | */ |
363 | virtual void setSorting(int column, bool ascending = true); | 363 | virtual void setSorting(int column, bool ascending = true); |
364 | 364 | ||
365 | /** | 365 | /** |
366 | * @return the currently sorted column, or -1 if none is sorted | 366 | * @return the currently sorted column, or -1 if none is sorted |
367 | */ | 367 | */ |
368 | int columnSorted(void) const; | 368 | int columnSorted(void) const; |
369 | 369 | ||
370 | /** | 370 | /** |
371 | * @return whether the current sort is ascending (or descending) | 371 | * @return whether the current sort is ascending (or descending) |
372 | */ | 372 | */ |
373 | bool ascendingSort(void) const; | 373 | bool ascendingSort(void) const; |
374 | 374 | ||
375 | signals: | 375 | signals: |
376 | 376 | ||
377 | /** | 377 | /** |
378 | * This signal is emitted whenever the user executes an listview item. | 378 | * This signal is emitted whenever the user executes an listview item. |
379 | * That means depending on the KDE wide Single Click/Double Click | 379 | * That means depending on the KDE wide Single Click/Double Click |
380 | * setting the user clicked or double clicked on that item. | 380 | * setting the user clicked or double clicked on that item. |
381 | * @param item is the pointer to the executed listview item. | 381 | * @param item is the pointer to the executed listview item. |
382 | * | 382 | * |
383 | * Note that you may not delete any @ref QListViewItem objects in slots | 383 | * Note that you may not delete any @ref QListViewItem objects in slots |
384 | * connected to this signal. | 384 | * connected to this signal. |
385 | */ | 385 | */ |
386 | void executed( QListViewItem *item ); | 386 | void executed( QListViewItem *item ); |
387 | 387 | ||
388 | /** | 388 | /** |
389 | * This signal is emitted whenever the user executes an listview item. | 389 | * This signal is emitted whenever the user executes an listview item. |
390 | * That means depending on the KDE wide Single Click/Double Click | 390 | * That means depending on the KDE wide Single Click/Double Click |
391 | * setting the user clicked or double clicked on that item. | 391 | * setting the user clicked or double clicked on that item. |
392 | * @param item is the pointer to the executed listview item. | 392 | * @param item is the pointer to the executed listview item. |
393 | * @param pos is the position where the user has clicked | 393 | * @param pos is the position where the user has clicked |
394 | * @param c is the column into which the user clicked. | 394 | * @param c is the column into which the user clicked. |
395 | * | 395 | * |
396 | * Note that you may not delete any @ref QListViewItem objects in slots | 396 | * Note that you may not delete any @ref QListViewItem objects in slots |
397 | * connected to this signal. | 397 | * connected to this signal. |
398 | */ | 398 | */ |
399 | void executed( QListViewItem *item, const QPoint &pos, int c ); | 399 | void executed( QListViewItem *item, const QPoint &pos, int c ); |
400 | 400 | ||
401 | /** | 401 | /** |
402 | * This signal gets emitted whenever the user double clicks into the | 402 | * This signal gets emitted whenever the user double clicks into the |
403 | * listview. | 403 | * listview. |
404 | * @param item is the pointer to the clicked listview item. | 404 | * @param item is the pointer to the clicked listview item. |
405 | * @param pos is the position where the user has clicked, and | 405 | * @param pos is the position where the user has clicked, and |
406 | * @param c is the column into which the user clicked. | 406 | * @param c is the column into which the user clicked. |
407 | * | 407 | * |
408 | * Note that you may not delete any @ref QListViewItem objects in slots | 408 | * Note that you may not delete any @ref QListViewItem objects in slots |
409 | * connected to this signal. | 409 | * connected to this signal. |
410 | * | 410 | * |
411 | * This signal is more or less here for the sake of completeness. | 411 | * This signal is more or less here for the sake of completeness. |
412 | * You should normally not need to use this. In most cases its better | 412 | * You should normally not need to use this. In most cases its better |
413 | * to use @ref #executed() instead. | 413 | * to use @ref #executed() instead. |
414 | */ | 414 | */ |
415 | void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); | 415 | void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); |
416 | void contextRequest( QListViewItem *item, const QPoint &pos, int c ); | ||
416 | 417 | ||
417 | /** | 418 | /** |
418 | * This signal gets emitted whenever something acceptable is | 419 | * This signal gets emitted whenever something acceptable is |
419 | * dropped onto the listview. | 420 | * dropped onto the listview. |
420 | * | 421 | * |
421 | * @param e is the drop event itself (it has already been accepted) | 422 | * @param e is the drop event itself (it has already been accepted) |
422 | * @param after is the item after which the drop occured (or 0L, if | 423 | * @param after is the item after which the drop occured (or 0L, if |
423 | * the drop was above all items) | 424 | * the drop was above all items) |
424 | * | 425 | * |
425 | * @see #acceptDrop() | 426 | * @see #acceptDrop() |
426 | */ | 427 | */ |
427 | void dropped (QDropEvent * e, QListViewItem *after); | 428 | void dropped (QDropEvent * e, QListViewItem *after); |
428 | 429 | ||
429 | /** | 430 | /** |
430 | * This signal gets emitted whenever something acceptable is | 431 | * This signal gets emitted whenever something acceptable is |
431 | * dropped onto the listview. | 432 | * dropped onto the listview. |
432 | * | 433 | * |
433 | * This is an overloaded version of the above (provided to simplify | 434 | * This is an overloaded version of the above (provided to simplify |
434 | * processing drops outside of the class). | 435 | * processing drops outside of the class). |
435 | * | 436 | * |
436 | * @param list is the listview | 437 | * @param list is the listview |
437 | * @param e is the drop event itself (it has already been accepted) | 438 | * @param e is the drop event itself (it has already been accepted) |
438 | * @param after is the item after which the drop occured (or 0L, if | 439 | * @param after is the item after which the drop occured (or 0L, if |
439 | * the drop was above all items | 440 | * the drop was above all items |
440 | */ | 441 | */ |
441 | void dropped (KListView* list, QDropEvent* e, QListViewItem* after); | 442 | void dropped (KListView* list, QDropEvent* e, QListViewItem* after); |
442 | 443 | ||
443 | /** | 444 | /** |
444 | * This signal gets emitted whenever something acceptable is | 445 | * This signal gets emitted whenever something acceptable is |
445 | * dropped onto the listview. | 446 | * dropped onto the listview. |
446 | * | 447 | * |
447 | * This function also provides a parent, in the event that your listview | 448 | * This function also provides a parent, in the event that your listview |
448 | * is a tree | 449 | * is a tree |
449 | * @param list is the listview | 450 | * @param list is the listview |
450 | * @param e is the drop event itself (it has already been accepted) | 451 | * @param e is the drop event itself (it has already been accepted) |
451 | * @param parent the item that is to be the parent of the new item | 452 | * @param parent the item that is to be the parent of the new item |
452 | * @param after is the item after which the drop occured (or 0L, if | 453 | * @param after is the item after which the drop occured (or 0L, if |
453 | * the drop was above all items | 454 | * the drop was above all items |
454 | */ | 455 | */ |
455 | void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); | 456 | void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); |
456 | 457 | ||
457 | /** | 458 | /** |
458 | * This signal gets emitted whenever something acceptable is | 459 | * This signal gets emitted whenever something acceptable is |
459 | * dropped onto the listview. | 460 | * dropped onto the listview. |
460 | * | 461 | * |
461 | * This function also provides a parent, in the event that your listview | 462 | * This function also provides a parent, in the event that your listview |
462 | * is a tree | 463 | * is a tree |
463 | * @param e is the drop event itself (it has already been accepted) | 464 | * @param e is the drop event itself (it has already been accepted) |
464 | * @param parent the item that is to be the parent of the new item | 465 | * @param parent the item that is to be the parent of the new item |
465 | * @param after is the item after which the drop occured (or 0L, if | 466 | * @param after is the item after which the drop occured (or 0L, if |
466 | * the drop was above all items | 467 | * the drop was above all items |
467 | */ | 468 | */ |
468 | void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); | 469 | void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); |
469 | 470 | ||
470 | /** | 471 | /** |
471 | * This signal is emitted when ever the user moves an item in the list via | 472 | * This signal is emitted when ever the user moves an item in the list via |
472 | * DnD. | 473 | * DnD. |
473 | * If more than one item is moved at the same time, this signal is only emitted | 474 | * If more than one item is moved at the same time, this signal is only emitted |
474 | * once. | 475 | * once. |
475 | */ | 476 | */ |
476 | void moved(); | 477 | void moved(); |
477 | 478 | ||
478 | /** | 479 | /** |
479 | * Connect to this signal if you want to do some preprocessing before | 480 | * Connect to this signal if you want to do some preprocessing before |
480 | * a move is made, for example, to disable sorting | 481 | * a move is made, for example, to disable sorting |
481 | * | 482 | * |
482 | * This is sent only once per each groups of moves. That is, for each | 483 | * This is sent only once per each groups of moves. That is, for each |
483 | * drop that is a move this will be emitted once, before KListView calls | 484 | * drop that is a move this will be emitted once, before KListView calls |
484 | * @see moveItem() | 485 | * @see moveItem() |
485 | */ | 486 | */ |
486 | void aboutToMove(); | 487 | void aboutToMove(); |
487 | 488 | ||
488 | /** | 489 | /** |
489 | * This signal is emitted when ever the user moves an item in the list via | 490 | * This signal is emitted when ever the user moves an item in the list via |
490 | * DnD. | 491 | * DnD. |
491 | * If more than one item is moved at the same time, @p afterFirst and | 492 | * If more than one item is moved at the same time, @p afterFirst and |
492 | * @p afterNow will reflect what was true before the move. | 493 | * @p afterNow will reflect what was true before the move. |
493 | * This differs from @ref moved(), so be careful. All the items will have been | 494 | * This differs from @ref moved(), so be careful. All the items will have been |
494 | * moved before @ref moved() is emitted, which is not true in this method. // FIXME | 495 | * moved before @ref moved() is emitted, which is not true in this method. // FIXME |
495 | * @param item the item that was moved | 496 | * @param item the item that was moved |
496 | * @param afterFirst the item that parameter item was in before the move, in the list | 497 | * @param afterFirst the item that parameter item was in before the move, in the list |
497 | * @param afterNow the item it's currently after. | 498 | * @param afterNow the item it's currently after. |
498 | */ | 499 | */ |
499 | void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); | 500 | void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); |
500 | 501 | ||
501 | 502 | ||
502 | /** | 503 | /** |
503 | * This signal is emitted after all the items have been moved. It reports info for | 504 | * This signal is emitted after all the items have been moved. It reports info for |
504 | * each and every item moved, in order. The first element in @p items associates | 505 | * each and every item moved, in order. The first element in @p items associates |
505 | * with the first of afterFirst and afterNow. | 506 | * with the first of afterFirst and afterNow. |
506 | */ | 507 | */ |
507 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); | 508 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); |
508 | 509 | ||
509 | /** | 510 | /** |
510 | * This signal gets emitted when an item is renamed via in-place renaming. | 511 | * This signal gets emitted when an item is renamed via in-place renaming. |
511 | * | 512 | * |
512 | * @param item is the renamed item. | 513 | * @param item is the renamed item. |
513 | * @param str is the new value of column @p col. | 514 | * @param str is the new value of column @p col. |
514 | * @param col is the renamed column. | 515 | * @param col is the renamed column. |
515 | */ | 516 | */ |
516 | void itemRenamed(QListViewItem* item, const QString &str, int col); | 517 | void itemRenamed(QListViewItem* item, const QString &str, int col); |
517 | 518 | ||
518 | /** | 519 | /** |
519 | * Same as above, but without the extra information. | 520 | * Same as above, but without the extra information. |
520 | */ | 521 | */ |
521 | void itemRenamed(QListViewItem* item); | 522 | void itemRenamed(QListViewItem* item); |
522 | void signalDelete(); | 523 | void signalDelete(); |
523 | 524 | ||
524 | /** | 525 | /** |
525 | * This signal is emitted when the shortcut key for popup-menus is pressed. | 526 | * This signal is emitted when the shortcut key for popup-menus is pressed. |
526 | * | 527 | * |
527 | * Normally you should not use this, just connect a slot to signal | 528 | * Normally you should not use this, just connect a slot to signal |
528 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly | 529 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly |
529 | * handle showing context menus regardless of settings. | 530 | * handle showing context menus regardless of settings. |
530 | * | 531 | * |
531 | * @param list is this listview. | 532 | * @param list is this listview. |
532 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. | 533 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. |
533 | */ | 534 | */ |
534 | void menuShortCutPressed (KListView* list, QListViewItem* item); | 535 | void menuShortCutPressed (KListView* list, QListViewItem* item); |
535 | 536 | ||
536 | /** | 537 | /** |
537 | * This signal is emitted whenever a context-menu should be shown for item @p i. | 538 | * This signal is emitted whenever a context-menu should be shown for item @p i. |
538 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). | 539 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). |
539 | * | 540 | * |
540 | * @param l is this listview. | 541 | * @param l is this listview. |
541 | * @param i is the item for which the menu should be shown. May be 0L. | 542 | * @param i is the item for which the menu should be shown. May be 0L. |
542 | * @param p is the point at which the menu should be shown. | 543 | * @param p is the point at which the menu should be shown. |
543 | */ | 544 | */ |
544 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); | 545 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); |
545 | 546 | ||
546 | public slots: | 547 | public slots: |
547 | /** | 548 | /** |
548 | * Rename column @p c of @p item. | 549 | * Rename column @p c of @p item. |
549 | */ | 550 | */ |
550 | virtual void rename(QListViewItem *item, int c); | 551 | virtual void rename(QListViewItem *item, int c); |
551 | 552 | ||
552 | /** | 553 | /** |
553 | * By default, if you called setItemsRenameable(true), | 554 | * By default, if you called setItemsRenameable(true), |
554 | * only the first column is renameable. | 555 | * only the first column is renameable. |
555 | * Use this function to enable the feature on other columns. | 556 | * Use this function to enable the feature on other columns. |
556 | * | 557 | * |
557 | * If you want more intelligent (dynamic) selection, | 558 | * If you want more intelligent (dynamic) selection, |
558 | * you'll have to derive from KListView, | 559 | * you'll have to derive from KListView, |
559 | * and override @ref rename() and call only call it | 560 | * and override @ref rename() and call only call it |
560 | * if you want the item to be renamed. | 561 | * if you want the item to be renamed. |
561 | */ | 562 | */ |
562 | void setRenameable (int column, bool yesno=true); | 563 | void setRenameable (int column, bool yesno=true); |
563 | 564 | ||
564 | /** | 565 | /** |
565 | * Set whether items in the list view can be moved. | 566 | * Set whether items in the list view can be moved. |
566 | * It is enabled by default. | 567 | * It is enabled by default. |
567 | * | 568 | * |
568 | * @see itemsMovable() | 569 | * @see itemsMovable() |
569 | */ | 570 | */ |
570 | virtual void setItemsMovable(bool b); | 571 | virtual void setItemsMovable(bool b); |
571 | 572 | ||
572 | /** | 573 | /** |
573 | * Enables inplace-renaming of items. | 574 | * Enables inplace-renaming of items. |
574 | * It is disabled by default. | 575 | * It is disabled by default. |
575 | * | 576 | * |
576 | * @see itemsRenameable() | 577 | * @see itemsRenameable() |
577 | * @see setRenameable() | 578 | * @see setRenameable() |
578 | */ | 579 | */ |
579 | virtual void setItemsRenameable(bool b); | 580 | virtual void setItemsRenameable(bool b); |
580 | 581 | ||
581 | /** | 582 | /** |
582 | * Enable/Disable the dragging of items. | 583 | * Enable/Disable the dragging of items. |
583 | * It is disabled by default. | 584 | * It is disabled by default. |
584 | */ | 585 | */ |
585 | virtual void setDragEnabled(bool b); | 586 | virtual void setDragEnabled(bool b); |
586 | 587 | ||
587 | /** | 588 | /** |
588 | * Enable/Disable AutoOpen (not implemented currently). | 589 | * Enable/Disable AutoOpen (not implemented currently). |
589 | */ | 590 | */ |
590 | virtual void setAutoOpen(bool b); | 591 | virtual void setAutoOpen(bool b); |
591 | 592 | ||
592 | /** | 593 | /** |
593 | * Enable/Disable the drawing of a drop-visualizer | 594 | * Enable/Disable the drawing of a drop-visualizer |
594 | * (a bar that shows where a dropped item would be inserted). | 595 | * (a bar that shows where a dropped item would be inserted). |
595 | * It is enabled by default, if dragging is enabled | 596 | * It is enabled by default, if dragging is enabled |
596 | */ | 597 | */ |
597 | virtual void setDropVisualizer(bool b); | 598 | virtual void setDropVisualizer(bool b); |
598 | 599 | ||
599 | /** | 600 | /** |
600 | * Set the width of the (default) drop-visualizer. | 601 | * Set the width of the (default) drop-visualizer. |
601 | * If you don't call this method, the width is set to 4. | 602 | * If you don't call this method, the width is set to 4. |
602 | */ | 603 | */ |
603 | void setDropVisualizerWidth (int w); | 604 | void setDropVisualizerWidth (int w); |
604 | 605 | ||
605 | /** | 606 | /** |
606 | * Set which column should be used for automatic tooltips. | 607 | * Set which column should be used for automatic tooltips. |
607 | * | 608 | * |
608 | * @param column is the column for which tooltips will be shown. | 609 | * @param column is the column for which tooltips will be shown. |
609 | * Set -1 to disable this feature. | 610 | * Set -1 to disable this feature. |
610 | */ | 611 | */ |
611 | virtual void setTooltipColumn(int column); | 612 | virtual void setTooltipColumn(int column); |
612 | 613 | ||
613 | /** | 614 | /** |
614 | * Enable/Disable the drawing of a drop-highlighter | 615 | * Enable/Disable the drawing of a drop-highlighter |
615 | * (a rectangle around the item under the mouse cursor). | 616 | * (a rectangle around the item under the mouse cursor). |
616 | * It is disabled by default. | 617 | * It is disabled by default. |
617 | */ | 618 | */ |
618 | virtual void setDropHighlighter(bool b); | 619 | virtual void setDropHighlighter(bool b); |
619 | 620 | ||
620 | /** | 621 | /** |
621 | * For future expansions. | 622 | * For future expansions. |
622 | * | 623 | * |
623 | * Do not use. | 624 | * Do not use. |
624 | * @deprecated | 625 | * @deprecated |
625 | */ | 626 | */ |
626 | virtual void setCreateChildren(bool b); | 627 | virtual void setCreateChildren(bool b); |
627 | 628 | ||
628 | /** | 629 | /** |
629 | * Set the selection mode. | 630 | * Set the selection mode. |
630 | * | 631 | * |
631 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). | 632 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). |
632 | */ | 633 | */ |
633 | void setSelectionModeExt (SelectionModeExt mode); | 634 | void setSelectionModeExt (SelectionModeExt mode); |
634 | 635 | ||
635 | /** | 636 | /** |
636 | * Enable/disable tabbing between editable cells | 637 | * Enable/disable tabbing between editable cells |
637 | * @since 3.1 | 638 | * @since 3.1 |
638 | */ | 639 | */ |
639 | void setTabOrderedRenaming(bool b); | 640 | void setTabOrderedRenaming(bool b); |
640 | 641 | ||
641 | /** | 642 | /** |
642 | * Returns whether tab ordered renaming is enabled | 643 | * Returns whether tab ordered renaming is enabled |
643 | * @since 3.1 | 644 | * @since 3.1 |
644 | */ | 645 | */ |
645 | bool tabOrderedRenaming() const; | 646 | bool tabOrderedRenaming() const; |
646 | 647 | ||
647 | protected: | 648 | protected: |
648 | /** | 649 | /** |
649 | * Determine whether a drop on position @p p would count as | 650 | * Determine whether a drop on position @p p would count as |
650 | * being above or below the QRect @p rect. | 651 | * being above or below the QRect @p rect. |
651 | * | 652 | * |
652 | * @param rect is the rectangle we examine. | 653 | * @param rect is the rectangle we examine. |
653 | * @param p is the point located in the rectangle, p is assumed to be in | 654 | * @param p is the point located in the rectangle, p is assumed to be in |
654 | * viewport coordinates. | 655 | * viewport coordinates. |
655 | */ | 656 | */ |
656 | inline bool below (const QRect& rect, const QPoint& p) | 657 | inline bool below (const QRect& rect, const QPoint& p) |
657 | { | 658 | { |
658 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); | 659 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); |
659 | } | 660 | } |
660 | 661 | ||
661 | /** | 662 | /** |
662 | * An overloaded version of below(const QRect&, const QPoint&). | 663 | * An overloaded version of below(const QRect&, const QPoint&). |
663 | * | 664 | * |
664 | * It differs from the above only in what arguments it takes. | 665 | * It differs from the above only in what arguments it takes. |
665 | * | 666 | * |
666 | * @param i the item whose rect() is passed to the above function. | 667 | * @param i the item whose rect() is passed to the above function. |
667 | * @param p is translated from contents coordinates to viewport coordinates | 668 | * @param p is translated from contents coordinates to viewport coordinates |
668 | * before being passed to the above function. | 669 | * before being passed to the above function. |
669 | */ | 670 | */ |
670 | inline bool below (QListViewItem* i, const QPoint& p) | 671 | inline bool below (QListViewItem* i, const QPoint& p) |
671 | { | 672 | { |
672 | return below (itemRect(i), contentsToViewport(p)); | 673 | return below (itemRect(i), contentsToViewport(p)); |
673 | } | 674 | } |
674 | 675 | ||
675 | /** | 676 | /** |
676 | * Reimplemented to reload the alternate background in palette changes. | 677 | * Reimplemented to reload the alternate background in palette changes. |
677 | * @internal | 678 | * @internal |
678 | */ | 679 | */ |
679 | virtual bool event( QEvent * ); | 680 | virtual bool event( QEvent * ); |
680 | 681 | ||
681 | /** | 682 | /** |
682 | * Emit signal @ref #executed. | 683 | * Emit signal @ref #executed. |
683 | * @internal | 684 | * @internal |
684 | */ | 685 | */ |
685 | void emitExecute( QListViewItem *item, const QPoint &pos, int c ); | 686 | void emitExecute( QListViewItem *item, const QPoint &pos, int c ); |
686 | 687 | ||
687 | /** | 688 | /** |
688 | * Reimplemented for internal reasons. | 689 | * Reimplemented for internal reasons. |
689 | * Further reimplementations should call this function or else | 690 | * Further reimplementations should call this function or else |
690 | * some features may not work correctly. | 691 | * some features may not work correctly. |
691 | * | 692 | * |
692 | * The API is unaffected. | 693 | * The API is unaffected. |
693 | */ | 694 | */ |
694 | virtual void focusInEvent(QFocusEvent* fe); | 695 | virtual void focusInEvent(QFocusEvent* fe); |
695 | 696 | ||
696 | /** | 697 | /** |
697 | * Reimplemented for internal reasons. | 698 | * Reimplemented for internal reasons. |
698 | * Further reimplementations should call this function or else | 699 | * Further reimplementations should call this function or else |
699 | * some features may not work correctly. | 700 | * some features may not work correctly. |
700 | * | 701 | * |
701 | * The API is unaffected. | 702 | * The API is unaffected. |
702 | */ | 703 | */ |
703 | virtual void focusOutEvent( QFocusEvent *fe ); | 704 | virtual void focusOutEvent( QFocusEvent *fe ); |
704 | 705 | ||
705 | /** | 706 | /** |
706 | * Reimplemented for internal reasons. | 707 | * Reimplemented for internal reasons. |
707 | * Further reimplementations should call this function or else | 708 | * Further reimplementations should call this function or else |
708 | * some features may not work correctly. | 709 | * some features may not work correctly. |
709 | * | 710 | * |
710 | * The API is unaffected. | 711 | * The API is unaffected. |
711 | */ | 712 | */ |
712 | virtual void leaveEvent( QEvent *e ); | 713 | virtual void leaveEvent( QEvent *e ); |
713 | 714 | ||
714 | /** | 715 | /** |
715 | * @return the tooltip for @p column of @p item. | 716 | * @return the tooltip for @p column of @p item. |
716 | */ | 717 | */ |
717 | virtual QString tooltip(QListViewItem* item, int column) const; | 718 | virtual QString tooltip(QListViewItem* item, int column) const; |
718 | 719 | ||
719 | /** | 720 | /** |
720 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. | 721 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. |
721 | */ | 722 | */ |
722 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; | 723 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; |
723 | 724 | ||
724 | /** | 725 | /** |
725 | * Reimplemented for internal reasons. | 726 | * Reimplemented for internal reasons. |
726 | * Further reimplementations should call this function or else | 727 | * Further reimplementations should call this function or else |
727 | * some features may not work correctly. | 728 | * some features may not work correctly. |
728 | * | 729 | * |
729 | * The API is unaffected. | 730 | * The API is unaffected. |
730 | */ | 731 | */ |
731 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); | 732 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); |
732 | 733 | ||
733 | /** | 734 | /** |
734 | * Reimplemented for internal reasons. | 735 | * Reimplemented for internal reasons. |
735 | * Further reimplementations should call this function or else | 736 | * Further reimplementations should call this function or else |
736 | * some features may not work correctly. | 737 | * some features may not work correctly. |
737 | * | 738 | * |
738 | * The API is unaffected. | 739 | * The API is unaffected. |
739 | */ | 740 | */ |
740 | virtual void contentsMousePressEvent( QMouseEvent *e ); | 741 | virtual void contentsMousePressEvent( QMouseEvent *e ); |
741 | 742 | ||
742 | /** | 743 | /** |
743 | * Reimplemented for internal reasons. | 744 | * Reimplemented for internal reasons. |
744 | * Further reimplementations should call this function or else | 745 | * Further reimplementations should call this function or else |
745 | * some features may not work correctly. | 746 | * some features may not work correctly. |
746 | * | 747 | * |
747 | * The API is unaffected. | 748 | * The API is unaffected. |
748 | */ | 749 | */ |
749 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); | 750 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); |
750 | 751 | ||
751 | /** | 752 | /** |
752 | * Reimplemented for internal reasons. | 753 | * Reimplemented for internal reasons. |
753 | * Further reimplementations should call this function or else | 754 | * Further reimplementations should call this function or else |
754 | * some features may not work correctly. | 755 | * some features may not work correctly. |
755 | * | 756 | * |
756 | * The API is unaffected. | 757 | * The API is unaffected. |
757 | */ | 758 | */ |
758 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); | 759 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); |
759 | 760 | ||
760 | /** | 761 | /** |
761 | * Reimplemented for internal reasons. | 762 | * Reimplemented for internal reasons. |
762 | * Further reimplementations should call this function or else | 763 | * Further reimplementations should call this function or else |
763 | * some features may not work correctly. | 764 | * some features may not work correctly. |
764 | * | 765 | * |
765 | * The API is unaffected. | 766 | * The API is unaffected. |
766 | */ | 767 | */ |
767 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); | 768 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); |
768 | 769 | ||
769 | /** | 770 | /** |
770 | * Reimplemented for internal reasons. | 771 | * Reimplemented for internal reasons. |
771 | * Further reimplementations should call this function or else | 772 | * Further reimplementations should call this function or else |
772 | * some features may not work correctly. | 773 | * some features may not work correctly. |
773 | * | 774 | * |
774 | * The API is unaffected. | 775 | * The API is unaffected. |
775 | */ | 776 | */ |
776 | virtual void contentsMouseReleaseEvent (QMouseEvent*); | 777 | virtual void contentsMouseReleaseEvent (QMouseEvent*); |
777 | 778 | ||
778 | /** | 779 | /** |
779 | * Reimplemented for internal reasons. | 780 | * Reimplemented for internal reasons. |
780 | * Further reimplementations should call this function or else | 781 | * Further reimplementations should call this function or else |
781 | * some features may not work correctly. | 782 | * some features may not work correctly. |
782 | * | 783 | * |
783 | * The API is unaffected. | 784 | * The API is unaffected. |
784 | */ | 785 | */ |
785 | virtual void contentsDropEvent (QDropEvent*); | 786 | virtual void contentsDropEvent (QDropEvent*); |
786 | 787 | ||
787 | /** | 788 | /** |
788 | * Reimplemented for internal reasons. | 789 | * Reimplemented for internal reasons. |
789 | * Further reimplementations should call this function or else | 790 | * Further reimplementations should call this function or else |
790 | * some features may not work correctly. | 791 | * some features may not work correctly. |
791 | * | 792 | * |
792 | * The API is unaffected. | 793 | * The API is unaffected. |
793 | */ | 794 | */ |
794 | virtual void contentsDragEnterEvent (QDragEnterEvent *); | 795 | virtual void contentsDragEnterEvent (QDragEnterEvent *); |
795 | 796 | ||
796 | /** | 797 | /** |
797 | * @return a dragobject encoding the current selection. | 798 | * @return a dragobject encoding the current selection. |
798 | * | 799 | * |
799 | * @see setDragEnabled() | 800 | * @see setDragEnabled() |
800 | */ | 801 | */ |
801 | virtual QDragObject *dragObject(); | 802 | virtual QDragObject *dragObject(); |
802 | 803 | ||
803 | /** | 804 | /** |
804 | * @return true if the @p event provides some acceptable | 805 | * @return true if the @p event provides some acceptable |
805 | * format. | 806 | * format. |
806 | * A common mistake is to forget the "const" in your reimplementation | 807 | * A common mistake is to forget the "const" in your reimplementation |
807 | */ | 808 | */ |
808 | virtual bool acceptDrag (QDropEvent* event) const; | 809 | virtual bool acceptDrag (QDropEvent* event) const; |
809 | 810 | ||
810 | /** | 811 | /** |
811 | * Paint the drag line. If painter is null, don't try to :) | 812 | * Paint the drag line. If painter is null, don't try to :) |
812 | * | 813 | * |
813 | * If after == 0 then the marker should be drawn at the top. | 814 | * If after == 0 then the marker should be drawn at the top. |
814 | * | 815 | * |
815 | * @return the rectangle that you painted to. | 816 | * @return the rectangle that you painted to. |
816 | */ | 817 | */ |
817 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); | 818 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); |
818 | 819 | ||
819 | /** | 820 | /** |
820 | * Paint the drag rectangle. If painter is null, don't try to :) | 821 | * Paint the drag rectangle. If painter is null, don't try to :) |
821 | * | 822 | * |
822 | * | 823 | * |
823 | * @return the rectangle that you painted to. | 824 | * @return the rectangle that you painted to. |
824 | */ | 825 | */ |
825 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); | 826 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); |
826 | 827 | ||
827 | /** | 828 | /** |
828 | * This method calls @ref dragObject() and starts the drag. | 829 | * This method calls @ref dragObject() and starts the drag. |
829 | * | 830 | * |
830 | * Reimplement it to do fancy stuff like setting a pixmap or | 831 | * Reimplement it to do fancy stuff like setting a pixmap or |
831 | * using a non-default DragMode | 832 | * using a non-default DragMode |
832 | */ | 833 | */ |
833 | virtual void startDrag(); | 834 | virtual void startDrag(); |
834 | 835 | ||
835 | /** | 836 | /** |
836 | * Reimplemented for internal reasons. | 837 | * Reimplemented for internal reasons. |
837 | * Further reimplementations should call this function or else | 838 | * Further reimplementations should call this function or else |
838 | * some features may not work correctly. | 839 | * some features may not work correctly. |
839 | * | 840 | * |
840 | * The API is unaffected. | 841 | * The API is unaffected. |
841 | */ | 842 | */ |
842 | virtual void keyPressEvent (QKeyEvent*); | 843 | virtual void keyPressEvent (QKeyEvent*); |
843 | 844 | ||
844 | /** | 845 | /** |
845 | * Reimplemented for internal reasons. | 846 | * Reimplemented for internal reasons. |
846 | * Further reimplementations should call this function or else | 847 | * Further reimplementations should call this function or else |
847 | * some features may not work correctly. | 848 | * some features may not work correctly. |
848 | * | 849 | * |
849 | * The API is unaffected. | 850 | * The API is unaffected. |
850 | */ | 851 | */ |
851 | virtual void viewportPaintEvent(QPaintEvent*); | 852 | virtual void viewportPaintEvent(QPaintEvent*); |
852 | 853 | ||
853 | /** | 854 | /** |
854 | * In FileManager selection mode: explicitely activate the mode | 855 | * In FileManager selection mode: explicitely activate the mode |
855 | * in which the current item is automatically selected. | 856 | * in which the current item is automatically selected. |
856 | */ | 857 | */ |
857 | void activateAutomaticSelection(); | 858 | void activateAutomaticSelection(); |
858 | /** | 859 | /** |
859 | * In FileManager selection mode: explicitely deactivate the mode | 860 | * In FileManager selection mode: explicitely deactivate the mode |
860 | * in which the current item is automatically selected. | 861 | * in which the current item is automatically selected. |
861 | */ | 862 | */ |
862 | void deactivateAutomaticSelection(); | 863 | void deactivateAutomaticSelection(); |
863 | /** | 864 | /** |
864 | * In FileManager selection mode: return whether it is currently in the mode | 865 | * In FileManager selection mode: return whether it is currently in the mode |
865 | * where the current item is selected automatically. | 866 | * where the current item is selected automatically. |
866 | * Returns false if items were selected explicitely, e.g. using the mouse. | 867 | * Returns false if items were selected explicitely, e.g. using the mouse. |
867 | */ | 868 | */ |
868 | bool automaticSelection() const; | 869 | bool automaticSelection() const; |
869 | 870 | ||
870 | /** | 871 | /** |
871 | * Reimplemented for setFullWidth() | 872 | * Reimplemented for setFullWidth() |
872 | */ | 873 | */ |
873 | virtual void viewportResizeEvent(QResizeEvent* e); | 874 | virtual void viewportResizeEvent(QResizeEvent* e); |
874 | 875 | ||
875 | protected slots: | 876 | protected slots: |
876 | /** | 877 | /** |
877 | * Update internal settings whenever the global ones change. | 878 | * Update internal settings whenever the global ones change. |
878 | * @internal | 879 | * @internal |
879 | */ | 880 | */ |
880 | void slotSettingsChanged(int); | 881 | void slotSettingsChanged(int); |
881 | 882 | ||
882 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); | 883 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); |
883 | void doneEditing(QListViewItem *item, int row); | 884 | void doneEditing(QListViewItem *item, int row); |
884 | 885 | ||
885 | /** | 886 | /** |
886 | * Repaint the rect where I was drawing the drop line. | 887 | * Repaint the rect where I was drawing the drop line. |
887 | */ | 888 | */ |
888 | void cleanDropVisualizer(); | 889 | void cleanDropVisualizer(); |
889 | 890 | ||
890 | /** | 891 | /** |
891 | * Repaint the rect where I was drawing the drop rectangle. | 892 | * Repaint the rect where I was drawing the drop rectangle. |
892 | */ | 893 | */ |
893 | void cleanItemHighlighter(); | 894 | void cleanItemHighlighter(); |
894 | 895 | ||
895 | /** | 896 | /** |
896 | * Emit the @ref contextMenu signal. This slot is for mouse actions. | 897 | * Emit the @ref contextMenu signal. This slot is for mouse actions. |
897 | */ | 898 | */ |
898 | void emitContextMenu (QListViewItem*, const QPoint&, int); | 899 | void emitContextMenu (QListViewItem*, const QPoint&, int); |
899 | 900 | ||
900 | /** | 901 | /** |
901 | * Emit the @ref #contextMenu signal. This slot is for key presses. | 902 | * Emit the @ref #contextMenu signal. This slot is for key presses. |
902 | */ | 903 | */ |
903 | void emitContextMenu (KListView*, QListViewItem*); | 904 | void emitContextMenu (KListView*, QListViewItem*); |
904 | 905 | ||
905 | /** | 906 | /** |
906 | * Accessory slot for AutoSelect | 907 | * Accessory slot for AutoSelect |
907 | * @internal | 908 | * @internal |
908 | */ | 909 | */ |
909 | void slotOnItem( QListViewItem *item ); | 910 | void slotOnItem( QListViewItem *item ); |
910 | 911 | ||
911 | /** | 912 | /** |
912 | * Accessory slot for AutoSelect/ChangeCursorOverItem | 913 | * Accessory slot for AutoSelect/ChangeCursorOverItem |
913 | * @internal | 914 | * @internal |
914 | */ | 915 | */ |
915 | void slotOnViewport(); | 916 | void slotOnViewport(); |
916 | 917 | ||
917 | /** | 918 | /** |
918 | * Process AutoSelection. | 919 | * Process AutoSelection. |
919 | * @internal | 920 | * @internal |
920 | */ | 921 | */ |
921 | void slotAutoSelect(); | 922 | void slotAutoSelect(); |
922 | 923 | ||
923 | void slotDragExpand(); | 924 | void slotDragExpand(); |
924 | 925 | ||
925 | /** | 926 | /** |
926 | * Reacts to header changes in full width mode | 927 | * Reacts to header changes in full width mode |
927 | * @internal | 928 | * @internal |
928 | */ | 929 | */ |
929 | void slotHeaderChanged(); | 930 | void slotHeaderChanged(); |
930 | 931 | ||
931 | protected: | 932 | protected: |
932 | /** | 933 | /** |
933 | * Handle dropEvent when itemsMovable() is set to true. | 934 | * Handle dropEvent when itemsMovable() is set to true. |
934 | */ | 935 | */ |
935 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); | 936 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); |
936 | 937 | ||
937 | /** | 938 | /** |
938 | * Where is the nearest QListViewItem that I'm going to drop? | 939 | * Where is the nearest QListViewItem that I'm going to drop? |
939 | * | 940 | * |
940 | * FIXME KDE 4.0: Make this method const so it can be called from an | 941 | * FIXME KDE 4.0: Make this method const so it can be called from an |
941 | * acceptDrag method without ugly casts | 942 | * acceptDrag method without ugly casts |
942 | */ | 943 | */ |
943 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); | 944 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); |
944 | 945 | ||
945 | /** | 946 | /** |
946 | * A special keyPressEvent (for FileManager selection mode). | 947 | * A special keyPressEvent (for FileManager selection mode). |
947 | */ | 948 | */ |
948 | void fileManagerKeyPressEvent (QKeyEvent*); | 949 | void fileManagerKeyPressEvent (QKeyEvent*); |
949 | 950 | ||
950 | /** | 951 | /** |
951 | * Convert the depth of an item into its indentation in pixels | 952 | * Convert the depth of an item into its indentation in pixels |
952 | */ | 953 | */ |
953 | int depthToPixels( int depth ); | 954 | int depthToPixels( int depth ); |
954 | 955 | ||
955 | private: | 956 | private: |
956 | class Tooltip; | 957 | class Tooltip; |
957 | protected: | 958 | protected: |
958 | virtual void virtual_hook( int id, void* data ); | 959 | virtual void virtual_hook( int id, void* data ); |
959 | private: | 960 | private: |
960 | class KListViewPrivate; | 961 | class KListViewPrivate; |
961 | KListViewPrivate *d; | 962 | KListViewPrivate *d; |
962 | }; | 963 | }; |
963 | 964 | ||
964 | /** | 965 | /** |
965 | * A listview item with support for alternate background colours. It is | 966 | * A listview item with support for alternate background colours. It is |
966 | * a drop-in replacement for @ref QListViewItem | 967 | * a drop-in replacement for @ref QListViewItem |
967 | * | 968 | * |
968 | * @short listview item with alternate background colour support | 969 | * @short listview item with alternate background colour support |
969 | */ | 970 | */ |
970 | class KListViewItem : public QListViewItem | 971 | class KListViewItem : public QListViewItem |
971 | { | 972 | { |
972 | public: | 973 | public: |
973 | /** | 974 | /** |
974 | * constructors. The semantics remain as in @ref QListViewItem. | 975 | * constructors. The semantics remain as in @ref QListViewItem. |
975 | * Although they accept a @ref QListViewItem as parent, please | 976 | * Although they accept a @ref QListViewItem as parent, please |
976 | * don't mix KListViewItem (or subclasses) with QListViewItem | 977 | * don't mix KListViewItem (or subclasses) with QListViewItem |
977 | * (or subclasses). | 978 | * (or subclasses). |
978 | */ | 979 | */ |
979 | KListViewItem(QListView *parent); | 980 | KListViewItem(QListView *parent); |
980 | KListViewItem(QListViewItem *parent); | 981 | KListViewItem(QListViewItem *parent); |
981 | KListViewItem(QListView *parent, QListViewItem *after); | 982 | KListViewItem(QListView *parent, QListViewItem *after); |
982 | KListViewItem(QListViewItem *parent, QListViewItem *after); | 983 | KListViewItem(QListViewItem *parent, QListViewItem *after); |
983 | 984 | ||
984 | KListViewItem(QListView *parent, | 985 | KListViewItem(QListView *parent, |
985 | QString, QString = QString::null, | 986 | QString, QString = QString::null, |
986 | QString = QString::null, QString = QString::null, | 987 | QString = QString::null, QString = QString::null, |
987 | QString = QString::null, QString = QString::null, | 988 | QString = QString::null, QString = QString::null, |
988 | QString = QString::null, QString = QString::null); | 989 | QString = QString::null, QString = QString::null); |
989 | 990 | ||
990 | KListViewItem(QListViewItem *parent, | 991 | KListViewItem(QListViewItem *parent, |
991 | QString, QString = QString::null, | 992 | QString, QString = QString::null, |
992 | QString = QString::null, QString = QString::null, | 993 | QString = QString::null, QString = QString::null, |
993 | QString = QString::null, QString = QString::null, | 994 | QString = QString::null, QString = QString::null, |
994 | QString = QString::null, QString = QString::null); | 995 | QString = QString::null, QString = QString::null); |
995 | 996 | ||
996 | KListViewItem(QListView *parent, QListViewItem *after, | 997 | KListViewItem(QListView *parent, QListViewItem *after, |
997 | QString, QString = QString::null, | 998 | QString, QString = QString::null, |
998 | QString = QString::null, QString = QString::null, | 999 | QString = QString::null, QString = QString::null, |
999 | QString = QString::null, QString = QString::null, | 1000 | QString = QString::null, QString = QString::null, |
1000 | QString = QString::null, QString = QString::null); | 1001 | QString = QString::null, QString = QString::null); |
1001 | 1002 | ||
1002 | KListViewItem(QListViewItem *parent, QListViewItem *after, | 1003 | KListViewItem(QListViewItem *parent, QListViewItem *after, |
1003 | QString, QString = QString::null, | 1004 | QString, QString = QString::null, |
1004 | QString = QString::null, QString = QString::null, | 1005 | QString = QString::null, QString = QString::null, |
1005 | QString = QString::null, QString = QString::null, | 1006 | QString = QString::null, QString = QString::null, |
1006 | QString = QString::null, QString = QString::null); | 1007 | QString = QString::null, QString = QString::null); |
1007 | 1008 | ||
1008 | virtual ~KListViewItem(); | 1009 | virtual ~KListViewItem(); |
1009 | 1010 | ||
1010 | /** | 1011 | /** |
1011 | * retuns true if this item is to be drawn with the alternate background | 1012 | * retuns true if this item is to be drawn with the alternate background |
1012 | */ | 1013 | */ |
1013 | bool isAlternate(); | 1014 | bool isAlternate(); |
1014 | /** | 1015 | /** |
1015 | * returns the background colour for this item | 1016 | * returns the background colour for this item |
1016 | */ | 1017 | */ |
1017 | const QColor &backgroundColor(); | 1018 | const QColor &backgroundColor(); |
1018 | 1019 | ||
1019 | virtual void paintCell(QPainter *p, const QColorGroup &cg, | 1020 | virtual void paintCell(QPainter *p, const QColorGroup &cg, |
1020 | int column, int width, int alignment); | 1021 | int column, int width, int alignment); |
1021 | 1022 | ||
1022 | private: | 1023 | private: |
1023 | void init(); | 1024 | void init(); |
1024 | 1025 | ||
1025 | private: | 1026 | private: |
1026 | uint m_odd : 1; | 1027 | uint m_odd : 1; |
1027 | uint m_known : 1; | 1028 | uint m_known : 1; |
1028 | uint m_unused : 30; | 1029 | uint m_unused : 30; |
1029 | }; | 1030 | }; |
1030 | 1031 | ||
1031 | #endif | 1032 | #endif |
1032 | 1033 | ||
1033 | // vim: ts=2 sw=2 et | 1034 | // vim: ts=2 sw=2 et |