-rw-r--r-- | bin/kdepim/WhatsNew.txt | 14 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/picture.cpp | 38 | ||||
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 30 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 77 | ||||
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.h | 1 | ||||
-rw-r--r-- | kaddressbook/imagewidget.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 9 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 1 | ||||
-rw-r--r-- | kde2file/abdump/main.cpp | 2 | ||||
-rw-r--r-- | kde2file/caldump/main.cpp | 2 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 16 | ||||
-rw-r--r-- | version | 2 |
15 files changed, 133 insertions, 88 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 2fd63e7..ff87423 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,394 +1,408 @@ | |||
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.17 ************ | 3 | ********** VERSION 1.9.17 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Fixed that tooltips were not updated after moving an item in agenda view. | 6 | Fixed that tooltips were not updated after moving an item in agenda view. |
7 | Fixed a bug in sorting start date for recurring events in list view. | ||
7 | 8 | ||
8 | KA/Pi: | 9 | KA/Pi: |
9 | All fields search does now actually search all the (possible) fields, | 10 | All fields search does now actually search all the (possible) fields, |
10 | not only those listed in the contact list. | 11 | not only those listed in the contact list. |
12 | Made is possible to inline a picture in a vcard on the Z. | ||
13 | This was only possible on the desktop, now is it possible on the Z as well. | ||
14 | Fixed of missing save settings after filter configuration. | ||
15 | Made saving of addressbook much faster. | ||
16 | |||
17 | QWhatsThis was not working on the Z ( only black rectangle was shown). | ||
18 | This is Fixed. | ||
19 | |||
20 | KDE-Sync: | ||
21 | Now readonly KDE resources are synced as well. | ||
22 | (They are not changed in KDE itself, of course). | ||
23 | |||
24 | |||
11 | 25 | ||
12 | ********** VERSION 1.9.16 ************ | 26 | ********** VERSION 1.9.16 ************ |
13 | 27 | ||
14 | KO/Pi: | 28 | KO/Pi: |
15 | Fixed search dialog size on Z 6000 (480x640 display). | 29 | Fixed search dialog size on Z 6000 (480x640 display). |
16 | Added setting to hide/show time in agenda items. | 30 | Added setting to hide/show time in agenda items. |
17 | Added setting to hide not running todos in todo view. | 31 | Added setting to hide not running todos in todo view. |
18 | Added columns for start date/time in todo view. | 32 | Added columns for start date/time in todo view. |
19 | Replaced the solid half-hour lines in agenda view by dot lines. | 33 | Replaced the solid half-hour lines in agenda view by dot lines. |
20 | Added possibility of printing the What's Next View on the desktop | 34 | Added possibility of printing the What's Next View on the desktop |
21 | (i.e. Windows and Linux). | 35 | (i.e. Windows and Linux). |
22 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. | 36 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. |
23 | Added tooltips in month view.(Tooltips only available on desktop) | 37 | Added tooltips in month view.(Tooltips only available on desktop) |
24 | 38 | ||
25 | Fixed a strange problem in KO/Pi alarm applet. | 39 | Fixed a strange problem in KO/Pi alarm applet. |
26 | Did not find the actual problem, | 40 | Did not find the actual problem, |
27 | such that now Qtopia reboots again if deinstalling the alarm applet. | 41 | such that now Qtopia reboots again if deinstalling the alarm applet. |
28 | But the alarm applet should work again. | 42 | But the alarm applet should work again. |
29 | 43 | ||
30 | KA/Pi: | 44 | KA/Pi: |
31 | Fixed the problem, that internal pictures were not saved. | 45 | Fixed the problem, that internal pictures were not saved. |
32 | 46 | ||
33 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. | 47 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. |
34 | 48 | ||
35 | Fixed some minor problems. (Like word wrap in help text windows). | 49 | Fixed some minor problems. (Like word wrap in help text windows). |
36 | 50 | ||
37 | Fixed a compiling problem in microkde/kresources. | 51 | Fixed a compiling problem in microkde/kresources. |
38 | 52 | ||
39 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. | 53 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. |
40 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) | 54 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) |
41 | such that now syncing KO/Pi with Sharp DTM should work on the | 55 | such that now syncing KO/Pi with Sharp DTM should work on the |
42 | Zaurus C 3000 model. | 56 | Zaurus C 3000 model. |
43 | 57 | ||
44 | ********** VERSION 1.9.15 ************ | 58 | ********** VERSION 1.9.15 ************ |
45 | 59 | ||
46 | Usebilty enhancements in KO/Pi: | 60 | Usebilty enhancements in KO/Pi: |
47 | When clicking on the date in a month view cell, the day view is shown. | 61 | When clicking on the date in a month view cell, the day view is shown. |
48 | Old behaviour was, that the "new event" dialog popped up. | 62 | Old behaviour was, that the "new event" dialog popped up. |
49 | 63 | ||
50 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). | 64 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). |
51 | That means, you can restore the latest | 65 | That means, you can restore the latest |
52 | event/todo/journal you have deleted. | 66 | event/todo/journal you have deleted. |
53 | A journal is deleted, if you clear all the text of the journal. | 67 | A journal is deleted, if you clear all the text of the journal. |
54 | 68 | ||
55 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. | 69 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. |
56 | 70 | ||
57 | KA/Pi starting in 480x640 resolution: | 71 | KA/Pi starting in 480x640 resolution: |
58 | Hide the filter action in toolbar | 72 | Hide the filter action in toolbar |
59 | and added icons for undo/delete/redo in toolbar. | 73 | and added icons for undo/delete/redo in toolbar. |
60 | 74 | ||
61 | Change in OM/Pi ViewMail dialog: | 75 | Change in OM/Pi ViewMail dialog: |
62 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. | 76 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. |
63 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). | 77 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). |
64 | 78 | ||
65 | Fixed a crash when deleting mail-accounts in OM/Pi. | 79 | Fixed a crash when deleting mail-accounts in OM/Pi. |
66 | 80 | ||
67 | 81 | ||
68 | ********** VERSION 1.9.14 ************ | 82 | ********** VERSION 1.9.14 ************ |
69 | 83 | ||
70 | Fixed some problems with the dialog sizes when switching | 84 | Fixed some problems with the dialog sizes when switching |
71 | portrait/landscape mode on 640x480 PDA display. | 85 | portrait/landscape mode on 640x480 PDA display. |
72 | 86 | ||
73 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. | 87 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. |
74 | 88 | ||
75 | Fixed an ugly bug in KOpieMail: | 89 | Fixed an ugly bug in KOpieMail: |
76 | KOpieMail was not able to write files (mails) to MSDOS file system, | 90 | KOpieMail was not able to write files (mails) to MSDOS file system, |
77 | like on an usual preformatted SD card. That should work now. | 91 | like on an usual preformatted SD card. That should work now. |
78 | To save your mail data on the Sd card do the following: | 92 | To save your mail data on the Sd card do the following: |
79 | Create a dir on the SD card: | 93 | Create a dir on the SD card: |
80 | mkdir /mnt/card/localmail | 94 | mkdir /mnt/card/localmail |
81 | Go to your home dir: | 95 | Go to your home dir: |
82 | cd | 96 | cd |
83 | Go to kopiemail data storage dir: | 97 | Go to kopiemail data storage dir: |
84 | cd kdepim/apps/kopiemail | 98 | cd kdepim/apps/kopiemail |
85 | Create a symlink to the SD card: | 99 | Create a symlink to the SD card: |
86 | ls -s /mnt/card/localmail | 100 | ls -s /mnt/card/localmail |
87 | Now KOpieMail will store all mails on the SD card. | 101 | Now KOpieMail will store all mails on the SD card. |
88 | 102 | ||
89 | KO/Pi Monthview: | 103 | KO/Pi Monthview: |
90 | Now "Go to Today" selects the current month from day 1-end, | 104 | Now "Go to Today" selects the current month from day 1-end, |
91 | not the current date + some days. | 105 | not the current date + some days. |
92 | I.e. "Go to Today" shows now always | 106 | I.e. "Go to Today" shows now always |
93 | the current month with first day of month in the first row. | 107 | the current month with first day of month in the first row. |
94 | 108 | ||
95 | Added missing German translation. | 109 | Added missing German translation. |
96 | 110 | ||
97 | Fixed icons of executeable on Wintendo. | 111 | Fixed icons of executeable on Wintendo. |
98 | 112 | ||
99 | Added a "Show next Mail" button to the OM/Pi | 113 | Added a "Show next Mail" button to the OM/Pi |
100 | mail viewer such that the mail below the current mail | 114 | mail viewer such that the mail below the current mail |
101 | in the mail list view of the current folder | 115 | in the mail list view of the current folder |
102 | can be read with a single click. | 116 | can be read with a single click. |
103 | 117 | ||
104 | 118 | ||
105 | ********** VERSION 1.9.13 ************ | 119 | ********** VERSION 1.9.13 ************ |
106 | 120 | ||
107 | Fixed nasty PwM/Pi file reading bug, when | 121 | Fixed nasty PwM/Pi file reading bug, when |
108 | the used hash algo of file is different then the global | 122 | the used hash algo of file is different then the global |
109 | hash algo. | 123 | hash algo. |
110 | 124 | ||
111 | Added KA/Pi support for opie mailit mailapplication. | 125 | Added KA/Pi support for opie mailit mailapplication. |
112 | 126 | ||
113 | Fixed some bugs in OM/Pi. | 127 | Fixed some bugs in OM/Pi. |
114 | Now character conversion tables are available for the Zaurus | 128 | Now character conversion tables are available for the Zaurus |
115 | to make OM/Pi working properly. | 129 | to make OM/Pi working properly. |
116 | To get the character conversion in OM/Pi working, please download | 130 | To get the character conversion in OM/Pi working, please download |
117 | at the sourceforge project site the package | 131 | at the sourceforge project site the package |
118 | sr-character-conversion_SharpROM_arm.ipk.zip | 132 | sr-character-conversion_SharpROM_arm.ipk.zip |
119 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) | 133 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) |
120 | from the section "general files for KDE/Pim" | 134 | from the section "general files for KDE/Pim" |
121 | Instructions how to install this package are in a ReadMe in this file. | 135 | Instructions how to install this package are in a ReadMe in this file. |
122 | 136 | ||
123 | 137 | ||
124 | Fixed the orientation change problem in KA/Pi when switching | 138 | Fixed the orientation change problem in KA/Pi when switching |
125 | portrait/landscape mode. | 139 | portrait/landscape mode. |
126 | 140 | ||
127 | French translation available for KA/Pi and OM/Pi. | 141 | French translation available for KA/Pi and OM/Pi. |
128 | 142 | ||
129 | Fixed some problems with categories in KO/Pi in DTM sync. | 143 | Fixed some problems with categories in KO/Pi in DTM sync. |
130 | 144 | ||
131 | Added selection dialog for export to phone in KA/Pi. | 145 | Added selection dialog for export to phone in KA/Pi. |
132 | 146 | ||
133 | If in KO/Pi is an attendee selected to add to a meeting and this | 147 | If in KO/Pi is an attendee selected to add to a meeting and this |
134 | attendee is already in the list of attendees, this person is not added | 148 | attendee is already in the list of attendees, this person is not added |
135 | again. | 149 | again. |
136 | 150 | ||
137 | Some menu cleanup in KA/Pi. | 151 | Some menu cleanup in KA/Pi. |
138 | 152 | ||
139 | ********** VERSION 1.9.12 ************ | 153 | ********** VERSION 1.9.12 ************ |
140 | 154 | ||
141 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. | 155 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. |
142 | 156 | ||
143 | Bugfix: Licence file is now shown again. | 157 | Bugfix: Licence file is now shown again. |
144 | 158 | ||
145 | OM/Pi now supports Unicode (utf8 charset). | 159 | OM/Pi now supports Unicode (utf8 charset). |
146 | Fixed some bugs in OM/Pi. | 160 | Fixed some bugs in OM/Pi. |
147 | 161 | ||
148 | KA/Pi has more German translation. | 162 | KA/Pi has more German translation. |
149 | 163 | ||
150 | 164 | ||
151 | ********** VERSION 1.9.11 ************ | 165 | ********** VERSION 1.9.11 ************ |
152 | 166 | ||
153 | Fixed several problems in PWM/Pi, like | 167 | Fixed several problems in PWM/Pi, like |
154 | asking the user, if unsaved changed are pending | 168 | asking the user, if unsaved changed are pending |
155 | when closing the app. | 169 | when closing the app. |
156 | And PwM/Pi handles now different texts for the | 170 | And PwM/Pi handles now different texts for the |
157 | fields Description, Username, Password, configurable per category. | 171 | fields Description, Username, Password, configurable per category. |
158 | 172 | ||
159 | Fixed a crash in KO/Pi , when importing/loading vcs files | 173 | Fixed a crash in KO/Pi , when importing/loading vcs files |
160 | which have an entry with an attendee with state: | 174 | which have an entry with an attendee with state: |
161 | NEEDS ACTION | 175 | NEEDS ACTION |
162 | 176 | ||
163 | Fixed some problems in the German translation of OM/Pi, | 177 | Fixed some problems in the German translation of OM/Pi, |
164 | which makes some dialogs not fitting on the screen | 178 | which makes some dialogs not fitting on the screen |
165 | of the Z 5500. | 179 | of the Z 5500. |
166 | 180 | ||
167 | Fixed Qtopia crash, when disabling/deinstalling | 181 | Fixed Qtopia crash, when disabling/deinstalling |
168 | KO/Pi alarm applet. | 182 | KO/Pi alarm applet. |
169 | 183 | ||
170 | Implemented direct KDE<->KA/Pi sync for KA/Pi running | 184 | Implemented direct KDE<->KA/Pi sync for KA/Pi running |
171 | on Linux desktop. | 185 | on Linux desktop. |
172 | 186 | ||
173 | Added feature "remove sync info" to sync menu. | 187 | Added feature "remove sync info" to sync menu. |
174 | 188 | ||
175 | Tweaked the KO/Pi What's next view a bit, added | 189 | Tweaked the KO/Pi What's next view a bit, added |
176 | setting to hide events that are done. | 190 | setting to hide events that are done. |
177 | 191 | ||
178 | Disabled "beam receive enabled" on startup to | 192 | Disabled "beam receive enabled" on startup to |
179 | avoid problems if Fastload is enabled. | 193 | avoid problems if Fastload is enabled. |
180 | Please set "beam receive enabled", | 194 | Please set "beam receive enabled", |
181 | if you want to receive data via IR. | 195 | if you want to receive data via IR. |
182 | 196 | ||
183 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running | 197 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running |
184 | on Linux desktop. | 198 | on Linux desktop. |
185 | 199 | ||
186 | Made in KA/Pi scrolling possible, if details view is selected. | 200 | Made in KA/Pi scrolling possible, if details view is selected. |
187 | (The keyboard focus is set automatically to the search line) | 201 | (The keyboard focus is set automatically to the search line) |
188 | 202 | ||
189 | Fixed a bug in DMT sync, that a new entry in DTM was added | 203 | Fixed a bug in DMT sync, that a new entry in DTM was added |
190 | on every sync to Kx/Pi. | 204 | on every sync to Kx/Pi. |
191 | 205 | ||
192 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. | 206 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. |
193 | 207 | ||
194 | Fixed a bug in DMT sync with todos created in KO/Pi containing | 208 | Fixed a bug in DMT sync with todos created in KO/Pi containing |
195 | non-latin1 characters. | 209 | non-latin1 characters. |
196 | 210 | ||
197 | Rearranged package contents of Sharp-ipks and made all | 211 | Rearranged package contents of Sharp-ipks and made all |
198 | packages installable on SD again. | 212 | packages installable on SD again. |
199 | 213 | ||
200 | Fixed the writing of addressbook data in DTM sync. | 214 | Fixed the writing of addressbook data in DTM sync. |
201 | Empty fields in KA/Pi were not removed. | 215 | Empty fields in KA/Pi were not removed. |
202 | 216 | ||
203 | Added better category handling in KA/Pi: | 217 | Added better category handling in KA/Pi: |
204 | Added item | 218 | Added item |
205 | Edit Categories and | 219 | Edit Categories and |
206 | Manage new categories | 220 | Manage new categories |
207 | to the settings menu. | 221 | to the settings menu. |
208 | Possible to configure a view to display categories. | 222 | Possible to configure a view to display categories. |
209 | 223 | ||
210 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. | 224 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. |
211 | 225 | ||
212 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. | 226 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. |
213 | 227 | ||
214 | ... and many other bugfixes. | 228 | ... and many other bugfixes. |
215 | 229 | ||
216 | ********** VERSION 1.9.10 ************ | 230 | ********** VERSION 1.9.10 ************ |
217 | 231 | ||
218 | Many internal small bugfixes. | 232 | Many internal small bugfixes. |
219 | And fix of the "big" bug in KO/Pi, | 233 | And fix of the "big" bug in KO/Pi, |
220 | that after Syncing the appointments had an offset by several hours. | 234 | that after Syncing the appointments had an offset by several hours. |
221 | That was a problem with the internal timezone setting, | 235 | That was a problem with the internal timezone setting, |
222 | introduced by the changed timezone configuration settings. | 236 | introduced by the changed timezone configuration settings. |
223 | 237 | ||
224 | German translation for OM/Pi is now available. | 238 | German translation for OM/Pi is now available. |
225 | 239 | ||
226 | 240 | ||
227 | ********** VERSION 1.9.9 ************ | 241 | ********** VERSION 1.9.9 ************ |
228 | 242 | ||
229 | KDE-Pim/Pi has a new Member! | 243 | KDE-Pim/Pi has a new Member! |
230 | It is called PWM/Pi (Passwordmanager/platform-independent) | 244 | It is called PWM/Pi (Passwordmanager/platform-independent) |
231 | and it is available for the Zaurus. | 245 | and it is available for the Zaurus. |
232 | It is planned, that it will be available later for Windows. | 246 | It is planned, that it will be available later for Windows. |
233 | (And for Linux, of course). | 247 | (And for Linux, of course). |
234 | It is a port of the Passwordmanager of KDE. | 248 | It is a port of the Passwordmanager of KDE. |
235 | It will need the MicroKDElibs to run. | 249 | It will need the MicroKDElibs to run. |
236 | 250 | ||
237 | Made loading of addressbooks in KA/Pi up to 7 times faster! | 251 | Made loading of addressbooks in KA/Pi up to 7 times faster! |
238 | The bigger your addressbook file, the more starting speed | 252 | The bigger your addressbook file, the more starting speed |
239 | will you gain. (relatively) | 253 | will you gain. (relatively) |
240 | 254 | ||
241 | The Qtopia addressbook connector is now platform independend | 255 | The Qtopia addressbook connector is now platform independend |
242 | as well and should work on any platform for importing/exporting | 256 | as well and should work on any platform for importing/exporting |
243 | Qtopia and Opie XML files. | 257 | Qtopia and Opie XML files. |
244 | 258 | ||
245 | Added a +30min feature to the timezone settings to make | 259 | Added a +30min feature to the timezone settings to make |
246 | KDE-Pim/Pi useable in Australia and other parts on the | 260 | KDE-Pim/Pi useable in Australia and other parts on the |
247 | world with strange timezones ;-) | 261 | world with strange timezones ;-) |
248 | 262 | ||
249 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. | 263 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. |
250 | 264 | ||
251 | It is now possible to disable the | 265 | It is now possible to disable the |
252 | "receive data via infrared" feature, such that syncing with | 266 | "receive data via infrared" feature, such that syncing with |
253 | Outlook is now possible again with Kx/Pi runing. | 267 | Outlook is now possible again with Kx/Pi runing. |
254 | Please disable it, before syncing Sharp DTM with Outlook. | 268 | Please disable it, before syncing Sharp DTM with Outlook. |
255 | For your convenience, the "receive data via infrared" feature | 269 | For your convenience, the "receive data via infrared" feature |
256 | is disabled automatically, if you sync Kx/Pi with DTM. | 270 | is disabled automatically, if you sync Kx/Pi with DTM. |
257 | You have to enable it again manually after syncing. | 271 | You have to enable it again manually after syncing. |
258 | Enabling this feature makes it impossible to start the | 272 | Enabling this feature makes it impossible to start the |
259 | Sharp DTM apps. If this feature is enabled, you will only get the | 273 | Sharp DTM apps. If this feature is enabled, you will only get the |
260 | alarm notification from KO/Pi and not from the Sharp calendar. | 274 | alarm notification from KO/Pi and not from the Sharp calendar. |
261 | This is very useful if you sync KO/Pi with Sharp DTM, | 275 | This is very useful if you sync KO/Pi with Sharp DTM, |
262 | because after syncing you usually would get notified about | 276 | because after syncing you usually would get notified about |
263 | an alarm by KO/Pi and the Sharp Calendar. | 277 | an alarm by KO/Pi and the Sharp Calendar. |
264 | 278 | ||
265 | Together with the Linux desktop version of KO/Pi | 279 | Together with the Linux desktop version of KO/Pi |
266 | it is now possible to sync KO/Pi on the Zaurus | 280 | it is now possible to sync KO/Pi on the Zaurus |
267 | with the complete KDE-desktop (3.3 or later) | 281 | with the complete KDE-desktop (3.3 or later) |
268 | calendar data easily. | 282 | calendar data easily. |
269 | That makes it possible to sync the Z with one | 283 | That makes it possible to sync the Z with one |
270 | click of a mouse with the KDE-Desktop. | 284 | click of a mouse with the KDE-Desktop. |
271 | This feature it available for all Zaurus platforms KO/Pi | 285 | This feature it available for all Zaurus platforms KO/Pi |
272 | is running on. | 286 | is running on. |
273 | The only thing needed is a running KO/Pi on Linux and | 287 | The only thing needed is a running KO/Pi on Linux and |
274 | a compiled version of the small | 288 | a compiled version of the small |
275 | KDE-Pim/Pi<->KDE-Desktop access command line program, | 289 | KDE-Pim/Pi<->KDE-Desktop access command line program, |
276 | which is in the KDE-Pim/Pi sources available. | 290 | which is in the KDE-Pim/Pi sources available. |
277 | 291 | ||
278 | The "KDE-desktop" syncing feature for KA/Pi will follow | 292 | The "KDE-desktop" syncing feature for KA/Pi will follow |
279 | in the next releases. | 293 | in the next releases. |
280 | 294 | ||
281 | Fixed the vcard export bug, which had the version 1.9.8. | 295 | Fixed the vcard export bug, which had the version 1.9.8. |
282 | 296 | ||
283 | Added missing GERMAN translation to KO/Pi. | 297 | Added missing GERMAN translation to KO/Pi. |
284 | Hi PsionX, could you add the missing french translation?Thx! | 298 | Hi PsionX, could you add the missing french translation?Thx! |
285 | 299 | ||
286 | Translation files for KA/Pi are available as well. | 300 | Translation files for KA/Pi are available as well. |
287 | GERMAN translation will be available in the next release. | 301 | GERMAN translation will be available in the next release. |
288 | PsionX ( yres, you again ;-) ), could you start translating | 302 | PsionX ( yres, you again ;-) ), could you start translating |
289 | KA/Pi? Thx! | 303 | KA/Pi? Thx! |
290 | 304 | ||
291 | You can download the version 1.9.9 at | 305 | You can download the version 1.9.9 at |
292 | 306 | ||
293 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 307 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 |
294 | 308 | ||
295 | Note: | 309 | Note: |
296 | To run the mail program OM/Pi you need libopenssl. | 310 | To run the mail program OM/Pi you need libopenssl. |
297 | A link to a download loaction is available at | 311 | A link to a download loaction is available at |
298 | ZSI at www.killefiz.de | 312 | ZSI at www.killefiz.de |
299 | 313 | ||
300 | 314 | ||
301 | ********** VERSION 1.9.8 ************ | 315 | ********** VERSION 1.9.8 ************ |
302 | 316 | ||
303 | Fixed character decoding in OM/Pi. | 317 | Fixed character decoding in OM/Pi. |
304 | (e.g. German "Umlaute" were not displayed properly.) | 318 | (e.g. German "Umlaute" were not displayed properly.) |
305 | 319 | ||
306 | Made is possible to reparent todos in KO/Pi. | 320 | Made is possible to reparent todos in KO/Pi. |
307 | Use contextmenu or keys (look at Help-Keys + Colors) for that. | 321 | Use contextmenu or keys (look at Help-Keys + Colors) for that. |
308 | 322 | ||
309 | Added the missing Sync-Howto and WhatsNew to the packages. | 323 | Added the missing Sync-Howto and WhatsNew to the packages. |
310 | 324 | ||
311 | KO/Pi on Linux desktop can now sync with KDE desktop. | 325 | KO/Pi on Linux desktop can now sync with KDE desktop. |
312 | That means: When using KO/Pi on Linux desktop for syncing with | 326 | That means: When using KO/Pi on Linux desktop for syncing with |
313 | KDE desktop and the Zaurus, the Zaurus can be synced now | 327 | KDE desktop and the Zaurus, the Zaurus can be synced now |
314 | with all KDE-Calendar resources, not only with one local file. | 328 | with all KDE-Calendar resources, not only with one local file. |
315 | (That makes it possible to sync the Zaurus with the | 329 | (That makes it possible to sync the Zaurus with the |
316 | calendar data on a Kolab server) | 330 | calendar data on a Kolab server) |
317 | 331 | ||
318 | KA/Pi syncing with KDE desktop will be available in the next version. | 332 | KA/Pi syncing with KDE desktop will be available in the next version. |
319 | 333 | ||
320 | 334 | ||
321 | ********** VERSION 1.9.7 ************ | 335 | ********** VERSION 1.9.7 ************ |
322 | 336 | ||
323 | KO/Pi - KA/Pi on Windows: | 337 | KO/Pi - KA/Pi on Windows: |
324 | Now a directory can be defined by the user, where the | 338 | Now a directory can be defined by the user, where the |
325 | application/config data should be saved. | 339 | application/config data should be saved. |
326 | Define your desired path in the evironment variable | 340 | Define your desired path in the evironment variable |
327 | MICROKDEHOME | 341 | MICROKDEHOME |
328 | before starting KO/Pi or KA/Pi. | 342 | before starting KO/Pi or KA/Pi. |
329 | 343 | ||
330 | An easy Kx/Pi to Kx/Pi syncing is now possible | 344 | An easy Kx/Pi to Kx/Pi syncing is now possible |
331 | (it is called Pi-Sync) via network. | 345 | (it is called Pi-Sync) via network. |
332 | Please look at the Sync Howto. | 346 | Please look at the Sync Howto. |
333 | 347 | ||
334 | Exporting of calendar data and contacts to mobile phones is now possible. | 348 | Exporting of calendar data and contacts to mobile phones is now possible. |
335 | The SyncHowto is updated with information howto | 349 | The SyncHowto is updated with information howto |
336 | access/sync mobile phones. | 350 | access/sync mobile phones. |
337 | Please look at the Sync Howto. | 351 | Please look at the Sync Howto. |
338 | 352 | ||
339 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. | 353 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. |
340 | Please disable Fastload for the original contact/calendar applications | 354 | Please disable Fastload for the original contact/calendar applications |
341 | and close them. | 355 | and close them. |
342 | KO/Pi and KA/Pi must be running in order to receive the data. | 356 | KO/Pi and KA/Pi must be running in order to receive the data. |
343 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) | 357 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) |
344 | 358 | ||
345 | In the KA/Pi details view are now the preferred tel. numbers displayed on top | 359 | In the KA/Pi details view are now the preferred tel. numbers displayed on top |
346 | of the other data ( emails/tel.numbers/addresses) | 360 | of the other data ( emails/tel.numbers/addresses) |
347 | 361 | ||
348 | Fixed some syncing problems in KA/Pi. | 362 | Fixed some syncing problems in KA/Pi. |
349 | 363 | ||
350 | Added font settings for the KA/Pi details view. | 364 | Added font settings for the KA/Pi details view. |
351 | Added fields "children's name" and "gender" to KA/Pi. | 365 | Added fields "children's name" and "gender" to KA/Pi. |
352 | 366 | ||
353 | Made searching in KA/Pi better: | 367 | Made searching in KA/Pi better: |
354 | Now the first item in a view is selected after a search automatically and | 368 | Now the first item in a view is selected after a search automatically and |
355 | the views can be scrolled up/down when the search input field has the keyboard focus. | 369 | the views can be scrolled up/down when the search input field has the keyboard focus. |
356 | 370 | ||
357 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. | 371 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. |
358 | 372 | ||
359 | 373 | ||
360 | ********** VERSION 1.9.6 ************ | 374 | ********** VERSION 1.9.6 ************ |
361 | 375 | ||
362 | Changes in the external application communication on the Zaurus | 376 | Changes in the external application communication on the Zaurus |
363 | in order to use less RAM when the apps are running. | 377 | in order to use less RAM when the apps are running. |
364 | First syncing of addressbooks (KA/Pi) is possible. | 378 | First syncing of addressbooks (KA/Pi) is possible. |
365 | 379 | ||
366 | 380 | ||
367 | ********** VERSION 1.9.5a ************ | 381 | ********** VERSION 1.9.5a ************ |
368 | 382 | ||
369 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. | 383 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. |
370 | Fixed some small bugs. | 384 | Fixed some small bugs. |
371 | KA/Pi shows now the birthday in summary view. | 385 | KA/Pi shows now the birthday in summary view. |
372 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi | 386 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi |
373 | for displaying dates. | 387 | for displaying dates. |
374 | 388 | ||
375 | 389 | ||
376 | ********** VERSION 1.9.5 ************ | 390 | ********** VERSION 1.9.5 ************ |
377 | 391 | ||
378 | There is still no Addressbook syncing! | 392 | There is still no Addressbook syncing! |
379 | 393 | ||
380 | New in 1.9.5: | 394 | New in 1.9.5: |
381 | 395 | ||
382 | Many bugfixes. | 396 | Many bugfixes. |
383 | Better searching in KA/Pi. | 397 | Better searching in KA/Pi. |
384 | You can configure in KA/Pi if you want to search only after | 398 | You can configure in KA/Pi if you want to search only after |
385 | <return> key pressed. | 399 | <return> key pressed. |
386 | 400 | ||
387 | Better mail downloading in OM/Pi. | 401 | Better mail downloading in OM/Pi. |
388 | 402 | ||
389 | First experimental alpha version of sync of KO/Pi with mobile phones. | 403 | First experimental alpha version of sync of KO/Pi with mobile phones. |
390 | See gammu documentation for supported phones. | 404 | See gammu documentation for supported phones. |
391 | 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. | 405 | 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. |
392 | Quick hint how to use: | 406 | Quick hint how to use: |
393 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! | 407 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! |
394 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. | 408 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3ce733d..568dfc4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1302,831 +1302,833 @@ void Addressee::setNameFromString( const QString &str ) | |||
1302 | prefixes += "von"; | 1302 | prefixes += "von"; |
1303 | prefixes += "de"; | 1303 | prefixes += "de"; |
1304 | 1304 | ||
1305 | KConfig config( locateLocal( "config", "kabcrc") ); | 1305 | KConfig config( locateLocal( "config", "kabcrc") ); |
1306 | config.setGroup( "General" ); | 1306 | config.setGroup( "General" ); |
1307 | titles += config.readListEntry( "Prefixes" ); | 1307 | titles += config.readListEntry( "Prefixes" ); |
1308 | titles.remove( "" ); | 1308 | titles.remove( "" ); |
1309 | prefixes += config.readListEntry( "Inclusions" ); | 1309 | prefixes += config.readListEntry( "Inclusions" ); |
1310 | prefixes.remove( "" ); | 1310 | prefixes.remove( "" ); |
1311 | suffixes += config.readListEntry( "Suffixes" ); | 1311 | suffixes += config.readListEntry( "Suffixes" ); |
1312 | suffixes.remove( "" ); | 1312 | suffixes.remove( "" ); |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | // clear all name parts | 1315 | // clear all name parts |
1316 | setPrefix( "" ); | 1316 | setPrefix( "" ); |
1317 | setGivenName( "" ); | 1317 | setGivenName( "" ); |
1318 | setAdditionalName( "" ); | 1318 | setAdditionalName( "" ); |
1319 | setFamilyName( "" ); | 1319 | setFamilyName( "" ); |
1320 | setSuffix( "" ); | 1320 | setSuffix( "" ); |
1321 | 1321 | ||
1322 | if ( str.isEmpty() ) | 1322 | if ( str.isEmpty() ) |
1323 | return; | 1323 | return; |
1324 | 1324 | ||
1325 | int i = str.find(','); | 1325 | int i = str.find(','); |
1326 | if( i < 0 ) { | 1326 | if( i < 0 ) { |
1327 | QStringList parts = QStringList::split( " ", str ); | 1327 | QStringList parts = QStringList::split( " ", str ); |
1328 | int leftOffset = 0; | 1328 | int leftOffset = 0; |
1329 | int rightOffset = parts.count() - 1; | 1329 | int rightOffset = parts.count() - 1; |
1330 | 1330 | ||
1331 | QString suffix; | 1331 | QString suffix; |
1332 | while ( rightOffset >= 0 ) { | 1332 | while ( rightOffset >= 0 ) { |
1333 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1333 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1334 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1334 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1335 | rightOffset--; | 1335 | rightOffset--; |
1336 | } else | 1336 | } else |
1337 | break; | 1337 | break; |
1338 | } | 1338 | } |
1339 | setSuffix( suffix ); | 1339 | setSuffix( suffix ); |
1340 | 1340 | ||
1341 | if ( rightOffset < 0 ) | 1341 | if ( rightOffset < 0 ) |
1342 | return; | 1342 | return; |
1343 | 1343 | ||
1344 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1344 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1345 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1345 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1346 | rightOffset--; | 1346 | rightOffset--; |
1347 | } else | 1347 | } else |
1348 | setFamilyName( parts[ rightOffset ] ); | 1348 | setFamilyName( parts[ rightOffset ] ); |
1349 | 1349 | ||
1350 | QString prefix; | 1350 | QString prefix; |
1351 | while ( leftOffset < rightOffset ) { | 1351 | while ( leftOffset < rightOffset ) { |
1352 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1352 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1353 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1353 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1354 | leftOffset++; | 1354 | leftOffset++; |
1355 | } else | 1355 | } else |
1356 | break; | 1356 | break; |
1357 | } | 1357 | } |
1358 | setPrefix( prefix ); | 1358 | setPrefix( prefix ); |
1359 | 1359 | ||
1360 | if ( leftOffset < rightOffset ) { | 1360 | if ( leftOffset < rightOffset ) { |
1361 | setGivenName( parts[ leftOffset ] ); | 1361 | setGivenName( parts[ leftOffset ] ); |
1362 | leftOffset++; | 1362 | leftOffset++; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | QString additionalName; | 1365 | QString additionalName; |
1366 | while ( leftOffset < rightOffset ) { | 1366 | while ( leftOffset < rightOffset ) { |
1367 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1367 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1368 | leftOffset++; | 1368 | leftOffset++; |
1369 | } | 1369 | } |
1370 | setAdditionalName( additionalName ); | 1370 | setAdditionalName( additionalName ); |
1371 | } else { | 1371 | } else { |
1372 | QString part1 = str.left( i ); | 1372 | QString part1 = str.left( i ); |
1373 | QString part2 = str.mid( i + 1 ); | 1373 | QString part2 = str.mid( i + 1 ); |
1374 | 1374 | ||
1375 | QStringList parts = QStringList::split( " ", part1 ); | 1375 | QStringList parts = QStringList::split( " ", part1 ); |
1376 | int leftOffset = 0; | 1376 | int leftOffset = 0; |
1377 | int rightOffset = parts.count() - 1; | 1377 | int rightOffset = parts.count() - 1; |
1378 | 1378 | ||
1379 | QString suffix; | 1379 | QString suffix; |
1380 | while ( rightOffset >= 0 ) { | 1380 | while ( rightOffset >= 0 ) { |
1381 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1381 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1382 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1382 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1383 | rightOffset--; | 1383 | rightOffset--; |
1384 | } else | 1384 | } else |
1385 | break; | 1385 | break; |
1386 | } | 1386 | } |
1387 | setSuffix( suffix ); | 1387 | setSuffix( suffix ); |
1388 | 1388 | ||
1389 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1389 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1390 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1390 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1391 | rightOffset--; | 1391 | rightOffset--; |
1392 | } else | 1392 | } else |
1393 | setFamilyName( parts[ rightOffset ] ); | 1393 | setFamilyName( parts[ rightOffset ] ); |
1394 | 1394 | ||
1395 | QString prefix; | 1395 | QString prefix; |
1396 | while ( leftOffset < rightOffset ) { | 1396 | while ( leftOffset < rightOffset ) { |
1397 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1397 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1398 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1398 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1399 | leftOffset++; | 1399 | leftOffset++; |
1400 | } else | 1400 | } else |
1401 | break; | 1401 | break; |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | parts = QStringList::split( " ", part2 ); | 1404 | parts = QStringList::split( " ", part2 ); |
1405 | 1405 | ||
1406 | leftOffset = 0; | 1406 | leftOffset = 0; |
1407 | rightOffset = parts.count(); | 1407 | rightOffset = parts.count(); |
1408 | 1408 | ||
1409 | while ( leftOffset < rightOffset ) { | 1409 | while ( leftOffset < rightOffset ) { |
1410 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1410 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1412 | leftOffset++; | 1412 | leftOffset++; |
1413 | } else | 1413 | } else |
1414 | break; | 1414 | break; |
1415 | } | 1415 | } |
1416 | setPrefix( prefix ); | 1416 | setPrefix( prefix ); |
1417 | 1417 | ||
1418 | if ( leftOffset < rightOffset ) { | 1418 | if ( leftOffset < rightOffset ) { |
1419 | setGivenName( parts[ leftOffset ] ); | 1419 | setGivenName( parts[ leftOffset ] ); |
1420 | leftOffset++; | 1420 | leftOffset++; |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | QString additionalName; | 1423 | QString additionalName; |
1424 | while ( leftOffset < rightOffset ) { | 1424 | while ( leftOffset < rightOffset ) { |
1425 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1425 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1426 | leftOffset++; | 1426 | leftOffset++; |
1427 | } | 1427 | } |
1428 | setAdditionalName( additionalName ); | 1428 | setAdditionalName( additionalName ); |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | QString Addressee::realName() const | 1432 | QString Addressee::realName() const |
1433 | { | 1433 | { |
1434 | if ( !formattedName().isEmpty() ) | 1434 | if ( !formattedName().isEmpty() ) |
1435 | return formattedName(); | 1435 | return formattedName(); |
1436 | 1436 | ||
1437 | QString n = assembledName(); | 1437 | QString n = assembledName(); |
1438 | 1438 | ||
1439 | if ( n.isEmpty() ) | 1439 | if ( n.isEmpty() ) |
1440 | n = name(); | 1440 | n = name(); |
1441 | 1441 | ||
1442 | return n; | 1442 | return n; |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | QString Addressee::assembledName() const | 1445 | QString Addressee::assembledName() const |
1446 | { | 1446 | { |
1447 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1447 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1448 | familyName() + " " + suffix(); | 1448 | familyName() + " " + suffix(); |
1449 | 1449 | ||
1450 | return name.simplifyWhiteSpace(); | 1450 | return name.simplifyWhiteSpace(); |
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | QString Addressee::fullEmail( const QString &email ) const | 1453 | QString Addressee::fullEmail( const QString &email ) const |
1454 | { | 1454 | { |
1455 | QString e; | 1455 | QString e; |
1456 | if ( email.isNull() ) { | 1456 | if ( email.isNull() ) { |
1457 | e = preferredEmail(); | 1457 | e = preferredEmail(); |
1458 | } else { | 1458 | } else { |
1459 | e = email; | 1459 | e = email; |
1460 | } | 1460 | } |
1461 | if ( e.isEmpty() ) return QString::null; | 1461 | if ( e.isEmpty() ) return QString::null; |
1462 | 1462 | ||
1463 | QString text; | 1463 | QString text; |
1464 | if ( realName().isEmpty() ) | 1464 | if ( realName().isEmpty() ) |
1465 | text = e; | 1465 | text = e; |
1466 | else | 1466 | else |
1467 | text = assembledName() + " <" + e + ">"; | 1467 | text = assembledName() + " <" + e + ">"; |
1468 | 1468 | ||
1469 | return text; | 1469 | return text; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1472 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1473 | { | 1473 | { |
1474 | detach(); | 1474 | detach(); |
1475 | 1475 | ||
1476 | QStringList::Iterator it = mData->emails.find( email ); | 1476 | QStringList::Iterator it = mData->emails.find( email ); |
1477 | 1477 | ||
1478 | if ( it != mData->emails.end() ) { | 1478 | if ( it != mData->emails.end() ) { |
1479 | if ( !preferred || it == mData->emails.begin() ) return; | 1479 | if ( !preferred || it == mData->emails.begin() ) return; |
1480 | mData->emails.remove( it ); | 1480 | mData->emails.remove( it ); |
1481 | mData->emails.prepend( email ); | 1481 | mData->emails.prepend( email ); |
1482 | } else { | 1482 | } else { |
1483 | if ( preferred ) { | 1483 | if ( preferred ) { |
1484 | mData->emails.prepend( email ); | 1484 | mData->emails.prepend( email ); |
1485 | } else { | 1485 | } else { |
1486 | mData->emails.append( email ); | 1486 | mData->emails.append( email ); |
1487 | } | 1487 | } |
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void Addressee::removeEmail( const QString &email ) | 1491 | void Addressee::removeEmail( const QString &email ) |
1492 | { | 1492 | { |
1493 | detach(); | 1493 | detach(); |
1494 | 1494 | ||
1495 | QStringList::Iterator it = mData->emails.find( email ); | 1495 | QStringList::Iterator it = mData->emails.find( email ); |
1496 | if ( it == mData->emails.end() ) return; | 1496 | if ( it == mData->emails.end() ) return; |
1497 | 1497 | ||
1498 | mData->emails.remove( it ); | 1498 | mData->emails.remove( it ); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | QString Addressee::preferredEmail() const | 1501 | QString Addressee::preferredEmail() const |
1502 | { | 1502 | { |
1503 | if ( mData->emails.count() == 0 ) return QString::null; | 1503 | if ( mData->emails.count() == 0 ) return QString::null; |
1504 | else return mData->emails.first(); | 1504 | else return mData->emails.first(); |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | QStringList Addressee::emails() const | 1507 | QStringList Addressee::emails() const |
1508 | { | 1508 | { |
1509 | return mData->emails; | 1509 | return mData->emails; |
1510 | } | 1510 | } |
1511 | void Addressee::setEmails( const QStringList& emails ) { | 1511 | void Addressee::setEmails( const QStringList& emails ) { |
1512 | detach(); | 1512 | detach(); |
1513 | mData->emails = emails; | 1513 | mData->emails = emails; |
1514 | } | 1514 | } |
1515 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1515 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1516 | { | 1516 | { |
1517 | detach(); | 1517 | detach(); |
1518 | mData->empty = false; | 1518 | mData->empty = false; |
1519 | 1519 | ||
1520 | PhoneNumber::List::Iterator it; | 1520 | PhoneNumber::List::Iterator it; |
1521 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1521 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1522 | if ( (*it).id() == phoneNumber.id() ) { | 1522 | if ( (*it).id() == phoneNumber.id() ) { |
1523 | *it = phoneNumber; | 1523 | *it = phoneNumber; |
1524 | return; | 1524 | return; |
1525 | } | 1525 | } |
1526 | } | 1526 | } |
1527 | mData->phoneNumbers.append( phoneNumber ); | 1527 | mData->phoneNumbers.append( phoneNumber ); |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1530 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1531 | { | 1531 | { |
1532 | detach(); | 1532 | detach(); |
1533 | 1533 | ||
1534 | PhoneNumber::List::Iterator it; | 1534 | PhoneNumber::List::Iterator it; |
1535 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1535 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1536 | if ( (*it).id() == phoneNumber.id() ) { | 1536 | if ( (*it).id() == phoneNumber.id() ) { |
1537 | mData->phoneNumbers.remove( it ); | 1537 | mData->phoneNumbers.remove( it ); |
1538 | return; | 1538 | return; |
1539 | } | 1539 | } |
1540 | } | 1540 | } |
1541 | } | 1541 | } |
1542 | 1542 | ||
1543 | PhoneNumber Addressee::phoneNumber( int type ) const | 1543 | PhoneNumber Addressee::phoneNumber( int type ) const |
1544 | { | 1544 | { |
1545 | PhoneNumber phoneNumber( "", type ); | 1545 | PhoneNumber phoneNumber( "", type ); |
1546 | PhoneNumber::List::ConstIterator it; | 1546 | PhoneNumber::List::ConstIterator it; |
1547 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1547 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1548 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1548 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1549 | if ( (*it).type() & PhoneNumber::Pref ) | 1549 | if ( (*it).type() & PhoneNumber::Pref ) |
1550 | return (*it); | 1550 | return (*it); |
1551 | else if ( phoneNumber.number().isEmpty() ) | 1551 | else if ( phoneNumber.number().isEmpty() ) |
1552 | phoneNumber = (*it); | 1552 | phoneNumber = (*it); |
1553 | } | 1553 | } |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | return phoneNumber; | 1556 | return phoneNumber; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | PhoneNumber::List Addressee::phoneNumbers() const | 1559 | PhoneNumber::List Addressee::phoneNumbers() const |
1560 | { | 1560 | { |
1561 | return mData->phoneNumbers; | 1561 | return mData->phoneNumbers; |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1564 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1565 | { | 1565 | { |
1566 | PhoneNumber::List list; | 1566 | PhoneNumber::List list; |
1567 | 1567 | ||
1568 | PhoneNumber::List::ConstIterator it; | 1568 | PhoneNumber::List::ConstIterator it; |
1569 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1569 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1570 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1570 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1571 | list.append( *it ); | 1571 | list.append( *it ); |
1572 | } | 1572 | } |
1573 | } | 1573 | } |
1574 | return list; | 1574 | return list; |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1577 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1578 | { | 1578 | { |
1579 | PhoneNumber::List::ConstIterator it; | 1579 | PhoneNumber::List::ConstIterator it; |
1580 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1580 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1581 | if ( (*it).id() == id ) { | 1581 | if ( (*it).id() == id ) { |
1582 | return *it; | 1582 | return *it; |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | return PhoneNumber(); | 1585 | return PhoneNumber(); |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | void Addressee::insertKey( const Key &key ) | 1588 | void Addressee::insertKey( const Key &key ) |
1589 | { | 1589 | { |
1590 | detach(); | 1590 | detach(); |
1591 | mData->empty = false; | 1591 | mData->empty = false; |
1592 | 1592 | ||
1593 | Key::List::Iterator it; | 1593 | Key::List::Iterator it; |
1594 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1594 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1595 | if ( (*it).id() == key.id() ) { | 1595 | if ( (*it).id() == key.id() ) { |
1596 | *it = key; | 1596 | *it = key; |
1597 | return; | 1597 | return; |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | mData->keys.append( key ); | 1600 | mData->keys.append( key ); |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | void Addressee::removeKey( const Key &key ) | 1603 | void Addressee::removeKey( const Key &key ) |
1604 | { | 1604 | { |
1605 | detach(); | 1605 | detach(); |
1606 | 1606 | ||
1607 | Key::List::Iterator it; | 1607 | Key::List::Iterator it; |
1608 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1608 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1609 | if ( (*it).id() == key.id() ) { | 1609 | if ( (*it).id() == key.id() ) { |
1610 | mData->keys.remove( key ); | 1610 | mData->keys.remove( key ); |
1611 | return; | 1611 | return; |
1612 | } | 1612 | } |
1613 | } | 1613 | } |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | Key Addressee::key( int type, QString customTypeString ) const | 1616 | Key Addressee::key( int type, QString customTypeString ) const |
1617 | { | 1617 | { |
1618 | Key::List::ConstIterator it; | 1618 | Key::List::ConstIterator it; |
1619 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1619 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1620 | if ( (*it).type() == type ) { | 1620 | if ( (*it).type() == type ) { |
1621 | if ( type == Key::Custom ) { | 1621 | if ( type == Key::Custom ) { |
1622 | if ( customTypeString.isEmpty() ) { | 1622 | if ( customTypeString.isEmpty() ) { |
1623 | return *it; | 1623 | return *it; |
1624 | } else { | 1624 | } else { |
1625 | if ( (*it).customTypeString() == customTypeString ) | 1625 | if ( (*it).customTypeString() == customTypeString ) |
1626 | return (*it); | 1626 | return (*it); |
1627 | } | 1627 | } |
1628 | } else { | 1628 | } else { |
1629 | return *it; | 1629 | return *it; |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | return Key( QString(), type ); | 1633 | return Key( QString(), type ); |
1634 | } | 1634 | } |
1635 | void Addressee::setKeys( const Key::List& list ) { | 1635 | void Addressee::setKeys( const Key::List& list ) { |
1636 | detach(); | 1636 | detach(); |
1637 | mData->keys = list; | 1637 | mData->keys = list; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | Key::List Addressee::keys() const | 1640 | Key::List Addressee::keys() const |
1641 | { | 1641 | { |
1642 | return mData->keys; | 1642 | return mData->keys; |
1643 | } | 1643 | } |
1644 | 1644 | ||
1645 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1645 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1646 | { | 1646 | { |
1647 | Key::List list; | 1647 | Key::List list; |
1648 | 1648 | ||
1649 | Key::List::ConstIterator it; | 1649 | Key::List::ConstIterator it; |
1650 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1650 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1651 | if ( (*it).type() == type ) { | 1651 | if ( (*it).type() == type ) { |
1652 | if ( type == Key::Custom ) { | 1652 | if ( type == Key::Custom ) { |
1653 | if ( customTypeString.isEmpty() ) { | 1653 | if ( customTypeString.isEmpty() ) { |
1654 | list.append(*it); | 1654 | list.append(*it); |
1655 | } else { | 1655 | } else { |
1656 | if ( (*it).customTypeString() == customTypeString ) | 1656 | if ( (*it).customTypeString() == customTypeString ) |
1657 | list.append(*it); | 1657 | list.append(*it); |
1658 | } | 1658 | } |
1659 | } else { | 1659 | } else { |
1660 | list.append(*it); | 1660 | list.append(*it); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | return list; | 1664 | return list; |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | Key Addressee::findKey( const QString &id ) const | 1667 | Key Addressee::findKey( const QString &id ) const |
1668 | { | 1668 | { |
1669 | Key::List::ConstIterator it; | 1669 | Key::List::ConstIterator it; |
1670 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1670 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1671 | if ( (*it).id() == id ) { | 1671 | if ( (*it).id() == id ) { |
1672 | return *it; | 1672 | return *it; |
1673 | } | 1673 | } |
1674 | } | 1674 | } |
1675 | return Key(); | 1675 | return Key(); |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | QString Addressee::asString() const | 1678 | QString Addressee::asString() const |
1679 | { | 1679 | { |
1680 | return "Smith, agent Smith..."; | 1680 | return "Smith, agent Smith..."; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | void Addressee::dump() const | 1683 | void Addressee::dump() const |
1684 | { | 1684 | { |
1685 | return; | 1685 | return; |
1686 | #if 0 | ||
1686 | kdDebug(5700) << "Addressee {" << endl; | 1687 | kdDebug(5700) << "Addressee {" << endl; |
1687 | 1688 | ||
1688 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1689 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1689 | 1690 | ||
1690 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1691 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1691 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1692 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1692 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1693 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1693 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1694 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1694 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1695 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1695 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1696 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1696 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1697 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1697 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1698 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1698 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1699 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1699 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1700 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1700 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1701 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1701 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1702 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1702 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1703 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1703 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1704 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1704 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1705 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1705 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1706 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1706 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1707 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1707 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1708 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1708 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1709 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1709 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1710 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1710 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1711 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1711 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1712 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1712 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1713 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1713 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1714 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1715 | 1716 | ||
1716 | kdDebug(5700) << " Emails {" << endl; | 1717 | kdDebug(5700) << " Emails {" << endl; |
1717 | QStringList e = emails(); | 1718 | QStringList e = emails(); |
1718 | QStringList::ConstIterator it; | 1719 | QStringList::ConstIterator it; |
1719 | for( it = e.begin(); it != e.end(); ++it ) { | 1720 | for( it = e.begin(); it != e.end(); ++it ) { |
1720 | kdDebug(5700) << " " << (*it) << endl; | 1721 | kdDebug(5700) << " " << (*it) << endl; |
1721 | } | 1722 | } |
1722 | kdDebug(5700) << " }" << endl; | 1723 | kdDebug(5700) << " }" << endl; |
1723 | 1724 | ||
1724 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1725 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1725 | PhoneNumber::List p = phoneNumbers(); | 1726 | PhoneNumber::List p = phoneNumbers(); |
1726 | PhoneNumber::List::ConstIterator it2; | 1727 | PhoneNumber::List::ConstIterator it2; |
1727 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1728 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1728 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1729 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1729 | } | 1730 | } |
1730 | kdDebug(5700) << " }" << endl; | 1731 | kdDebug(5700) << " }" << endl; |
1731 | 1732 | ||
1732 | Address::List a = addresses(); | 1733 | Address::List a = addresses(); |
1733 | Address::List::ConstIterator it3; | 1734 | Address::List::ConstIterator it3; |
1734 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1735 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1735 | (*it3).dump(); | 1736 | (*it3).dump(); |
1736 | } | 1737 | } |
1737 | 1738 | ||
1738 | kdDebug(5700) << " Keys {" << endl; | 1739 | kdDebug(5700) << " Keys {" << endl; |
1739 | Key::List k = keys(); | 1740 | Key::List k = keys(); |
1740 | Key::List::ConstIterator it4; | 1741 | Key::List::ConstIterator it4; |
1741 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1742 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1742 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1743 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1743 | " Key: " << (*it4).textData() << | 1744 | " Key: " << (*it4).textData() << |
1744 | " CustomString: " << (*it4).customTypeString() << endl; | 1745 | " CustomString: " << (*it4).customTypeString() << endl; |
1745 | } | 1746 | } |
1746 | kdDebug(5700) << " }" << endl; | 1747 | kdDebug(5700) << " }" << endl; |
1747 | 1748 | ||
1748 | kdDebug(5700) << "}" << endl; | 1749 | kdDebug(5700) << "}" << endl; |
1750 | #endif | ||
1749 | } | 1751 | } |
1750 | 1752 | ||
1751 | 1753 | ||
1752 | void Addressee::insertAddress( const Address &address ) | 1754 | void Addressee::insertAddress( const Address &address ) |
1753 | { | 1755 | { |
1754 | detach(); | 1756 | detach(); |
1755 | mData->empty = false; | 1757 | mData->empty = false; |
1756 | 1758 | ||
1757 | Address::List::Iterator it; | 1759 | Address::List::Iterator it; |
1758 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1760 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1759 | if ( (*it).id() == address.id() ) { | 1761 | if ( (*it).id() == address.id() ) { |
1760 | *it = address; | 1762 | *it = address; |
1761 | return; | 1763 | return; |
1762 | } | 1764 | } |
1763 | } | 1765 | } |
1764 | mData->addresses.append( address ); | 1766 | mData->addresses.append( address ); |
1765 | } | 1767 | } |
1766 | 1768 | ||
1767 | void Addressee::removeAddress( const Address &address ) | 1769 | void Addressee::removeAddress( const Address &address ) |
1768 | { | 1770 | { |
1769 | detach(); | 1771 | detach(); |
1770 | 1772 | ||
1771 | Address::List::Iterator it; | 1773 | Address::List::Iterator it; |
1772 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1774 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1773 | if ( (*it).id() == address.id() ) { | 1775 | if ( (*it).id() == address.id() ) { |
1774 | mData->addresses.remove( it ); | 1776 | mData->addresses.remove( it ); |
1775 | return; | 1777 | return; |
1776 | } | 1778 | } |
1777 | } | 1779 | } |
1778 | } | 1780 | } |
1779 | 1781 | ||
1780 | Address Addressee::address( int type ) const | 1782 | Address Addressee::address( int type ) const |
1781 | { | 1783 | { |
1782 | Address address( type ); | 1784 | Address address( type ); |
1783 | Address::List::ConstIterator it; | 1785 | Address::List::ConstIterator it; |
1784 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1786 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1785 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1787 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1786 | if ( (*it).type() & Address::Pref ) | 1788 | if ( (*it).type() & Address::Pref ) |
1787 | return (*it); | 1789 | return (*it); |
1788 | else if ( address.isEmpty() ) | 1790 | else if ( address.isEmpty() ) |
1789 | address = (*it); | 1791 | address = (*it); |
1790 | } | 1792 | } |
1791 | } | 1793 | } |
1792 | 1794 | ||
1793 | return address; | 1795 | return address; |
1794 | } | 1796 | } |
1795 | 1797 | ||
1796 | Address::List Addressee::addresses() const | 1798 | Address::List Addressee::addresses() const |
1797 | { | 1799 | { |
1798 | return mData->addresses; | 1800 | return mData->addresses; |
1799 | } | 1801 | } |
1800 | 1802 | ||
1801 | Address::List Addressee::addresses( int type ) const | 1803 | Address::List Addressee::addresses( int type ) const |
1802 | { | 1804 | { |
1803 | Address::List list; | 1805 | Address::List list; |
1804 | 1806 | ||
1805 | Address::List::ConstIterator it; | 1807 | Address::List::ConstIterator it; |
1806 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1808 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1807 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1809 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1808 | list.append( *it ); | 1810 | list.append( *it ); |
1809 | } | 1811 | } |
1810 | } | 1812 | } |
1811 | 1813 | ||
1812 | return list; | 1814 | return list; |
1813 | } | 1815 | } |
1814 | 1816 | ||
1815 | Address Addressee::findAddress( const QString &id ) const | 1817 | Address Addressee::findAddress( const QString &id ) const |
1816 | { | 1818 | { |
1817 | Address::List::ConstIterator it; | 1819 | Address::List::ConstIterator it; |
1818 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1820 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1819 | if ( (*it).id() == id ) { | 1821 | if ( (*it).id() == id ) { |
1820 | return *it; | 1822 | return *it; |
1821 | } | 1823 | } |
1822 | } | 1824 | } |
1823 | return Address(); | 1825 | return Address(); |
1824 | } | 1826 | } |
1825 | 1827 | ||
1826 | void Addressee::insertCategory( const QString &c ) | 1828 | void Addressee::insertCategory( const QString &c ) |
1827 | { | 1829 | { |
1828 | detach(); | 1830 | detach(); |
1829 | mData->empty = false; | 1831 | mData->empty = false; |
1830 | 1832 | ||
1831 | if ( mData->categories.contains( c ) ) return; | 1833 | if ( mData->categories.contains( c ) ) return; |
1832 | 1834 | ||
1833 | mData->categories.append( c ); | 1835 | mData->categories.append( c ); |
1834 | } | 1836 | } |
1835 | 1837 | ||
1836 | void Addressee::removeCategory( const QString &c ) | 1838 | void Addressee::removeCategory( const QString &c ) |
1837 | { | 1839 | { |
1838 | detach(); | 1840 | detach(); |
1839 | 1841 | ||
1840 | QStringList::Iterator it = mData->categories.find( c ); | 1842 | QStringList::Iterator it = mData->categories.find( c ); |
1841 | if ( it == mData->categories.end() ) return; | 1843 | if ( it == mData->categories.end() ) return; |
1842 | 1844 | ||
1843 | mData->categories.remove( it ); | 1845 | mData->categories.remove( it ); |
1844 | } | 1846 | } |
1845 | 1847 | ||
1846 | bool Addressee::hasCategory( const QString &c ) const | 1848 | bool Addressee::hasCategory( const QString &c ) const |
1847 | { | 1849 | { |
1848 | return ( mData->categories.contains( c ) ); | 1850 | return ( mData->categories.contains( c ) ); |
1849 | } | 1851 | } |
1850 | 1852 | ||
1851 | void Addressee::setCategories( const QStringList &c ) | 1853 | void Addressee::setCategories( const QStringList &c ) |
1852 | { | 1854 | { |
1853 | detach(); | 1855 | detach(); |
1854 | mData->empty = false; | 1856 | mData->empty = false; |
1855 | 1857 | ||
1856 | mData->categories = c; | 1858 | mData->categories = c; |
1857 | } | 1859 | } |
1858 | 1860 | ||
1859 | QStringList Addressee::categories() const | 1861 | QStringList Addressee::categories() const |
1860 | { | 1862 | { |
1861 | return mData->categories; | 1863 | return mData->categories; |
1862 | } | 1864 | } |
1863 | 1865 | ||
1864 | void Addressee::insertCustom( const QString &app, const QString &name, | 1866 | void Addressee::insertCustom( const QString &app, const QString &name, |
1865 | const QString &value ) | 1867 | const QString &value ) |
1866 | { | 1868 | { |
1867 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1869 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1868 | 1870 | ||
1869 | detach(); | 1871 | detach(); |
1870 | mData->empty = false; | 1872 | mData->empty = false; |
1871 | 1873 | ||
1872 | QString qualifiedName = app + "-" + name + ":"; | 1874 | QString qualifiedName = app + "-" + name + ":"; |
1873 | 1875 | ||
1874 | QStringList::Iterator it; | 1876 | QStringList::Iterator it; |
1875 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1877 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1876 | if ( (*it).startsWith( qualifiedName ) ) { | 1878 | if ( (*it).startsWith( qualifiedName ) ) { |
1877 | (*it) = qualifiedName + value; | 1879 | (*it) = qualifiedName + value; |
1878 | return; | 1880 | return; |
1879 | } | 1881 | } |
1880 | } | 1882 | } |
1881 | mData->custom.append( qualifiedName + value ); | 1883 | mData->custom.append( qualifiedName + value ); |
1882 | } | 1884 | } |
1883 | 1885 | ||
1884 | void Addressee::removeCustom( const QString &app, const QString &name) | 1886 | void Addressee::removeCustom( const QString &app, const QString &name) |
1885 | { | 1887 | { |
1886 | detach(); | 1888 | detach(); |
1887 | 1889 | ||
1888 | QString qualifiedName = app + "-" + name + ":"; | 1890 | QString qualifiedName = app + "-" + name + ":"; |
1889 | 1891 | ||
1890 | QStringList::Iterator it; | 1892 | QStringList::Iterator it; |
1891 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1893 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1892 | if ( (*it).startsWith( qualifiedName ) ) { | 1894 | if ( (*it).startsWith( qualifiedName ) ) { |
1893 | mData->custom.remove( it ); | 1895 | mData->custom.remove( it ); |
1894 | return; | 1896 | return; |
1895 | } | 1897 | } |
1896 | } | 1898 | } |
1897 | } | 1899 | } |
1898 | 1900 | ||
1899 | QString Addressee::custom( const QString &app, const QString &name ) const | 1901 | QString Addressee::custom( const QString &app, const QString &name ) const |
1900 | { | 1902 | { |
1901 | QString qualifiedName = app + "-" + name + ":"; | 1903 | QString qualifiedName = app + "-" + name + ":"; |
1902 | QString value; | 1904 | QString value; |
1903 | 1905 | ||
1904 | QStringList::ConstIterator it; | 1906 | QStringList::ConstIterator it; |
1905 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1907 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1906 | if ( (*it).startsWith( qualifiedName ) ) { | 1908 | if ( (*it).startsWith( qualifiedName ) ) { |
1907 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1909 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1908 | break; | 1910 | break; |
1909 | } | 1911 | } |
1910 | } | 1912 | } |
1911 | 1913 | ||
1912 | return value; | 1914 | return value; |
1913 | } | 1915 | } |
1914 | 1916 | ||
1915 | void Addressee::setCustoms( const QStringList &l ) | 1917 | void Addressee::setCustoms( const QStringList &l ) |
1916 | { | 1918 | { |
1917 | detach(); | 1919 | detach(); |
1918 | mData->empty = false; | 1920 | mData->empty = false; |
1919 | 1921 | ||
1920 | mData->custom = l; | 1922 | mData->custom = l; |
1921 | } | 1923 | } |
1922 | 1924 | ||
1923 | QStringList Addressee::customs() const | 1925 | QStringList Addressee::customs() const |
1924 | { | 1926 | { |
1925 | return mData->custom; | 1927 | return mData->custom; |
1926 | } | 1928 | } |
1927 | 1929 | ||
1928 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1930 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1929 | QString &email) | 1931 | QString &email) |
1930 | { | 1932 | { |
1931 | int startPos, endPos, len; | 1933 | int startPos, endPos, len; |
1932 | QString partA, partB, result; | 1934 | QString partA, partB, result; |
1933 | char endCh = '>'; | 1935 | char endCh = '>'; |
1934 | 1936 | ||
1935 | startPos = rawEmail.find('<'); | 1937 | startPos = rawEmail.find('<'); |
1936 | if (startPos < 0) | 1938 | if (startPos < 0) |
1937 | { | 1939 | { |
1938 | startPos = rawEmail.find('('); | 1940 | startPos = rawEmail.find('('); |
1939 | endCh = ')'; | 1941 | endCh = ')'; |
1940 | } | 1942 | } |
1941 | if (startPos < 0) | 1943 | if (startPos < 0) |
1942 | { | 1944 | { |
1943 | // We couldn't find any separators, so we assume the whole string | 1945 | // We couldn't find any separators, so we assume the whole string |
1944 | // is the email address | 1946 | // is the email address |
1945 | email = rawEmail; | 1947 | email = rawEmail; |
1946 | fullName = ""; | 1948 | fullName = ""; |
1947 | } | 1949 | } |
1948 | else | 1950 | else |
1949 | { | 1951 | { |
1950 | // We have a start position, try to find an end | 1952 | // We have a start position, try to find an end |
1951 | endPos = rawEmail.find(endCh, startPos+1); | 1953 | endPos = rawEmail.find(endCh, startPos+1); |
1952 | 1954 | ||
1953 | if (endPos < 0) | 1955 | if (endPos < 0) |
1954 | { | 1956 | { |
1955 | // We couldn't find the end of the email address. We can only | 1957 | // We couldn't find the end of the email address. We can only |
1956 | // assume the entire string is the email address. | 1958 | // assume the entire string is the email address. |
1957 | email = rawEmail; | 1959 | email = rawEmail; |
1958 | fullName = ""; | 1960 | fullName = ""; |
1959 | } | 1961 | } |
1960 | else | 1962 | else |
1961 | { | 1963 | { |
1962 | // We have a start and end to the email address | 1964 | // We have a start and end to the email address |
1963 | 1965 | ||
1964 | // Grab the name part | 1966 | // Grab the name part |
1965 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1967 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1966 | 1968 | ||
1967 | // grab the email part | 1969 | // grab the email part |
1968 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1970 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1969 | 1971 | ||
1970 | // Check that we do not have any extra characters on the end of the | 1972 | // Check that we do not have any extra characters on the end of the |
1971 | // strings | 1973 | // strings |
1972 | len = fullName.length(); | 1974 | len = fullName.length(); |
1973 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1975 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1974 | fullName = fullName.mid(1, len-2); | 1976 | fullName = fullName.mid(1, len-2); |
1975 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1977 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1976 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1977 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1979 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1978 | fullName = fullName.mid(1, len-2); | 1980 | fullName = fullName.mid(1, len-2); |
1979 | } | 1981 | } |
1980 | } | 1982 | } |
1981 | } | 1983 | } |
1982 | 1984 | ||
1983 | void Addressee::setResource( Resource *resource ) | 1985 | void Addressee::setResource( Resource *resource ) |
1984 | { | 1986 | { |
1985 | detach(); | 1987 | detach(); |
1986 | mData->resource = resource; | 1988 | mData->resource = resource; |
1987 | } | 1989 | } |
1988 | 1990 | ||
1989 | Resource *Addressee::resource() const | 1991 | Resource *Addressee::resource() const |
1990 | { | 1992 | { |
1991 | return mData->resource; | 1993 | return mData->resource; |
1992 | } | 1994 | } |
1993 | 1995 | ||
1994 | //US | 1996 | //US |
1995 | QString Addressee::resourceLabel() | 1997 | QString Addressee::resourceLabel() |
1996 | { | 1998 | { |
1997 | return i18n("Resource"); | 1999 | return i18n("Resource"); |
1998 | } | 2000 | } |
1999 | QString Addressee::categoryLabel() | 2001 | QString Addressee::categoryLabel() |
2000 | { | 2002 | { |
2001 | return i18n("Category"); | 2003 | return i18n("Category"); |
2002 | } | 2004 | } |
2003 | 2005 | ||
2004 | void Addressee::setChanged( bool value ) | 2006 | void Addressee::setChanged( bool value ) |
2005 | { | 2007 | { |
2006 | detach(); | 2008 | detach(); |
2007 | mData->changed = value; | 2009 | mData->changed = value; |
2008 | } | 2010 | } |
2009 | 2011 | ||
2010 | bool Addressee::changed() const | 2012 | bool Addressee::changed() const |
2011 | { | 2013 | { |
2012 | return mData->changed; | 2014 | return mData->changed; |
2013 | } | 2015 | } |
2014 | 2016 | ||
2015 | void Addressee::setTagged( bool value ) | 2017 | void Addressee::setTagged( bool value ) |
2016 | { | 2018 | { |
2017 | detach(); | 2019 | detach(); |
2018 | mData->tagged = value; | 2020 | mData->tagged = value; |
2019 | } | 2021 | } |
2020 | 2022 | ||
2021 | bool Addressee::tagged() const | 2023 | bool Addressee::tagged() const |
2022 | { | 2024 | { |
2023 | return mData->tagged; | 2025 | return mData->tagged; |
2024 | } | 2026 | } |
2025 | 2027 | ||
2026 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2028 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2027 | { | 2029 | { |
2028 | if (!a.mData) return s; | 2030 | if (!a.mData) return s; |
2029 | 2031 | ||
2030 | s << a.uid(); | 2032 | s << a.uid(); |
2031 | 2033 | ||
2032 | s << a.mData->name; | 2034 | s << a.mData->name; |
2033 | s << a.mData->formattedName; | 2035 | s << a.mData->formattedName; |
2034 | s << a.mData->familyName; | 2036 | s << a.mData->familyName; |
2035 | s << a.mData->givenName; | 2037 | s << a.mData->givenName; |
2036 | s << a.mData->additionalName; | 2038 | s << a.mData->additionalName; |
2037 | s << a.mData->prefix; | 2039 | s << a.mData->prefix; |
2038 | s << a.mData->suffix; | 2040 | s << a.mData->suffix; |
2039 | s << a.mData->nickName; | 2041 | s << a.mData->nickName; |
2040 | s << a.mData->birthday; | 2042 | s << a.mData->birthday; |
2041 | s << a.mData->mailer; | 2043 | s << a.mData->mailer; |
2042 | s << a.mData->timeZone; | 2044 | s << a.mData->timeZone; |
2043 | s << a.mData->geo; | 2045 | s << a.mData->geo; |
2044 | s << a.mData->title; | 2046 | s << a.mData->title; |
2045 | s << a.mData->role; | 2047 | s << a.mData->role; |
2046 | s << a.mData->organization; | 2048 | s << a.mData->organization; |
2047 | s << a.mData->note; | 2049 | s << a.mData->note; |
2048 | s << a.mData->productId; | 2050 | s << a.mData->productId; |
2049 | s << a.mData->revision; | 2051 | s << a.mData->revision; |
2050 | s << a.mData->sortString; | 2052 | s << a.mData->sortString; |
2051 | s << a.mData->url; | 2053 | s << a.mData->url; |
2052 | s << a.mData->secrecy; | 2054 | s << a.mData->secrecy; |
2053 | s << a.mData->logo; | 2055 | s << a.mData->logo; |
2054 | s << a.mData->photo; | 2056 | s << a.mData->photo; |
2055 | s << a.mData->sound; | 2057 | s << a.mData->sound; |
2056 | s << a.mData->agent; | 2058 | s << a.mData->agent; |
2057 | s << a.mData->phoneNumbers; | 2059 | s << a.mData->phoneNumbers; |
2058 | s << a.mData->addresses; | 2060 | s << a.mData->addresses; |
2059 | s << a.mData->emails; | 2061 | s << a.mData->emails; |
2060 | s << a.mData->categories; | 2062 | s << a.mData->categories; |
2061 | s << a.mData->custom; | 2063 | s << a.mData->custom; |
2062 | s << a.mData->keys; | 2064 | s << a.mData->keys; |
2063 | return s; | 2065 | return s; |
2064 | } | 2066 | } |
2065 | 2067 | ||
2066 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2068 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2067 | { | 2069 | { |
2068 | if (!a.mData) return s; | 2070 | if (!a.mData) return s; |
2069 | 2071 | ||
2070 | s >> a.mData->uid; | 2072 | s >> a.mData->uid; |
2071 | 2073 | ||
2072 | s >> a.mData->name; | 2074 | s >> a.mData->name; |
2073 | s >> a.mData->formattedName; | 2075 | s >> a.mData->formattedName; |
2074 | s >> a.mData->familyName; | 2076 | s >> a.mData->familyName; |
2075 | s >> a.mData->givenName; | 2077 | s >> a.mData->givenName; |
2076 | s >> a.mData->additionalName; | 2078 | s >> a.mData->additionalName; |
2077 | s >> a.mData->prefix; | 2079 | s >> a.mData->prefix; |
2078 | s >> a.mData->suffix; | 2080 | s >> a.mData->suffix; |
2079 | s >> a.mData->nickName; | 2081 | s >> a.mData->nickName; |
2080 | s >> a.mData->birthday; | 2082 | s >> a.mData->birthday; |
2081 | s >> a.mData->mailer; | 2083 | s >> a.mData->mailer; |
2082 | s >> a.mData->timeZone; | 2084 | s >> a.mData->timeZone; |
2083 | s >> a.mData->geo; | 2085 | s >> a.mData->geo; |
2084 | s >> a.mData->title; | 2086 | s >> a.mData->title; |
2085 | s >> a.mData->role; | 2087 | s >> a.mData->role; |
2086 | s >> a.mData->organization; | 2088 | s >> a.mData->organization; |
2087 | s >> a.mData->note; | 2089 | s >> a.mData->note; |
2088 | s >> a.mData->productId; | 2090 | s >> a.mData->productId; |
2089 | s >> a.mData->revision; | 2091 | s >> a.mData->revision; |
2090 | s >> a.mData->sortString; | 2092 | s >> a.mData->sortString; |
2091 | s >> a.mData->url; | 2093 | s >> a.mData->url; |
2092 | s >> a.mData->secrecy; | 2094 | s >> a.mData->secrecy; |
2093 | s >> a.mData->logo; | 2095 | s >> a.mData->logo; |
2094 | s >> a.mData->photo; | 2096 | s >> a.mData->photo; |
2095 | s >> a.mData->sound; | 2097 | s >> a.mData->sound; |
2096 | s >> a.mData->agent; | 2098 | s >> a.mData->agent; |
2097 | s >> a.mData->phoneNumbers; | 2099 | s >> a.mData->phoneNumbers; |
2098 | s >> a.mData->addresses; | 2100 | s >> a.mData->addresses; |
2099 | s >> a.mData->emails; | 2101 | s >> a.mData->emails; |
2100 | s >> a.mData->categories; | 2102 | s >> a.mData->categories; |
2101 | s >> a.mData->custom; | 2103 | s >> a.mData->custom; |
2102 | s >> a.mData->keys; | 2104 | s >> a.mData->keys; |
2103 | 2105 | ||
2104 | a.mData->empty = false; | 2106 | a.mData->empty = false; |
2105 | 2107 | ||
2106 | return s; | 2108 | return s; |
2107 | } | 2109 | } |
2108 | bool matchBinaryPattern( int value, int pattern ) | 2110 | bool matchBinaryPattern( int value, int pattern ) |
2109 | { | 2111 | { |
2110 | /** | 2112 | /** |
2111 | We want to match all telephonnumbers/addresses which have the bits in the | 2113 | We want to match all telephonnumbers/addresses which have the bits in the |
2112 | pattern set. More are allowed. | 2114 | pattern set. More are allowed. |
2113 | if pattern == 0 we have a special handling, then we want only those with | 2115 | if pattern == 0 we have a special handling, then we want only those with |
2114 | exactly no bit set. | 2116 | exactly no bit set. |
2115 | */ | 2117 | */ |
2116 | if ( pattern == 0 ) | 2118 | if ( pattern == 0 ) |
2117 | return ( value == 0 ); | 2119 | return ( value == 0 ); |
2118 | else | 2120 | else |
2119 | return ( pattern == ( pattern & value ) ); | 2121 | return ( pattern == ( pattern & value ) ); |
2120 | } | 2122 | } |
2121 | 2123 | ||
2122 | bool matchBinaryPatternP( int value, int pattern ) | 2124 | bool matchBinaryPatternP( int value, int pattern ) |
2123 | { | 2125 | { |
2124 | 2126 | ||
2125 | if ( pattern == 0 ) | 2127 | if ( pattern == 0 ) |
2126 | return ( value == 0 ); | 2128 | return ( value == 0 ); |
2127 | else | 2129 | else |
2128 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2130 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2129 | } | 2131 | } |
2130 | bool matchBinaryPatternA( int value, int pattern ) | 2132 | bool matchBinaryPatternA( int value, int pattern ) |
2131 | { | 2133 | { |
2132 | 2134 | ||
diff --git a/kabc/picture.cpp b/kabc/picture.cpp index 6a34b98..57aa297 100644 --- a/kabc/picture.cpp +++ b/kabc/picture.cpp | |||
@@ -1,141 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "picture.h" | 28 | #include "picture.h" |
29 | 29 | ||
30 | using namespace KABC; | 30 | using namespace KABC; |
31 | 31 | ||
32 | Picture::Picture() | 32 | Picture::Picture() |
33 | : mIntern( false ) | 33 | : mIntern( false ) |
34 | { | 34 | { |
35 | mUndefined = true; | 35 | mUndefined = true; |
36 | } | 36 | } |
37 | 37 | ||
38 | Picture::Picture( const QString &url ) | 38 | Picture::Picture( const QString &url ) |
39 | : mUrl( url ), mIntern( false ) | 39 | : mUrl( url ), mIntern( false ) |
40 | { | 40 | { |
41 | mUndefined = false; | 41 | mUndefined = false; |
42 | } | 42 | } |
43 | 43 | ||
44 | Picture::Picture( const QImage &data ) | 44 | Picture::Picture( const QImage &data ) |
45 | : mData( data ), mIntern( true ) | 45 | : mData( data ), mIntern( true ) |
46 | { | 46 | { |
47 | mUndefined = false; | 47 | mUndefined = false; |
48 | } | 48 | } |
49 | 49 | ||
50 | Picture::~Picture() | 50 | Picture::~Picture() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | bool Picture::operator==( const Picture &p ) const | 54 | bool Picture::operator==( const Picture &p ) const |
55 | { | 55 | { |
56 | if ( mIntern != p.mIntern ) return false; | 56 | //qDebug("compare PIC "); |
57 | 57 | if ( mUndefined && p.mUndefined ) { | |
58 | //qDebug("compare PIC true 1 "); | ||
59 | return true; | ||
60 | } | ||
61 | if ( mUndefined || p.mUndefined ) { | ||
62 | //qDebug("compare PIC false 1"); | ||
63 | return false; | ||
64 | } | ||
65 | // now we should deal with two defined pics! | ||
66 | if ( mIntern != p.mIntern ) { | ||
67 | //qDebug("compare PIC false 2"); | ||
68 | return false; | ||
69 | } | ||
58 | if ( mIntern ) { | 70 | if ( mIntern ) { |
59 | if ( mData != p.mData ) | 71 | //qDebug("mIntern "); |
72 | if ( mData.isNull() && p.mData.isNull() ) { | ||
73 | //qDebug("compare PIC true 2 "); | ||
74 | return true; | ||
75 | } | ||
76 | if ( mData.isNull() || p.mData.isNull() ){ | ||
77 | //qDebug("compare PIC false 3-1"); | ||
78 | |||
79 | return false; | ||
80 | } | ||
81 | if ( mData != p.mData ) { | ||
82 | //qDebug("compare PIC false 3"); | ||
60 | return false; | 83 | return false; |
84 | } | ||
61 | } else { | 85 | } else { |
62 | if ( mUrl != p.mUrl ) | 86 | if ( mUrl != p.mUrl ) { |
63 | return false; | 87 | //qDebug("compare PIC false 4"); |
88 | return false; | ||
89 | } | ||
64 | } | 90 | } |
65 | 91 | //qDebug("compare PIC true "); | |
66 | return true; | 92 | return true; |
67 | } | 93 | } |
68 | 94 | ||
69 | bool Picture::operator!=( const Picture &p ) const | 95 | bool Picture::operator!=( const Picture &p ) const |
70 | { | 96 | { |
71 | return !( p == *this ); | 97 | return !( p == *this ); |
72 | } | 98 | } |
73 | 99 | ||
74 | void Picture::setUrl( const QString &url ) | 100 | void Picture::setUrl( const QString &url ) |
75 | { | 101 | { |
76 | mUrl = url; | 102 | mUrl = url; |
77 | mIntern = false; | 103 | mIntern = false; |
78 | mUndefined = false; | 104 | mUndefined = false; |
79 | } | 105 | } |
80 | 106 | ||
81 | void Picture::setData( const QImage &data ) | 107 | void Picture::setData( const QImage &data ) |
82 | { | 108 | { |
83 | mData = data; | 109 | mData = data; |
84 | mIntern = true; | 110 | mIntern = true; |
85 | mUndefined = false; | 111 | mUndefined = false; |
86 | } | 112 | } |
87 | 113 | ||
88 | void Picture::setType( const QString &type ) | 114 | void Picture::setType( const QString &type ) |
89 | { | 115 | { |
90 | mType = type; | 116 | mType = type; |
91 | } | 117 | } |
92 | 118 | ||
93 | bool Picture::isIntern() const | 119 | bool Picture::isIntern() const |
94 | { | 120 | { |
95 | return mIntern; | 121 | return mIntern; |
96 | } | 122 | } |
97 | 123 | ||
98 | QString Picture::url() const | 124 | QString Picture::url() const |
99 | { | 125 | { |
100 | return mUrl; | 126 | return mUrl; |
101 | } | 127 | } |
102 | 128 | ||
103 | QImage Picture::data() const | 129 | QImage Picture::data() const |
104 | { | 130 | { |
105 | return mData; | 131 | return mData; |
106 | } | 132 | } |
107 | QPixmap Picture::pixmap() const | 133 | QPixmap Picture::pixmap() const |
108 | { | 134 | { |
109 | QPixmap p; | 135 | QPixmap p; |
110 | p.convertFromImage ( mData ); | 136 | p.convertFromImage ( mData ); |
111 | return p; | 137 | return p; |
112 | } | 138 | } |
113 | 139 | ||
114 | QString Picture::type() const | 140 | QString Picture::type() const |
115 | { | 141 | { |
116 | return mType; | 142 | return mType; |
117 | } | 143 | } |
118 | bool Picture::undefined() const | 144 | bool Picture::undefined() const |
119 | { | 145 | { |
120 | return mUndefined; | 146 | return mUndefined; |
121 | } | 147 | } |
122 | 148 | ||
123 | 149 | ||
124 | QString Picture::asString() const | 150 | QString Picture::asString() const |
125 | { | 151 | { |
126 | if ( mIntern ) | 152 | if ( mIntern ) |
127 | return "intern picture"; | 153 | return "intern picture"; |
128 | else | 154 | else |
129 | return mUrl; | 155 | return mUrl; |
130 | } | 156 | } |
131 | 157 | ||
132 | QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) | 158 | QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) |
133 | { | 159 | { |
134 | return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; | 160 | return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; |
135 | } | 161 | } |
136 | 162 | ||
137 | QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) | 163 | QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) |
138 | { | 164 | { |
139 | s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; | 165 | s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; |
140 | return s; | 166 | return s; |
141 | } | 167 | } |
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index c368172..2f88cde 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -1,321 +1,349 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1999 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1999 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <VCardAdrParam.h> | 30 | #include <VCardAdrParam.h> |
31 | #include <VCardAgentParam.h> | 31 | #include <VCardAgentParam.h> |
32 | #include <VCardDateParam.h> | 32 | #include <VCardDateParam.h> |
33 | #include <VCardEmailParam.h> | 33 | #include <VCardEmailParam.h> |
34 | #include <VCardImageParam.h> | 34 | #include <VCardImageParam.h> |
35 | #include <VCardSourceParam.h> | 35 | #include <VCardSourceParam.h> |
36 | #include <VCardTelParam.h> | 36 | #include <VCardTelParam.h> |
37 | #include <VCardTextBinParam.h> | 37 | #include <VCardTextBinParam.h> |
38 | #include <VCardTextParam.h> | 38 | #include <VCardTextParam.h> |
39 | 39 | ||
40 | #include <VCardAdrValue.h> | 40 | #include <VCardAdrValue.h> |
41 | #include <VCardAgentValue.h> | 41 | #include <VCardAgentValue.h> |
42 | #include <VCardDateValue.h> | 42 | #include <VCardDateValue.h> |
43 | #include <VCardImageValue.h> | 43 | #include <VCardImageValue.h> |
44 | #include <VCardTextValue.h> | 44 | #include <VCardTextValue.h> |
45 | #include <VCardTextBinValue.h> | 45 | #include <VCardTextBinValue.h> |
46 | #include <VCardLangValue.h> | 46 | #include <VCardLangValue.h> |
47 | #include <VCardNValue.h> | 47 | #include <VCardNValue.h> |
48 | #include <VCardURIValue.h> | 48 | #include <VCardURIValue.h> |
49 | #include <VCardSoundValue.h> | 49 | #include <VCardSoundValue.h> |
50 | #include <VCardClassValue.h> | 50 | #include <VCardClassValue.h> |
51 | #include <VCardFloatValue.h> | 51 | #include <VCardFloatValue.h> |
52 | #include <VCardOrgValue.h> | 52 | #include <VCardOrgValue.h> |
53 | #include <VCardTelValue.h> | 53 | #include <VCardTelValue.h> |
54 | #include <VCardTextListValue.h> | 54 | #include <VCardTextListValue.h> |
55 | #include <VCardUTCValue.h> | 55 | #include <VCardUTCValue.h> |
56 | #include <VCardGeoValue.h> | 56 | #include <VCardGeoValue.h> |
57 | 57 | ||
58 | #include <VCardRToken.h> | 58 | #include <VCardRToken.h> |
59 | #include <VCardContentLine.h> | 59 | #include <VCardContentLine.h> |
60 | 60 | ||
61 | #include <VCardEntity.h> | 61 | #include <VCardEntity.h> |
62 | #include <VCardEnum.h> | 62 | #include <VCardEnum.h> |
63 | #include <VCardDefines.h> | 63 | #include <VCardDefines.h> |
64 | 64 | ||
65 | using namespace VCARD; | 65 | using namespace VCARD; |
66 | 66 | ||
67 | ContentLine::ContentLine() | 67 | ContentLine::ContentLine() |
68 | :Entity(), | 68 | :Entity(), |
69 | value_(0), | 69 | value_(0), |
70 | paramType_( ParamUnknown ), | 70 | paramType_( ParamUnknown ), |
71 | valueType_( ValueUnknown ), | 71 | valueType_( ValueUnknown ), |
72 | entityType_( EntityUnknown ) | 72 | entityType_( EntityUnknown ) |
73 | { | 73 | { |
74 | paramList_.setAutoDelete( TRUE ); | 74 | paramList_.setAutoDelete( TRUE ); |
75 | } | 75 | } |
76 | 76 | ||
77 | ContentLine::ContentLine(const ContentLine & x) | 77 | ContentLine::ContentLine(const ContentLine & x) |
78 | :Entity(x), | 78 | :Entity(x), |
79 | group_ (x.group_), | 79 | group_ (x.group_), |
80 | name_ (x.name_), | 80 | name_ (x.name_), |
81 | /*US paramList_(x.paramList_),*/ | 81 | /*US paramList_(x.paramList_),*/ |
82 | value_(x.value_->clone()), | 82 | value_(x.value_->clone()), |
83 | paramType_(x.paramType_), | 83 | paramType_(x.paramType_), |
84 | valueType_(x.valueType_), | 84 | valueType_(x.valueType_), |
85 | entityType_(x.entityType_) | 85 | entityType_(x.entityType_) |
86 | { | 86 | { |
87 | paramList_.setAutoDelete( TRUE ); | 87 | paramList_.setAutoDelete( TRUE ); |
88 | 88 | ||
89 | 89 | ||
90 | ParamListIterator it(x.paramList_); | 90 | ParamListIterator it(x.paramList_); |
91 | for (; it.current(); ++it) | 91 | for (; it.current(); ++it) |
92 | { | 92 | { |
93 | Param *p = new Param; | 93 | Param *p = new Param; |
94 | p->setName( it.current()->name() ); | 94 | p->setName( it.current()->name() ); |
95 | p->setValue( it.current()->value() ); | 95 | p->setValue( it.current()->value() ); |
96 | paramList_.append(p); | 96 | paramList_.append(p); |
97 | } | 97 | } |
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | ContentLine::ContentLine(const QCString & s) | 101 | ContentLine::ContentLine(const QCString & s) |
102 | :Entity(s), | 102 | :Entity(s), |
103 | value_(0), | 103 | value_(0), |
104 | paramType_( ParamUnknown ), | 104 | paramType_( ParamUnknown ), |
105 | valueType_( ValueUnknown ), | 105 | valueType_( ValueUnknown ), |
106 | entityType_( EntityUnknown ) | 106 | entityType_( EntityUnknown ) |
107 | { | 107 | { |
108 | paramList_.setAutoDelete( TRUE ); | 108 | paramList_.setAutoDelete( TRUE ); |
109 | } | 109 | } |
110 | 110 | ||
111 | ContentLine & | 111 | ContentLine & |
112 | ContentLine::operator = (ContentLine & x) | 112 | ContentLine::operator = (ContentLine & x) |
113 | { | 113 | { |
114 | if (*this == x) return *this; | 114 | if (*this == x) return *this; |
115 | 115 | ||
116 | ParamListIterator it(x.paramList_); | 116 | ParamListIterator it(x.paramList_); |
117 | for (; it.current(); ++it) | 117 | for (; it.current(); ++it) |
118 | { | 118 | { |
119 | Param *p = new Param; | 119 | Param *p = new Param; |
120 | p->setName( it.current()->name() ); | 120 | p->setName( it.current()->name() ); |
121 | p->setValue( it.current()->value() ); | 121 | p->setValue( it.current()->value() ); |
122 | paramList_.append(p); | 122 | paramList_.append(p); |
123 | } | 123 | } |
124 | 124 | ||
125 | value_ = x.value_->clone(); | 125 | value_ = x.value_->clone(); |
126 | 126 | ||
127 | Entity::operator = (x); | 127 | Entity::operator = (x); |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | ContentLine & | 131 | ContentLine & |
132 | ContentLine::operator = (const QCString & s) | 132 | ContentLine::operator = (const QCString & s) |
133 | { | 133 | { |
134 | Entity::operator = (s); | 134 | Entity::operator = (s); |
135 | delete value_; | 135 | delete value_; |
136 | value_ = 0; | 136 | value_ = 0; |
137 | return *this; | 137 | return *this; |
138 | } | 138 | } |
139 | 139 | ||
140 | bool | 140 | bool |
141 | ContentLine::operator == (ContentLine & x) | 141 | ContentLine::operator == (ContentLine & x) |
142 | { | 142 | { |
143 | x.parse(); | 143 | x.parse(); |
144 | 144 | ||
145 | QPtrListIterator<Param> it(x.paramList()); | 145 | QPtrListIterator<Param> it(x.paramList()); |
146 | 146 | ||
147 | if (!paramList_.find(it.current())) | 147 | if (!paramList_.find(it.current())) |
148 | return false; | 148 | return false; |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | ContentLine::~ContentLine() | 153 | ContentLine::~ContentLine() |
154 | { | 154 | { |
155 | delete value_; | 155 | delete value_; |
156 | value_ = 0; | 156 | value_ = 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | void | 159 | void |
160 | ContentLine::_parse() | 160 | ContentLine::_parse() |
161 | { | 161 | { |
162 | vDebug("parse"); | 162 | vDebug("parse"); |
163 | 163 | ||
164 | // Unqote newlines | 164 | // Unqote newlines |
165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); | 165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); |
166 | 166 | ||
167 | int split = strRep_.find(':'); | 167 | int split = strRep_.find(':'); |
168 | 168 | ||
169 | if (split == -1) { // invalid content line | 169 | if (split == -1) { // invalid content line |
170 | vDebug("No ':'"); | 170 | vDebug("No ':'"); |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | 173 | ||
174 | QCString firstPart(strRep_.left(split)); | 174 | QCString firstPart(strRep_.left(split)); |
175 | QCString valuePart(strRep_.mid(split + 1)); | 175 | QCString valuePart(strRep_.mid(split + 1)); |
176 | 176 | ||
177 | split = firstPart.find('.'); | 177 | split = firstPart.find('.'); |
178 | 178 | ||
179 | if (split != -1) { | 179 | if (split != -1) { |
180 | group_ = firstPart.left(split); | 180 | group_ = firstPart.left(split); |
181 | firstPart= firstPart.mid(split + 1); | 181 | firstPart= firstPart.mid(split + 1); |
182 | } | 182 | } |
183 | 183 | ||
184 | vDebug("Group == " + group_); | 184 | vDebug("Group == " + group_); |
185 | vDebug("firstPart == " + firstPart); | 185 | vDebug("firstPart == " + firstPart); |
186 | vDebug("valuePart == " + valuePart); | 186 | vDebug("valuePart == " + valuePart); |
187 | 187 | ||
188 | // Now we have the group, the name and param list together and the value. | 188 | // Now we have the group, the name and param list together and the value. |
189 | 189 | ||
190 | QStrList l; | 190 | QStrList l; |
191 | 191 | ||
192 | RTokenise(firstPart, ";", l); | 192 | RTokenise(firstPart, ";", l); |
193 | 193 | ||
194 | if (l.count() == 0) {// invalid - no name ! | 194 | if (l.count() == 0) {// invalid - no name ! |
195 | vDebug("No name for this content line !"); | 195 | vDebug("No name for this content line !"); |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | name_ = l.at(0); | 199 | name_ = l.at(0); |
200 | 200 | ||
201 | // Now we have the name, so the rest of 'l' is the params. | 201 | // Now we have the name, so the rest of 'l' is the params. |
202 | // Remove the name part. | 202 | // Remove the name part. |
203 | l.remove(0u); | 203 | l.remove(0u); |
204 | 204 | ||
205 | entityType_= EntityNameToEntityType(name_); | 205 | entityType_= EntityNameToEntityType(name_); |
206 | paramType_= EntityTypeToParamType(entityType_); | 206 | paramType_= EntityTypeToParamType(entityType_); |
207 | 207 | ||
208 | unsigned int i = 0; | 208 | unsigned int i = 0; |
209 | 209 | ||
210 | // For each parameter, create a new parameter of the correct type. | 210 | // For each parameter, create a new parameter of the correct type. |
211 | 211 | ||
212 | QStrListIterator it(l); | 212 | QStrListIterator it(l); |
213 | 213 | ||
214 | for (; it.current(); ++it, i++) { | 214 | for (; it.current(); ++it, i++) { |
215 | 215 | ||
216 | QCString str = *it; | 216 | QCString str = *it; |
217 | 217 | ||
218 | split = str.find("="); | 218 | split = str.find("="); |
219 | if (split < 0 ) { | 219 | if (split < 0 ) { |
220 | vDebug("No '=' in paramter."); | 220 | vDebug("No '=' in paramter."); |
221 | continue; | 221 | continue; |
222 | } | 222 | } |
223 | 223 | ||
224 | QCString paraName = str.left(split); | 224 | QCString paraName = str.left(split); |
225 | QCString paraValue = str.mid(split + 1); | 225 | QCString paraValue = str.mid(split + 1); |
226 | 226 | ||
227 | QStrList paraValues; | 227 | QStrList paraValues; |
228 | RTokenise(paraValue, ",", paraValues); | 228 | RTokenise(paraValue, ",", paraValues); |
229 | 229 | ||
230 | QStrListIterator it2( paraValues ); | 230 | QStrListIterator it2( paraValues ); |
231 | 231 | ||
232 | for(; it2.current(); ++it2) { | 232 | for(; it2.current(); ++it2) { |
233 | 233 | ||
234 | Param *p = new Param; | 234 | Param *p = new Param; |
235 | p->setName( paraName ); | 235 | p->setName( paraName ); |
236 | p->setValue( *it2 ); | 236 | p->setValue( *it2 ); |
237 | 237 | ||
238 | paramList_.append(p); | 238 | paramList_.append(p); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | // Create a new value of the correct type. | 242 | // Create a new value of the correct type. |
243 | 243 | ||
244 | valueType_ = EntityTypeToValueType(entityType_); | 244 | valueType_ = EntityTypeToValueType(entityType_); |
245 | 245 | ||
246 | //kdDebug(5710) << "valueType: " << valueType_ << endl; | 246 | //kdDebug(5710) << "valueType: " << valueType_ << endl; |
247 | 247 | ||
248 | switch (valueType_) { | 248 | switch (valueType_) { |
249 | 249 | ||
250 | case ValueSound: value_ = new SoundValue;break; | 250 | case ValueSound: value_ = new SoundValue;break; |
251 | case ValueAgent: value_ = new AgentValue;break; | 251 | case ValueAgent: value_ = new AgentValue;break; |
252 | case ValueAddress: value_ = new AdrValue; break; | 252 | case ValueAddress: value_ = new AdrValue; break; |
253 | case ValueTel: value_ = new TelValue; break; | 253 | case ValueTel: value_ = new TelValue; break; |
254 | case ValueTextBin: value_ = new TextBinValue;break; | 254 | case ValueTextBin: value_ = new TextBinValue;break; |
255 | case ValueOrg: value_ = new OrgValue; break; | 255 | case ValueOrg: value_ = new OrgValue; break; |
256 | case ValueN: value_ = new NValue; break; | 256 | case ValueN: value_ = new NValue; break; |
257 | case ValueUTC: value_ = new UTCValue; break; | 257 | case ValueUTC: value_ = new UTCValue; break; |
258 | case ValueURI: value_ = new URIValue; break; | 258 | case ValueURI: value_ = new URIValue; break; |
259 | case ValueClass: value_ = new ClassValue;break; | 259 | case ValueClass: value_ = new ClassValue;break; |
260 | case ValueFloat: value_ = new FloatValue;break; | 260 | case ValueFloat: value_ = new FloatValue;break; |
261 | case ValueImage: value_ = new ImageValue;break; | 261 | case ValueImage: value_ = new ImageValue;break; |
262 | case ValueDate: value_ = new DateValue; break; | 262 | case ValueDate: value_ = new DateValue; break; |
263 | case ValueTextList: value_ = new TextListValue;break; | 263 | case ValueTextList: value_ = new TextListValue;break; |
264 | case ValueGeo: value_ = new GeoValue; break; | 264 | case ValueGeo: value_ = new GeoValue; break; |
265 | case ValueText: | 265 | case ValueText: |
266 | case ValueUnknown: | 266 | case ValueUnknown: |
267 | default: value_ = new TextValue; break; | 267 | default: value_ = new TextValue; break; |
268 | } | 268 | } |
269 | 269 | ||
270 | *value_ = valuePart; | 270 | *value_ = valuePart; |
271 | } | 271 | } |
272 | 272 | ||
273 | void | 273 | void |
274 | ContentLine::_assemble() | 274 | ContentLine::_assemble() |
275 | { | 275 | { |
276 | //strRep_.truncate(0); | ||
277 | QString line; | ||
278 | if (!group_.isEmpty()) | ||
279 | line = group_ + '.'; | ||
280 | line += name_; | ||
281 | ParamListIterator it(paramList_); | ||
282 | for (; it.current(); ++it) | ||
283 | line += ";" + it.current()->asString(); | ||
284 | |||
285 | if (value_ != 0) | ||
286 | line += ":" + value_->asString(); | ||
287 | |||
288 | line = line.replace( QRegExp( "\n" ), "\\n" ); | ||
289 | |||
290 | // Fold lines longer than 72 chars | ||
291 | const int maxLen = 72; | ||
292 | uint cursor = 0; | ||
293 | QString cut; | ||
294 | while( line.length() > ( cursor + 1 ) * maxLen ) { | ||
295 | cut += line.mid( cursor * maxLen, maxLen ); | ||
296 | cut += "\r\n "; | ||
297 | ++cursor; | ||
298 | } | ||
299 | cut += line.mid( cursor * maxLen ); | ||
300 | strRep_ = cut.latin1(); | ||
301 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | ||
302 | #if 0 | ||
276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 303 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
277 | strRep_.truncate(0); | 304 | strRep_.truncate(0); |
278 | 305 | ||
279 | QCString line; | 306 | QCString line; |
280 | 307 | ||
281 | if (!group_.isEmpty()) | 308 | if (!group_.isEmpty()) |
282 | line += group_ + '.'; | 309 | line += group_ + '.'; |
283 | 310 | ||
284 | line += name_; | 311 | line += name_; |
285 | 312 | ||
286 | vDebug("Adding parameters"); | 313 | vDebug("Adding parameters"); |
287 | ParamListIterator it(paramList_); | 314 | ParamListIterator it(paramList_); |
288 | 315 | ||
289 | for (; it.current(); ++it) | 316 | for (; it.current(); ++it) |
290 | line += ";" + it.current()->asString(); | 317 | line += ";" + it.current()->asString(); |
291 | 318 | ||
292 | vDebug("Adding value"); | 319 | vDebug("Adding value"); |
293 | if (value_ != 0) | 320 | if (value_ != 0) |
294 | line += ":" + value_->asString(); | 321 | line += ":" + value_->asString(); |
295 | else | 322 | else |
296 | vDebug("No value"); | 323 | vDebug("No value"); |
297 | 324 | ||
298 | // Quote newlines | 325 | // Quote newlines |
299 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 326 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
300 | 327 | ||
301 | // Fold lines longer than 72 chars | 328 | // Fold lines longer than 72 chars |
302 | const int maxLen = 72; | 329 | const int maxLen = 72; |
303 | uint cursor = 0; | 330 | uint cursor = 0; |
304 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 331 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
305 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 332 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
306 | strRep_ += "\r\n "; | 333 | strRep_ += "\r\n "; |
307 | ++cursor; | 334 | ++cursor; |
308 | } | 335 | } |
309 | strRep_ += line.mid( cursor * maxLen ); | 336 | strRep_ += line.mid( cursor * maxLen ); |
310 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 337 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
338 | #endif | ||
311 | } | 339 | } |
312 | 340 | ||
313 | void | 341 | void |
314 | ContentLine::clear() | 342 | ContentLine::clear() |
315 | { | 343 | { |
316 | group_.truncate(0); | 344 | group_.truncate(0); |
317 | name_.truncate(0); | 345 | name_.truncate(0); |
318 | paramList_.clear(); | 346 | paramList_.clear(); |
319 | delete value_; | 347 | delete value_; |
320 | value_ = 0; | 348 | value_ = 0; |
321 | } | 349 | } |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index bc80707..49bfe43 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -1,299 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qstringlist.h> | ||
27 | #include <qstring.h> | ||
28 | #include <qvaluelist.h> | ||
26 | 29 | ||
27 | #include <VCardEntity.h> | 30 | #include <VCardEntity.h> |
28 | #include <VCardVCard.h> | 31 | #include <VCardVCard.h> |
29 | #include <VCardContentLine.h> | 32 | #include <VCardContentLine.h> |
30 | #include <VCardRToken.h> | 33 | #include <VCardRToken.h> |
31 | 34 | ||
32 | #include <VCardDefines.h> | 35 | #include <VCardDefines.h> |
33 | 36 | ||
34 | using namespace VCARD; | 37 | using namespace VCARD; |
35 | 38 | ||
36 | VCard::VCard() | 39 | VCard::VCard() |
37 | :Entity() | 40 | :Entity() |
38 | { | 41 | { |
39 | contentLineList_.setAutoDelete( TRUE ); | 42 | contentLineList_.setAutoDelete( TRUE ); |
40 | } | 43 | } |
41 | 44 | ||
42 | VCard::VCard(const VCard & x) | 45 | VCard::VCard(const VCard & x) |
43 | :Entity(x), | 46 | :Entity(x), |
44 | group_(x.group_) | 47 | group_(x.group_) |
45 | { | 48 | { |
46 | contentLineList_.setAutoDelete( TRUE ); | 49 | contentLineList_.setAutoDelete( TRUE ); |
47 | 50 | ||
48 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 51 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
49 | for (; it.current(); ++it) { | 52 | for (; it.current(); ++it) { |
50 | ContentLine * c = new ContentLine(*it.current()); | 53 | ContentLine * c = new ContentLine(*it.current()); |
51 | contentLineList_.append(c); | 54 | contentLineList_.append(c); |
52 | } | 55 | } |
53 | 56 | ||
54 | } | 57 | } |
55 | 58 | ||
56 | VCard::VCard(const QCString & s) | 59 | VCard::VCard(const QCString & s) |
57 | :Entity(s) | 60 | :Entity(s) |
58 | { | 61 | { |
59 | contentLineList_.setAutoDelete( TRUE ); | 62 | contentLineList_.setAutoDelete( TRUE ); |
60 | } | 63 | } |
61 | 64 | ||
62 | VCard & | 65 | VCard & |
63 | VCard::operator = (VCard & x) | 66 | VCard::operator = (VCard & x) |
64 | { | 67 | { |
65 | if (*this == x) return *this; | 68 | if (*this == x) return *this; |
66 | 69 | ||
67 | group_ = x.group(); | 70 | group_ = x.group(); |
68 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 71 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
69 | for (; it.current(); ++it) { | 72 | for (; it.current(); ++it) { |
70 | ContentLine * c = new ContentLine(*it.current()); | 73 | ContentLine * c = new ContentLine(*it.current()); |
71 | contentLineList_.append(c); | 74 | contentLineList_.append(c); |
72 | } | 75 | } |
73 | 76 | ||
74 | Entity::operator = (x); | 77 | Entity::operator = (x); |
75 | return *this; | 78 | return *this; |
76 | } | 79 | } |
77 | 80 | ||
78 | VCard & | 81 | VCard & |
79 | VCard::operator = (const QCString & s) | 82 | VCard::operator = (const QCString & s) |
80 | { | 83 | { |
81 | Entity::operator = (s); | 84 | Entity::operator = (s); |
82 | return *this; | 85 | return *this; |
83 | } | 86 | } |
84 | 87 | ||
85 | bool | 88 | bool |
86 | VCard::operator == (VCard & x) | 89 | VCard::operator == (VCard & x) |
87 | { | 90 | { |
88 | x.parse(); | 91 | x.parse(); |
89 | return false; | 92 | return false; |
90 | } | 93 | } |
91 | 94 | ||
92 | VCard::~VCard() | 95 | VCard::~VCard() |
93 | { | 96 | { |
94 | } | 97 | } |
95 | 98 | ||
96 | void | 99 | void |
97 | VCard::_parse() | 100 | VCard::_parse() |
98 | { | 101 | { |
99 | vDebug("parse() called"); | 102 | |
100 | QStrList l; | 103 | QStringList l; |
104 | QStrList sl; | ||
101 | 105 | ||
102 | RTokenise(strRep_, "\r\n", l); | 106 | RTokenise(strRep_, "\r\n", sl); |
103 | 107 | ||
104 | if (l.count() < 3) { // Invalid VCARD ! | 108 | if (sl.count() < 3) { // Invalid VCARD ! |
105 | vDebug("Invalid vcard"); | 109 | //qDebug("invalid vcard "); |
106 | return; | 110 | return; |
107 | } | 111 | } |
108 | 112 | l = QStringList::fromStrList( sl ); | |
109 | // Get the first line | 113 | // Get the first line |
110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 114 | QString beginLine = l[0].stripWhiteSpace(); |
111 | |||
112 | vDebug("Begin line == \"" + beginLine + "\""); | ||
113 | 115 | ||
114 | // Remove extra blank lines | 116 | // Remove extra blank lines |
115 | while (QCString(l.last()).isEmpty()) | 117 | while (l.last().isEmpty()) |
116 | l.remove(l.last()); | 118 | l.remove(l.last()); |
117 | 119 | ||
118 | // Now we know this is the last line | 120 | // Now we know this is the last line |
119 | QCString endLine = l.last(); | 121 | QString endLine = l.last(); |
120 | 122 | ||
121 | // Trash the first and last lines as we have seen them. | 123 | // Trash the first and last lines as we have seen them. |
122 | l.remove(0u); | 124 | l.remove(l.first()); |
123 | l.remove(l.last()); | 125 | l.remove(l.last()); |
124 | 126 | ||
125 | /////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////// |
126 | // FIRST LINE | 128 | // FIRST LINE |
127 | 129 | ||
128 | int split = beginLine.find(':'); | 130 | int split = beginLine.find(':'); |
129 | 131 | ||
130 | if (split == -1) { // invalid, no BEGIN | 132 | if (split == -1) { // invalid, no BEGIN |
131 | vDebug("No split"); | 133 | vDebug("No split"); |
132 | return; | 134 | return; |
133 | } | 135 | } |
134 | 136 | ||
135 | QCString firstPart(beginLine.left(split)); | 137 | QString firstPart(beginLine.left(split)); |
136 | QCString valuePart(beginLine.mid(split + 1)); | 138 | QString valuePart(beginLine.mid(split + 1)); |
137 | 139 | ||
138 | split = firstPart.find('.'); | 140 | split = firstPart.find('.'); |
139 | 141 | ||
140 | if (split != -1) { | 142 | if (split != -1) { |
141 | group_ = firstPart.left(split); | 143 | group_ = firstPart.left(split); |
142 | firstPart= firstPart.right(firstPart.length() - split - 1); | 144 | firstPart= firstPart.right(firstPart.length() - split - 1); |
143 | } | 145 | } |
144 | 146 | ||
145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! |
146 | vDebug("No BEGIN"); | 148 | qDebug("no BEGIN in vcard "); |
147 | return; | 149 | return; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! |
151 | vDebug("No VCARD"); | 153 | qDebug("not a VCARD "); |
152 | return; | 154 | return; |
153 | } | 155 | } |
154 | 156 | ||
155 | /////////////////////////////////////////////////////////////// | 157 | /////////////////////////////////////////////////////////////// |
156 | // CONTENT LINES | 158 | // CONTENT LINES |
157 | // | 159 | // |
158 | vDebug("Content lines"); | 160 | vDebug("Content lines"); |
159 | 161 | ||
160 | // Handle folded lines. | 162 | // Handle folded lines. |
161 | 163 | ||
162 | QStrList refolded; | 164 | QStringList refolded; |
163 | |||
164 | QStrListIterator it(l); | ||
165 | 165 | ||
166 | QCString cur; | ||
167 | 166 | ||
168 | for (; it.current(); ++it) { | 167 | QStringList::Iterator it = l.begin(); |
169 | 168 | ||
170 | cur = it.current(); | 169 | QString cur; |
171 | 170 | ||
171 | for (; it != l.end(); ++it) { | ||
172 | cur = (*it); | ||
172 | ++it; | 173 | ++it; |
173 | 174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { | |
174 | while ( | 175 | cur += (*it) ; |
175 | it.current() && | ||
176 | it.current()[0] == ' '&& | ||
177 | strlen(it.current()) != 1) | ||
178 | { | ||
179 | cur += it.current() + 1; | ||
180 | ++it; | 176 | ++it; |
181 | } | 177 | } |
182 | |||
183 | --it; | 178 | --it; |
184 | |||
185 | refolded.append(cur); | 179 | refolded.append(cur); |
186 | } | 180 | } |
187 | 181 | QStringList::Iterator it2 = refolded.begin(); | |
188 | QStrListIterator it2(refolded); | 182 | for (; it2 != refolded.end(); ++it2) { |
189 | 183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); | |
190 | for (; it2.current(); ++it2) { | ||
191 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | ||
192 | ContentLine * cl = new ContentLine(it2.current()); | ||
193 | |||
194 | cl->parse(); | 184 | cl->parse(); |
195 | if (cl->value() == 0) | 185 | if (cl->value() == 0) |
196 | { | 186 | { |
197 | qDebug("Content line could not be parsed. Discarded: %s", it2.current()); | 187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); |
198 | delete cl; | 188 | delete cl; |
199 | } | 189 | } |
200 | else | 190 | else |
201 | contentLineList_.append(cl); | 191 | contentLineList_.append(cl); |
202 | } | 192 | } |
203 | 193 | ||
204 | /////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////// |
205 | // LAST LINE | 195 | // LAST LINE |
206 | 196 | ||
197 | |||
198 | // LR: sorry, but the remaining code in this method makes no sense | ||
199 | |||
200 | #if 0 | ||
207 | split = endLine.find(':'); | 201 | split = endLine.find(':'); |
208 | 202 | ||
209 | if (split == -1) // invalid, no END | 203 | if (split == -1) // invalid, no END |
210 | return; | 204 | return; |
211 | 205 | ||
212 | firstPart = endLine.left(split); | 206 | firstPart = endLine.left(split); |
213 | valuePart = endLine.right(firstPart.length() - split - 1); | 207 | valuePart = endLine.right(firstPart.length() - split - 1); |
214 | 208 | ||
215 | split = firstPart.find('.'); | 209 | split = firstPart.find('.'); |
216 | 210 | ||
217 | if (split != -1) { | 211 | if (split != -1) { |
218 | group_ = firstPart.left(split); | 212 | group_ = firstPart.left(split); |
219 | firstPart= firstPart.right(firstPart.length() - split - 1); | 213 | firstPart= firstPart.right(firstPart.length() - split - 1); |
220 | } | 214 | } |
221 | 215 | ||
222 | if (qstricmp(firstPart, "END") != 0) // No END ! | 216 | if (qstricmp(firstPart, "END") != 0) // No END ! |
223 | return; | 217 | return; |
224 | 218 | ||
225 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
226 | return; | 220 | return; |
221 | #endif | ||
227 | } | 222 | } |
228 | 223 | ||
229 | void | 224 | void |
230 | VCard::_assemble() | 225 | VCard::_assemble() |
231 | { | 226 | { |
232 | vDebug("Assembling vcard"); | 227 | vDebug("Assembling vcard"); |
233 | strRep_ = "BEGIN:VCARD\r\n"; | 228 | strRep_ = "BEGIN:VCARD\r\n"; |
234 | strRep_ += "VERSION:3.0\r\n"; | 229 | strRep_ += "VERSION:3.0\r\n"; |
235 | 230 | ||
236 | QPtrListIterator<ContentLine> it(contentLineList_); | 231 | QPtrListIterator<ContentLine> it(contentLineList_); |
237 | 232 | ||
238 | for (; it.current(); ++it) | 233 | for (; it.current(); ++it) |
239 | strRep_ += it.current()->asString() + "\r\n"; | 234 | strRep_ += it.current()->asString() + "\r\n"; |
240 | 235 | ||
241 | strRep_ += "END:VCARD\r\n"; | 236 | strRep_ += "END:VCARD\r\n"; |
242 | } | 237 | } |
243 | 238 | ||
244 | bool | 239 | bool |
245 | VCard::has(EntityType t) | 240 | VCard::has(EntityType t) |
246 | { | 241 | { |
247 | parse(); | 242 | parse(); |
248 | return contentLine(t) == 0 ? false : true; | 243 | return contentLine(t) == 0 ? false : true; |
249 | } | 244 | } |
250 | 245 | ||
251 | bool | 246 | bool |
252 | VCard::has(const QCString & s) | 247 | VCard::has(const QCString & s) |
253 | { | 248 | { |
254 | parse(); | 249 | parse(); |
255 | return contentLine(s) == 0 ? false : true; | 250 | return contentLine(s) == 0 ? false : true; |
256 | } | 251 | } |
257 | 252 | ||
258 | void | 253 | void |
259 | VCard::add(const ContentLine & cl) | 254 | VCard::add(const ContentLine & cl) |
260 | { | 255 | { |
261 | parse(); | 256 | parse(); |
262 | ContentLine * c = new ContentLine(cl); | 257 | ContentLine * c = new ContentLine(cl); |
263 | contentLineList_.append(c); | 258 | contentLineList_.append(c); |
264 | } | 259 | } |
265 | 260 | ||
266 | void | 261 | void |
267 | VCard::add(const QCString & s) | 262 | VCard::add(const QCString & s) |
268 | { | 263 | { |
269 | parse(); | 264 | parse(); |
270 | ContentLine * c = new ContentLine(s); | 265 | ContentLine * c = new ContentLine(s); |
271 | contentLineList_.append(c); | 266 | contentLineList_.append(c); |
272 | } | 267 | } |
273 | 268 | ||
274 | ContentLine * | 269 | ContentLine * |
275 | VCard::contentLine(EntityType t) | 270 | VCard::contentLine(EntityType t) |
276 | { | 271 | { |
277 | parse(); | 272 | parse(); |
278 | QPtrListIterator<ContentLine> it(contentLineList_); | 273 | QPtrListIterator<ContentLine> it(contentLineList_); |
279 | 274 | ||
280 | for (; it.current(); ++it) | 275 | for (; it.current(); ++it) |
281 | if (it.current()->entityType() == t) | 276 | if (it.current()->entityType() == t) |
282 | return it.current(); | 277 | return it.current(); |
283 | 278 | ||
284 | return 0; | 279 | return 0; |
285 | } | 280 | } |
286 | 281 | ||
287 | ContentLine * | 282 | ContentLine * |
288 | VCard::contentLine(const QCString & s) | 283 | VCard::contentLine(const QCString & s) |
289 | { | 284 | { |
290 | parse(); | 285 | parse(); |
291 | QPtrListIterator<ContentLine> it(contentLineList_); | 286 | QPtrListIterator<ContentLine> it(contentLineList_); |
292 | 287 | ||
293 | for (; it.current(); ++it) | 288 | for (; it.current(); ++it) |
294 | if (it.current()->entityType() == EntityNameToEntityType(s)) | 289 | if (it.current()->entityType() == EntityNameToEntityType(s)) |
295 | return it.current(); | 290 | return it.current(); |
296 | 291 | ||
297 | return 0; | 292 | return 0; |
298 | } | 293 | } |
299 | 294 | ||
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp index ceffc77..229cce0 100644 --- a/kaddressbook/details/detailsviewcontainer.cpp +++ b/kaddressbook/details/detailsviewcontainer.cpp | |||
@@ -1,169 +1,160 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> | 3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@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 <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | 29 | ||
30 | #include <kapplication.h> | 30 | #include <kapplication.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kdialog.h> | 32 | #include <kdialog.h> |
33 | 33 | ||
34 | #include "look_basic.h" | 34 | #include "look_basic.h" |
35 | //#include "look_details.h" | 35 | //#include "look_details.h" |
36 | #include "look_html.h" | 36 | #include "look_html.h" |
37 | 37 | ||
38 | #ifdef KAB_EMBEDDED | 38 | #ifdef KAB_EMBEDDED |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #endif //KAB_EMBEDDED | 40 | #endif //KAB_EMBEDDED |
41 | 41 | ||
42 | 42 | ||
43 | #include "detailsviewcontainer.h" | 43 | #include "detailsviewcontainer.h" |
44 | 44 | ||
45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) | 45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) |
46 | : QWidget( parent, name ), mCurrentLook( 0 ) | 46 | : QWidget( parent, name ), mCurrentLook( 0 ) |
47 | { | 47 | { |
48 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 48 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
49 | //topLayout->setMargin( KDialog::marginHint() ); | 49 | //topLayout->setMargin( KDialog::marginHint() ); |
50 | //topLayout->setSpacing( KDialog::spacingHint() ); | 50 | //topLayout->setSpacing( KDialog::spacingHint() ); |
51 | topLayout->setMargin( 0 ); | 51 | topLayout->setMargin( 0 ); |
52 | topLayout->setSpacing( 0 ); | 52 | topLayout->setSpacing( 0 ); |
53 | 53 | ||
54 | QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); | 54 | QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); |
55 | 55 | ||
56 | QLabel *label = new QLabel( i18n("Style:"), this ); | 56 | QLabel *label = new QLabel( i18n("Style:"), this ); |
57 | styleLayout->addWidget( label ); | 57 | styleLayout->addWidget( label ); |
58 | 58 | ||
59 | mStyleCombo = new QComboBox( this ); | 59 | mStyleCombo = new QComboBox( this ); |
60 | styleLayout->addWidget( mStyleCombo ); | 60 | styleLayout->addWidget( mStyleCombo ); |
61 | 61 | ||
62 | QFrame *frameRuler = new QFrame( this ); | 62 | QFrame *frameRuler = new QFrame( this ); |
63 | //US frameRuler->setFrameShape( QFrame::HLine ); | 63 | //US frameRuler->setFrameShape( QFrame::HLine ); |
64 | //US frameRuler->setFrameShadow( QFrame::Sunken ); | 64 | //US frameRuler->setFrameShadow( QFrame::Sunken ); |
65 | //US topLayout->addWidget( frameRuler ); | 65 | //US topLayout->addWidget( frameRuler ); |
66 | 66 | ||
67 | mDetailsStack = new QWidgetStack( this ); | 67 | mDetailsStack = new QWidgetStack( this ); |
68 | topLayout->addWidget( mDetailsStack, 1 ); | 68 | topLayout->addWidget( mDetailsStack, 1 ); |
69 | 69 | ||
70 | registerLooks(); | 70 | registerLooks(); |
71 | 71 | ||
72 | #if 1 | 72 | #if 1 |
73 | // Hide detailed view selection combo box, because we currently have | 73 | // Hide detailed view selection combo box, because we currently have |
74 | // only one. Reenable it when there are more detailed views. | 74 | // only one. Reenable it when there are more detailed views. |
75 | label->hide(); | 75 | label->hide(); |
76 | mStyleCombo->hide(); | 76 | mStyleCombo->hide(); |
77 | frameRuler->hide(); | 77 | frameRuler->hide(); |
78 | #endif | 78 | #endif |
79 | } | 79 | } |
80 | 80 | ||
81 | KABBasicLook *ViewContainer::currentLook() | 81 | KABBasicLook *ViewContainer::currentLook() |
82 | { | 82 | { |
83 | return mCurrentLook; | 83 | return mCurrentLook; |
84 | } | 84 | } |
85 | 85 | ||
86 | void ViewContainer::registerLooks() | 86 | void ViewContainer::registerLooks() |
87 | { | 87 | { |
88 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); | 88 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); |
89 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); | 89 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); |
90 | mStyleCombo->clear(); | 90 | mStyleCombo->clear(); |
91 | 91 | ||
92 | for ( uint i = 0; i < mLookFactories.count(); ++i ) | 92 | for ( uint i = 0; i < mLookFactories.count(); ++i ) |
93 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); | 93 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); |
94 | 94 | ||
95 | if ( !mLookFactories.isEmpty() ) | 95 | if ( !mLookFactories.isEmpty() ) |
96 | slotStyleSelected( 0 ); | 96 | slotStyleSelected( 0 ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void ViewContainer::slotStyleSelected( int index ) | 99 | void ViewContainer::slotStyleSelected( int index ) |
100 | { | 100 | { |
101 | #ifndef KAB_EMBEDDED | 101 | #ifndef KAB_EMBEDDED |
102 | KConfig *config = kapp->config(); | 102 | KConfig *config = kapp->config(); |
103 | #else //KAB_EMBEDDED | 103 | #else //KAB_EMBEDDED |
104 | //US I hope I got the same config object as above expected. | 104 | //US I hope I got the same config object as above expected. |
105 | KConfig *config = KABPrefs::instance()->getConfig(); | 105 | KConfig *config = KABPrefs::instance()->getConfig(); |
106 | #endif //KAB_EMBEDDED | 106 | #endif //KAB_EMBEDDED |
107 | KABC::Addressee addr; | 107 | KABC::Addressee addr; |
108 | 108 | ||
109 | if ( index >= 0 && index < mStyleCombo->count() ) { | 109 | if ( index >= 0 && index < mStyleCombo->count() ) { |
110 | if ( mCurrentLook != 0 ) { | 110 | if ( mCurrentLook != 0 ) { |
111 | mCurrentLook->saveSettings( config ); | 111 | mCurrentLook->saveSettings( config ); |
112 | addr = mCurrentLook->addressee(); | 112 | addr = mCurrentLook->addressee(); |
113 | 113 | ||
114 | delete mCurrentLook; | 114 | delete mCurrentLook; |
115 | mCurrentLook = 0; | 115 | mCurrentLook = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | KABLookFactory *factory = mLookFactories.at( index ); | 118 | KABLookFactory *factory = mLookFactories.at( index ); |
119 | 119 | ||
120 | mCurrentLook = factory->create(); | 120 | mCurrentLook = factory->create(); |
121 | mDetailsStack->raiseWidget( mCurrentLook ); | 121 | mDetailsStack->raiseWidget( mCurrentLook ); |
122 | 122 | ||
123 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, | 123 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, |
124 | SIGNAL( sendEmail( const QString& ) ) ); | 124 | SIGNAL( sendEmail( const QString& ) ) ); |
125 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, | 125 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, |
126 | SIGNAL( browse( const QString& ) ) ); | 126 | SIGNAL( browse( const QString& ) ) ); |
127 | } | 127 | } |
128 | 128 | ||
129 | mCurrentLook->restoreSettings( config ); | 129 | mCurrentLook->restoreSettings( config ); |
130 | mCurrentLook->setAddressee( addr ); | 130 | mCurrentLook->setAddressee( addr ); |
131 | } | 131 | } |
132 | void ViewContainer::refreshView() | ||
133 | { | ||
134 | if ( mCurrentLook ) { | ||
135 | mCurrentLook->setAddressee( mCurrentAddressee ); | ||
136 | } | ||
137 | } | ||
138 | 132 | ||
139 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) | 133 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) |
140 | { | 134 | { |
141 | if ( mCurrentLook != 0 ) { | 135 | if ( mCurrentLook != 0 ) { |
142 | if ( addressee == mCurrentAddressee ) | ||
143 | return; | ||
144 | else { | ||
145 | mCurrentAddressee = addressee; | 136 | mCurrentAddressee = addressee; |
146 | mCurrentLook->setAddressee( mCurrentAddressee ); | 137 | mCurrentLook->setAddressee( mCurrentAddressee ); |
147 | } | 138 | |
148 | } | 139 | } |
149 | } | 140 | } |
150 | 141 | ||
151 | KABC::Addressee ViewContainer::addressee() | 142 | KABC::Addressee ViewContainer::addressee() |
152 | { | 143 | { |
153 | static KABC::Addressee empty; // do not use! | 144 | static KABC::Addressee empty; // do not use! |
154 | 145 | ||
155 | if ( !mCurrentLook ) | 146 | if ( !mCurrentLook ) |
156 | return empty; | 147 | return empty; |
157 | else | 148 | else |
158 | return mCurrentLook->addressee(); | 149 | return mCurrentLook->addressee(); |
159 | } | 150 | } |
160 | 151 | ||
161 | void ViewContainer::setReadOnly( bool state ) | 152 | void ViewContainer::setReadOnly( bool state ) |
162 | { | 153 | { |
163 | if ( mCurrentLook ) | 154 | if ( mCurrentLook ) |
164 | mCurrentLook->setReadOnly( state ); | 155 | mCurrentLook->setReadOnly( state ); |
165 | } | 156 | } |
166 | 157 | ||
167 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
168 | #include "detailsviewcontainer.moc" | 159 | #include "detailsviewcontainer.moc" |
169 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h index b561d12..667f0cb 100644 --- a/kaddressbook/details/detailsviewcontainer.h +++ b/kaddressbook/details/detailsviewcontainer.h | |||
@@ -1,103 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> | 3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@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 | #ifndef DETAILSVIEWCONTAINER_H | 24 | #ifndef DETAILSVIEWCONTAINER_H |
25 | #define DETAILSVIEWCONTAINER_H | 25 | #define DETAILSVIEWCONTAINER_H |
26 | 26 | ||
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | 28 | ||
29 | #include "look_basic.h" | 29 | #include "look_basic.h" |
30 | 30 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class QWidgetStack; | 32 | class QWidgetStack; |
33 | 33 | ||
34 | class ViewContainer : public QWidget | 34 | class ViewContainer : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | ViewContainer( QWidget *parent = 0, const char* name = 0 ); | 39 | ViewContainer( QWidget *parent = 0, const char* name = 0 ); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | Return the look currently selected. If there is none, it | 42 | Return the look currently selected. If there is none, it |
43 | returns zero. Do not use this pointer to store a reference | 43 | returns zero. Do not use this pointer to store a reference |
44 | to a look, the user might select another one (e.g., create | 44 | to a look, the user might select another one (e.g., create |
45 | a new object) at any time. | 45 | a new object) at any time. |
46 | */ | 46 | */ |
47 | KABBasicLook *currentLook(); | 47 | KABBasicLook *currentLook(); |
48 | void refreshView(); | ||
49 | /** | 48 | /** |
50 | Return the contact currently displayed. | 49 | Return the contact currently displayed. |
51 | */ | 50 | */ |
52 | KABC::Addressee addressee(); | 51 | KABC::Addressee addressee(); |
53 | 52 | ||
54 | public slots: | 53 | public slots: |
55 | /** | 54 | /** |
56 | Set the contact currently displayed. | 55 | Set the contact currently displayed. |
57 | */ | 56 | */ |
58 | void setAddressee( const KABC::Addressee& addressee ); | 57 | void setAddressee( const KABC::Addressee& addressee ); |
59 | 58 | ||
60 | /** | 59 | /** |
61 | Set read-write state. | 60 | Set read-write state. |
62 | */ | 61 | */ |
63 | void setReadOnly( bool state ); | 62 | void setReadOnly( bool state ); |
64 | 63 | ||
65 | signals: | 64 | signals: |
66 | /** | 65 | /** |
67 | The contact has been changed. | 66 | The contact has been changed. |
68 | */ | 67 | */ |
69 | void addresseeChanged(); | 68 | void addresseeChanged(); |
70 | 69 | ||
71 | /** | 70 | /** |
72 | The user acticated the email address displayed. This may happen | 71 | The user acticated the email address displayed. This may happen |
73 | by, for example, clicking on the displayed mailto-URL. | 72 | by, for example, clicking on the displayed mailto-URL. |
74 | */ | 73 | */ |
75 | void sendEmail( const QString& ); | 74 | void sendEmail( const QString& ); |
76 | 75 | ||
77 | /** | 76 | /** |
78 | The user activated one of the displayed HTTP URLs. For example | 77 | The user activated one of the displayed HTTP URLs. For example |
79 | by clicking on the displayed homepage address. | 78 | by clicking on the displayed homepage address. |
80 | */ | 79 | */ |
81 | void browse( const QString& ); | 80 | void browse( const QString& ); |
82 | 81 | ||
83 | protected: | 82 | protected: |
84 | /** | 83 | /** |
85 | A style has been selected. Overloaded from base class. | 84 | A style has been selected. Overloaded from base class. |
86 | */ | 85 | */ |
87 | void slotStyleSelected( int ); | 86 | void slotStyleSelected( int ); |
88 | 87 | ||
89 | /** | 88 | /** |
90 | Register the available looks. | 89 | Register the available looks. |
91 | */ | 90 | */ |
92 | void registerLooks(); | 91 | void registerLooks(); |
93 | 92 | ||
94 | private: | 93 | private: |
95 | KABC::Addressee mCurrentAddressee; | 94 | KABC::Addressee mCurrentAddressee; |
96 | KABBasicLook *mCurrentLook; | 95 | KABBasicLook *mCurrentLook; |
97 | QPtrList<KABLookFactory> mLookFactories; | 96 | QPtrList<KABLookFactory> mLookFactories; |
98 | 97 | ||
99 | QComboBox *mStyleCombo; | 98 | QComboBox *mStyleCombo; |
100 | QWidgetStack *mDetailsStack; | 99 | QWidgetStack *mDetailsStack; |
101 | }; | 100 | }; |
102 | 101 | ||
103 | #endif | 102 | #endif |
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 49d456b..48370e3 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -1,299 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 <kabc/picture.h> | 24 | #include <kabc/picture.h> |
25 | 25 | ||
26 | #ifndef KAB_EMBEDDED | 26 | #ifndef KAB_EMBEDDED |
27 | #include <kaccelmanager.h> | 27 | #include <kaccelmanager.h> |
28 | #include <kio/netaccess.h> | 28 | #include <kio/netaccess.h> |
29 | #include <kimageio.h> | 29 | #include <kimageio.h> |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kdialog.h> | 33 | #include <kdialog.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kurlrequester.h> | 36 | #include <kurlrequester.h> |
37 | #include <kurl.h> | 37 | #include <kurl.h> |
38 | 38 | ||
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qgroupbox.h> | 40 | #include <qgroupbox.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | 45 | ||
46 | #include "imagewidget.h" | 46 | #include "imagewidget.h" |
47 | 47 | ||
48 | ImageWidget::ImageWidget( QWidget *parent, const char *name ) | 48 | ImageWidget::ImageWidget( QWidget *parent, const char *name ) |
49 | : QWidget( parent, name ) | 49 | : QWidget( parent, name ) |
50 | { | 50 | { |
51 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), | 51 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), |
52 | KDialog::spacingHint() ); | 52 | KDialog::spacingHint() ); |
53 | 53 | ||
54 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); | 54 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); |
55 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, | 55 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, |
56 | KDialog::spacingHint() ); | 56 | KDialog::spacingHint() ); |
57 | boxLayout->setRowStretch( 2, 1 ); | 57 | boxLayout->setRowStretch( 2, 1 ); |
58 | 58 | ||
59 | mPhotoLabel = new QLabel( photoBox ); | 59 | mPhotoLabel = new QLabel( photoBox ); |
60 | int fac = 9; | 60 | int fac = 9; |
61 | if ( QApplication::desktop()->width() > 320 ) | 61 | if ( QApplication::desktop()->width() > 320 ) |
62 | fac = 6; | 62 | fac = 6; |
63 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 63 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
64 | mPhotoLabel->setScaledContents( true ); | 64 | mPhotoLabel->setScaledContents( true ); |
65 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 65 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
66 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 2, 0, 0 ); | 66 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 2, 0, 0 ); |
67 | 67 | ||
68 | mPhotoUrl = new KURLRequester( photoBox ); | 68 | mPhotoUrl = new KURLRequester( photoBox ); |
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | mPhotoUrl->setFilter( KImageIO::pattern() ); | 70 | mPhotoUrl->setFilter( KImageIO::pattern() ); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); | 72 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | 74 | ||
75 | 75 | ||
76 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); | 76 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); |
77 | 77 | ||
78 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); | 78 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); |
79 | mUsePhotoUrl->setEnabled( false ); | 79 | mUsePhotoUrl->setEnabled( false ); |
80 | boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); | 80 | boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); |
81 | 81 | ||
82 | topLayout->addWidget( photoBox, 0, 0 ); | 82 | topLayout->addWidget( photoBox, 0, 0 ); |
83 | 83 | ||
84 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); | 84 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); |
85 | boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); | 85 | boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); |
86 | boxLayout->setRowStretch( 2, 1 ); | 86 | boxLayout->setRowStretch( 2, 1 ); |
87 | 87 | ||
88 | mLogoLabel = new QLabel( logoBox ); | 88 | mLogoLabel = new QLabel( logoBox ); |
89 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 89 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
90 | mLogoLabel->setScaledContents( true ); | 90 | mLogoLabel->setScaledContents( true ); |
91 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 91 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
92 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 ); | 92 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 ); |
93 | 93 | ||
94 | mLogoUrl = new KURLRequester( logoBox ); | 94 | mLogoUrl = new KURLRequester( logoBox ); |
95 | #ifndef KAB_EMBEDDED | 95 | #ifndef KAB_EMBEDDED |
96 | mLogoUrl->setFilter( KImageIO::pattern() ); | 96 | mLogoUrl->setFilter( KImageIO::pattern() ); |
97 | #else //KAB_EMBEDDED | 97 | #else //KAB_EMBEDDED |
98 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); | 98 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); |
99 | #endif //KAB_EMBEDDED | 99 | #endif //KAB_EMBEDDED |
100 | boxLayout->addWidget( mLogoUrl, 0, 1 ); | 100 | boxLayout->addWidget( mLogoUrl, 0, 1 ); |
101 | 101 | ||
102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); | 102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); |
103 | mUseLogoUrl->setEnabled( false ); | 103 | mUseLogoUrl->setEnabled( false ); |
104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); | 104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); |
105 | 105 | ||
106 | topLayout->addWidget( logoBox, 1, 0 ); | 106 | topLayout->addWidget( logoBox, 1, 0 ); |
107 | 107 | ||
108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), | 108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), |
109 | SIGNAL( changed() ) ); | 109 | SIGNAL( changed() ) ); |
110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
111 | SLOT( loadPhoto() ) ); | 111 | SLOT( loadPhoto() ) ); |
112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
113 | SIGNAL( changed() ) ); | 113 | SIGNAL( changed() ) ); |
114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
115 | SLOT( updateGUI() ) ); | 115 | SLOT( updateGUI() ) ); |
116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), | 116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), |
117 | SIGNAL( changed() ) ); | 117 | SIGNAL( changed() ) ); |
118 | 118 | ||
119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), | 119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), |
120 | SIGNAL( changed() ) ); | 120 | SIGNAL( changed() ) ); |
121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
122 | SLOT( loadLogo() ) ); | 122 | SLOT( loadLogo() ) ); |
123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
124 | SIGNAL( changed() ) ); | 124 | SIGNAL( changed() ) ); |
125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
126 | SLOT( updateGUI() ) ); | 126 | SLOT( updateGUI() ) ); |
127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), | 127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), |
128 | SIGNAL( changed() ) ); | 128 | SIGNAL( changed() ) ); |
129 | 129 | ||
130 | #ifndef KAB_EMBEDDED | 130 | #ifndef KAB_EMBEDDED |
131 | KAcceleratorManager::manage( this ); | 131 | KAcceleratorManager::manage( this ); |
132 | #endif //KAB_EMBEDDED | 132 | #endif //KAB_EMBEDDED |
133 | 133 | ||
134 | #ifndef DESKTOP_VERSION | ||
135 | mUsePhotoUrl->setChecked( true ); | ||
136 | mUseLogoUrl->setChecked( true ); | ||
137 | #endif | ||
138 | } | 134 | } |
139 | 135 | ||
140 | ImageWidget::~ImageWidget() | 136 | ImageWidget::~ImageWidget() |
141 | { | 137 | { |
142 | } | 138 | } |
143 | 139 | ||
144 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 140 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
145 | { | 141 | { |
146 | bool blocked = signalsBlocked(); | 142 | bool blocked = signalsBlocked(); |
147 | blockSignals( true ); | 143 | blockSignals( true ); |
148 | 144 | ||
149 | if ( photo.isIntern() ) { | 145 | if ( photo.isIntern() ) { |
150 | //US | 146 | //US |
151 | //US mPhotoLabel->setPixmap( photo.data() ); | 147 | //US mPhotoLabel->setPixmap( photo.data() ); |
152 | if (photo.data().isNull() != true) | 148 | if (photo.data().isNull() != true) |
153 | { | 149 | { |
154 | QPixmap pm; | 150 | QPixmap pm; |
155 | pm.convertFromImage(photo.data()); | 151 | pm.convertFromImage(photo.data()); |
156 | 152 | ||
157 | mPhotoLabel->setPixmap( pm ); | 153 | mPhotoLabel->setPixmap( pm ); |
158 | } | 154 | } |
159 | 155 | ||
160 | mUsePhotoUrl->setChecked( false ); | 156 | mUsePhotoUrl->setChecked( false ); |
161 | } else { | 157 | } else { |
162 | mPhotoUrl->setURL( photo.url() ); | 158 | mPhotoUrl->setURL( photo.url() ); |
163 | if ( !photo.url().isEmpty() ) | 159 | if ( !photo.url().isEmpty() ) |
164 | mUsePhotoUrl->setChecked( true ); | 160 | mUsePhotoUrl->setChecked( true ); |
165 | loadPhoto(); | 161 | loadPhoto(); |
166 | } | 162 | } |
167 | 163 | ||
168 | blockSignals( blocked ); | 164 | blockSignals( blocked ); |
169 | } | 165 | } |
170 | 166 | ||
171 | KABC::Picture ImageWidget::photo() const | 167 | KABC::Picture ImageWidget::photo() const |
172 | { | 168 | { |
173 | KABC::Picture photo; | 169 | KABC::Picture photo; |
174 | 170 | ||
175 | if ( mUsePhotoUrl->isChecked() ) | 171 | if ( mUsePhotoUrl->isChecked() ) |
176 | photo.setUrl( mPhotoUrl->url() ); | 172 | photo.setUrl( mPhotoUrl->url() ); |
177 | else { | 173 | else { |
178 | QPixmap *px = mPhotoLabel->pixmap(); | 174 | QPixmap *px = mPhotoLabel->pixmap(); |
179 | if ( px ) { | 175 | if ( px ) { |
180 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
181 | if ( px->height() > px->width() ) | 177 | if ( px->height() > px->width() ) |
182 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); | 178 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); |
183 | else | 179 | else |
184 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); | 180 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); |
185 | #else //KAB_EMBEDDED | 181 | #else //KAB_EMBEDDED |
186 | //US add teh nullcheck | 182 | //US add teh nullcheck |
187 | if (px->isNull() != true ) | 183 | if (px->isNull() != true ) |
188 | photo.setData( px->convertToImage() ); | 184 | photo.setData( px->convertToImage() ); |
189 | #endif //KAB_EMBEDDED | 185 | #endif //KAB_EMBEDDED |
190 | 186 | ||
191 | photo.setType( "PNG" ); | 187 | photo.setType( "PNG" ); |
192 | } | 188 | } |
193 | } | 189 | } |
194 | 190 | ||
195 | return photo; | 191 | return photo; |
196 | } | 192 | } |
197 | 193 | ||
198 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 194 | void ImageWidget::setLogo( const KABC::Picture &logo ) |
199 | { | 195 | { |
200 | bool blocked = signalsBlocked(); | 196 | bool blocked = signalsBlocked(); |
201 | blockSignals( true ); | 197 | blockSignals( true ); |
202 | 198 | ||
203 | if ( logo.isIntern() ) { | 199 | if ( logo.isIntern() ) { |
204 | //US | 200 | //US |
205 | //US mLogoLabel->setPixmap( logo.data() ); | 201 | //US mLogoLabel->setPixmap( logo.data() ); |
206 | if (logo.data().isNull() != true) | 202 | if (logo.data().isNull() != true) |
207 | { | 203 | { |
208 | QPixmap pm; | 204 | QPixmap pm; |
209 | pm.convertFromImage(logo.data()); | 205 | pm.convertFromImage(logo.data()); |
210 | mLogoLabel->setPixmap( pm ); | 206 | mLogoLabel->setPixmap( pm ); |
211 | } | 207 | } |
212 | mUseLogoUrl->setChecked( false ); | 208 | mUseLogoUrl->setChecked( false ); |
213 | } else { | 209 | } else { |
214 | mLogoUrl->setURL( logo.url() ); | 210 | mLogoUrl->setURL( logo.url() ); |
215 | if ( !logo.url().isEmpty() ) | 211 | if ( !logo.url().isEmpty() ) |
216 | mUseLogoUrl->setChecked( true ); | 212 | mUseLogoUrl->setChecked( true ); |
217 | loadLogo(); | 213 | loadLogo(); |
218 | } | 214 | } |
219 | 215 | ||
220 | blockSignals( blocked ); | 216 | blockSignals( blocked ); |
221 | } | 217 | } |
222 | 218 | ||
223 | KABC::Picture ImageWidget::logo() const | 219 | KABC::Picture ImageWidget::logo() const |
224 | { | 220 | { |
225 | KABC::Picture logo; | 221 | KABC::Picture logo; |
226 | 222 | ||
227 | if ( mUseLogoUrl->isChecked() ) | 223 | if ( mUseLogoUrl->isChecked() ) |
228 | logo.setUrl( mLogoUrl->url() ); | 224 | logo.setUrl( mLogoUrl->url() ); |
229 | else { | 225 | else { |
230 | QPixmap *px = mLogoLabel->pixmap(); | 226 | QPixmap *px = mLogoLabel->pixmap(); |
231 | if ( px ) { | 227 | if ( px ) { |
232 | #ifndef KAB_EMBEDDED | 228 | #ifndef KAB_EMBEDDED |
233 | if ( px->height() > px->width() ) | 229 | if ( px->height() > px->width() ) |
234 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 230 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
235 | else | 231 | else |
236 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 232 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
237 | #else //KAB_EMBEDDED | 233 | #else //KAB_EMBEDDED |
238 | logo.setData( px->convertToImage() ); | 234 | logo.setData( px->convertToImage() ); |
239 | #endif //KAB_EMBEDDED | 235 | #endif //KAB_EMBEDDED |
240 | 236 | ||
241 | logo.setType( "PNG" ); | 237 | logo.setType( "PNG" ); |
242 | 238 | ||
243 | } | 239 | } |
244 | } | 240 | } |
245 | 241 | ||
246 | return logo; | 242 | return logo; |
247 | } | 243 | } |
248 | 244 | ||
249 | void ImageWidget::loadPhoto() | 245 | void ImageWidget::loadPhoto() |
250 | { | 246 | { |
251 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 247 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
252 | } | 248 | } |
253 | 249 | ||
254 | void ImageWidget::loadLogo() | 250 | void ImageWidget::loadLogo() |
255 | { | 251 | { |
256 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 252 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
257 | } | 253 | } |
258 | 254 | ||
259 | void ImageWidget::updateGUI() | 255 | void ImageWidget::updateGUI() |
260 | { | 256 | { |
261 | KURLRequester *ptr = (KURLRequester*)sender(); | 257 | KURLRequester *ptr = (KURLRequester*)sender(); |
262 | 258 | ||
263 | #ifdef DESKTOP_VERSION | 259 | |
264 | if ( ptr == mPhotoUrl ) | 260 | if ( ptr == mPhotoUrl ) |
265 | mUsePhotoUrl->setEnabled( true ); | 261 | mUsePhotoUrl->setEnabled( true ); |
266 | else if ( ptr == mLogoUrl ) | 262 | else if ( ptr == mLogoUrl ) |
267 | mUseLogoUrl->setEnabled( true ); | 263 | mUseLogoUrl->setEnabled( true ); |
268 | #endif | ||
269 | } | 264 | } |
270 | 265 | ||
271 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 266 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
272 | { | 267 | { |
273 | QString tempFile; | 268 | QString tempFile; |
274 | QPixmap pixmap; | 269 | QPixmap pixmap; |
275 | 270 | ||
276 | if ( url.isEmpty() ) | 271 | if ( url.isEmpty() ) |
277 | return pixmap; | 272 | return pixmap; |
278 | 273 | ||
279 | if ( url.isLocalFile() ) | 274 | if ( url.isLocalFile() ) |
280 | pixmap = QPixmap( url.path() ); | 275 | pixmap = QPixmap( url.path() ); |
281 | else | 276 | else |
282 | { | 277 | { |
283 | #ifndef KAB_EMBEDDED | 278 | #ifndef KAB_EMBEDDED |
284 | if ( KIO::NetAccess::download( url, tempFile ) ) { | 279 | if ( KIO::NetAccess::download( url, tempFile ) ) { |
285 | pixmap = QPixmap( tempFile ); | 280 | pixmap = QPixmap( tempFile ); |
286 | KIO::NetAccess::removeTempFile( tempFile ); | 281 | KIO::NetAccess::removeTempFile( tempFile ); |
287 | } | 282 | } |
288 | #else //KAB_EMBEDDED | 283 | #else //KAB_EMBEDDED |
289 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | 284 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); |
290 | #endif //KAB_EMBEDDED | 285 | #endif //KAB_EMBEDDED |
291 | 286 | ||
292 | } | 287 | } |
293 | 288 | ||
294 | return pixmap; | 289 | return pixmap; |
295 | } | 290 | } |
296 | 291 | ||
297 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
298 | #include "imagewidget.moc" | 293 | #include "imagewidget.moc" |
299 | #endif //KAB_EMBEDDED | 294 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f6bdda4..e14e579 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -745,1932 +745,1927 @@ void KABCore::mailVCard( const QStringList& uids ) | |||
745 | urls.append( fileName ); | 745 | urls.append( fileName ); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
750 | 750 | ||
751 | 751 | ||
752 | /*US | 752 | /*US |
753 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 753 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
754 | QString::null, // subject | 754 | QString::null, // subject |
755 | QString::null, // body | 755 | QString::null, // body |
756 | QString::null, | 756 | QString::null, |
757 | urls ); // attachments | 757 | urls ); // attachments |
758 | */ | 758 | */ |
759 | 759 | ||
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Beams the "WhoAmI contact. | 763 | Beams the "WhoAmI contact. |
764 | */ | 764 | */ |
765 | void KABCore::beamMySelf() | 765 | void KABCore::beamMySelf() |
766 | { | 766 | { |
767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
768 | if (!a.isEmpty()) | 768 | if (!a.isEmpty()) |
769 | { | 769 | { |
770 | QStringList uids; | 770 | QStringList uids; |
771 | uids << a.uid(); | 771 | uids << a.uid(); |
772 | 772 | ||
773 | beamVCard(uids); | 773 | beamVCard(uids); |
774 | } else { | 774 | } else { |
775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
776 | 776 | ||
777 | 777 | ||
778 | } | 778 | } |
779 | } | 779 | } |
780 | void KABCore::updateMainWindow() | 780 | void KABCore::updateMainWindow() |
781 | { | 781 | { |
782 | 782 | ||
783 | mMainWindow->showMaximized(); | 783 | mMainWindow->showMaximized(); |
784 | mMainWindow->update(); | 784 | mMainWindow->update(); |
785 | } | 785 | } |
786 | void KABCore::resizeEvent(QResizeEvent* e ) | 786 | void KABCore::resizeEvent(QResizeEvent* e ) |
787 | { | 787 | { |
788 | if ( !mMiniSplitter ) | 788 | if ( !mMiniSplitter ) |
789 | return; | 789 | return; |
790 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 790 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
791 | if ( QApplication::desktop()->width() >= 480 ) { | 791 | if ( QApplication::desktop()->width() >= 480 ) { |
792 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 792 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
793 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 793 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
794 | mMiniSplitter->setOrientation( Qt::Horizontal); | 794 | mMiniSplitter->setOrientation( Qt::Horizontal); |
795 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 795 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
796 | if ( QApplication::desktop()->width() <= 640 ) { | 796 | if ( QApplication::desktop()->width() <= 640 ) { |
797 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 797 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
798 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 798 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
799 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 799 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 802 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
803 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 803 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
804 | mMiniSplitter->setOrientation( Qt::Vertical ); | 804 | mMiniSplitter->setOrientation( Qt::Vertical ); |
805 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 805 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
806 | if ( QApplication::desktop()->width() <= 640 ) { | 806 | if ( QApplication::desktop()->width() <= 640 ) { |
807 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 807 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
808 | mMainWindow->showMinimized(); | 808 | mMainWindow->showMinimized(); |
809 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 809 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
810 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 810 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
811 | } | 811 | } |
812 | } | 812 | } |
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | } | 816 | } |
817 | void KABCore::export2phone() | 817 | void KABCore::export2phone() |
818 | { | 818 | { |
819 | 819 | ||
820 | QStringList uids; | 820 | QStringList uids; |
821 | XXPortSelectDialog dlg( this, false, this ); | 821 | XXPortSelectDialog dlg( this, false, this ); |
822 | if ( dlg.exec() ) | 822 | if ( dlg.exec() ) |
823 | uids = dlg.uids(); | 823 | uids = dlg.uids(); |
824 | else | 824 | else |
825 | return; | 825 | return; |
826 | if ( uids.isEmpty() ) | 826 | if ( uids.isEmpty() ) |
827 | return; | 827 | return; |
828 | // qDebug("count %d ", uids.count()); | 828 | // qDebug("count %d ", uids.count()); |
829 | 829 | ||
830 | KAex2phonePrefs ex2phone; | 830 | KAex2phonePrefs ex2phone; |
831 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 831 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
832 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 832 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
833 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 833 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
834 | 834 | ||
835 | if ( !ex2phone.exec() ) { | 835 | if ( !ex2phone.exec() ) { |
836 | return; | 836 | return; |
837 | } | 837 | } |
838 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 838 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
839 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 839 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
840 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 840 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
841 | 841 | ||
842 | 842 | ||
843 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 843 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
844 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 844 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
845 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 845 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
846 | 846 | ||
847 | QString fileName = getPhoneFile(); | 847 | QString fileName = getPhoneFile(); |
848 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 848 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
849 | return; | 849 | return; |
850 | 850 | ||
851 | message(i18n("Exporting to phone...")); | 851 | message(i18n("Exporting to phone...")); |
852 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 852 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
853 | 853 | ||
854 | } | 854 | } |
855 | QString KABCore::getPhoneFile() | 855 | QString KABCore::getPhoneFile() |
856 | { | 856 | { |
857 | #ifdef DESKTOP_VERSION | 857 | #ifdef DESKTOP_VERSION |
858 | return locateLocal("tmp", "phonefile.vcf"); | 858 | return locateLocal("tmp", "phonefile.vcf"); |
859 | #else | 859 | #else |
860 | return "/tmp/phonefile.vcf"; | 860 | return "/tmp/phonefile.vcf"; |
861 | #endif | 861 | #endif |
862 | 862 | ||
863 | } | 863 | } |
864 | void KABCore::writeToPhone( ) | 864 | void KABCore::writeToPhone( ) |
865 | { | 865 | { |
866 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 866 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
867 | message(i18n("Export to phone finished!")); | 867 | message(i18n("Export to phone finished!")); |
868 | else | 868 | else |
869 | qDebug(i18n("Error exporting to phone")); | 869 | qDebug(i18n("Error exporting to phone")); |
870 | } | 870 | } |
871 | void KABCore::beamVCard() | 871 | void KABCore::beamVCard() |
872 | { | 872 | { |
873 | QStringList uids; | 873 | QStringList uids; |
874 | XXPortSelectDialog dlg( this, false, this ); | 874 | XXPortSelectDialog dlg( this, false, this ); |
875 | if ( dlg.exec() ) | 875 | if ( dlg.exec() ) |
876 | uids = dlg.uids(); | 876 | uids = dlg.uids(); |
877 | else | 877 | else |
878 | return; | 878 | return; |
879 | if ( uids.isEmpty() ) | 879 | if ( uids.isEmpty() ) |
880 | return; | 880 | return; |
881 | beamVCard( uids ); | 881 | beamVCard( uids ); |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void KABCore::beamVCard(const QStringList& uids) | 885 | void KABCore::beamVCard(const QStringList& uids) |
886 | { | 886 | { |
887 | 887 | ||
888 | // LR: we should use the /tmp dir on the Zaurus, | 888 | // LR: we should use the /tmp dir on the Zaurus, |
889 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 889 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
890 | 890 | ||
891 | #ifdef DESKTOP_VERSION | 891 | #ifdef DESKTOP_VERSION |
892 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 892 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
893 | #else | 893 | #else |
894 | QString fileName = "/tmp/kapibeamfile.vcf"; | 894 | QString fileName = "/tmp/kapibeamfile.vcf"; |
895 | #endif | 895 | #endif |
896 | 896 | ||
897 | KABC::VCardConverter converter; | 897 | KABC::VCardConverter converter; |
898 | QString description; | 898 | QString description; |
899 | QString datastream; | 899 | QString datastream; |
900 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 900 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
901 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 901 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
902 | 902 | ||
903 | if ( a.isEmpty() ) | 903 | if ( a.isEmpty() ) |
904 | continue; | 904 | continue; |
905 | 905 | ||
906 | if (description.isEmpty()) | 906 | if (description.isEmpty()) |
907 | description = a.formattedName(); | 907 | description = a.formattedName(); |
908 | 908 | ||
909 | QString vcard; | 909 | QString vcard; |
910 | converter.addresseeToVCard( a, vcard ); | 910 | converter.addresseeToVCard( a, vcard ); |
911 | int start = 0; | 911 | int start = 0; |
912 | int next; | 912 | int next; |
913 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 913 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
914 | int semi = vcard.find(";", next); | 914 | int semi = vcard.find(";", next); |
915 | int dopp = vcard.find(":", next); | 915 | int dopp = vcard.find(":", next); |
916 | int sep; | 916 | int sep; |
917 | if ( semi < dopp && semi >= 0 ) | 917 | if ( semi < dopp && semi >= 0 ) |
918 | sep = semi ; | 918 | sep = semi ; |
919 | else | 919 | else |
920 | sep = dopp; | 920 | sep = dopp; |
921 | datastream +=vcard.mid( start, next - start); | 921 | datastream +=vcard.mid( start, next - start); |
922 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 922 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
923 | start = sep; | 923 | start = sep; |
924 | } | 924 | } |
925 | datastream += vcard.mid( start,vcard.length() ); | 925 | datastream += vcard.mid( start,vcard.length() ); |
926 | } | 926 | } |
927 | #ifndef DESKTOP_VERSION | 927 | #ifndef DESKTOP_VERSION |
928 | QFile outFile(fileName); | 928 | QFile outFile(fileName); |
929 | if ( outFile.open(IO_WriteOnly) ) { | 929 | if ( outFile.open(IO_WriteOnly) ) { |
930 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 930 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
931 | QTextStream t( &outFile ); // use a text stream | 931 | QTextStream t( &outFile ); // use a text stream |
932 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 932 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
933 | t.setEncoding( QTextStream::Latin1 ); | 933 | t.setEncoding( QTextStream::Latin1 ); |
934 | t <<datastream.latin1(); | 934 | t <<datastream.latin1(); |
935 | outFile.close(); | 935 | outFile.close(); |
936 | Ir *ir = new Ir( this ); | 936 | Ir *ir = new Ir( this ); |
937 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 937 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
938 | ir->send( fileName, description, "text/x-vCard" ); | 938 | ir->send( fileName, description, "text/x-vCard" ); |
939 | } else { | 939 | } else { |
940 | qDebug("Error open temp beam file "); | 940 | qDebug("Error open temp beam file "); |
941 | return; | 941 | return; |
942 | } | 942 | } |
943 | #endif | 943 | #endif |
944 | 944 | ||
945 | } | 945 | } |
946 | 946 | ||
947 | void KABCore::beamDone( Ir *ir ) | 947 | void KABCore::beamDone( Ir *ir ) |
948 | { | 948 | { |
949 | #ifndef DESKTOP_VERSION | 949 | #ifndef DESKTOP_VERSION |
950 | delete ir; | 950 | delete ir; |
951 | #endif | 951 | #endif |
952 | topLevelWidget()->raise(); | 952 | topLevelWidget()->raise(); |
953 | message( i18n("Beaming finished!") ); | 953 | message( i18n("Beaming finished!") ); |
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | void KABCore::browse( const QString& url ) | 957 | void KABCore::browse( const QString& url ) |
958 | { | 958 | { |
959 | #ifndef KAB_EMBEDDED | 959 | #ifndef KAB_EMBEDDED |
960 | kapp->invokeBrowser( url ); | 960 | kapp->invokeBrowser( url ); |
961 | #else //KAB_EMBEDDED | 961 | #else //KAB_EMBEDDED |
962 | qDebug("KABCore::browse must be fixed"); | 962 | qDebug("KABCore::browse must be fixed"); |
963 | #endif //KAB_EMBEDDED | 963 | #endif //KAB_EMBEDDED |
964 | } | 964 | } |
965 | 965 | ||
966 | void KABCore::selectAllContacts() | 966 | void KABCore::selectAllContacts() |
967 | { | 967 | { |
968 | mViewManager->setSelected( QString::null, true ); | 968 | mViewManager->setSelected( QString::null, true ); |
969 | } | 969 | } |
970 | 970 | ||
971 | void KABCore::deleteContacts() | 971 | void KABCore::deleteContacts() |
972 | { | 972 | { |
973 | QStringList uidList = mViewManager->selectedUids(); | 973 | QStringList uidList = mViewManager->selectedUids(); |
974 | deleteContacts( uidList ); | 974 | deleteContacts( uidList ); |
975 | } | 975 | } |
976 | 976 | ||
977 | void KABCore::deleteContacts( const QStringList &uids ) | 977 | void KABCore::deleteContacts( const QStringList &uids ) |
978 | { | 978 | { |
979 | if ( uids.count() > 0 ) { | 979 | if ( uids.count() > 0 ) { |
980 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 980 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
981 | UndoStack::instance()->push( command ); | 981 | UndoStack::instance()->push( command ); |
982 | RedoStack::instance()->clear(); | 982 | RedoStack::instance()->clear(); |
983 | 983 | ||
984 | // now if we deleted anything, refresh | 984 | // now if we deleted anything, refresh |
985 | setContactSelected( QString::null ); | 985 | setContactSelected( QString::null ); |
986 | setModified( true ); | 986 | setModified( true ); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | 989 | ||
990 | void KABCore::copyContacts() | 990 | void KABCore::copyContacts() |
991 | { | 991 | { |
992 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 992 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
993 | 993 | ||
994 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 994 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
995 | 995 | ||
996 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 996 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
997 | 997 | ||
998 | QClipboard *cb = QApplication::clipboard(); | 998 | QClipboard *cb = QApplication::clipboard(); |
999 | cb->setText( clipText ); | 999 | cb->setText( clipText ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void KABCore::cutContacts() | 1002 | void KABCore::cutContacts() |
1003 | { | 1003 | { |
1004 | QStringList uidList = mViewManager->selectedUids(); | 1004 | QStringList uidList = mViewManager->selectedUids(); |
1005 | 1005 | ||
1006 | //US if ( uidList.size() > 0 ) { | 1006 | //US if ( uidList.size() > 0 ) { |
1007 | if ( uidList.count() > 0 ) { | 1007 | if ( uidList.count() > 0 ) { |
1008 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1008 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1009 | UndoStack::instance()->push( command ); | 1009 | UndoStack::instance()->push( command ); |
1010 | RedoStack::instance()->clear(); | 1010 | RedoStack::instance()->clear(); |
1011 | 1011 | ||
1012 | setModified( true ); | 1012 | setModified( true ); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | void KABCore::pasteContacts() | 1016 | void KABCore::pasteContacts() |
1017 | { | 1017 | { |
1018 | QClipboard *cb = QApplication::clipboard(); | 1018 | QClipboard *cb = QApplication::clipboard(); |
1019 | 1019 | ||
1020 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1020 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1021 | 1021 | ||
1022 | pasteContacts( list ); | 1022 | pasteContacts( list ); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1025 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1026 | { | 1026 | { |
1027 | KABC::Resource *resource = requestResource( this ); | 1027 | KABC::Resource *resource = requestResource( this ); |
1028 | KABC::Addressee::List::Iterator it; | 1028 | KABC::Addressee::List::Iterator it; |
1029 | for ( it = list.begin(); it != list.end(); ++it ) | 1029 | for ( it = list.begin(); it != list.end(); ++it ) |
1030 | (*it).setResource( resource ); | 1030 | (*it).setResource( resource ); |
1031 | 1031 | ||
1032 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1032 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1033 | UndoStack::instance()->push( command ); | 1033 | UndoStack::instance()->push( command ); |
1034 | RedoStack::instance()->clear(); | 1034 | RedoStack::instance()->clear(); |
1035 | 1035 | ||
1036 | setModified( true ); | 1036 | setModified( true ); |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | void KABCore::setWhoAmI() | 1039 | void KABCore::setWhoAmI() |
1040 | { | 1040 | { |
1041 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1041 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1042 | 1042 | ||
1043 | if ( addrList.count() > 1 ) { | 1043 | if ( addrList.count() > 1 ) { |
1044 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1044 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1045 | return; | 1045 | return; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1048 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1049 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1049 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1050 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1050 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1051 | } | 1051 | } |
1052 | void KABCore::editCategories() | 1052 | void KABCore::editCategories() |
1053 | { | 1053 | { |
1054 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1054 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1055 | dlg.exec(); | 1055 | dlg.exec(); |
1056 | } | 1056 | } |
1057 | void KABCore::setCategories() | 1057 | void KABCore::setCategories() |
1058 | { | 1058 | { |
1059 | 1059 | ||
1060 | QStringList uids; | 1060 | QStringList uids; |
1061 | XXPortSelectDialog dlgx( this, false, this ); | 1061 | XXPortSelectDialog dlgx( this, false, this ); |
1062 | if ( dlgx.exec() ) | 1062 | if ( dlgx.exec() ) |
1063 | uids = dlgx.uids(); | 1063 | uids = dlgx.uids(); |
1064 | else | 1064 | else |
1065 | return; | 1065 | return; |
1066 | if ( uids.isEmpty() ) | 1066 | if ( uids.isEmpty() ) |
1067 | return; | 1067 | return; |
1068 | // qDebug("count %d ", uids.count()); | 1068 | // qDebug("count %d ", uids.count()); |
1069 | 1069 | ||
1070 | 1070 | ||
1071 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1071 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1072 | if ( !dlg.exec() ) { | 1072 | if ( !dlg.exec() ) { |
1073 | message( i18n("Setting categories cancelled") ); | 1073 | message( i18n("Setting categories cancelled") ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | bool merge = false; | 1076 | bool merge = false; |
1077 | QString msg = i18n( "Merge with existing categories?" ); | 1077 | QString msg = i18n( "Merge with existing categories?" ); |
1078 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1078 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1079 | merge = true; | 1079 | merge = true; |
1080 | 1080 | ||
1081 | message( i18n("Setting categories ... please wait!") ); | 1081 | message( i18n("Setting categories ... please wait!") ); |
1082 | QStringList categories = dlg.selectedCategories(); | 1082 | QStringList categories = dlg.selectedCategories(); |
1083 | 1083 | ||
1084 | //QStringList uids = mViewManager->selectedUids(); | 1084 | //QStringList uids = mViewManager->selectedUids(); |
1085 | QStringList::Iterator it; | 1085 | QStringList::Iterator it; |
1086 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1086 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1087 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1087 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1088 | if ( !addr.isEmpty() ) { | 1088 | if ( !addr.isEmpty() ) { |
1089 | if ( !merge ) | 1089 | if ( !merge ) |
1090 | addr.setCategories( categories ); | 1090 | addr.setCategories( categories ); |
1091 | else { | 1091 | else { |
1092 | QStringList addrCategories = addr.categories(); | 1092 | QStringList addrCategories = addr.categories(); |
1093 | QStringList::Iterator catIt; | 1093 | QStringList::Iterator catIt; |
1094 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1094 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1095 | if ( !addrCategories.contains( *catIt ) ) | 1095 | if ( !addrCategories.contains( *catIt ) ) |
1096 | addrCategories.append( *catIt ); | 1096 | addrCategories.append( *catIt ); |
1097 | } | 1097 | } |
1098 | addr.setCategories( addrCategories ); | 1098 | addr.setCategories( addrCategories ); |
1099 | } | 1099 | } |
1100 | mAddressBook->insertAddressee( addr ); | 1100 | mAddressBook->insertAddressee( addr ); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | if ( uids.count() > 0 ) | 1104 | if ( uids.count() > 0 ) |
1105 | setModified( true ); | 1105 | setModified( true ); |
1106 | message( i18n("Setting categories completed!") ); | 1106 | message( i18n("Setting categories completed!") ); |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1109 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1110 | { | 1110 | { |
1111 | mIncSearchWidget->setFields( fields ); | 1111 | mIncSearchWidget->setFields( fields ); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void KABCore::incrementalSearch( const QString& text ) | 1114 | void KABCore::incrementalSearch( const QString& text ) |
1115 | { | 1115 | { |
1116 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1116 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void KABCore::setModified() | 1119 | void KABCore::setModified() |
1120 | { | 1120 | { |
1121 | setModified( true ); | 1121 | setModified( true ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void KABCore::setModifiedWOrefresh() | 1124 | void KABCore::setModifiedWOrefresh() |
1125 | { | 1125 | { |
1126 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1126 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1127 | mModified = true; | 1127 | mModified = true; |
1128 | mActionSave->setEnabled( mModified ); | 1128 | mActionSave->setEnabled( mModified ); |
1129 | #ifdef DESKTOP_VERSION | 1129 | |
1130 | mDetails->refreshView(); | ||
1131 | #endif | ||
1132 | 1130 | ||
1133 | } | 1131 | } |
1134 | void KABCore::setModified( bool modified ) | 1132 | void KABCore::setModified( bool modified ) |
1135 | { | 1133 | { |
1136 | mModified = modified; | 1134 | mModified = modified; |
1137 | mActionSave->setEnabled( mModified ); | 1135 | mActionSave->setEnabled( mModified ); |
1138 | 1136 | ||
1139 | if ( modified ) | 1137 | if ( modified ) |
1140 | mJumpButtonBar->recreateButtons(); | 1138 | mJumpButtonBar->recreateButtons(); |
1141 | 1139 | ||
1142 | mViewManager->refreshView(); | 1140 | mViewManager->refreshView(); |
1143 | mDetails->refreshView(); | ||
1144 | 1141 | ||
1145 | } | 1142 | } |
1146 | 1143 | ||
1147 | bool KABCore::modified() const | 1144 | bool KABCore::modified() const |
1148 | { | 1145 | { |
1149 | return mModified; | 1146 | return mModified; |
1150 | } | 1147 | } |
1151 | 1148 | ||
1152 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1149 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1153 | { | 1150 | { |
1154 | 1151 | ||
1155 | Command *command = 0; | 1152 | Command *command = 0; |
1156 | QString uid; | 1153 | QString uid; |
1157 | 1154 | ||
1158 | // check if it exists already | 1155 | // check if it exists already |
1159 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1156 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1160 | if ( origAddr.isEmpty() ) | 1157 | if ( origAddr.isEmpty() ) |
1161 | command = new PwNewCommand( mAddressBook, addr ); | 1158 | command = new PwNewCommand( mAddressBook, addr ); |
1162 | else { | 1159 | else { |
1163 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1160 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1164 | uid = addr.uid(); | 1161 | uid = addr.uid(); |
1165 | } | 1162 | } |
1166 | 1163 | ||
1167 | UndoStack::instance()->push( command ); | 1164 | UndoStack::instance()->push( command ); |
1168 | RedoStack::instance()->clear(); | 1165 | RedoStack::instance()->clear(); |
1169 | 1166 | mDetails->setAddressee( addr ); | |
1170 | setModified( true ); | 1167 | setModified( true ); |
1171 | } | 1168 | } |
1172 | 1169 | ||
1173 | void KABCore::newContact() | 1170 | void KABCore::newContact() |
1174 | { | 1171 | { |
1175 | 1172 | ||
1176 | 1173 | ||
1177 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1174 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1178 | 1175 | ||
1179 | QPtrList<KRES::Resource> kresResources; | 1176 | QPtrList<KRES::Resource> kresResources; |
1180 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1177 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1181 | KABC::Resource *resource; | 1178 | KABC::Resource *resource; |
1182 | while ( ( resource = it.current() ) != 0 ) { | 1179 | while ( ( resource = it.current() ) != 0 ) { |
1183 | ++it; | 1180 | ++it; |
1184 | if ( !resource->readOnly() ) { | 1181 | if ( !resource->readOnly() ) { |
1185 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1182 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1186 | if ( res ) | 1183 | if ( res ) |
1187 | kresResources.append( res ); | 1184 | kresResources.append( res ); |
1188 | } | 1185 | } |
1189 | } | 1186 | } |
1190 | 1187 | ||
1191 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1188 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1192 | resource = static_cast<KABC::Resource*>( res ); | 1189 | resource = static_cast<KABC::Resource*>( res ); |
1193 | 1190 | ||
1194 | if ( resource ) { | 1191 | if ( resource ) { |
1195 | KABC::Addressee addr; | 1192 | KABC::Addressee addr; |
1196 | addr.setResource( resource ); | 1193 | addr.setResource( resource ); |
1197 | mEditorDialog->setAddressee( addr ); | 1194 | mEditorDialog->setAddressee( addr ); |
1198 | KApplication::execDialog ( mEditorDialog ); | 1195 | KApplication::execDialog ( mEditorDialog ); |
1199 | 1196 | ||
1200 | } else | 1197 | } else |
1201 | return; | 1198 | return; |
1202 | 1199 | ||
1203 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1200 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1204 | 1201 | ||
1205 | 1202 | ||
1206 | } | 1203 | } |
1207 | 1204 | ||
1208 | void KABCore::addEmail( QString aStr ) | 1205 | void KABCore::addEmail( QString aStr ) |
1209 | { | 1206 | { |
1210 | #ifndef KAB_EMBEDDED | 1207 | #ifndef KAB_EMBEDDED |
1211 | QString fullName, email; | 1208 | QString fullName, email; |
1212 | 1209 | ||
1213 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1210 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1214 | 1211 | ||
1215 | // Try to lookup the addressee matching the email address | 1212 | // Try to lookup the addressee matching the email address |
1216 | bool found = false; | 1213 | bool found = false; |
1217 | QStringList emailList; | 1214 | QStringList emailList; |
1218 | KABC::AddressBook::Iterator it; | 1215 | KABC::AddressBook::Iterator it; |
1219 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1216 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1220 | emailList = (*it).emails(); | 1217 | emailList = (*it).emails(); |
1221 | if ( emailList.contains( email ) > 0 ) { | 1218 | if ( emailList.contains( email ) > 0 ) { |
1222 | found = true; | 1219 | found = true; |
1223 | (*it).setNameFromString( fullName ); | 1220 | (*it).setNameFromString( fullName ); |
1224 | editContact( (*it).uid() ); | 1221 | editContact( (*it).uid() ); |
1225 | } | 1222 | } |
1226 | } | 1223 | } |
1227 | 1224 | ||
1228 | if ( !found ) { | 1225 | if ( !found ) { |
1229 | KABC::Addressee addr; | 1226 | KABC::Addressee addr; |
1230 | addr.setNameFromString( fullName ); | 1227 | addr.setNameFromString( fullName ); |
1231 | addr.insertEmail( email, true ); | 1228 | addr.insertEmail( email, true ); |
1232 | 1229 | ||
1233 | mAddressBook->insertAddressee( addr ); | 1230 | mAddressBook->insertAddressee( addr ); |
1234 | mViewManager->refreshView( addr.uid() ); | 1231 | mViewManager->refreshView( addr.uid() ); |
1235 | editContact( addr.uid() ); | 1232 | editContact( addr.uid() ); |
1236 | } | 1233 | } |
1237 | #else //KAB_EMBEDDED | 1234 | #else //KAB_EMBEDDED |
1238 | qDebug("KABCore::addEmail finsih method"); | 1235 | qDebug("KABCore::addEmail finsih method"); |
1239 | #endif //KAB_EMBEDDED | 1236 | #endif //KAB_EMBEDDED |
1240 | } | 1237 | } |
1241 | 1238 | ||
1242 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1239 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1243 | { | 1240 | { |
1244 | mXXPortManager->importVCard( url, showPreview ); | 1241 | mXXPortManager->importVCard( url, showPreview ); |
1245 | } | 1242 | } |
1246 | void KABCore::importFromOL() | 1243 | void KABCore::importFromOL() |
1247 | { | 1244 | { |
1248 | #ifdef _WIN32_ | 1245 | #ifdef _WIN32_ |
1249 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1246 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1250 | idgl->exec(); | 1247 | idgl->exec(); |
1251 | KABC::Addressee::List list = idgl->getAddressList(); | 1248 | KABC::Addressee::List list = idgl->getAddressList(); |
1252 | if ( list.count() > 0 ) { | 1249 | if ( list.count() > 0 ) { |
1253 | KABC::Addressee::List listNew; | 1250 | KABC::Addressee::List listNew; |
1254 | KABC::Addressee::List listExisting; | 1251 | KABC::Addressee::List listExisting; |
1255 | KABC::Addressee::List::Iterator it; | 1252 | KABC::Addressee::List::Iterator it; |
1256 | KABC::AddressBook::Iterator iter; | 1253 | KABC::AddressBook::Iterator iter; |
1257 | for ( it = list.begin(); it != list.end(); ++it ) { | 1254 | for ( it = list.begin(); it != list.end(); ++it ) { |
1258 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1255 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1259 | listNew.append( (*it) ); | 1256 | listNew.append( (*it) ); |
1260 | else | 1257 | else |
1261 | listExisting.append( (*it) ); | 1258 | listExisting.append( (*it) ); |
1262 | } | 1259 | } |
1263 | if ( listExisting.count() > 0 ) | 1260 | if ( listExisting.count() > 0 ) |
1264 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1261 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1265 | if ( listNew.count() > 0 ) { | 1262 | if ( listNew.count() > 0 ) { |
1266 | pasteWithNewUid = false; | 1263 | pasteWithNewUid = false; |
1267 | pasteContacts( listNew ); | 1264 | pasteContacts( listNew ); |
1268 | pasteWithNewUid = true; | 1265 | pasteWithNewUid = true; |
1269 | } | 1266 | } |
1270 | } | 1267 | } |
1271 | delete idgl; | 1268 | delete idgl; |
1272 | #endif | 1269 | #endif |
1273 | } | 1270 | } |
1274 | 1271 | ||
1275 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1272 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1276 | { | 1273 | { |
1277 | mXXPortManager->importVCard( vCard, showPreview ); | 1274 | mXXPortManager->importVCard( vCard, showPreview ); |
1278 | } | 1275 | } |
1279 | 1276 | ||
1280 | //US added a second method without defaultparameter | 1277 | //US added a second method without defaultparameter |
1281 | void KABCore::editContact2() { | 1278 | void KABCore::editContact2() { |
1282 | editContact( QString::null ); | 1279 | editContact( QString::null ); |
1283 | } | 1280 | } |
1284 | 1281 | ||
1285 | void KABCore::editContact( const QString &uid ) | 1282 | void KABCore::editContact( const QString &uid ) |
1286 | { | 1283 | { |
1287 | 1284 | ||
1288 | if ( mExtensionManager->isQuickEditVisible() ) | 1285 | if ( mExtensionManager->isQuickEditVisible() ) |
1289 | return; | 1286 | return; |
1290 | 1287 | ||
1291 | // First, locate the contact entry | 1288 | // First, locate the contact entry |
1292 | QString localUID = uid; | 1289 | QString localUID = uid; |
1293 | if ( localUID.isNull() ) { | 1290 | if ( localUID.isNull() ) { |
1294 | QStringList uidList = mViewManager->selectedUids(); | 1291 | QStringList uidList = mViewManager->selectedUids(); |
1295 | if ( uidList.count() > 0 ) | 1292 | if ( uidList.count() > 0 ) |
1296 | localUID = *( uidList.at( 0 ) ); | 1293 | localUID = *( uidList.at( 0 ) ); |
1297 | } | 1294 | } |
1298 | 1295 | ||
1299 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1296 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1300 | if ( !addr.isEmpty() ) { | 1297 | if ( !addr.isEmpty() ) { |
1301 | mEditorDialog->setAddressee( addr ); | 1298 | mEditorDialog->setAddressee( addr ); |
1302 | KApplication::execDialog ( mEditorDialog ); | 1299 | KApplication::execDialog ( mEditorDialog ); |
1303 | } | 1300 | } |
1304 | } | 1301 | } |
1305 | 1302 | ||
1306 | /** | 1303 | /** |
1307 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1304 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1308 | the method will try to find a selected addressee in the view. | 1305 | the method will try to find a selected addressee in the view. |
1309 | */ | 1306 | */ |
1310 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1307 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1311 | { | 1308 | { |
1312 | if ( mMultipleViewsAtOnce ) | 1309 | if ( mMultipleViewsAtOnce ) |
1313 | { | 1310 | { |
1314 | editContact( uid ); | 1311 | editContact( uid ); |
1315 | } | 1312 | } |
1316 | else | 1313 | else |
1317 | { | 1314 | { |
1318 | setDetailsVisible( true ); | 1315 | setDetailsVisible( true ); |
1319 | mActionDetails->setChecked(true); | 1316 | mActionDetails->setChecked(true); |
1320 | } | 1317 | } |
1321 | 1318 | ||
1322 | } | 1319 | } |
1323 | 1320 | ||
1324 | void KABCore::save() | 1321 | void KABCore::save() |
1325 | { | 1322 | { |
1326 | if (syncManager->blockSave()) | 1323 | if (syncManager->blockSave()) |
1327 | return; | 1324 | return; |
1328 | if ( !mModified ) | 1325 | if ( !mModified ) |
1329 | return; | 1326 | return; |
1330 | 1327 | ||
1331 | syncManager->setBlockSave(true); | 1328 | syncManager->setBlockSave(true); |
1332 | QString text = i18n( "There was an error while attempting to save\n the " | 1329 | QString text = i18n( "There was an error while attempting to save\n the " |
1333 | "address book. Please check that some \nother application is " | 1330 | "address book. Please check that some \nother application is " |
1334 | "not using it. " ); | 1331 | "not using it. " ); |
1335 | message(i18n("Saving addressbook ... ")); | 1332 | message(i18n("Saving addressbook ... ")); |
1336 | #ifndef KAB_EMBEDDED | 1333 | #ifndef KAB_EMBEDDED |
1337 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1334 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1338 | if ( !b || !b->save() ) { | 1335 | if ( !b || !b->save() ) { |
1339 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1336 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1340 | } | 1337 | } |
1341 | #else //KAB_EMBEDDED | 1338 | #else //KAB_EMBEDDED |
1342 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1339 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1343 | if ( !b || !b->save() ) { | 1340 | if ( !b || !b->save() ) { |
1344 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1341 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1345 | } | 1342 | } |
1346 | #endif //KAB_EMBEDDED | 1343 | #endif //KAB_EMBEDDED |
1347 | 1344 | ||
1348 | message(i18n("Addressbook saved!")); | 1345 | message(i18n("Addressbook saved!")); |
1349 | setModified( false ); | 1346 | setModified( false ); |
1350 | syncManager->setBlockSave(false); | 1347 | syncManager->setBlockSave(false); |
1351 | } | 1348 | } |
1352 | 1349 | ||
1353 | 1350 | ||
1354 | void KABCore::undo() | 1351 | void KABCore::undo() |
1355 | { | 1352 | { |
1356 | UndoStack::instance()->undo(); | 1353 | UndoStack::instance()->undo(); |
1357 | 1354 | ||
1358 | // Refresh the view | 1355 | // Refresh the view |
1359 | mViewManager->refreshView(); | 1356 | mViewManager->refreshView(); |
1360 | } | 1357 | } |
1361 | 1358 | ||
1362 | void KABCore::redo() | 1359 | void KABCore::redo() |
1363 | { | 1360 | { |
1364 | RedoStack::instance()->redo(); | 1361 | RedoStack::instance()->redo(); |
1365 | 1362 | ||
1366 | // Refresh the view | 1363 | // Refresh the view |
1367 | mViewManager->refreshView(); | 1364 | mViewManager->refreshView(); |
1368 | } | 1365 | } |
1369 | 1366 | ||
1370 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1367 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1371 | { | 1368 | { |
1372 | if (mMultipleViewsAtOnce) | 1369 | if (mMultipleViewsAtOnce) |
1373 | { | 1370 | { |
1374 | if ( visible ) | 1371 | if ( visible ) |
1375 | mJumpButtonBar->show(); | 1372 | mJumpButtonBar->show(); |
1376 | else | 1373 | else |
1377 | mJumpButtonBar->hide(); | 1374 | mJumpButtonBar->hide(); |
1378 | } | 1375 | } |
1379 | else | 1376 | else |
1380 | { | 1377 | { |
1381 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1378 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1382 | if (mViewManager->isVisible()) | 1379 | if (mViewManager->isVisible()) |
1383 | { | 1380 | { |
1384 | if ( visible ) | 1381 | if ( visible ) |
1385 | mJumpButtonBar->show(); | 1382 | mJumpButtonBar->show(); |
1386 | else | 1383 | else |
1387 | mJumpButtonBar->hide(); | 1384 | mJumpButtonBar->hide(); |
1388 | } | 1385 | } |
1389 | else | 1386 | else |
1390 | { | 1387 | { |
1391 | mJumpButtonBar->hide(); | 1388 | mJumpButtonBar->hide(); |
1392 | } | 1389 | } |
1393 | } | 1390 | } |
1394 | } | 1391 | } |
1395 | 1392 | ||
1396 | 1393 | ||
1397 | void KABCore::setDetailsToState() | 1394 | void KABCore::setDetailsToState() |
1398 | { | 1395 | { |
1399 | setDetailsVisible( mActionDetails->isChecked() ); | 1396 | setDetailsVisible( mActionDetails->isChecked() ); |
1400 | } | 1397 | } |
1401 | void KABCore::setDetailsToggle() | 1398 | void KABCore::setDetailsToggle() |
1402 | { | 1399 | { |
1403 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1400 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1404 | setDetailsToState(); | 1401 | setDetailsToState(); |
1405 | } | 1402 | } |
1406 | 1403 | ||
1407 | 1404 | ||
1408 | 1405 | ||
1409 | void KABCore::setDetailsVisible( bool visible ) | 1406 | void KABCore::setDetailsVisible( bool visible ) |
1410 | { | 1407 | { |
1411 | if (visible && mDetails->isHidden()) | 1408 | if (visible && mDetails->isHidden()) |
1412 | { | 1409 | { |
1413 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1410 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1414 | if ( addrList.count() > 0 ) | 1411 | if ( addrList.count() > 0 ) |
1415 | mDetails->setAddressee( addrList[ 0 ] ); | 1412 | mDetails->setAddressee( addrList[ 0 ] ); |
1416 | } | 1413 | } |
1417 | 1414 | ||
1418 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1415 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1419 | // the listview and the detailview. We do that by changing the splitbar size. | 1416 | // the listview and the detailview. We do that by changing the splitbar size. |
1420 | if (mMultipleViewsAtOnce) | 1417 | if (mMultipleViewsAtOnce) |
1421 | { | 1418 | { |
1422 | if ( visible ) | 1419 | if ( visible ) |
1423 | mDetails->show(); | 1420 | mDetails->show(); |
1424 | else | 1421 | else |
1425 | mDetails->hide(); | 1422 | mDetails->hide(); |
1426 | } | 1423 | } |
1427 | else | 1424 | else |
1428 | { | 1425 | { |
1429 | if ( visible ) { | 1426 | if ( visible ) { |
1430 | mViewManager->hide(); | 1427 | mViewManager->hide(); |
1431 | mDetails->show(); | 1428 | mDetails->show(); |
1432 | mIncSearchWidget->setFocus(); | 1429 | mIncSearchWidget->setFocus(); |
1433 | } | 1430 | } |
1434 | else { | 1431 | else { |
1435 | mViewManager->show(); | 1432 | mViewManager->show(); |
1436 | mDetails->hide(); | 1433 | mDetails->hide(); |
1437 | mViewManager->setFocusAV(); | 1434 | mViewManager->setFocusAV(); |
1438 | } | 1435 | } |
1439 | setJumpButtonBarVisible( !visible ); | 1436 | setJumpButtonBarVisible( !visible ); |
1440 | } | 1437 | } |
1441 | 1438 | ||
1442 | } | 1439 | } |
1443 | 1440 | ||
1444 | void KABCore::extensionChanged( int id ) | 1441 | void KABCore::extensionChanged( int id ) |
1445 | { | 1442 | { |
1446 | //change the details view only for non desktop systems | 1443 | //change the details view only for non desktop systems |
1447 | #ifndef DESKTOP_VERSION | 1444 | #ifndef DESKTOP_VERSION |
1448 | 1445 | ||
1449 | if (id == 0) | 1446 | if (id == 0) |
1450 | { | 1447 | { |
1451 | //the user disabled the extension. | 1448 | //the user disabled the extension. |
1452 | 1449 | ||
1453 | if (mMultipleViewsAtOnce) | 1450 | if (mMultipleViewsAtOnce) |
1454 | { // enable detailsview again | 1451 | { // enable detailsview again |
1455 | setDetailsVisible( true ); | 1452 | setDetailsVisible( true ); |
1456 | mActionDetails->setChecked( true ); | 1453 | mActionDetails->setChecked( true ); |
1457 | } | 1454 | } |
1458 | else | 1455 | else |
1459 | { //go back to the listview | 1456 | { //go back to the listview |
1460 | setDetailsVisible( false ); | 1457 | setDetailsVisible( false ); |
1461 | mActionDetails->setChecked( false ); | 1458 | mActionDetails->setChecked( false ); |
1462 | mActionDetails->setEnabled(true); | 1459 | mActionDetails->setEnabled(true); |
1463 | } | 1460 | } |
1464 | 1461 | ||
1465 | } | 1462 | } |
1466 | else | 1463 | else |
1467 | { | 1464 | { |
1468 | //the user enabled the extension. | 1465 | //the user enabled the extension. |
1469 | setDetailsVisible( false ); | 1466 | setDetailsVisible( false ); |
1470 | mActionDetails->setChecked( false ); | 1467 | mActionDetails->setChecked( false ); |
1471 | 1468 | ||
1472 | if (!mMultipleViewsAtOnce) | 1469 | if (!mMultipleViewsAtOnce) |
1473 | { | 1470 | { |
1474 | mActionDetails->setEnabled(false); | 1471 | mActionDetails->setEnabled(false); |
1475 | } | 1472 | } |
1476 | 1473 | ||
1477 | mExtensionManager->setSelectionChanged(); | 1474 | mExtensionManager->setSelectionChanged(); |
1478 | 1475 | ||
1479 | } | 1476 | } |
1480 | 1477 | ||
1481 | #endif// DESKTOP_VERSION | 1478 | #endif// DESKTOP_VERSION |
1482 | 1479 | ||
1483 | } | 1480 | } |
1484 | 1481 | ||
1485 | 1482 | ||
1486 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1483 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1487 | { | 1484 | { |
1488 | 1485 | ||
1489 | if ( list.count() != 0 ) { | 1486 | if ( list.count() != 0 ) { |
1490 | KABC::Addressee::List::ConstIterator it; | 1487 | KABC::Addressee::List::ConstIterator it; |
1491 | for ( it = list.begin(); it != list.end(); ++it ) | 1488 | for ( it = list.begin(); it != list.end(); ++it ) |
1492 | mAddressBook->insertAddressee( *it ); | 1489 | mAddressBook->insertAddressee( *it ); |
1493 | if ( list.count() > 1 ) | 1490 | if ( list.count() > 1 ) |
1494 | setModified(); | 1491 | setModified(); |
1495 | else | 1492 | else |
1496 | setModifiedWOrefresh(); | 1493 | setModifiedWOrefresh(); |
1497 | } | 1494 | } |
1498 | if ( list.count() == 0 ) | 1495 | if ( list.count() == 0 ) |
1499 | mViewManager->refreshView(); | 1496 | mViewManager->refreshView(); |
1500 | else | 1497 | else |
1501 | mViewManager->refreshView( list[ 0 ].uid() ); | 1498 | mViewManager->refreshView( list[ 0 ].uid() ); |
1502 | 1499 | ||
1503 | 1500 | ||
1504 | 1501 | ||
1505 | } | 1502 | } |
1506 | 1503 | ||
1507 | QString KABCore::getNameByPhone( const QString &phone ) | 1504 | QString KABCore::getNameByPhone( const QString &phone ) |
1508 | { | 1505 | { |
1509 | #ifndef KAB_EMBEDDED | 1506 | #ifndef KAB_EMBEDDED |
1510 | QRegExp r( "[/*/-/ ]" ); | 1507 | QRegExp r( "[/*/-/ ]" ); |
1511 | QString localPhone( phone ); | 1508 | QString localPhone( phone ); |
1512 | 1509 | ||
1513 | bool found = false; | 1510 | bool found = false; |
1514 | QString ownerName = ""; | 1511 | QString ownerName = ""; |
1515 | KABC::AddressBook::Iterator iter; | 1512 | KABC::AddressBook::Iterator iter; |
1516 | KABC::PhoneNumber::List::Iterator phoneIter; | 1513 | KABC::PhoneNumber::List::Iterator phoneIter; |
1517 | KABC::PhoneNumber::List phoneList; | 1514 | KABC::PhoneNumber::List phoneList; |
1518 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1515 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1519 | phoneList = (*iter).phoneNumbers(); | 1516 | phoneList = (*iter).phoneNumbers(); |
1520 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1517 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1521 | ++phoneIter) { | 1518 | ++phoneIter) { |
1522 | // Get rid of separator chars so just the numbers are compared. | 1519 | // Get rid of separator chars so just the numbers are compared. |
1523 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1520 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1524 | ownerName = (*iter).formattedName(); | 1521 | ownerName = (*iter).formattedName(); |
1525 | found = true; | 1522 | found = true; |
1526 | } | 1523 | } |
1527 | } | 1524 | } |
1528 | } | 1525 | } |
1529 | 1526 | ||
1530 | return ownerName; | 1527 | return ownerName; |
1531 | #else //KAB_EMBEDDED | 1528 | #else //KAB_EMBEDDED |
1532 | qDebug("KABCore::getNameByPhone finsih method"); | 1529 | qDebug("KABCore::getNameByPhone finsih method"); |
1533 | return ""; | 1530 | return ""; |
1534 | #endif //KAB_EMBEDDED | 1531 | #endif //KAB_EMBEDDED |
1535 | 1532 | ||
1536 | } | 1533 | } |
1537 | 1534 | ||
1538 | void KABCore::openConfigDialog() | 1535 | void KABCore::openConfigDialog() |
1539 | { | 1536 | { |
1540 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1537 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1541 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1538 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1542 | ConfigureDialog->addModule(kabcfg ); | 1539 | ConfigureDialog->addModule(kabcfg ); |
1543 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1540 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1544 | ConfigureDialog->addModule(kdelibcfg ); | 1541 | ConfigureDialog->addModule(kdelibcfg ); |
1545 | 1542 | ||
1546 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1543 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1547 | this, SLOT( configurationChanged() ) ); | 1544 | this, SLOT( configurationChanged() ) ); |
1548 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1545 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1549 | this, SLOT( configurationChanged() ) ); | 1546 | this, SLOT( configurationChanged() ) ); |
1550 | saveSettings(); | 1547 | saveSettings(); |
1551 | #ifndef DESKTOP_VERSION | 1548 | #ifndef DESKTOP_VERSION |
1552 | ConfigureDialog->showMaximized(); | 1549 | ConfigureDialog->showMaximized(); |
1553 | #endif | 1550 | #endif |
1554 | if ( ConfigureDialog->exec() ) | 1551 | if ( ConfigureDialog->exec() ) |
1555 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1552 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1556 | delete ConfigureDialog; | 1553 | delete ConfigureDialog; |
1557 | } | 1554 | } |
1558 | 1555 | ||
1559 | void KABCore::openLDAPDialog() | 1556 | void KABCore::openLDAPDialog() |
1560 | { | 1557 | { |
1561 | #ifndef KAB_EMBEDDED | 1558 | #ifndef KAB_EMBEDDED |
1562 | if ( !mLdapSearchDialog ) { | 1559 | if ( !mLdapSearchDialog ) { |
1563 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1560 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1564 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1561 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1565 | SLOT( refreshView() ) ); | 1562 | SLOT( refreshView() ) ); |
1566 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1563 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1567 | SLOT( setModified() ) ); | 1564 | SLOT( setModified() ) ); |
1568 | } else | 1565 | } else |
1569 | mLdapSearchDialog->restoreSettings(); | 1566 | mLdapSearchDialog->restoreSettings(); |
1570 | 1567 | ||
1571 | if ( mLdapSearchDialog->isOK() ) | 1568 | if ( mLdapSearchDialog->isOK() ) |
1572 | mLdapSearchDialog->exec(); | 1569 | mLdapSearchDialog->exec(); |
1573 | #else //KAB_EMBEDDED | 1570 | #else //KAB_EMBEDDED |
1574 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1571 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1575 | #endif //KAB_EMBEDDED | 1572 | #endif //KAB_EMBEDDED |
1576 | } | 1573 | } |
1577 | 1574 | ||
1578 | void KABCore::print() | 1575 | void KABCore::print() |
1579 | { | 1576 | { |
1580 | #ifndef KAB_EMBEDDED | 1577 | #ifndef KAB_EMBEDDED |
1581 | KPrinter printer; | 1578 | KPrinter printer; |
1582 | if ( !printer.setup( this ) ) | 1579 | if ( !printer.setup( this ) ) |
1583 | return; | 1580 | return; |
1584 | 1581 | ||
1585 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1582 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1586 | mViewManager->selectedUids(), this ); | 1583 | mViewManager->selectedUids(), this ); |
1587 | 1584 | ||
1588 | wizard.exec(); | 1585 | wizard.exec(); |
1589 | #else //KAB_EMBEDDED | 1586 | #else //KAB_EMBEDDED |
1590 | qDebug("KABCore::print() finsih method"); | 1587 | qDebug("KABCore::print() finsih method"); |
1591 | #endif //KAB_EMBEDDED | 1588 | #endif //KAB_EMBEDDED |
1592 | 1589 | ||
1593 | } | 1590 | } |
1594 | 1591 | ||
1595 | 1592 | ||
1596 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1593 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1597 | { | 1594 | { |
1598 | if ( mGUIClient ) | 1595 | if ( mGUIClient ) |
1599 | mGUIClient->insertChildClient( client ); | 1596 | mGUIClient->insertChildClient( client ); |
1600 | else | 1597 | else |
1601 | KMessageBox::error( this, "no KXMLGUICLient"); | 1598 | KMessageBox::error( this, "no KXMLGUICLient"); |
1602 | } | 1599 | } |
1603 | 1600 | ||
1604 | 1601 | ||
1605 | void KABCore::configurationChanged() | 1602 | void KABCore::configurationChanged() |
1606 | { | 1603 | { |
1607 | mExtensionManager->reconfigure(); | 1604 | mExtensionManager->reconfigure(); |
1608 | } | 1605 | } |
1609 | 1606 | ||
1610 | void KABCore::addressBookChanged() | 1607 | void KABCore::addressBookChanged() |
1611 | { | 1608 | { |
1612 | /*US | 1609 | /*US |
1613 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1610 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1614 | while ( it.current() ) { | 1611 | while ( it.current() ) { |
1615 | if ( it.current()->dirty() ) { | 1612 | if ( it.current()->dirty() ) { |
1616 | QString text = i18n( "Data has been changed externally. Unsaved " | 1613 | QString text = i18n( "Data has been changed externally. Unsaved " |
1617 | "changes will be lost." ); | 1614 | "changes will be lost." ); |
1618 | KMessageBox::information( this, text ); | 1615 | KMessageBox::information( this, text ); |
1619 | } | 1616 | } |
1620 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1617 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1621 | ++it; | 1618 | ++it; |
1622 | } | 1619 | } |
1623 | */ | 1620 | */ |
1624 | if (mEditorDialog) | 1621 | if (mEditorDialog) |
1625 | { | 1622 | { |
1626 | if (mEditorDialog->dirty()) | 1623 | if (mEditorDialog->dirty()) |
1627 | { | 1624 | { |
1628 | QString text = i18n( "Data has been changed externally. Unsaved " | 1625 | QString text = i18n( "Data has been changed externally. Unsaved " |
1629 | "changes will be lost." ); | 1626 | "changes will be lost." ); |
1630 | KMessageBox::information( this, text ); | 1627 | KMessageBox::information( this, text ); |
1631 | } | 1628 | } |
1632 | QString currentuid = mEditorDialog->addressee().uid(); | 1629 | QString currentuid = mEditorDialog->addressee().uid(); |
1633 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1630 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1634 | } | 1631 | } |
1635 | mViewManager->refreshView(); | 1632 | mViewManager->refreshView(); |
1636 | // mDetails->refreshView(); | ||
1637 | 1633 | ||
1638 | 1634 | ||
1639 | } | 1635 | } |
1640 | 1636 | ||
1641 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1637 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1642 | const char *name ) | 1638 | const char *name ) |
1643 | { | 1639 | { |
1644 | 1640 | ||
1645 | if ( mEditorDialog == 0 ) { | 1641 | if ( mEditorDialog == 0 ) { |
1646 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1642 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1647 | name ? name : "editorDialog" ); | 1643 | name ? name : "editorDialog" ); |
1648 | 1644 | ||
1649 | 1645 | ||
1650 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1646 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1651 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1647 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1652 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1648 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1653 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1649 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1654 | } | 1650 | } |
1655 | 1651 | ||
1656 | return mEditorDialog; | 1652 | return mEditorDialog; |
1657 | } | 1653 | } |
1658 | 1654 | ||
1659 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1655 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1660 | { | 1656 | { |
1661 | //mEditorDict.remove( uid ); | 1657 | //mEditorDict.remove( uid ); |
1662 | } | 1658 | } |
1663 | 1659 | ||
1664 | void KABCore::initGUI() | 1660 | void KABCore::initGUI() |
1665 | { | 1661 | { |
1666 | #ifndef KAB_EMBEDDED | 1662 | #ifndef KAB_EMBEDDED |
1667 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1663 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1668 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1664 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1669 | 1665 | ||
1670 | mExtensionBarSplitter = new QSplitter( this ); | 1666 | mExtensionBarSplitter = new QSplitter( this ); |
1671 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1667 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1672 | 1668 | ||
1673 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1669 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1674 | 1670 | ||
1675 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1671 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1676 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1672 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1677 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1673 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1678 | SLOT( incrementalSearch( const QString& ) ) ); | 1674 | SLOT( incrementalSearch( const QString& ) ) ); |
1679 | 1675 | ||
1680 | mViewManager = new ViewManager( this, viewSpace ); | 1676 | mViewManager = new ViewManager( this, viewSpace ); |
1681 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1677 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1682 | 1678 | ||
1683 | mDetails = new ViewContainer( mDetailsSplitter ); | 1679 | mDetails = new ViewContainer( mDetailsSplitter ); |
1684 | 1680 | ||
1685 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1681 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1686 | 1682 | ||
1687 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1683 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1688 | 1684 | ||
1689 | topLayout->addWidget( mExtensionBarSplitter ); | 1685 | topLayout->addWidget( mExtensionBarSplitter ); |
1690 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1686 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1691 | topLayout->addWidget( mJumpButtonBar ); | 1687 | topLayout->addWidget( mJumpButtonBar ); |
1692 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1688 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1693 | 1689 | ||
1694 | mXXPortManager = new XXPortManager( this, this ); | 1690 | mXXPortManager = new XXPortManager( this, this ); |
1695 | 1691 | ||
1696 | #else //KAB_EMBEDDED | 1692 | #else //KAB_EMBEDDED |
1697 | //US initialize viewMenu before settingup viewmanager. | 1693 | //US initialize viewMenu before settingup viewmanager. |
1698 | // Viewmanager needs this menu to plugin submenues. | 1694 | // Viewmanager needs this menu to plugin submenues. |
1699 | viewMenu = new QPopupMenu( this ); | 1695 | viewMenu = new QPopupMenu( this ); |
1700 | settingsMenu = new QPopupMenu( this ); | 1696 | settingsMenu = new QPopupMenu( this ); |
1701 | //filterMenu = new QPopupMenu( this ); | 1697 | //filterMenu = new QPopupMenu( this ); |
1702 | ImportMenu = new QPopupMenu( this ); | 1698 | ImportMenu = new QPopupMenu( this ); |
1703 | ExportMenu = new QPopupMenu( this ); | 1699 | ExportMenu = new QPopupMenu( this ); |
1704 | syncMenu = new QPopupMenu( this ); | 1700 | syncMenu = new QPopupMenu( this ); |
1705 | changeMenu= new QPopupMenu( this ); | 1701 | changeMenu= new QPopupMenu( this ); |
1706 | beamMenu= new QPopupMenu( this ); | 1702 | beamMenu= new QPopupMenu( this ); |
1707 | 1703 | ||
1708 | //US since we have no splitter for the embedded system, setup | 1704 | //US since we have no splitter for the embedded system, setup |
1709 | // a layout with two frames. One left and one right. | 1705 | // a layout with two frames. One left and one right. |
1710 | 1706 | ||
1711 | QBoxLayout *topLayout; | 1707 | QBoxLayout *topLayout; |
1712 | 1708 | ||
1713 | // = new QHBoxLayout( this ); | 1709 | // = new QHBoxLayout( this ); |
1714 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1710 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1715 | 1711 | ||
1716 | // QWidget *mainBox = new QWidget( this ); | 1712 | // QWidget *mainBox = new QWidget( this ); |
1717 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1713 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1718 | 1714 | ||
1719 | #ifdef DESKTOP_VERSION | 1715 | #ifdef DESKTOP_VERSION |
1720 | topLayout = new QHBoxLayout( this ); | 1716 | topLayout = new QHBoxLayout( this ); |
1721 | 1717 | ||
1722 | 1718 | ||
1723 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1719 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1724 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1720 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1725 | 1721 | ||
1726 | topLayout->addWidget(mMiniSplitter ); | 1722 | topLayout->addWidget(mMiniSplitter ); |
1727 | 1723 | ||
1728 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1724 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1729 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1725 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1730 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1726 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1731 | mDetails = new ViewContainer( mMiniSplitter ); | 1727 | mDetails = new ViewContainer( mMiniSplitter ); |
1732 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1728 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1733 | #else | 1729 | #else |
1734 | if ( QApplication::desktop()->width() > 480 ) { | 1730 | if ( QApplication::desktop()->width() > 480 ) { |
1735 | topLayout = new QHBoxLayout( this ); | 1731 | topLayout = new QHBoxLayout( this ); |
1736 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1732 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1737 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1733 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1738 | } else { | 1734 | } else { |
1739 | 1735 | ||
1740 | topLayout = new QHBoxLayout( this ); | 1736 | topLayout = new QHBoxLayout( this ); |
1741 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1737 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1742 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1738 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1743 | } | 1739 | } |
1744 | 1740 | ||
1745 | topLayout->addWidget(mMiniSplitter ); | 1741 | topLayout->addWidget(mMiniSplitter ); |
1746 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1742 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1747 | mDetails = new ViewContainer( mMiniSplitter ); | 1743 | mDetails = new ViewContainer( mMiniSplitter ); |
1748 | 1744 | ||
1749 | 1745 | ||
1750 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1746 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1751 | #endif | 1747 | #endif |
1752 | //eh->hide(); | 1748 | //eh->hide(); |
1753 | // topLayout->addWidget(mExtensionManager ); | 1749 | // topLayout->addWidget(mExtensionManager ); |
1754 | 1750 | ||
1755 | 1751 | ||
1756 | /*US | 1752 | /*US |
1757 | #ifndef KAB_NOSPLITTER | 1753 | #ifndef KAB_NOSPLITTER |
1758 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1754 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1759 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1755 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1760 | topLayout->setSpacing( 10 ); | 1756 | topLayout->setSpacing( 10 ); |
1761 | 1757 | ||
1762 | mDetailsSplitter = new QSplitter( this ); | 1758 | mDetailsSplitter = new QSplitter( this ); |
1763 | 1759 | ||
1764 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1760 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1765 | 1761 | ||
1766 | mViewManager = new ViewManager( this, viewSpace ); | 1762 | mViewManager = new ViewManager( this, viewSpace ); |
1767 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1763 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1768 | 1764 | ||
1769 | mDetails = new ViewContainer( mDetailsSplitter ); | 1765 | mDetails = new ViewContainer( mDetailsSplitter ); |
1770 | 1766 | ||
1771 | topLayout->addWidget( mDetailsSplitter ); | 1767 | topLayout->addWidget( mDetailsSplitter ); |
1772 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1768 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1773 | #else //KAB_NOSPLITTER | 1769 | #else //KAB_NOSPLITTER |
1774 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1770 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1775 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1771 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1776 | topLayout->setSpacing( 10 ); | 1772 | topLayout->setSpacing( 10 ); |
1777 | 1773 | ||
1778 | // mDetailsSplitter = new QSplitter( this ); | 1774 | // mDetailsSplitter = new QSplitter( this ); |
1779 | 1775 | ||
1780 | QVBox *viewSpace = new QVBox( this ); | 1776 | QVBox *viewSpace = new QVBox( this ); |
1781 | 1777 | ||
1782 | mViewManager = new ViewManager( this, viewSpace ); | 1778 | mViewManager = new ViewManager( this, viewSpace ); |
1783 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1779 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1784 | 1780 | ||
1785 | mDetails = new ViewContainer( this ); | 1781 | mDetails = new ViewContainer( this ); |
1786 | 1782 | ||
1787 | topLayout->addWidget( viewSpace ); | 1783 | topLayout->addWidget( viewSpace ); |
1788 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1784 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1789 | topLayout->addWidget( mDetails ); | 1785 | topLayout->addWidget( mDetails ); |
1790 | #endif //KAB_NOSPLITTER | 1786 | #endif //KAB_NOSPLITTER |
1791 | */ | 1787 | */ |
1792 | 1788 | ||
1793 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1789 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1794 | syncManager->setBlockSave(false); | 1790 | syncManager->setBlockSave(false); |
1795 | 1791 | ||
1796 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1792 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1797 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1793 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1798 | QString sync_file = sentSyncFile(); | 1794 | QString sync_file = sentSyncFile(); |
1799 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1795 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1800 | syncManager->setDefaultFileName( sync_file ); | 1796 | syncManager->setDefaultFileName( sync_file ); |
1801 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1797 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1802 | 1798 | ||
1803 | #endif //KAB_EMBEDDED | 1799 | #endif //KAB_EMBEDDED |
1804 | initActions(); | 1800 | initActions(); |
1805 | 1801 | ||
1806 | #ifdef KAB_EMBEDDED | 1802 | #ifdef KAB_EMBEDDED |
1807 | addActionsManually(); | 1803 | addActionsManually(); |
1808 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1804 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1809 | mXXPortManager = new XXPortManager( this, this ); | 1805 | mXXPortManager = new XXPortManager( this, this ); |
1810 | 1806 | ||
1811 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1807 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1812 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1808 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1813 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1809 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1814 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1810 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1815 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1811 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1816 | // mIncSearchWidget->hide(); | 1812 | // mIncSearchWidget->hide(); |
1817 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1813 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1818 | SLOT( incrementalSearch( const QString& ) ) ); | 1814 | SLOT( incrementalSearch( const QString& ) ) ); |
1819 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1815 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1820 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1816 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1821 | 1817 | ||
1822 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1818 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1823 | 1819 | ||
1824 | topLayout->addWidget( mJumpButtonBar ); | 1820 | topLayout->addWidget( mJumpButtonBar ); |
1825 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1821 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1826 | 1822 | ||
1827 | // mMainWindow->getIconToolBar()->raise(); | 1823 | // mMainWindow->getIconToolBar()->raise(); |
1828 | 1824 | ||
1829 | #endif //KAB_EMBEDDED | 1825 | #endif //KAB_EMBEDDED |
1830 | 1826 | ||
1831 | } | 1827 | } |
1832 | void KABCore::initActions() | 1828 | void KABCore::initActions() |
1833 | { | 1829 | { |
1834 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1830 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1835 | 1831 | ||
1836 | #ifndef KAB_EMBEDDED | 1832 | #ifndef KAB_EMBEDDED |
1837 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1833 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1838 | SLOT( clipboardDataChanged() ) ); | 1834 | SLOT( clipboardDataChanged() ) ); |
1839 | #endif //KAB_EMBEDDED | 1835 | #endif //KAB_EMBEDDED |
1840 | 1836 | ||
1841 | // file menu | 1837 | // file menu |
1842 | if ( mIsPart ) { | 1838 | if ( mIsPart ) { |
1843 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1839 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1844 | SLOT( sendMail() ), actionCollection(), | 1840 | SLOT( sendMail() ), actionCollection(), |
1845 | "kaddressbook_mail" ); | 1841 | "kaddressbook_mail" ); |
1846 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1842 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1847 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1843 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1848 | 1844 | ||
1849 | } else { | 1845 | } else { |
1850 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1846 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1851 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1847 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1852 | } | 1848 | } |
1853 | 1849 | ||
1854 | 1850 | ||
1855 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1851 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1856 | SLOT( save() ), actionCollection(), "file_sync" ); | 1852 | SLOT( save() ), actionCollection(), "file_sync" ); |
1857 | 1853 | ||
1858 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1854 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1859 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1855 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1860 | 1856 | ||
1861 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1857 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1862 | this, SLOT( mailVCard() ), | 1858 | this, SLOT( mailVCard() ), |
1863 | actionCollection(), "file_mail_vcard"); | 1859 | actionCollection(), "file_mail_vcard"); |
1864 | 1860 | ||
1865 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1861 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1866 | SLOT( export2phone() ), actionCollection(), | 1862 | SLOT( export2phone() ), actionCollection(), |
1867 | "kaddressbook_ex2phone" ); | 1863 | "kaddressbook_ex2phone" ); |
1868 | 1864 | ||
1869 | mActionBeamVCard = 0; | 1865 | mActionBeamVCard = 0; |
1870 | mActionBeam = 0; | 1866 | mActionBeam = 0; |
1871 | 1867 | ||
1872 | #ifndef DESKTOP_VERSION | 1868 | #ifndef DESKTOP_VERSION |
1873 | if ( Ir::supported() ) { | 1869 | if ( Ir::supported() ) { |
1874 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1870 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1875 | SLOT( beamVCard() ), actionCollection(), | 1871 | SLOT( beamVCard() ), actionCollection(), |
1876 | "kaddressbook_beam_vcard" ); | 1872 | "kaddressbook_beam_vcard" ); |
1877 | 1873 | ||
1878 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1874 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1879 | SLOT( beamMySelf() ), actionCollection(), | 1875 | SLOT( beamMySelf() ), actionCollection(), |
1880 | "kaddressbook_beam_myself" ); | 1876 | "kaddressbook_beam_myself" ); |
1881 | } | 1877 | } |
1882 | #endif | 1878 | #endif |
1883 | 1879 | ||
1884 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1880 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1885 | this, SLOT( editContact2() ), | 1881 | this, SLOT( editContact2() ), |
1886 | actionCollection(), "file_properties" ); | 1882 | actionCollection(), "file_properties" ); |
1887 | 1883 | ||
1888 | #ifdef KAB_EMBEDDED | 1884 | #ifdef KAB_EMBEDDED |
1889 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1885 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1890 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1886 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1891 | mMainWindow, SLOT( exit() ), | 1887 | mMainWindow, SLOT( exit() ), |
1892 | actionCollection(), "quit" ); | 1888 | actionCollection(), "quit" ); |
1893 | #endif //KAB_EMBEDDED | 1889 | #endif //KAB_EMBEDDED |
1894 | 1890 | ||
1895 | // edit menu | 1891 | // edit menu |
1896 | if ( mIsPart ) { | 1892 | if ( mIsPart ) { |
1897 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1893 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1898 | SLOT( copyContacts() ), actionCollection(), | 1894 | SLOT( copyContacts() ), actionCollection(), |
1899 | "kaddressbook_copy" ); | 1895 | "kaddressbook_copy" ); |
1900 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1896 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1901 | SLOT( cutContacts() ), actionCollection(), | 1897 | SLOT( cutContacts() ), actionCollection(), |
1902 | "kaddressbook_cut" ); | 1898 | "kaddressbook_cut" ); |
1903 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1899 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1904 | SLOT( pasteContacts() ), actionCollection(), | 1900 | SLOT( pasteContacts() ), actionCollection(), |
1905 | "kaddressbook_paste" ); | 1901 | "kaddressbook_paste" ); |
1906 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1902 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1907 | SLOT( selectAllContacts() ), actionCollection(), | 1903 | SLOT( selectAllContacts() ), actionCollection(), |
1908 | "kaddressbook_select_all" ); | 1904 | "kaddressbook_select_all" ); |
1909 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1905 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1910 | SLOT( undo() ), actionCollection(), | 1906 | SLOT( undo() ), actionCollection(), |
1911 | "kaddressbook_undo" ); | 1907 | "kaddressbook_undo" ); |
1912 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1908 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1913 | this, SLOT( redo() ), actionCollection(), | 1909 | this, SLOT( redo() ), actionCollection(), |
1914 | "kaddressbook_redo" ); | 1910 | "kaddressbook_redo" ); |
1915 | } else { | 1911 | } else { |
1916 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1912 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1917 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1913 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1918 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1914 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1919 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1915 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1920 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1916 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1921 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1917 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1922 | } | 1918 | } |
1923 | 1919 | ||
1924 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1920 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1925 | Key_Delete, this, SLOT( deleteContacts() ), | 1921 | Key_Delete, this, SLOT( deleteContacts() ), |
1926 | actionCollection(), "edit_delete" ); | 1922 | actionCollection(), "edit_delete" ); |
1927 | 1923 | ||
1928 | mActionUndo->setEnabled( false ); | 1924 | mActionUndo->setEnabled( false ); |
1929 | mActionRedo->setEnabled( false ); | 1925 | mActionRedo->setEnabled( false ); |
1930 | 1926 | ||
1931 | // settings menu | 1927 | // settings menu |
1932 | #ifdef KAB_EMBEDDED | 1928 | #ifdef KAB_EMBEDDED |
1933 | //US special menuentry to configure the addressbook resources. On KDE | 1929 | //US special menuentry to configure the addressbook resources. On KDE |
1934 | // you do that through the control center !!! | 1930 | // you do that through the control center !!! |
1935 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1931 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1936 | SLOT( configureResources() ), actionCollection(), | 1932 | SLOT( configureResources() ), actionCollection(), |
1937 | "kaddressbook_configure_resources" ); | 1933 | "kaddressbook_configure_resources" ); |
1938 | #endif //KAB_EMBEDDED | 1934 | #endif //KAB_EMBEDDED |
1939 | 1935 | ||
1940 | if ( mIsPart ) { | 1936 | if ( mIsPart ) { |
1941 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1937 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1942 | SLOT( openConfigDialog() ), actionCollection(), | 1938 | SLOT( openConfigDialog() ), actionCollection(), |
1943 | "kaddressbook_configure" ); | 1939 | "kaddressbook_configure" ); |
1944 | 1940 | ||
1945 | //US not implemented yet | 1941 | //US not implemented yet |
1946 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1942 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1947 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1943 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1948 | // "kaddressbook_configure_shortcuts" ); | 1944 | // "kaddressbook_configure_shortcuts" ); |
1949 | #ifdef KAB_EMBEDDED | 1945 | #ifdef KAB_EMBEDDED |
1950 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1946 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1951 | mActionConfigureToolbars->setEnabled( false ); | 1947 | mActionConfigureToolbars->setEnabled( false ); |
1952 | #endif //KAB_EMBEDDED | 1948 | #endif //KAB_EMBEDDED |
1953 | 1949 | ||
1954 | } else { | 1950 | } else { |
1955 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1951 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1956 | 1952 | ||
1957 | //US not implemented yet | 1953 | //US not implemented yet |
1958 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1954 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1959 | } | 1955 | } |
1960 | 1956 | ||
1961 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1957 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1962 | actionCollection(), "options_show_jump_bar" ); | 1958 | actionCollection(), "options_show_jump_bar" ); |
1963 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1959 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1964 | 1960 | ||
1965 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1961 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1966 | actionCollection(), "options_show_details" ); | 1962 | actionCollection(), "options_show_details" ); |
1967 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1963 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1968 | 1964 | ||
1969 | 1965 | ||
1970 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1966 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1971 | SLOT( toggleBeamReceive() ), actionCollection(), | 1967 | SLOT( toggleBeamReceive() ), actionCollection(), |
1972 | "kaddressbook_beam_rec" ); | 1968 | "kaddressbook_beam_rec" ); |
1973 | 1969 | ||
1974 | 1970 | ||
1975 | // misc | 1971 | // misc |
1976 | // only enable LDAP lookup if we can handle the protocol | 1972 | // only enable LDAP lookup if we can handle the protocol |
1977 | #ifndef KAB_EMBEDDED | 1973 | #ifndef KAB_EMBEDDED |
1978 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1974 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1979 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1975 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1980 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1976 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1981 | "ldap_lookup" ); | 1977 | "ldap_lookup" ); |
1982 | } | 1978 | } |
1983 | #else //KAB_EMBEDDED | 1979 | #else //KAB_EMBEDDED |
1984 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1980 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1985 | #endif //KAB_EMBEDDED | 1981 | #endif //KAB_EMBEDDED |
1986 | 1982 | ||
1987 | 1983 | ||
1988 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1984 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1989 | SLOT( setWhoAmI() ), actionCollection(), | 1985 | SLOT( setWhoAmI() ), actionCollection(), |
1990 | "set_personal" ); | 1986 | "set_personal" ); |
1991 | 1987 | ||
1992 | 1988 | ||
1993 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1989 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1994 | SLOT( setCategories() ), actionCollection(), | 1990 | SLOT( setCategories() ), actionCollection(), |
1995 | "edit_set_categories" ); | 1991 | "edit_set_categories" ); |
1996 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 1992 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
1997 | SLOT( editCategories() ), actionCollection(), | 1993 | SLOT( editCategories() ), actionCollection(), |
1998 | "edit__categories" ); | 1994 | "edit__categories" ); |
1999 | 1995 | ||
2000 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1996 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2001 | SLOT( removeVoice() ), actionCollection(), | 1997 | SLOT( removeVoice() ), actionCollection(), |
2002 | "remove_voice" ); | 1998 | "remove_voice" ); |
2003 | 1999 | ||
2004 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2000 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2005 | SLOT( manageCategories() ), actionCollection(), | 2001 | SLOT( manageCategories() ), actionCollection(), |
2006 | "remove_voice" ); | 2002 | "remove_voice" ); |
2007 | 2003 | ||
2008 | 2004 | ||
2009 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2005 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2010 | SLOT( importFromOL() ), actionCollection(), | 2006 | SLOT( importFromOL() ), actionCollection(), |
2011 | "import_OL" ); | 2007 | "import_OL" ); |
2012 | #ifdef KAB_EMBEDDED | 2008 | #ifdef KAB_EMBEDDED |
2013 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2009 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2014 | this, SLOT( showLicence() ), actionCollection(), | 2010 | this, SLOT( showLicence() ), actionCollection(), |
2015 | "licence_about_data" ); | 2011 | "licence_about_data" ); |
2016 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2012 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2017 | this, SLOT( faq() ), actionCollection(), | 2013 | this, SLOT( faq() ), actionCollection(), |
2018 | "faq_about_data" ); | 2014 | "faq_about_data" ); |
2019 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2015 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2020 | this, SLOT( whatsnew() ), actionCollection(), | 2016 | this, SLOT( whatsnew() ), actionCollection(), |
2021 | "wn" ); | 2017 | "wn" ); |
2022 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2018 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2023 | this, SLOT( synchowto() ), actionCollection(), | 2019 | this, SLOT( synchowto() ), actionCollection(), |
2024 | "sync" ); | 2020 | "sync" ); |
2025 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2021 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2026 | this, SLOT( kdesynchowto() ), actionCollection(), | 2022 | this, SLOT( kdesynchowto() ), actionCollection(), |
2027 | "kdesync" ); | 2023 | "kdesync" ); |
2028 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2024 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2029 | this, SLOT( multisynchowto() ), actionCollection(), | 2025 | this, SLOT( multisynchowto() ), actionCollection(), |
2030 | "multisync" ); | 2026 | "multisync" ); |
2031 | 2027 | ||
2032 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2028 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2033 | this, SLOT( createAboutData() ), actionCollection(), | 2029 | this, SLOT( createAboutData() ), actionCollection(), |
2034 | "kaddressbook_about_data" ); | 2030 | "kaddressbook_about_data" ); |
2035 | #endif //KAB_EMBEDDED | 2031 | #endif //KAB_EMBEDDED |
2036 | 2032 | ||
2037 | clipboardDataChanged(); | 2033 | clipboardDataChanged(); |
2038 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2034 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2039 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2035 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2040 | } | 2036 | } |
2041 | 2037 | ||
2042 | //US we need this function, to plug all actions into the correct menues. | 2038 | //US we need this function, to plug all actions into the correct menues. |
2043 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2039 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2044 | void KABCore::addActionsManually() | 2040 | void KABCore::addActionsManually() |
2045 | { | 2041 | { |
2046 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2042 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2047 | 2043 | ||
2048 | #ifdef KAB_EMBEDDED | 2044 | #ifdef KAB_EMBEDDED |
2049 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2045 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2050 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2046 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2051 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2047 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2052 | 2048 | ||
2053 | KToolBar* tb = mMainWindow->toolBar(); | 2049 | KToolBar* tb = mMainWindow->toolBar(); |
2054 | 2050 | ||
2055 | #ifndef DESKTOP_VERSION | 2051 | #ifndef DESKTOP_VERSION |
2056 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2052 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2057 | #endif | 2053 | #endif |
2058 | QMenuBar* mb = mMainWindow->menuBar(); | 2054 | QMenuBar* mb = mMainWindow->menuBar(); |
2059 | 2055 | ||
2060 | //US setup menubar. | 2056 | //US setup menubar. |
2061 | //Disable the following block if you do not want to have a menubar. | 2057 | //Disable the following block if you do not want to have a menubar. |
2062 | mb->insertItem( i18n("&File"), fileMenu ); | 2058 | mb->insertItem( i18n("&File"), fileMenu ); |
2063 | mb->insertItem( i18n("&Edit"), editMenu ); | 2059 | mb->insertItem( i18n("&Edit"), editMenu ); |
2064 | mb->insertItem( i18n("&View"), viewMenu ); | 2060 | mb->insertItem( i18n("&View"), viewMenu ); |
2065 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2061 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2066 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2062 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2067 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2063 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2068 | mb->insertItem( i18n("&Help"), helpMenu ); | 2064 | mb->insertItem( i18n("&Help"), helpMenu ); |
2069 | mIncSearchWidget = new IncSearchWidget( tb ); | 2065 | mIncSearchWidget = new IncSearchWidget( tb ); |
2070 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2066 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2071 | #ifndef DESKTOP_VERSION | 2067 | #ifndef DESKTOP_VERSION |
2072 | } else { | 2068 | } else { |
2073 | //US setup toolbar | 2069 | //US setup toolbar |
2074 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2070 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2075 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2071 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2076 | menuBarTB->insertItem( "ME", popupBarTB); | 2072 | menuBarTB->insertItem( "ME", popupBarTB); |
2077 | tb->insertWidget(-1, 0, menuBarTB); | 2073 | tb->insertWidget(-1, 0, menuBarTB); |
2078 | mIncSearchWidget = new IncSearchWidget( tb ); | 2074 | mIncSearchWidget = new IncSearchWidget( tb ); |
2079 | 2075 | ||
2080 | tb->enableMoving(false); | 2076 | tb->enableMoving(false); |
2081 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2077 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2082 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2078 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2083 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2079 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2084 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2080 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2085 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2081 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2086 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2082 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2087 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2083 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2088 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2084 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2089 | if (QApplication::desktop()->width() > 320 ) { | 2085 | if (QApplication::desktop()->width() > 320 ) { |
2090 | // mViewManager->getFilterAction()->plug ( tb); | 2086 | // mViewManager->getFilterAction()->plug ( tb); |
2091 | } | 2087 | } |
2092 | } | 2088 | } |
2093 | #endif | 2089 | #endif |
2094 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2090 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2095 | 2091 | ||
2096 | 2092 | ||
2097 | 2093 | ||
2098 | //US Now connect the actions with the menue entries. | 2094 | //US Now connect the actions with the menue entries. |
2099 | mActionPrint->plug( fileMenu ); | 2095 | mActionPrint->plug( fileMenu ); |
2100 | mActionMail->plug( fileMenu ); | 2096 | mActionMail->plug( fileMenu ); |
2101 | fileMenu->insertSeparator(); | 2097 | fileMenu->insertSeparator(); |
2102 | 2098 | ||
2103 | mActionNewContact->plug( fileMenu ); | 2099 | mActionNewContact->plug( fileMenu ); |
2104 | mActionNewContact->plug( tb ); | 2100 | mActionNewContact->plug( tb ); |
2105 | 2101 | ||
2106 | mActionEditAddressee->plug( fileMenu ); | 2102 | mActionEditAddressee->plug( fileMenu ); |
2107 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2103 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2108 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2104 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2109 | mActionEditAddressee->plug( tb ); | 2105 | mActionEditAddressee->plug( tb ); |
2110 | 2106 | ||
2111 | fileMenu->insertSeparator(); | 2107 | fileMenu->insertSeparator(); |
2112 | mActionSave->plug( fileMenu ); | 2108 | mActionSave->plug( fileMenu ); |
2113 | fileMenu->insertItem( "&Import", ImportMenu ); | 2109 | fileMenu->insertItem( "&Import", ImportMenu ); |
2114 | fileMenu->insertItem( "&Export", ExportMenu ); | 2110 | fileMenu->insertItem( "&Export", ExportMenu ); |
2115 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2111 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2116 | #ifndef DESKTOP_VERSION | 2112 | #ifndef DESKTOP_VERSION |
2117 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2113 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2118 | #endif | 2114 | #endif |
2119 | 2115 | ||
2120 | fileMenu->insertSeparator(); | 2116 | fileMenu->insertSeparator(); |
2121 | mActionMailVCard->plug( fileMenu ); | 2117 | mActionMailVCard->plug( fileMenu ); |
2122 | #ifndef DESKTOP_VERSION | 2118 | #ifndef DESKTOP_VERSION |
2123 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2119 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2124 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2120 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2125 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2121 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2126 | #endif | 2122 | #endif |
2127 | fileMenu->insertSeparator(); | 2123 | fileMenu->insertSeparator(); |
2128 | mActionQuit->plug( fileMenu ); | 2124 | mActionQuit->plug( fileMenu ); |
2129 | #ifdef _WIN32_ | 2125 | #ifdef _WIN32_ |
2130 | mActionImportOL->plug( ImportMenu ); | 2126 | mActionImportOL->plug( ImportMenu ); |
2131 | #endif | 2127 | #endif |
2132 | // edit menu | 2128 | // edit menu |
2133 | mActionUndo->plug( editMenu ); | 2129 | mActionUndo->plug( editMenu ); |
2134 | mActionRedo->plug( editMenu ); | 2130 | mActionRedo->plug( editMenu ); |
2135 | editMenu->insertSeparator(); | 2131 | editMenu->insertSeparator(); |
2136 | mActionCut->plug( editMenu ); | 2132 | mActionCut->plug( editMenu ); |
2137 | mActionCopy->plug( editMenu ); | 2133 | mActionCopy->plug( editMenu ); |
2138 | mActionPaste->plug( editMenu ); | 2134 | mActionPaste->plug( editMenu ); |
2139 | mActionDelete->plug( editMenu ); | 2135 | mActionDelete->plug( editMenu ); |
2140 | editMenu->insertSeparator(); | 2136 | editMenu->insertSeparator(); |
2141 | mActionSelectAll->plug( editMenu ); | 2137 | mActionSelectAll->plug( editMenu ); |
2142 | 2138 | ||
2143 | mActionRemoveVoice->plug( changeMenu ); | 2139 | mActionRemoveVoice->plug( changeMenu ); |
2144 | // settings menu | 2140 | // settings menu |
2145 | //US special menuentry to configure the addressbook resources. On KDE | 2141 | //US special menuentry to configure the addressbook resources. On KDE |
2146 | // you do that through the control center !!! | 2142 | // you do that through the control center !!! |
2147 | mActionConfigResources->plug( settingsMenu ); | 2143 | mActionConfigResources->plug( settingsMenu ); |
2148 | settingsMenu->insertSeparator(); | 2144 | settingsMenu->insertSeparator(); |
2149 | 2145 | ||
2150 | mActionConfigKAddressbook->plug( settingsMenu ); | 2146 | mActionConfigKAddressbook->plug( settingsMenu ); |
2151 | 2147 | ||
2152 | if ( mIsPart ) { | 2148 | if ( mIsPart ) { |
2153 | //US not implemented yet | 2149 | //US not implemented yet |
2154 | //mActionConfigShortcuts->plug( settingsMenu ); | 2150 | //mActionConfigShortcuts->plug( settingsMenu ); |
2155 | //mActionConfigureToolbars->plug( settingsMenu ); | 2151 | //mActionConfigureToolbars->plug( settingsMenu ); |
2156 | 2152 | ||
2157 | } else { | 2153 | } else { |
2158 | //US not implemented yet | 2154 | //US not implemented yet |
2159 | //mActionKeyBindings->plug( settingsMenu ); | 2155 | //mActionKeyBindings->plug( settingsMenu ); |
2160 | } | 2156 | } |
2161 | 2157 | ||
2162 | settingsMenu->insertSeparator(); | 2158 | settingsMenu->insertSeparator(); |
2163 | 2159 | ||
2164 | mActionJumpBar->plug( settingsMenu ); | 2160 | mActionJumpBar->plug( settingsMenu ); |
2165 | mActionDetails->plug( settingsMenu ); | 2161 | mActionDetails->plug( settingsMenu ); |
2166 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2162 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2167 | mActionDetails->plug( tb ); | 2163 | mActionDetails->plug( tb ); |
2168 | settingsMenu->insertSeparator(); | 2164 | settingsMenu->insertSeparator(); |
2169 | #ifndef DESKTOP_VERSION | 2165 | #ifndef DESKTOP_VERSION |
2170 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2166 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2171 | #endif | 2167 | #endif |
2172 | settingsMenu->insertSeparator(); | 2168 | settingsMenu->insertSeparator(); |
2173 | 2169 | ||
2174 | mActionWhoAmI->plug( settingsMenu ); | 2170 | mActionWhoAmI->plug( settingsMenu ); |
2175 | mActionEditCategories->plug( settingsMenu ); | 2171 | mActionEditCategories->plug( settingsMenu ); |
2176 | mActionEditCategories->plug( changeMenu ); | 2172 | mActionEditCategories->plug( changeMenu ); |
2177 | mActionCategories->plug( changeMenu ); | 2173 | mActionCategories->plug( changeMenu ); |
2178 | mActionManageCategories->plug( changeMenu ); | 2174 | mActionManageCategories->plug( changeMenu ); |
2179 | 2175 | ||
2180 | mActionCategories->plug( settingsMenu ); | 2176 | mActionCategories->plug( settingsMenu ); |
2181 | mActionManageCategories->plug( settingsMenu ); | 2177 | mActionManageCategories->plug( settingsMenu ); |
2182 | 2178 | ||
2183 | 2179 | ||
2184 | mActionWN->plug( helpMenu ); | 2180 | mActionWN->plug( helpMenu ); |
2185 | mActionSyncHowto->plug( helpMenu ); | 2181 | mActionSyncHowto->plug( helpMenu ); |
2186 | mActionKdeSyncHowto->plug( helpMenu ); | 2182 | mActionKdeSyncHowto->plug( helpMenu ); |
2187 | mActionMultiSyncHowto->plug( helpMenu ); | 2183 | mActionMultiSyncHowto->plug( helpMenu ); |
2188 | mActionFaq->plug( helpMenu ); | 2184 | mActionFaq->plug( helpMenu ); |
2189 | mActionLicence->plug( helpMenu ); | 2185 | mActionLicence->plug( helpMenu ); |
2190 | mActionAboutKAddressbook->plug( helpMenu ); | 2186 | mActionAboutKAddressbook->plug( helpMenu ); |
2191 | 2187 | ||
2192 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2188 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2193 | 2189 | ||
2194 | mActionSave->plug( tb ); | 2190 | mActionSave->plug( tb ); |
2195 | mViewManager->getFilterAction()->plug ( tb); | 2191 | mViewManager->getFilterAction()->plug ( tb); |
2196 | //LR hide filteraction on started in 480x640 | 2192 | //LR hide filteraction on started in 480x640 |
2197 | if (QApplication::desktop()->width() == 480 ) { | 2193 | if (QApplication::desktop()->width() == 480 ) { |
2198 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2194 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2199 | } | 2195 | } |
2200 | mActionUndo->plug( tb ); | 2196 | mActionUndo->plug( tb ); |
2201 | mActionDelete->plug( tb ); | 2197 | mActionDelete->plug( tb ); |
2202 | mActionRedo->plug( tb ); | 2198 | mActionRedo->plug( tb ); |
2203 | } else { | 2199 | } else { |
2204 | mActionSave->plug( tb ); | 2200 | mActionSave->plug( tb ); |
2205 | tb->enableMoving(false); | 2201 | tb->enableMoving(false); |
2206 | } | 2202 | } |
2207 | //mActionQuit->plug ( tb ); | 2203 | //mActionQuit->plug ( tb ); |
2208 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2204 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2209 | 2205 | ||
2210 | //US link the searchwidget first to this. | 2206 | //US link the searchwidget first to this. |
2211 | // The real linkage to the toolbar happens later. | 2207 | // The real linkage to the toolbar happens later. |
2212 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2208 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2213 | //US tb->insertItem( mIncSearchWidget ); | 2209 | //US tb->insertItem( mIncSearchWidget ); |
2214 | /*US | 2210 | /*US |
2215 | mIncSearchWidget = new IncSearchWidget( tb ); | 2211 | mIncSearchWidget = new IncSearchWidget( tb ); |
2216 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2212 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2217 | SLOT( incrementalSearch( const QString& ) ) ); | 2213 | SLOT( incrementalSearch( const QString& ) ) ); |
2218 | 2214 | ||
2219 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2215 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2220 | 2216 | ||
2221 | //US topLayout->addWidget( mJumpButtonBar ); | 2217 | //US topLayout->addWidget( mJumpButtonBar ); |
2222 | this->layout()->add( mJumpButtonBar ); | 2218 | this->layout()->add( mJumpButtonBar ); |
2223 | */ | 2219 | */ |
2224 | 2220 | ||
2225 | #endif //KAB_EMBEDDED | 2221 | #endif //KAB_EMBEDDED |
2226 | 2222 | ||
2227 | mActionExport2phone->plug( ExportMenu ); | 2223 | mActionExport2phone->plug( ExportMenu ); |
2228 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2224 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2229 | syncManager->fillSyncMenu(); | 2225 | syncManager->fillSyncMenu(); |
2230 | 2226 | ||
2231 | } | 2227 | } |
2232 | void KABCore::showLicence() | 2228 | void KABCore::showLicence() |
2233 | { | 2229 | { |
2234 | KApplication::showLicence(); | 2230 | KApplication::showLicence(); |
2235 | } | 2231 | } |
2236 | 2232 | ||
2237 | void KABCore::manageCategories( ) | 2233 | void KABCore::manageCategories( ) |
2238 | { | 2234 | { |
2239 | KABCatPrefs* cp = new KABCatPrefs(); | 2235 | KABCatPrefs* cp = new KABCatPrefs(); |
2240 | cp->show(); | 2236 | cp->show(); |
2241 | int w =cp->sizeHint().width() ; | 2237 | int w =cp->sizeHint().width() ; |
2242 | int h = cp->sizeHint().height() ; | 2238 | int h = cp->sizeHint().height() ; |
2243 | int dw = QApplication::desktop()->width(); | 2239 | int dw = QApplication::desktop()->width(); |
2244 | int dh = QApplication::desktop()->height(); | 2240 | int dh = QApplication::desktop()->height(); |
2245 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2241 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2246 | if ( !cp->exec() ) { | 2242 | if ( !cp->exec() ) { |
2247 | delete cp; | 2243 | delete cp; |
2248 | return; | 2244 | return; |
2249 | } | 2245 | } |
2250 | int count = 0; | 2246 | int count = 0; |
2251 | message( i18n("Please wait, processing categories...")); | 2247 | message( i18n("Please wait, processing categories...")); |
2252 | if ( cp->addCat() ) { | 2248 | if ( cp->addCat() ) { |
2253 | KABC::AddressBook::Iterator it; | 2249 | KABC::AddressBook::Iterator it; |
2254 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2250 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2255 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2251 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2256 | QStringList catIncList = (*it).categories(); | 2252 | QStringList catIncList = (*it).categories(); |
2257 | int i; | 2253 | int i; |
2258 | for( i = 0; i< catIncList.count(); ++i ) { | 2254 | for( i = 0; i< catIncList.count(); ++i ) { |
2259 | if ( !catList.contains (catIncList[i])) { | 2255 | if ( !catList.contains (catIncList[i])) { |
2260 | catList.append( catIncList[i] ); | 2256 | catList.append( catIncList[i] ); |
2261 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2257 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2262 | ++count; | 2258 | ++count; |
2263 | } | 2259 | } |
2264 | } | 2260 | } |
2265 | } | 2261 | } |
2266 | catList.sort(); | 2262 | catList.sort(); |
2267 | KABPrefs::instance()->mCustomCategories = catList; | 2263 | KABPrefs::instance()->mCustomCategories = catList; |
2268 | KABPrefs::instance()->writeConfig(); | 2264 | KABPrefs::instance()->writeConfig(); |
2269 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2265 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2270 | } else { | 2266 | } else { |
2271 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2267 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2272 | QStringList catIncList; | 2268 | QStringList catIncList; |
2273 | QStringList newCatList; | 2269 | QStringList newCatList; |
2274 | KABC::AddressBook::Iterator it; | 2270 | KABC::AddressBook::Iterator it; |
2275 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2271 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2276 | QStringList catIncList = (*it).categories(); | 2272 | QStringList catIncList = (*it).categories(); |
2277 | int i; | 2273 | int i; |
2278 | if ( catIncList.count() ) { | 2274 | if ( catIncList.count() ) { |
2279 | newCatList.clear(); | 2275 | newCatList.clear(); |
2280 | for( i = 0; i< catIncList.count(); ++i ) { | 2276 | for( i = 0; i< catIncList.count(); ++i ) { |
2281 | if ( catList.contains (catIncList[i])) { | 2277 | if ( catList.contains (catIncList[i])) { |
2282 | newCatList.append( catIncList[i] ); | 2278 | newCatList.append( catIncList[i] ); |
2283 | } | 2279 | } |
2284 | } | 2280 | } |
2285 | newCatList.sort(); | 2281 | newCatList.sort(); |
2286 | (*it).setCategories( newCatList ); | 2282 | (*it).setCategories( newCatList ); |
2287 | mAddressBook->insertAddressee( (*it) ); | 2283 | mAddressBook->insertAddressee( (*it) ); |
2288 | } | 2284 | } |
2289 | } | 2285 | } |
2290 | setModified( true ); | 2286 | setModified( true ); |
2291 | mViewManager->refreshView(); | 2287 | mViewManager->refreshView(); |
2292 | mDetails->refreshView(); | ||
2293 | message( i18n("Removing categories done!")); | 2288 | message( i18n("Removing categories done!")); |
2294 | } | 2289 | } |
2295 | delete cp; | 2290 | delete cp; |
2296 | } | 2291 | } |
2297 | void KABCore::removeVoice() | 2292 | void KABCore::removeVoice() |
2298 | { | 2293 | { |
2299 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2294 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2300 | return; | 2295 | return; |
2301 | KABC::Addressee::List list; | 2296 | KABC::Addressee::List list; |
2302 | XXPortSelectDialog dlg( this, false, this ); | 2297 | XXPortSelectDialog dlg( this, false, this ); |
2303 | if ( dlg.exec() ) | 2298 | if ( dlg.exec() ) |
2304 | list = dlg.contacts(); | 2299 | list = dlg.contacts(); |
2305 | else | 2300 | else |
2306 | return; | 2301 | return; |
2307 | KABC::Addressee::List::Iterator it; | 2302 | KABC::Addressee::List::Iterator it; |
2308 | for ( it = list.begin(); it != list.end(); ++it ) { | 2303 | for ( it = list.begin(); it != list.end(); ++it ) { |
2309 | if ( (*it).removeVoice() ) | 2304 | if ( (*it).removeVoice() ) |
2310 | contactModified((*it) ); | 2305 | contactModified((*it) ); |
2311 | } | 2306 | } |
2312 | } | 2307 | } |
2313 | 2308 | ||
2314 | 2309 | ||
2315 | 2310 | ||
2316 | void KABCore::clipboardDataChanged() | 2311 | void KABCore::clipboardDataChanged() |
2317 | { | 2312 | { |
2318 | 2313 | ||
2319 | if ( mReadWrite ) | 2314 | if ( mReadWrite ) |
2320 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2315 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2321 | 2316 | ||
2322 | } | 2317 | } |
2323 | 2318 | ||
2324 | void KABCore::updateActionMenu() | 2319 | void KABCore::updateActionMenu() |
2325 | { | 2320 | { |
2326 | UndoStack *undo = UndoStack::instance(); | 2321 | UndoStack *undo = UndoStack::instance(); |
2327 | RedoStack *redo = RedoStack::instance(); | 2322 | RedoStack *redo = RedoStack::instance(); |
2328 | 2323 | ||
2329 | if ( undo->isEmpty() ) | 2324 | if ( undo->isEmpty() ) |
2330 | mActionUndo->setText( i18n( "Undo" ) ); | 2325 | mActionUndo->setText( i18n( "Undo" ) ); |
2331 | else | 2326 | else |
2332 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2327 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2333 | 2328 | ||
2334 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2329 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2335 | 2330 | ||
2336 | if ( !redo->top() ) | 2331 | if ( !redo->top() ) |
2337 | mActionRedo->setText( i18n( "Redo" ) ); | 2332 | mActionRedo->setText( i18n( "Redo" ) ); |
2338 | else | 2333 | else |
2339 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2334 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2340 | 2335 | ||
2341 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2336 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2342 | } | 2337 | } |
2343 | 2338 | ||
2344 | void KABCore::configureKeyBindings() | 2339 | void KABCore::configureKeyBindings() |
2345 | { | 2340 | { |
2346 | #ifndef KAB_EMBEDDED | 2341 | #ifndef KAB_EMBEDDED |
2347 | KKeyDialog::configure( actionCollection(), true ); | 2342 | KKeyDialog::configure( actionCollection(), true ); |
2348 | #else //KAB_EMBEDDED | 2343 | #else //KAB_EMBEDDED |
2349 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2344 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2350 | #endif //KAB_EMBEDDED | 2345 | #endif //KAB_EMBEDDED |
2351 | } | 2346 | } |
2352 | 2347 | ||
2353 | #ifdef KAB_EMBEDDED | 2348 | #ifdef KAB_EMBEDDED |
2354 | void KABCore::configureResources() | 2349 | void KABCore::configureResources() |
2355 | { | 2350 | { |
2356 | KRES::KCMKResources dlg( this, "" , 0 ); | 2351 | KRES::KCMKResources dlg( this, "" , 0 ); |
2357 | 2352 | ||
2358 | if ( !dlg.exec() ) | 2353 | if ( !dlg.exec() ) |
2359 | return; | 2354 | return; |
2360 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2355 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2361 | } | 2356 | } |
2362 | #endif //KAB_EMBEDDED | 2357 | #endif //KAB_EMBEDDED |
2363 | 2358 | ||
2364 | 2359 | ||
2365 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2360 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2366 | * for the attendees list of an event. | 2361 | * for the attendees list of an event. |
2367 | */ | 2362 | */ |
2368 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2363 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2369 | { | 2364 | { |
2370 | QStringList nameList; | 2365 | QStringList nameList; |
2371 | QStringList emailList; | 2366 | QStringList emailList; |
2372 | QStringList uidList; | 2367 | QStringList uidList; |
2373 | 2368 | ||
2374 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2369 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2375 | uint i=0; | 2370 | uint i=0; |
2376 | for (i=0; i < list.count(); i++) | 2371 | for (i=0; i < list.count(); i++) |
2377 | { | 2372 | { |
2378 | nameList.append(list[i].realName()); | 2373 | nameList.append(list[i].realName()); |
2379 | emailList.append(list[i].preferredEmail()); | 2374 | emailList.append(list[i].preferredEmail()); |
2380 | uidList.append(list[i].uid()); | 2375 | uidList.append(list[i].uid()); |
2381 | } | 2376 | } |
2382 | 2377 | ||
2383 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2378 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2384 | 2379 | ||
2385 | } | 2380 | } |
2386 | 2381 | ||
2387 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2382 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2388 | * to put them into the calendar. | 2383 | * to put them into the calendar. |
2389 | */ | 2384 | */ |
2390 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2385 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2391 | { | 2386 | { |
2392 | // qDebug("KABCore::requestForBirthdayList"); | 2387 | // qDebug("KABCore::requestForBirthdayList"); |
2393 | QStringList birthdayList; | 2388 | QStringList birthdayList; |
2394 | QStringList anniversaryList; | 2389 | QStringList anniversaryList; |
2395 | QStringList realNameList; | 2390 | QStringList realNameList; |
2396 | QStringList preferredEmailList; | 2391 | QStringList preferredEmailList; |
2397 | QStringList assembledNameList; | 2392 | QStringList assembledNameList; |
2398 | QStringList uidList; | 2393 | QStringList uidList; |
2399 | 2394 | ||
2400 | KABC::AddressBook::Iterator it; | 2395 | KABC::AddressBook::Iterator it; |
2401 | 2396 | ||
2402 | int count = 0; | 2397 | int count = 0; |
2403 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2398 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2404 | ++count; | 2399 | ++count; |
2405 | } | 2400 | } |
2406 | QProgressBar bar(count,0 ); | 2401 | QProgressBar bar(count,0 ); |
2407 | int w = 300; | 2402 | int w = 300; |
2408 | if ( QApplication::desktop()->width() < 320 ) | 2403 | if ( QApplication::desktop()->width() < 320 ) |
2409 | w = 220; | 2404 | w = 220; |
2410 | int h = bar.sizeHint().height() ; | 2405 | int h = bar.sizeHint().height() ; |
2411 | int dw = QApplication::desktop()->width(); | 2406 | int dw = QApplication::desktop()->width(); |
2412 | int dh = QApplication::desktop()->height(); | 2407 | int dh = QApplication::desktop()->height(); |
2413 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2408 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2414 | bar.show(); | 2409 | bar.show(); |
2415 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2410 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2416 | qApp->processEvents(); | 2411 | qApp->processEvents(); |
2417 | 2412 | ||
2418 | QDate bday; | 2413 | QDate bday; |
2419 | QString anni; | 2414 | QString anni; |
2420 | QString formattedbday; | 2415 | QString formattedbday; |
2421 | 2416 | ||
2422 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2417 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2423 | { | 2418 | { |
2424 | if ( ! bar.isVisible() ) | 2419 | if ( ! bar.isVisible() ) |
2425 | return; | 2420 | return; |
2426 | bar.setProgress( count++ ); | 2421 | bar.setProgress( count++ ); |
2427 | qApp->processEvents(); | 2422 | qApp->processEvents(); |
2428 | bday = (*it).birthday().date(); | 2423 | bday = (*it).birthday().date(); |
2429 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2424 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2430 | 2425 | ||
2431 | if ( bday.isValid() || !anni.isEmpty()) | 2426 | if ( bday.isValid() || !anni.isEmpty()) |
2432 | { | 2427 | { |
2433 | if (bday.isValid()) | 2428 | if (bday.isValid()) |
2434 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2429 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2435 | else | 2430 | else |
2436 | formattedbday = "NOTVALID"; | 2431 | formattedbday = "NOTVALID"; |
2437 | if (anni.isEmpty()) | 2432 | if (anni.isEmpty()) |
2438 | anni = "INVALID"; | 2433 | anni = "INVALID"; |
2439 | 2434 | ||
2440 | birthdayList.append(formattedbday); | 2435 | birthdayList.append(formattedbday); |
2441 | anniversaryList.append(anni); //should be ISODate | 2436 | anniversaryList.append(anni); //should be ISODate |
2442 | realNameList.append((*it).realName()); | 2437 | realNameList.append((*it).realName()); |
2443 | preferredEmailList.append((*it).preferredEmail()); | 2438 | preferredEmailList.append((*it).preferredEmail()); |
2444 | assembledNameList.append((*it).assembledName()); | 2439 | assembledNameList.append((*it).assembledName()); |
2445 | uidList.append((*it).uid()); | 2440 | uidList.append((*it).uid()); |
2446 | 2441 | ||
2447 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2442 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2448 | } | 2443 | } |
2449 | } | 2444 | } |
2450 | 2445 | ||
2451 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2446 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2452 | 2447 | ||
2453 | } | 2448 | } |
2454 | 2449 | ||
2455 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2450 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2456 | */ | 2451 | */ |
2457 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2452 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2458 | { | 2453 | { |
2459 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2454 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2460 | 2455 | ||
2461 | QString foundUid = QString::null; | 2456 | QString foundUid = QString::null; |
2462 | if ( ! uid.isEmpty() ) { | 2457 | if ( ! uid.isEmpty() ) { |
2463 | Addressee adrr = mAddressBook->findByUid( uid ); | 2458 | Addressee adrr = mAddressBook->findByUid( uid ); |
2464 | if ( !adrr.isEmpty() ) { | 2459 | if ( !adrr.isEmpty() ) { |
2465 | foundUid = uid; | 2460 | foundUid = uid; |
2466 | } | 2461 | } |
2467 | if ( email == "sendbacklist" ) { | 2462 | if ( email == "sendbacklist" ) { |
2468 | //qDebug("ssssssssssssssssssssssend "); | 2463 | //qDebug("ssssssssssssssssssssssend "); |
2469 | QStringList nameList; | 2464 | QStringList nameList; |
2470 | QStringList emailList; | 2465 | QStringList emailList; |
2471 | QStringList uidList; | 2466 | QStringList uidList; |
2472 | nameList.append(adrr.realName()); | 2467 | nameList.append(adrr.realName()); |
2473 | emailList = adrr.emails(); | 2468 | emailList = adrr.emails(); |
2474 | uidList.append( adrr.preferredEmail()); | 2469 | uidList.append( adrr.preferredEmail()); |
2475 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2470 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2476 | return; | 2471 | return; |
2477 | } | 2472 | } |
2478 | 2473 | ||
2479 | } | 2474 | } |
2480 | 2475 | ||
2481 | if ( email == "sendbacklist" ) | 2476 | if ( email == "sendbacklist" ) |
2482 | return; | 2477 | return; |
2483 | if (foundUid.isEmpty()) | 2478 | if (foundUid.isEmpty()) |
2484 | { | 2479 | { |
2485 | //find the uid of the person first | 2480 | //find the uid of the person first |
2486 | Addressee::List namelist; | 2481 | Addressee::List namelist; |
2487 | Addressee::List emaillist; | 2482 | Addressee::List emaillist; |
2488 | 2483 | ||
2489 | if (!name.isEmpty()) | 2484 | if (!name.isEmpty()) |
2490 | namelist = mAddressBook->findByName( name ); | 2485 | namelist = mAddressBook->findByName( name ); |
2491 | 2486 | ||
2492 | if (!email.isEmpty()) | 2487 | if (!email.isEmpty()) |
2493 | emaillist = mAddressBook->findByEmail( email ); | 2488 | emaillist = mAddressBook->findByEmail( email ); |
2494 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2489 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2495 | //check if we have a match in Namelist and Emaillist | 2490 | //check if we have a match in Namelist and Emaillist |
2496 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2491 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2497 | foundUid = emaillist[0].uid(); | 2492 | foundUid = emaillist[0].uid(); |
2498 | } | 2493 | } |
2499 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2494 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2500 | foundUid = namelist[0].uid(); | 2495 | foundUid = namelist[0].uid(); |
2501 | else | 2496 | else |
2502 | { | 2497 | { |
2503 | for (int i = 0; i < namelist.count(); i++) | 2498 | for (int i = 0; i < namelist.count(); i++) |
2504 | { | 2499 | { |
2505 | for (int j = 0; j < emaillist.count(); j++) | 2500 | for (int j = 0; j < emaillist.count(); j++) |
2506 | { | 2501 | { |
2507 | if (namelist[i] == emaillist[j]) | 2502 | if (namelist[i] == emaillist[j]) |
2508 | { | 2503 | { |
2509 | foundUid = namelist[i].uid(); | 2504 | foundUid = namelist[i].uid(); |
2510 | } | 2505 | } |
2511 | } | 2506 | } |
2512 | } | 2507 | } |
2513 | } | 2508 | } |
2514 | } | 2509 | } |
2515 | else | 2510 | else |
2516 | { | 2511 | { |
2517 | foundUid = uid; | 2512 | foundUid = uid; |
2518 | } | 2513 | } |
2519 | 2514 | ||
2520 | if (!foundUid.isEmpty()) | 2515 | if (!foundUid.isEmpty()) |
2521 | { | 2516 | { |
2522 | 2517 | ||
2523 | // raise Ka/Pi if it is in the background | 2518 | // raise Ka/Pi if it is in the background |
2524 | #ifndef DESKTOP_VERSION | 2519 | #ifndef DESKTOP_VERSION |
2525 | #ifndef KORG_NODCOP | 2520 | #ifndef KORG_NODCOP |
2526 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2521 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2527 | #endif | 2522 | #endif |
2528 | #endif | 2523 | #endif |
2529 | 2524 | ||
2530 | mMainWindow->showMaximized(); | 2525 | mMainWindow->showMaximized(); |
2531 | mMainWindow-> raise(); | 2526 | mMainWindow-> raise(); |
2532 | 2527 | ||
2533 | mViewManager->setSelected( "", false); | 2528 | mViewManager->setSelected( "", false); |
2534 | mViewManager->refreshView( "" ); | 2529 | mViewManager->refreshView( "" ); |
2535 | mViewManager->setSelected( foundUid, true ); | 2530 | mViewManager->setSelected( foundUid, true ); |
2536 | mViewManager->refreshView( foundUid ); | 2531 | mViewManager->refreshView( foundUid ); |
2537 | 2532 | ||
2538 | if ( !mMultipleViewsAtOnce ) | 2533 | if ( !mMultipleViewsAtOnce ) |
2539 | { | 2534 | { |
2540 | setDetailsVisible( true ); | 2535 | setDetailsVisible( true ); |
2541 | mActionDetails->setChecked(true); | 2536 | mActionDetails->setChecked(true); |
2542 | } | 2537 | } |
2543 | } | 2538 | } |
2544 | } | 2539 | } |
2545 | 2540 | ||
2546 | void KABCore::whatsnew() | 2541 | void KABCore::whatsnew() |
2547 | { | 2542 | { |
2548 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2543 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2549 | } | 2544 | } |
2550 | void KABCore::synchowto() | 2545 | void KABCore::synchowto() |
2551 | { | 2546 | { |
2552 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2547 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2553 | } | 2548 | } |
2554 | void KABCore::kdesynchowto() | 2549 | void KABCore::kdesynchowto() |
2555 | { | 2550 | { |
2556 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2551 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2557 | } | 2552 | } |
2558 | void KABCore::multisynchowto() | 2553 | void KABCore::multisynchowto() |
2559 | { | 2554 | { |
2560 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2555 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2561 | } | 2556 | } |
2562 | void KABCore::faq() | 2557 | void KABCore::faq() |
2563 | { | 2558 | { |
2564 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2559 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2565 | } | 2560 | } |
2566 | 2561 | ||
2567 | #include <libkcal/syncdefines.h> | 2562 | #include <libkcal/syncdefines.h> |
2568 | 2563 | ||
2569 | KABC::Addressee KABCore::getLastSyncAddressee() | 2564 | KABC::Addressee KABCore::getLastSyncAddressee() |
2570 | { | 2565 | { |
2571 | Addressee lse; | 2566 | Addressee lse; |
2572 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2567 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2573 | 2568 | ||
2574 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2569 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2575 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2570 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2576 | if (lse.isEmpty()) { | 2571 | if (lse.isEmpty()) { |
2577 | qDebug("Creating new last-syncAddressee "); | 2572 | qDebug("Creating new last-syncAddressee "); |
2578 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2573 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2579 | QString sum = ""; | 2574 | QString sum = ""; |
2580 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2575 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2581 | sum = "E: "; | 2576 | sum = "E: "; |
2582 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2577 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2583 | lse.setRevision( mLastAddressbookSync ); | 2578 | lse.setRevision( mLastAddressbookSync ); |
2584 | lse.setCategories( i18n("SyncEvent") ); | 2579 | lse.setCategories( i18n("SyncEvent") ); |
2585 | mAddressBook->insertAddressee( lse ); | 2580 | mAddressBook->insertAddressee( lse ); |
2586 | } | 2581 | } |
2587 | return lse; | 2582 | return lse; |
2588 | } | 2583 | } |
2589 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2584 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2590 | { | 2585 | { |
2591 | 2586 | ||
2592 | //void setZaurusId(int id); | 2587 | //void setZaurusId(int id); |
2593 | // int zaurusId() const; | 2588 | // int zaurusId() const; |
2594 | // void setZaurusUid(int id); | 2589 | // void setZaurusUid(int id); |
2595 | // int zaurusUid() const; | 2590 | // int zaurusUid() const; |
2596 | // void setZaurusStat(int id); | 2591 | // void setZaurusStat(int id); |
2597 | // int zaurusStat() const; | 2592 | // int zaurusStat() const; |
2598 | // 0 equal | 2593 | // 0 equal |
2599 | // 1 take local | 2594 | // 1 take local |
2600 | // 2 take remote | 2595 | // 2 take remote |
2601 | // 3 cancel | 2596 | // 3 cancel |
2602 | QDateTime lastSync = mLastAddressbookSync; | 2597 | QDateTime lastSync = mLastAddressbookSync; |
2603 | QDateTime localMod = local->revision(); | 2598 | QDateTime localMod = local->revision(); |
2604 | QDateTime remoteMod = remote->revision(); | 2599 | QDateTime remoteMod = remote->revision(); |
2605 | 2600 | ||
2606 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2601 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2607 | 2602 | ||
2608 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2603 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2609 | bool remCh, locCh; | 2604 | bool remCh, locCh; |
2610 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2605 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2611 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2606 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2612 | locCh = ( localMod > mLastAddressbookSync ); | 2607 | locCh = ( localMod > mLastAddressbookSync ); |
2613 | if ( !remCh && ! locCh ) { | 2608 | if ( !remCh && ! locCh ) { |
2614 | //qDebug("both not changed "); | 2609 | //qDebug("both not changed "); |
2615 | lastSync = localMod.addDays(1); | 2610 | lastSync = localMod.addDays(1); |
2616 | if ( mode <= SYNC_PREF_ASK ) | 2611 | if ( mode <= SYNC_PREF_ASK ) |
2617 | return 0; | 2612 | return 0; |
2618 | } else { | 2613 | } else { |
2619 | if ( locCh ) { | 2614 | if ( locCh ) { |
2620 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2615 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2621 | lastSync = localMod.addDays( -1 ); | 2616 | lastSync = localMod.addDays( -1 ); |
2622 | if ( !remCh ) | 2617 | if ( !remCh ) |
2623 | remoteMod =( lastSync.addDays( -1 ) ); | 2618 | remoteMod =( lastSync.addDays( -1 ) ); |
2624 | } else { | 2619 | } else { |
2625 | //qDebug(" not loc changed "); | 2620 | //qDebug(" not loc changed "); |
2626 | lastSync = localMod.addDays( 1 ); | 2621 | lastSync = localMod.addDays( 1 ); |
2627 | if ( remCh ) { | 2622 | if ( remCh ) { |
2628 | //qDebug("rem changed "); | 2623 | //qDebug("rem changed "); |
2629 | remoteMod =( lastSync.addDays( 1 ) ); | 2624 | remoteMod =( lastSync.addDays( 1 ) ); |
2630 | } | 2625 | } |
2631 | 2626 | ||
2632 | } | 2627 | } |
2633 | } | 2628 | } |
2634 | full = true; | 2629 | full = true; |
2635 | if ( mode < SYNC_PREF_ASK ) | 2630 | if ( mode < SYNC_PREF_ASK ) |
2636 | mode = SYNC_PREF_ASK; | 2631 | mode = SYNC_PREF_ASK; |
2637 | } else { | 2632 | } else { |
2638 | if ( localMod == remoteMod ) | 2633 | if ( localMod == remoteMod ) |
2639 | return 0; | 2634 | return 0; |
2640 | 2635 | ||
2641 | } | 2636 | } |
2642 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2637 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2643 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2638 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2644 | //full = true; //debug only | 2639 | //full = true; //debug only |
2645 | if ( full ) { | 2640 | if ( full ) { |
2646 | bool equ = ( (*local) == (*remote) ); | 2641 | bool equ = ( (*local) == (*remote) ); |
2647 | if ( equ ) { | 2642 | if ( equ ) { |
2648 | //qDebug("equal "); | 2643 | //qDebug("equal "); |
2649 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2644 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2650 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2645 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2651 | } | 2646 | } |
2652 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2647 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2653 | return 0; | 2648 | return 0; |
2654 | 2649 | ||
2655 | }//else //debug only | 2650 | }//else //debug only |
2656 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2651 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2657 | } | 2652 | } |
2658 | int result; | 2653 | int result; |
2659 | bool localIsNew; | 2654 | bool localIsNew; |
2660 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2655 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2661 | 2656 | ||
2662 | if ( full && mode < SYNC_PREF_NEWEST ) | 2657 | if ( full && mode < SYNC_PREF_NEWEST ) |
2663 | mode = SYNC_PREF_ASK; | 2658 | mode = SYNC_PREF_ASK; |
2664 | 2659 | ||
2665 | switch( mode ) { | 2660 | switch( mode ) { |
2666 | case SYNC_PREF_LOCAL: | 2661 | case SYNC_PREF_LOCAL: |
2667 | if ( lastSync > remoteMod ) | 2662 | if ( lastSync > remoteMod ) |
2668 | return 1; | 2663 | return 1; |
2669 | if ( lastSync > localMod ) | 2664 | if ( lastSync > localMod ) |
2670 | return 2; | 2665 | return 2; |
2671 | return 1; | 2666 | return 1; |
2672 | break; | 2667 | break; |
2673 | case SYNC_PREF_REMOTE: | 2668 | case SYNC_PREF_REMOTE: |
2674 | if ( lastSync > remoteMod ) | 2669 | if ( lastSync > remoteMod ) |
2675 | return 1; | 2670 | return 1; |
2676 | if ( lastSync > localMod ) | 2671 | if ( lastSync > localMod ) |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c7c12ff..85ffbdb 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,516 +1,515 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | /** | 98 | |
99 | Saves the global settings. | ||
100 | */ | ||
101 | void saveSettings(); | ||
102 | 99 | ||
103 | /** | 100 | /** |
104 | Returns a pointer to the StdAddressBook of the application. | 101 | Returns a pointer to the StdAddressBook of the application. |
105 | */ | 102 | */ |
106 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
107 | 104 | ||
108 | /** | 105 | /** |
109 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
110 | */ | 107 | */ |
111 | static KConfig *config(); | 108 | static KConfig *config(); |
112 | 109 | ||
113 | /** | 110 | /** |
114 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
115 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
116 | */ | 113 | */ |
117 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
118 | 115 | ||
119 | /** | 116 | /** |
120 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
121 | */ | 118 | */ |
122 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
123 | 120 | ||
124 | /** | 121 | /** |
125 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
126 | */ | 123 | */ |
127 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
128 | 125 | ||
129 | /** | 126 | /** |
130 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
131 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
132 | the user. | 129 | the user. |
133 | */ | 130 | */ |
134 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
135 | 132 | ||
136 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
137 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
138 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
139 | 136 | ||
140 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
143 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
144 | 141 | ||
145 | public slots: | 142 | public slots: |
146 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
147 | void createAboutData(); | 144 | void createAboutData(); |
148 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
149 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
150 | 147 | ||
151 | void showLicence(); | 148 | void showLicence(); |
152 | void faq(); | 149 | void faq(); |
153 | void whatsnew() ; | 150 | void whatsnew() ; |
154 | void synchowto() ; | 151 | void synchowto() ; |
155 | void multisynchowto() ; | 152 | void multisynchowto() ; |
156 | void kdesynchowto() ; | 153 | void kdesynchowto() ; |
157 | void writeToPhone(); | 154 | void writeToPhone(); |
158 | 155 | ||
159 | /** | 156 | /** |
160 | Is called whenever a contact is selected in the view. | 157 | Is called whenever a contact is selected in the view. |
161 | */ | 158 | */ |
162 | void setContactSelected( const QString &uid ); | 159 | void setContactSelected( const QString &uid ); |
163 | 160 | ||
164 | /** | 161 | /** |
165 | Opens the preferred mail composer with all selected contacts as | 162 | Opens the preferred mail composer with all selected contacts as |
166 | arguments. | 163 | arguments. |
167 | */ | 164 | */ |
168 | void sendMail(); | 165 | void sendMail(); |
169 | 166 | ||
170 | /** | 167 | /** |
171 | Opens the preferred mail composer with the given contacts as | 168 | Opens the preferred mail composer with the given contacts as |
172 | arguments. | 169 | arguments. |
173 | */ | 170 | */ |
174 | void sendMail( const QString& email ); | 171 | void sendMail( const QString& email ); |
175 | 172 | ||
176 | 173 | ||
177 | void mailVCard(); | 174 | void mailVCard(); |
178 | void mailVCard(const QStringList& uids); | 175 | void mailVCard(const QStringList& uids); |
179 | 176 | ||
180 | /** | 177 | /** |
181 | Beams the "WhoAmI contact. | 178 | Beams the "WhoAmI contact. |
182 | */ | 179 | */ |
183 | void beamMySelf(); | 180 | void beamMySelf(); |
184 | 181 | ||
185 | void beamVCard(); | 182 | void beamVCard(); |
186 | void export2phone(); | 183 | void export2phone(); |
187 | void beamVCard(const QStringList& uids); | 184 | void beamVCard(const QStringList& uids); |
188 | void beamDone( Ir *ir ); | 185 | void beamDone( Ir *ir ); |
189 | 186 | ||
190 | 187 | ||
191 | /** | 188 | /** |
192 | Starts the preferred web browser with the given URL as argument. | 189 | Starts the preferred web browser with the given URL as argument. |
193 | */ | 190 | */ |
194 | void browse( const QString& url ); | 191 | void browse( const QString& url ); |
195 | 192 | ||
196 | /** | 193 | /** |
197 | Select all contacts in the view. | 194 | Select all contacts in the view. |
198 | */ | 195 | */ |
199 | void selectAllContacts(); | 196 | void selectAllContacts(); |
200 | 197 | ||
201 | /** | 198 | /** |
202 | Deletes all selected contacts from the address book. | 199 | Deletes all selected contacts from the address book. |
203 | */ | 200 | */ |
204 | void deleteContacts(); | 201 | void deleteContacts(); |
205 | 202 | ||
206 | /** | 203 | /** |
207 | Deletes given contacts from the address book. | 204 | Deletes given contacts from the address book. |
208 | 205 | ||
209 | @param uids The uids of the contacts, which shall be deleted. | 206 | @param uids The uids of the contacts, which shall be deleted. |
210 | */ | 207 | */ |
211 | void deleteContacts( const QStringList &uids ); | 208 | void deleteContacts( const QStringList &uids ); |
212 | 209 | ||
213 | /** | 210 | /** |
214 | Copys the selected contacts into clipboard for later pasting. | 211 | Copys the selected contacts into clipboard for later pasting. |
215 | */ | 212 | */ |
216 | void copyContacts(); | 213 | void copyContacts(); |
217 | 214 | ||
218 | /** | 215 | /** |
219 | Cuts the selected contacts and stores them for later pasting. | 216 | Cuts the selected contacts and stores them for later pasting. |
220 | */ | 217 | */ |
221 | void cutContacts(); | 218 | void cutContacts(); |
222 | 219 | ||
223 | /** | 220 | /** |
224 | Paste contacts from clipboard into the address book. | 221 | Paste contacts from clipboard into the address book. |
225 | */ | 222 | */ |
226 | void pasteContacts(); | 223 | void pasteContacts(); |
227 | 224 | ||
228 | /** | 225 | /** |
229 | Paste given contacts into the address book. | 226 | Paste given contacts into the address book. |
230 | 227 | ||
231 | @param list The list of addressee, which shall be pasted. | 228 | @param list The list of addressee, which shall be pasted. |
232 | */ | 229 | */ |
233 | void pasteContacts( KABC::Addressee::List &list ); | 230 | void pasteContacts( KABC::Addressee::List &list ); |
234 | 231 | ||
235 | /** | 232 | /** |
236 | Sets the whoAmI contact, that is used by many other programs to | 233 | Sets the whoAmI contact, that is used by many other programs to |
237 | get personal information about the current user. | 234 | get personal information about the current user. |
238 | */ | 235 | */ |
239 | void setWhoAmI(); | 236 | void setWhoAmI(); |
240 | 237 | ||
241 | /** | 238 | /** |
242 | Displays the category dialog and applies the result to all | 239 | Displays the category dialog and applies the result to all |
243 | selected contacts. | 240 | selected contacts. |
244 | */ | 241 | */ |
245 | void setCategories(); | 242 | void setCategories(); |
246 | void manageCategories(); | 243 | void manageCategories(); |
247 | void editCategories(); | 244 | void editCategories(); |
248 | 245 | ||
249 | /** | 246 | /** |
250 | Sets the field list of the Incremental Search Widget. | 247 | Sets the field list of the Incremental Search Widget. |
251 | */ | 248 | */ |
252 | void setSearchFields( const KABC::Field::List &fields ); | 249 | void setSearchFields( const KABC::Field::List &fields ); |
253 | 250 | ||
254 | /** | 251 | /** |
255 | Search with the current search field for a contact, that matches | 252 | Search with the current search field for a contact, that matches |
256 | the given text, and selects it in the view. | 253 | the given text, and selects it in the view. |
257 | */ | 254 | */ |
258 | void incrementalSearch( const QString& text ); | 255 | void incrementalSearch( const QString& text ); |
259 | 256 | ||
260 | /** | 257 | /** |
261 | Marks the address book as modified. | 258 | Marks the address book as modified. |
262 | */ | 259 | */ |
263 | void setModified(); | 260 | void setModified(); |
264 | /** | 261 | /** |
265 | Marks the address book as modified without refreshing the view. | 262 | Marks the address book as modified without refreshing the view. |
266 | */ | 263 | */ |
267 | void setModifiedWOrefresh(); | 264 | void setModifiedWOrefresh(); |
268 | 265 | ||
269 | /** | 266 | /** |
270 | Marks the address book as modified concerning the argument. | 267 | Marks the address book as modified concerning the argument. |
271 | */ | 268 | */ |
272 | void setModified( bool modified ); | 269 | void setModified( bool modified ); |
273 | 270 | ||
274 | /** | 271 | /** |
275 | Returns whether the address book is modified. | 272 | Returns whether the address book is modified. |
276 | */ | 273 | */ |
277 | bool modified() const; | 274 | bool modified() const; |
278 | 275 | ||
279 | /** | 276 | /** |
280 | Called whenever an contact is modified in the contact editor | 277 | Called whenever an contact is modified in the contact editor |
281 | dialog or the quick edit. | 278 | dialog or the quick edit. |
282 | */ | 279 | */ |
283 | void contactModified( const KABC::Addressee &addr ); | 280 | void contactModified( const KABC::Addressee &addr ); |
284 | 281 | ||
285 | /** | 282 | /** |
286 | DCOP METHODS. | 283 | DCOP METHODS. |
287 | */ | 284 | */ |
288 | void addEmail( QString addr ); | 285 | void addEmail( QString addr ); |
289 | void importVCard( const KURL& url, bool showPreview ); | 286 | void importVCard( const KURL& url, bool showPreview ); |
290 | void importVCard( const QString& vCard, bool showPreview ); | 287 | void importVCard( const QString& vCard, bool showPreview ); |
291 | void newContact(); | 288 | void newContact(); |
292 | QString getNameByPhone( const QString& phone ); | 289 | QString getNameByPhone( const QString& phone ); |
293 | /** | 290 | /** |
294 | END DCOP METHODS | 291 | END DCOP METHODS |
295 | */ | 292 | */ |
296 | 293 | ||
297 | /** | 294 | /** |
298 | Saves the contents of the AddressBook back to disk. | 295 | Saves the contents of the AddressBook back to disk. |
299 | */ | 296 | */ |
300 | void save(); | 297 | void save(); |
301 | 298 | ||
302 | /** | 299 | /** |
303 | Undos the last command using the undo stack. | 300 | Undos the last command using the undo stack. |
304 | */ | 301 | */ |
305 | void undo(); | 302 | void undo(); |
306 | 303 | ||
307 | /** | 304 | /** |
308 | Redos the last command that was undone, using the redo stack. | 305 | Redos the last command that was undone, using the redo stack. |
309 | */ | 306 | */ |
310 | void redo(); | 307 | void redo(); |
311 | 308 | ||
312 | /** | 309 | /** |
313 | Shows the edit dialog for the given uid. If the uid is QString::null, | 310 | Shows the edit dialog for the given uid. If the uid is QString::null, |
314 | the method will try to find a selected addressee in the view. | 311 | the method will try to find a selected addressee in the view. |
315 | */ | 312 | */ |
316 | void editContact( const QString &uid /*US = QString::null*/ ); | 313 | void editContact( const QString &uid /*US = QString::null*/ ); |
317 | //US added a second method without defaultparameter | 314 | //US added a second method without defaultparameter |
318 | void editContact2(); | 315 | void editContact2(); |
319 | 316 | ||
320 | /** | 317 | /** |
321 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 318 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
322 | the method will try to find a selected addressee in the view. | 319 | the method will try to find a selected addressee in the view. |
323 | */ | 320 | */ |
324 | void executeContact( const QString &uid /*US = QString::null*/ ); | 321 | void executeContact( const QString &uid /*US = QString::null*/ ); |
325 | 322 | ||
326 | /** | 323 | /** |
327 | Launches the configuration dialog. | 324 | Launches the configuration dialog. |
328 | */ | 325 | */ |
329 | void openConfigDialog(); | 326 | void openConfigDialog(); |
330 | 327 | ||
331 | /** | 328 | /** |
332 | Launches the ldap search dialog. | 329 | Launches the ldap search dialog. |
333 | */ | 330 | */ |
334 | void openLDAPDialog(); | 331 | void openLDAPDialog(); |
335 | 332 | ||
336 | /** | 333 | /** |
337 | Creates a KAddressBookPrinter, which will display the print | 334 | Creates a KAddressBookPrinter, which will display the print |
338 | dialog and do the printing. | 335 | dialog and do the printing. |
339 | */ | 336 | */ |
340 | void print(); | 337 | void print(); |
341 | 338 | ||
342 | /** | 339 | /** |
343 | Registers a new GUI client, so plugins can register its actions. | 340 | Registers a new GUI client, so plugins can register its actions. |
344 | */ | 341 | */ |
345 | void addGUIClient( KXMLGUIClient *client ); | 342 | void addGUIClient( KXMLGUIClient *client ); |
346 | 343 | ||
347 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 344 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
348 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 345 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
349 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 346 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
350 | 347 | ||
351 | 348 | ||
352 | signals: | 349 | signals: |
353 | void contactSelected( const QString &name ); | 350 | void contactSelected( const QString &name ); |
354 | void contactSelected( const QPixmap &pixmap ); | 351 | void contactSelected( const QPixmap &pixmap ); |
355 | public slots: | 352 | public slots: |
356 | void recieve(QString cmsg ); | 353 | void recieve(QString cmsg ); |
357 | void getFile( bool success ); | 354 | void getFile( bool success ); |
358 | void syncFileRequest(); | 355 | void syncFileRequest(); |
359 | void setDetailsVisible( bool visible ); | 356 | void setDetailsVisible( bool visible ); |
360 | void setDetailsToState(); | 357 | void setDetailsToState(); |
361 | // void slotSyncMenu( int ); | 358 | |
359 | void saveSettings(); | ||
360 | |||
362 | private slots: | 361 | private slots: |
363 | void updateToolBar(); | 362 | void updateToolBar(); |
364 | void updateMainWindow(); | 363 | void updateMainWindow(); |
365 | void receive( const QCString& cmsg, const QByteArray& data ); | 364 | void receive( const QCString& cmsg, const QByteArray& data ); |
366 | void toggleBeamReceive( ); | 365 | void toggleBeamReceive( ); |
367 | void disableBR(bool); | 366 | void disableBR(bool); |
368 | void setJumpButtonBarVisible( bool visible ); | 367 | void setJumpButtonBarVisible( bool visible ); |
369 | void setCaptionBack(); | 368 | void setCaptionBack(); |
370 | void importFromOL(); | 369 | void importFromOL(); |
371 | void extensionModified( const KABC::Addressee::List &list ); | 370 | void extensionModified( const KABC::Addressee::List &list ); |
372 | void extensionChanged( int id ); | 371 | void extensionChanged( int id ); |
373 | void clipboardDataChanged(); | 372 | void clipboardDataChanged(); |
374 | void updateActionMenu(); | 373 | void updateActionMenu(); |
375 | void configureKeyBindings(); | 374 | void configureKeyBindings(); |
376 | void removeVoice(); | 375 | void removeVoice(); |
377 | #ifdef KAB_EMBEDDED | 376 | #ifdef KAB_EMBEDDED |
378 | void configureResources(); | 377 | void configureResources(); |
379 | #endif //KAB_EMBEDDED | 378 | #endif //KAB_EMBEDDED |
380 | 379 | ||
381 | void slotEditorDestroyed( const QString &uid ); | 380 | void slotEditorDestroyed( const QString &uid ); |
382 | void configurationChanged(); | 381 | void configurationChanged(); |
383 | void addressBookChanged(); | 382 | void addressBookChanged(); |
384 | 383 | ||
385 | private: | 384 | private: |
386 | void resizeEvent(QResizeEvent* e ); | 385 | void resizeEvent(QResizeEvent* e ); |
387 | bool mBRdisabled; | 386 | bool mBRdisabled; |
388 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
389 | QCopChannel* infrared; | 388 | QCopChannel* infrared; |
390 | #endif | 389 | #endif |
391 | QTimer *mMessageTimer; | 390 | QTimer *mMessageTimer; |
392 | void initGUI(); | 391 | void initGUI(); |
393 | void initActions(); | 392 | void initActions(); |
394 | QString getPhoneFile(); | 393 | QString getPhoneFile(); |
395 | 394 | ||
396 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 395 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
397 | const char *name = 0 ); | 396 | const char *name = 0 ); |
398 | 397 | ||
399 | KXMLGUIClient *mGUIClient; | 398 | KXMLGUIClient *mGUIClient; |
400 | 399 | ||
401 | KABC::AddressBook *mAddressBook; | 400 | KABC::AddressBook *mAddressBook; |
402 | 401 | ||
403 | ViewManager *mViewManager; | 402 | ViewManager *mViewManager; |
404 | // QSplitter *mDetailsSplitter; | 403 | // QSplitter *mDetailsSplitter; |
405 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 404 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
406 | ViewContainer *mDetails; | 405 | ViewContainer *mDetails; |
407 | KDGanttMinimizeSplitter* mMiniSplitter; | 406 | KDGanttMinimizeSplitter* mMiniSplitter; |
408 | XXPortManager *mXXPortManager; | 407 | XXPortManager *mXXPortManager; |
409 | JumpButtonBar *mJumpButtonBar; | 408 | JumpButtonBar *mJumpButtonBar; |
410 | IncSearchWidget *mIncSearchWidget; | 409 | IncSearchWidget *mIncSearchWidget; |
411 | ExtensionManager *mExtensionManager; | 410 | ExtensionManager *mExtensionManager; |
412 | 411 | ||
413 | KCMultiDialog *mConfigureDialog; | 412 | KCMultiDialog *mConfigureDialog; |
414 | 413 | ||
415 | #ifndef KAB_EMBEDDED | 414 | #ifndef KAB_EMBEDDED |
416 | LDAPSearchDialog *mLdapSearchDialog; | 415 | LDAPSearchDialog *mLdapSearchDialog; |
417 | #endif //KAB_EMBEDDED | 416 | #endif //KAB_EMBEDDED |
418 | // QDict<AddresseeEditorDialog> mEditorDict; | 417 | // QDict<AddresseeEditorDialog> mEditorDict; |
419 | AddresseeEditorDialog *mEditorDialog; | 418 | AddresseeEditorDialog *mEditorDialog; |
420 | bool mReadWrite; | 419 | bool mReadWrite; |
421 | bool mModified; | 420 | bool mModified; |
422 | bool mIsPart; | 421 | bool mIsPart; |
423 | bool mMultipleViewsAtOnce; | 422 | bool mMultipleViewsAtOnce; |
424 | 423 | ||
425 | 424 | ||
426 | //US file menu | 425 | //US file menu |
427 | KAction *mActionMail; | 426 | KAction *mActionMail; |
428 | KAction *mActionBeam; | 427 | KAction *mActionBeam; |
429 | KToggleAction *mActionBR; | 428 | KToggleAction *mActionBR; |
430 | KAction *mActionExport2phone; | 429 | KAction *mActionExport2phone; |
431 | KAction* mActionPrint; | 430 | KAction* mActionPrint; |
432 | KAction* mActionNewContact; | 431 | KAction* mActionNewContact; |
433 | KAction *mActionSave; | 432 | KAction *mActionSave; |
434 | KAction *mActionEditAddressee; | 433 | KAction *mActionEditAddressee; |
435 | KAction *mActionMailVCard; | 434 | KAction *mActionMailVCard; |
436 | KAction *mActionBeamVCard; | 435 | KAction *mActionBeamVCard; |
437 | 436 | ||
438 | KAction *mActionQuit; | 437 | KAction *mActionQuit; |
439 | 438 | ||
440 | //US edit menu | 439 | //US edit menu |
441 | KAction *mActionCopy; | 440 | KAction *mActionCopy; |
442 | KAction *mActionCut; | 441 | KAction *mActionCut; |
443 | KAction *mActionPaste; | 442 | KAction *mActionPaste; |
444 | KAction *mActionSelectAll; | 443 | KAction *mActionSelectAll; |
445 | KAction *mActionUndo; | 444 | KAction *mActionUndo; |
446 | KAction *mActionRedo; | 445 | KAction *mActionRedo; |
447 | KAction *mActionDelete; | 446 | KAction *mActionDelete; |
448 | 447 | ||
449 | //US settings menu | 448 | //US settings menu |
450 | KAction *mActionConfigResources; | 449 | KAction *mActionConfigResources; |
451 | KAction *mActionConfigKAddressbook; | 450 | KAction *mActionConfigKAddressbook; |
452 | KAction *mActionConfigShortcuts; | 451 | KAction *mActionConfigShortcuts; |
453 | KAction *mActionConfigureToolbars; | 452 | KAction *mActionConfigureToolbars; |
454 | KAction *mActionKeyBindings; | 453 | KAction *mActionKeyBindings; |
455 | KToggleAction *mActionJumpBar; | 454 | KToggleAction *mActionJumpBar; |
456 | KToggleAction *mActionDetails; | 455 | KToggleAction *mActionDetails; |
457 | KAction *mActionWhoAmI; | 456 | KAction *mActionWhoAmI; |
458 | KAction *mActionCategories; | 457 | KAction *mActionCategories; |
459 | KAction *mActionEditCategories; | 458 | KAction *mActionEditCategories; |
460 | KAction *mActionManageCategories; | 459 | KAction *mActionManageCategories; |
461 | KAction *mActionAboutKAddressbook; | 460 | KAction *mActionAboutKAddressbook; |
462 | KAction *mActionLicence; | 461 | KAction *mActionLicence; |
463 | KAction *mActionFaq; | 462 | KAction *mActionFaq; |
464 | KAction *mActionWN; | 463 | KAction *mActionWN; |
465 | KAction *mActionSyncHowto; | 464 | KAction *mActionSyncHowto; |
466 | KAction *mActionKdeSyncHowto; | 465 | KAction *mActionKdeSyncHowto; |
467 | KAction *mActionMultiSyncHowto; | 466 | KAction *mActionMultiSyncHowto; |
468 | 467 | ||
469 | KAction *mActionDeleteView; | 468 | KAction *mActionDeleteView; |
470 | 469 | ||
471 | QPopupMenu *viewMenu; | 470 | QPopupMenu *viewMenu; |
472 | QPopupMenu *filterMenu; | 471 | QPopupMenu *filterMenu; |
473 | QPopupMenu *settingsMenu; | 472 | QPopupMenu *settingsMenu; |
474 | QPopupMenu *changeMenu; | 473 | QPopupMenu *changeMenu; |
475 | QPopupMenu *beamMenu; | 474 | QPopupMenu *beamMenu; |
476 | //US QAction *mActionSave; | 475 | //US QAction *mActionSave; |
477 | QPopupMenu *ImportMenu; | 476 | QPopupMenu *ImportMenu; |
478 | QPopupMenu *ExportMenu; | 477 | QPopupMenu *ExportMenu; |
479 | //LR additional methods | 478 | //LR additional methods |
480 | KAction *mActionRemoveVoice; | 479 | KAction *mActionRemoveVoice; |
481 | KAction * mActionImportOL; | 480 | KAction * mActionImportOL; |
482 | 481 | ||
483 | #ifndef KAB_EMBEDDED | 482 | #ifndef KAB_EMBEDDED |
484 | KAddressBookService *mAddressBookService; | 483 | KAddressBookService *mAddressBookService; |
485 | #endif //KAB_EMBEDDED | 484 | #endif //KAB_EMBEDDED |
486 | 485 | ||
487 | class KABCorePrivate; | 486 | class KABCorePrivate; |
488 | KABCorePrivate *d; | 487 | KABCorePrivate *d; |
489 | //US bool mBlockSaveFlag; | 488 | //US bool mBlockSaveFlag; |
490 | 489 | ||
491 | #ifdef KAB_EMBEDDED | 490 | #ifdef KAB_EMBEDDED |
492 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 491 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
493 | #endif //KAB_EMBEDDED | 492 | #endif //KAB_EMBEDDED |
494 | 493 | ||
495 | //this are the overwritten callbackmethods from the syncinterface | 494 | //this are the overwritten callbackmethods from the syncinterface |
496 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 495 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
497 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 496 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
498 | virtual void removeSyncInfo( QString syncProfile); | 497 | virtual void removeSyncInfo( QString syncProfile); |
499 | bool syncPhone(); | 498 | bool syncPhone(); |
500 | void message( QString m ); | 499 | void message( QString m ); |
501 | 500 | ||
502 | // LR ******************************* | 501 | // LR ******************************* |
503 | // sync stuff! | 502 | // sync stuff! |
504 | QString sentSyncFile(); | 503 | QString sentSyncFile(); |
505 | QPopupMenu *syncMenu; | 504 | QPopupMenu *syncMenu; |
506 | KSyncManager* syncManager; | 505 | KSyncManager* syncManager; |
507 | int mGlobalSyncMode; | 506 | int mGlobalSyncMode; |
508 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 507 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
509 | KABC::Addressee getLastSyncAddressee(); | 508 | KABC::Addressee getLastSyncAddressee(); |
510 | QDateTime mLastAddressbookSync; | 509 | QDateTime mLastAddressbookSync; |
511 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 510 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
512 | // ********************* | 511 | // ********************* |
513 | 512 | ||
514 | }; | 513 | }; |
515 | 514 | ||
516 | #endif | 515 | #endif |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 33bef5a..59bddd9 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -224,502 +224,503 @@ void ViewManager::setActiveView( const QString &name ) | |||
224 | KConfig *config = mCore->config(); | 224 | KConfig *config = mCore->config(); |
225 | 225 | ||
226 | KConfigGroupSaver saver( config, name ); | 226 | KConfigGroupSaver saver( config, name ); |
227 | 227 | ||
228 | QString type = config->readEntry( "Type", "Table" ); | 228 | QString type = config->readEntry( "Type", "Table" ); |
229 | 229 | ||
230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
231 | 231 | ||
232 | ViewFactory *factory = mViewFactoryDict.find( type ); | 232 | ViewFactory *factory = mViewFactoryDict.find( type ); |
233 | if ( factory ) | 233 | if ( factory ) |
234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
235 | 235 | ||
236 | if ( view ) { | 236 | if ( view ) { |
237 | view->setCaption( name ); | 237 | view->setCaption( name ); |
238 | mViewDict.insert( name, view ); | 238 | mViewDict.insert( name, view ); |
239 | //US my version needs an int as second parameter to addWidget | 239 | //US my version needs an int as second parameter to addWidget |
240 | mViewWidgetStack->addWidget( view, -1 ); | 240 | mViewWidgetStack->addWidget( view, -1 ); |
241 | view->readConfig( config ); | 241 | view->readConfig( config ); |
242 | 242 | ||
243 | // The manager just relays the signals | 243 | // The manager just relays the signals |
244 | connect( view, SIGNAL( selected( const QString& ) ), | 244 | connect( view, SIGNAL( selected( const QString& ) ), |
245 | SIGNAL( selected( const QString & ) ) ); | 245 | SIGNAL( selected( const QString & ) ) ); |
246 | connect( view, SIGNAL( executed( const QString& ) ), | 246 | connect( view, SIGNAL( executed( const QString& ) ), |
247 | SIGNAL( executed( const QString& ) ) ); | 247 | SIGNAL( executed( const QString& ) ) ); |
248 | 248 | ||
249 | connect( view, SIGNAL( deleteRequest( ) ), | 249 | connect( view, SIGNAL( deleteRequest( ) ), |
250 | SIGNAL( deleteRequest( ) ) ); | 250 | SIGNAL( deleteRequest( ) ) ); |
251 | 251 | ||
252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
254 | SLOT( dropped( QDropEvent* ) ) ); | 254 | SLOT( dropped( QDropEvent* ) ) ); |
255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | // If we found or created the view, raise it and refresh it | 259 | // If we found or created the view, raise it and refresh it |
260 | if ( view ) { | 260 | if ( view ) { |
261 | mActiveView = view; | 261 | mActiveView = view; |
262 | mViewWidgetStack->raiseWidget( view ); | 262 | mViewWidgetStack->raiseWidget( view ); |
263 | // Set the proper filter in the view. By setting the combo | 263 | // Set the proper filter in the view. By setting the combo |
264 | // box, the activated slot will be called, which will push | 264 | // box, the activated slot will be called, which will push |
265 | // the filter to the view and refresh it. | 265 | // the filter to the view and refresh it. |
266 | 266 | ||
267 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 267 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
268 | 268 | ||
269 | mActionSelectFilter->setCurrentItem( 0 ); | 269 | mActionSelectFilter->setCurrentItem( 0 ); |
270 | setActiveFilter( 0 ); | 270 | setActiveFilter( 0 ); |
271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
272 | setActiveFilter( mActionSelectFilter->currentItem() ); | 272 | setActiveFilter( mActionSelectFilter->currentItem() ); |
273 | } else { | 273 | } else { |
274 | uint pos = filterPosition( view->defaultFilterName() ); | 274 | uint pos = filterPosition( view->defaultFilterName() ); |
275 | mActionSelectFilter->setCurrentItem( pos ); | 275 | mActionSelectFilter->setCurrentItem( pos ); |
276 | setActiveFilter( pos ); | 276 | setActiveFilter( pos ); |
277 | } | 277 | } |
278 | //US qDebug("ViewManager::setActiveView 6" ); | 278 | //US qDebug("ViewManager::setActiveView 6" ); |
279 | 279 | ||
280 | // Update the inc search widget to show the fields in the new active | 280 | // Update the inc search widget to show the fields in the new active |
281 | // view. | 281 | // view. |
282 | mCore->setSearchFields( mActiveView->fields() ); | 282 | mCore->setSearchFields( mActiveView->fields() ); |
283 | 283 | ||
284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
285 | //US mActiveView->refresh(); | 285 | //US mActiveView->refresh(); |
286 | 286 | ||
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | qDebug("ViewManager::setActiveView: unable to find view" ); | 290 | qDebug("ViewManager::setActiveView: unable to find view" ); |
291 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 291 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 295 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
296 | void ViewManager::refreshView() | 296 | void ViewManager::refreshView() |
297 | { | 297 | { |
298 | refreshView( QString::null ); | 298 | refreshView( QString::null ); |
299 | } | 299 | } |
300 | 300 | ||
301 | void ViewManager::refreshView( const QString &uid ) | 301 | void ViewManager::refreshView( const QString &uid ) |
302 | { | 302 | { |
303 | if ( mActiveView ) | 303 | if ( mActiveView ) |
304 | mActiveView->refresh( uid ); | 304 | mActiveView->refresh( uid ); |
305 | } | 305 | } |
306 | 306 | ||
307 | void ViewManager::setFocusAV() | 307 | void ViewManager::setFocusAV() |
308 | { | 308 | { |
309 | if ( mActiveView ) | 309 | if ( mActiveView ) |
310 | mActiveView->setFocusAV(); | 310 | mActiveView->setFocusAV(); |
311 | } | 311 | } |
312 | void ViewManager::editView() | 312 | void ViewManager::editView() |
313 | { | 313 | { |
314 | if ( !mActiveView ) | 314 | if ( !mActiveView ) |
315 | return; | 315 | return; |
316 | 316 | ||
317 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 317 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
318 | ViewConfigureWidget *wdg = 0; | 318 | ViewConfigureWidget *wdg = 0; |
319 | ViewConfigureDialog* dlg = 0; | 319 | ViewConfigureDialog* dlg = 0; |
320 | if ( factory ) { | 320 | if ( factory ) { |
321 | // Save the filters so the dialog has the latest set | 321 | // Save the filters so the dialog has the latest set |
322 | Filter::save( mCore->config(), "Filter", mFilterList ); | 322 | Filter::save( mCore->config(), "Filter", mFilterList ); |
323 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 323 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
324 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 324 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
325 | } else { | 325 | } else { |
326 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 326 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | if ( wdg ) { | 329 | if ( wdg ) { |
330 | dlg->setWidget( wdg ); | 330 | dlg->setWidget( wdg ); |
331 | 331 | ||
332 | #ifndef DESKTOP_VERSION | 332 | #ifndef DESKTOP_VERSION |
333 | //dlg.setMaximumSize( 640, 480 ); | 333 | //dlg.setMaximumSize( 640, 480 ); |
334 | //dlg->setGeometry( 40,40, 400, 300); | 334 | //dlg->setGeometry( 40,40, 400, 300); |
335 | dlg->showMaximized(); | 335 | dlg->showMaximized(); |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 338 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
339 | 339 | ||
340 | dlg->restoreSettings( mCore->config() ); | 340 | dlg->restoreSettings( mCore->config() ); |
341 | 341 | ||
342 | if ( dlg->exec() ) { | 342 | if ( dlg->exec() ) { |
343 | dlg->saveSettings( mCore->config() ); | 343 | dlg->saveSettings( mCore->config() ); |
344 | mActiveView->readConfig( mCore->config() ); | 344 | mActiveView->readConfig( mCore->config() ); |
345 | 345 | ||
346 | // Set the proper filter in the view. By setting the combo | 346 | // Set the proper filter in the view. By setting the combo |
347 | // box, the activated slot will be called, which will push | 347 | // box, the activated slot will be called, which will push |
348 | // the filter to the view and refresh it. | 348 | // the filter to the view and refresh it. |
349 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 349 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
350 | mActionSelectFilter->setCurrentItem( 0 ); | 350 | mActionSelectFilter->setCurrentItem( 0 ); |
351 | setActiveFilter( 0 ); | 351 | setActiveFilter( 0 ); |
352 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 352 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
353 | setActiveFilter( mActionSelectFilter->currentItem() ); | 353 | setActiveFilter( mActionSelectFilter->currentItem() ); |
354 | } else { | 354 | } else { |
355 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 355 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
356 | mActionSelectFilter->setCurrentItem( pos ); | 356 | mActionSelectFilter->setCurrentItem( pos ); |
357 | setActiveFilter( pos ); | 357 | setActiveFilter( pos ); |
358 | } | 358 | } |
359 | mCore->setSearchFields( mActiveView->fields() ); | 359 | mCore->setSearchFields( mActiveView->fields() ); |
360 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 360 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
361 | //US mActiveView->refresh(); | 361 | //US mActiveView->refresh(); |
362 | 362 | ||
363 | 363 | ||
364 | //US this is a bugfix, that we get notified if we change a views configuration | 364 | //US this is a bugfix, that we get notified if we change a views configuration |
365 | emit modified(); | 365 | emit modified(); |
366 | 366 | ||
367 | } | 367 | } |
368 | 368 | ||
369 | } | 369 | } |
370 | delete dlg; | 370 | delete dlg; |
371 | } | 371 | } |
372 | 372 | ||
373 | void ViewManager::deleteView() | 373 | void ViewManager::deleteView() |
374 | { | 374 | { |
375 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 375 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
376 | .arg( mActiveView->caption() ); | 376 | .arg( mActiveView->caption() ); |
377 | QString caption = i18n( "Confirm Delete" ); | 377 | QString caption = i18n( "Confirm Delete" ); |
378 | 378 | ||
379 | 379 | ||
380 | if (QMessageBox::information( this, caption, | 380 | if (QMessageBox::information( this, caption, |
381 | text, | 381 | text, |
382 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 382 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
383 | { | 383 | { |
384 | mViewNameList.remove( mActiveView->caption() ); | 384 | mViewNameList.remove( mActiveView->caption() ); |
385 | 385 | ||
386 | // remove the view from the config file | 386 | // remove the view from the config file |
387 | KConfig *config = mCore->config(); | 387 | KConfig *config = mCore->config(); |
388 | config->deleteGroup( mActiveView->caption() ); | 388 | config->deleteGroup( mActiveView->caption() ); |
389 | 389 | ||
390 | mViewDict.remove( mActiveView->caption() ); | 390 | mViewDict.remove( mActiveView->caption() ); |
391 | mActiveView = 0; | 391 | mActiveView = 0; |
392 | 392 | ||
393 | // we are in an invalid state now, but that should be fixed after | 393 | // we are in an invalid state now, but that should be fixed after |
394 | // we emit the signal | 394 | // we emit the signal |
395 | mActionSelectView->setItems( mViewNameList ); | 395 | mActionSelectView->setItems( mViewNameList ); |
396 | if ( mViewNameList.count() > 0 ) { | 396 | if ( mViewNameList.count() > 0 ) { |
397 | mActionSelectView->setCurrentItem( 0 ); | 397 | mActionSelectView->setCurrentItem( 0 ); |
398 | setActiveView( mViewNameList[ 0 ] ); | 398 | setActiveView( mViewNameList[ 0 ] ); |
399 | } | 399 | } |
400 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 400 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | void ViewManager::addView() | 404 | void ViewManager::addView() |
405 | { | 405 | { |
406 | AddViewDialog dialog( &mViewFactoryDict, this ); | 406 | AddViewDialog dialog( &mViewFactoryDict, this ); |
407 | 407 | ||
408 | if ( dialog.exec() ) { | 408 | if ( dialog.exec() ) { |
409 | QString newName = dialog.viewName(); | 409 | QString newName = dialog.viewName(); |
410 | QString type = dialog.viewType(); | 410 | QString type = dialog.viewType(); |
411 | 411 | ||
412 | // Check for name conflicts | 412 | // Check for name conflicts |
413 | bool firstConflict = true; | 413 | bool firstConflict = true; |
414 | int numTries = 1; | 414 | int numTries = 1; |
415 | while ( mViewNameList.contains( newName ) > 0 ) { | 415 | while ( mViewNameList.contains( newName ) > 0 ) { |
416 | if ( !firstConflict ) { | 416 | if ( !firstConflict ) { |
417 | newName = newName.left( newName.length() - 4 ); | 417 | newName = newName.left( newName.length() - 4 ); |
418 | firstConflict = false; | 418 | firstConflict = false; |
419 | } | 419 | } |
420 | 420 | ||
421 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 421 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
422 | numTries++; | 422 | numTries++; |
423 | } | 423 | } |
424 | 424 | ||
425 | // Add the new one to the list | 425 | // Add the new one to the list |
426 | mViewNameList.append( newName ); | 426 | mViewNameList.append( newName ); |
427 | 427 | ||
428 | // write the view to the config file, | 428 | // write the view to the config file, |
429 | KConfig *config = mCore->config(); | 429 | KConfig *config = mCore->config(); |
430 | 430 | ||
431 | config->deleteGroup( newName ); | 431 | config->deleteGroup( newName ); |
432 | 432 | ||
433 | KConfigGroupSaver saver( config, newName ); | 433 | KConfigGroupSaver saver( config, newName ); |
434 | 434 | ||
435 | config->writeEntry( "Type", type ); | 435 | config->writeEntry( "Type", type ); |
436 | 436 | ||
437 | // try to set the active view | 437 | // try to set the active view |
438 | mActionSelectView->setItems( mViewNameList ); | 438 | mActionSelectView->setItems( mViewNameList ); |
439 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 439 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
440 | setActiveView( newName ); | 440 | setActiveView( newName ); |
441 | 441 | ||
442 | editView(); | 442 | editView(); |
443 | 443 | ||
444 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 444 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | void ViewManager::createViewFactories() | 448 | void ViewManager::createViewFactories() |
449 | { | 449 | { |
450 | #ifndef KAB_EMBEDDED | 450 | #ifndef KAB_EMBEDDED |
451 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 451 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
452 | KTrader::OfferList::ConstIterator it; | 452 | KTrader::OfferList::ConstIterator it; |
453 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 453 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
454 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 454 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
455 | continue; | 455 | continue; |
456 | 456 | ||
457 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 457 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
458 | 458 | ||
459 | if ( !factory ) { | 459 | if ( !factory ) { |
460 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 460 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
461 | continue; | 461 | continue; |
462 | } | 462 | } |
463 | 463 | ||
464 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 464 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
465 | 465 | ||
466 | if ( !viewFactory ) { | 466 | if ( !viewFactory ) { |
467 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 467 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
468 | continue; | 468 | continue; |
469 | } | 469 | } |
470 | 470 | ||
471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
472 | } | 472 | } |
473 | 473 | ||
474 | #else //KAB_EMBEDDED | 474 | #else //KAB_EMBEDDED |
475 | ViewFactory* viewFactory = new IconViewFactory(); | 475 | ViewFactory* viewFactory = new IconViewFactory(); |
476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
478 | 478 | ||
479 | viewFactory = new TableViewFactory(); | 479 | viewFactory = new TableViewFactory(); |
480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
482 | 482 | ||
483 | viewFactory = new CardViewFactory(); | 483 | viewFactory = new CardViewFactory(); |
484 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 484 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
485 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 485 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
486 | 486 | ||
487 | #endif //KAB_EMBEDDED | 487 | #endif //KAB_EMBEDDED |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void ViewManager::dropped( QDropEvent *e ) | 491 | void ViewManager::dropped( QDropEvent *e ) |
492 | { | 492 | { |
493 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 493 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
494 | 494 | ||
495 | #ifndef KAB_EMBEDDED | 495 | #ifndef KAB_EMBEDDED |
496 | 496 | ||
497 | QString clipText, vcards; | 497 | QString clipText, vcards; |
498 | KURL::List urls; | 498 | KURL::List urls; |
499 | 499 | ||
500 | if ( KURLDrag::decode( e, urls) ) { | 500 | if ( KURLDrag::decode( e, urls) ) { |
501 | KURL::List::Iterator it = urls.begin(); | 501 | KURL::List::Iterator it = urls.begin(); |
502 | int c = urls.count(); | 502 | int c = urls.count(); |
503 | if ( c > 1 ) { | 503 | if ( c > 1 ) { |
504 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 504 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
505 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 505 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
506 | for ( ; it != urls.end(); ++it ) | 506 | for ( ; it != urls.end(); ++it ) |
507 | emit urlDropped( *it ); | 507 | emit urlDropped( *it ); |
508 | } | 508 | } |
509 | } else if ( c == 1 ) | 509 | } else if ( c == 1 ) |
510 | emit urlDropped( *it ); | 510 | emit urlDropped( *it ); |
511 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 511 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
512 | KABC::Addressee addr; | 512 | KABC::Addressee addr; |
513 | KABC::VCardConverter converter; | 513 | KABC::VCardConverter converter; |
514 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 514 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
515 | QStringList::Iterator it; | 515 | QStringList::Iterator it; |
516 | for ( it = list.begin(); it != list.end(); ++it ) { | 516 | for ( it = list.begin(); it != list.end(); ++it ) { |
517 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 517 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
518 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 518 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
519 | if ( a.isEmpty() ) { | 519 | if ( a.isEmpty() ) { |
520 | mCore->addressBook()->insertAddressee( addr ); | 520 | mCore->addressBook()->insertAddressee( addr ); |
521 | emit modified(); | 521 | emit modified(); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | mActiveView->refresh(); | 526 | mActiveView->refresh(); |
527 | } | 527 | } |
528 | #else //KAB_EMBEDDED | 528 | #else //KAB_EMBEDDED |
529 | qDebug("ViewManager::dropped() has to be changed!!" ); | 529 | qDebug("ViewManager::dropped() has to be changed!!" ); |
530 | #endif //KAB_EMBEDDED | 530 | #endif //KAB_EMBEDDED |
531 | 531 | ||
532 | } | 532 | } |
533 | 533 | ||
534 | void ViewManager::startDrag() | 534 | void ViewManager::startDrag() |
535 | { | 535 | { |
536 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 536 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
537 | 537 | ||
538 | #ifndef KAB_EMBEDDED | 538 | #ifndef KAB_EMBEDDED |
539 | 539 | ||
540 | // Get the list of all the selected addressees | 540 | // Get the list of all the selected addressees |
541 | KABC::Addressee::List addrList; | 541 | KABC::Addressee::List addrList; |
542 | QStringList uidList = selectedUids(); | 542 | QStringList uidList = selectedUids(); |
543 | QStringList::Iterator iter; | 543 | QStringList::Iterator iter; |
544 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 544 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
545 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 545 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
546 | 546 | ||
547 | KMultipleDrag *drag = new KMultipleDrag( this ); | 547 | KMultipleDrag *drag = new KMultipleDrag( this ); |
548 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 548 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
549 | KABC::Addressee::List::Iterator it; | 549 | KABC::Addressee::List::Iterator it; |
550 | QStringList vcards; | 550 | QStringList vcards; |
551 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 551 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
552 | QString vcard = QString::null; | 552 | QString vcard = QString::null; |
553 | KABC::VCardConverter converter; | 553 | KABC::VCardConverter converter; |
554 | if ( converter.addresseeToVCard( *it, vcard ) ) | 554 | if ( converter.addresseeToVCard( *it, vcard ) ) |
555 | vcards.append( vcard ); | 555 | vcards.append( vcard ); |
556 | } | 556 | } |
557 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 557 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
558 | 558 | ||
559 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 559 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
560 | drag->dragCopy(); | 560 | drag->dragCopy(); |
561 | 561 | ||
562 | #else //KAB_EMBEDDED | 562 | #else //KAB_EMBEDDED |
563 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 563 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
564 | #endif //KAB_EMBEDDED | 564 | #endif //KAB_EMBEDDED |
565 | 565 | ||
566 | } | 566 | } |
567 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 567 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
568 | { | 568 | { |
569 | if ( mActiveView ) | 569 | if ( mActiveView ) |
570 | mActiveView->doSearch( s, field ); | 570 | mActiveView->doSearch( s, field ); |
571 | 571 | ||
572 | } | 572 | } |
573 | void ViewManager::setActiveFilter( int index ) | 573 | void ViewManager::setActiveFilter( int index ) |
574 | { | 574 | { |
575 | Filter currentFilter; | 575 | Filter currentFilter; |
576 | 576 | ||
577 | if ( ( index - 1 ) < 0 ) | 577 | if ( ( index - 1 ) < 0 ) |
578 | currentFilter = Filter(); | 578 | currentFilter = Filter(); |
579 | else | 579 | else |
580 | currentFilter = mFilterList[ index - 1 ]; | 580 | currentFilter = mFilterList[ index - 1 ]; |
581 | 581 | ||
582 | // Check if we have a view. Since the filter combo is created before | 582 | // Check if we have a view. Since the filter combo is created before |
583 | // the view, this slot could be called before there is a valid view. | 583 | // the view, this slot could be called before there is a valid view. |
584 | if ( mActiveView ) { | 584 | if ( mActiveView ) { |
585 | mActiveView->setFilter( currentFilter ); | 585 | mActiveView->setFilter( currentFilter ); |
586 | mActiveView->refresh(); | 586 | mActiveView->refresh(); |
587 | emit selected( QString::null ); | 587 | emit selected( QString::null ); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void ViewManager::configureFilters() | 591 | void ViewManager::configureFilters() |
592 | { | 592 | { |
593 | FilterDialog dlg( this ); | 593 | FilterDialog dlg( this ); |
594 | 594 | ||
595 | dlg.setFilters( mFilterList ); | 595 | dlg.setFilters( mFilterList ); |
596 | 596 | ||
597 | if ( dlg.exec() ) | 597 | if ( dlg.exec() ) |
598 | mFilterList = dlg.filters(); | 598 | mFilterList = dlg.filters(); |
599 | 599 | ||
600 | uint pos = mActionSelectFilter->currentItem(); | 600 | uint pos = mActionSelectFilter->currentItem(); |
601 | mActionSelectFilter->setItems( filterNames() ); | 601 | mActionSelectFilter->setItems( filterNames() ); |
602 | mActionSelectFilter->setCurrentItem( pos ); | 602 | mActionSelectFilter->setCurrentItem( pos ); |
603 | setActiveFilter( pos ); | 603 | setActiveFilter( pos ); |
604 | int cw = 150; | 604 | int cw = 150; |
605 | if (QApplication::desktop()->width() == 480 ) | 605 | if (QApplication::desktop()->width() == 480 ) |
606 | cw = 0; | 606 | cw = 0; |
607 | mActionSelectFilter->setComboWidth( cw ); | 607 | mActionSelectFilter->setComboWidth( cw ); |
608 | saveSettings(); | ||
608 | } | 609 | } |
609 | 610 | ||
610 | QStringList ViewManager::filterNames() const | 611 | QStringList ViewManager::filterNames() const |
611 | { | 612 | { |
612 | QStringList names( i18n( "No Filter" ) ); | 613 | QStringList names( i18n( "No Filter" ) ); |
613 | 614 | ||
614 | Filter::List::ConstIterator it; | 615 | Filter::List::ConstIterator it; |
615 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 616 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
616 | names.append( (*it).name() ); | 617 | names.append( (*it).name() ); |
617 | 618 | ||
618 | return names; | 619 | return names; |
619 | } | 620 | } |
620 | 621 | ||
621 | int ViewManager::filterPosition( const QString &name ) const | 622 | int ViewManager::filterPosition( const QString &name ) const |
622 | { | 623 | { |
623 | int pos = 0; | 624 | int pos = 0; |
624 | 625 | ||
625 | Filter::List::ConstIterator it; | 626 | Filter::List::ConstIterator it; |
626 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 627 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
627 | if ( name == (*it).name() ) | 628 | if ( name == (*it).name() ) |
628 | return pos + 1; | 629 | return pos + 1; |
629 | 630 | ||
630 | return 0; | 631 | return 0; |
631 | } | 632 | } |
632 | 633 | ||
633 | void ViewManager::initActions() | 634 | void ViewManager::initActions() |
634 | { | 635 | { |
635 | //US <ActionList name="view_loadedviews"/> | 636 | //US <ActionList name="view_loadedviews"/> |
636 | //US <Separator/> | 637 | //US <Separator/> |
637 | 638 | ||
638 | #ifdef KAB_EMBEDDED | 639 | #ifdef KAB_EMBEDDED |
639 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 640 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
640 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 641 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
641 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 642 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
642 | #endif //KAB_EMBEDDED | 643 | #endif //KAB_EMBEDDED |
643 | 644 | ||
644 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 645 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
645 | #if KDE_VERSION >= 309 | 646 | #if KDE_VERSION >= 309 |
646 | mActionSelectView->setMenuAccelsEnabled( false ); | 647 | mActionSelectView->setMenuAccelsEnabled( false ); |
647 | #endif | 648 | #endif |
648 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 649 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
649 | SLOT( setActiveView( const QString& ) ) ); | 650 | SLOT( setActiveView( const QString& ) ) ); |
650 | 651 | ||
651 | 652 | ||
652 | #ifdef KAB_EMBEDDED | 653 | #ifdef KAB_EMBEDDED |
653 | mActionSelectView->plug(viewmenu); | 654 | mActionSelectView->plug(viewmenu); |
654 | viewmenu->insertSeparator(); | 655 | viewmenu->insertSeparator(); |
655 | #endif //KAB_EMBEDDED | 656 | #endif //KAB_EMBEDDED |
656 | 657 | ||
657 | KAction *action; | 658 | KAction *action; |
658 | 659 | ||
659 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 660 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
660 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 661 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
661 | #ifndef KAB_EMBEDDED | 662 | #ifndef KAB_EMBEDDED |
662 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 663 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
663 | #else //KAB_EMBEDDED | 664 | #else //KAB_EMBEDDED |
664 | action->plug(viewmenu); | 665 | action->plug(viewmenu); |
665 | #endif //KAB_EMBEDDED | 666 | #endif //KAB_EMBEDDED |
666 | 667 | ||
667 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 668 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
668 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 669 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
669 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
670 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 671 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
671 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
672 | action->plug(viewmenu); | 673 | action->plug(viewmenu); |
673 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
674 | 675 | ||
675 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 676 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
676 | this, SLOT( deleteView() ), | 677 | this, SLOT( deleteView() ), |
677 | mCore->actionCollection(), "view_delete" ); | 678 | mCore->actionCollection(), "view_delete" ); |
678 | #ifndef KAB_EMBEDDED | 679 | #ifndef KAB_EMBEDDED |
679 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 680 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
680 | #else //KAB_EMBEDDED | 681 | #else //KAB_EMBEDDED |
681 | mActionDeleteView->plug(viewmenu); | 682 | mActionDeleteView->plug(viewmenu); |
682 | viewmenu->insertSeparator(); | 683 | viewmenu->insertSeparator(); |
683 | #endif //KAB_EMBEDDED | 684 | #endif //KAB_EMBEDDED |
684 | 685 | ||
685 | #ifndef KAB_EMBEDDED | 686 | #ifndef KAB_EMBEDDED |
686 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 687 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
687 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 688 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
688 | "view_refresh" ); | 689 | "view_refresh" ); |
689 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 690 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
690 | #else //KAB_EMBEDDED | 691 | #else //KAB_EMBEDDED |
691 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 692 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
692 | SLOT( refreshView()), mCore->actionCollection(), | 693 | SLOT( refreshView()), mCore->actionCollection(), |
693 | "view_refresh" ); | 694 | "view_refresh" ); |
694 | action->plug(viewmenu); | 695 | action->plug(viewmenu); |
695 | viewmenu->insertSeparator(); | 696 | viewmenu->insertSeparator(); |
696 | #endif //KAB_EMBEDDED | 697 | #endif //KAB_EMBEDDED |
697 | 698 | ||
698 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 699 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
699 | SLOT( configureFilters() ), mCore->actionCollection(), | 700 | SLOT( configureFilters() ), mCore->actionCollection(), |
700 | "options_edit_filters" ); | 701 | "options_edit_filters" ); |
701 | 702 | ||
702 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 703 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
703 | #if KDE_VERSION >= 309 | 704 | #if KDE_VERSION >= 309 |
704 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 705 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
705 | #endif | 706 | #endif |
706 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 707 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
707 | SLOT( setActiveFilter( int ) ) ); | 708 | SLOT( setActiveFilter( int ) ) ); |
708 | 709 | ||
709 | #ifdef KAB_EMBEDDED | 710 | #ifdef KAB_EMBEDDED |
710 | action->plug(settingsmenu); | 711 | action->plug(settingsmenu); |
711 | mActionSelectFilter->plug(viewmenu); | 712 | mActionSelectFilter->plug(viewmenu); |
712 | #endif //KAB_EMBEDDED | 713 | #endif //KAB_EMBEDDED |
713 | 714 | ||
714 | } | 715 | } |
715 | 716 | ||
716 | void ViewManager::initGUI() | 717 | void ViewManager::initGUI() |
717 | { | 718 | { |
718 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 719 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
719 | mViewWidgetStack = new QWidgetStack( this ); | 720 | mViewWidgetStack = new QWidgetStack( this ); |
720 | layout->addWidget( mViewWidgetStack ); | 721 | layout->addWidget( mViewWidgetStack ); |
721 | } | 722 | } |
722 | 723 | ||
723 | #ifndef KAB_EMBEDDED | 724 | #ifndef KAB_EMBEDDED |
724 | #include "viewmanager.moc" | 725 | #include "viewmanager.moc" |
725 | #endif //KAB_EMBEDDED | 726 | #endif //KAB_EMBEDDED |
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp index 1ee64f5..9ad78e5 100644 --- a/kde2file/abdump/main.cpp +++ b/kde2file/abdump/main.cpp | |||
@@ -1,195 +1,193 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * main.cpp * | 2 | * main.cpp * |
3 | * * | 3 | * * |
4 | * | 4 | * |
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 | ******************************************************************************/ | 24 | ******************************************************************************/ |
25 | 25 | ||
26 | #include <kcmdlineargs.h> | 26 | #include <kcmdlineargs.h> |
27 | #include <kaboutdata.h> | 27 | #include <kaboutdata.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kstandarddirs.h> | 31 | #include <kstandarddirs.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | 33 | ||
34 | #include <kabc/addressbook.h> | 34 | #include <kabc/addressbook.h> |
35 | #include <kabc/stdaddressbook.h> | 35 | #include <kabc/stdaddressbook.h> |
36 | #include <kabc/resource.h> | 36 | #include <kabc/resource.h> |
37 | #include <kabc/vcardconverter.h> | 37 | #include <kabc/vcardconverter.h> |
38 | 38 | ||
39 | #include <qdatetime.h> | 39 | #include <qdatetime.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qapplication.h> | 42 | #include <qapplication.h> |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <iostream> | 45 | #include <iostream> |
46 | 46 | ||
47 | using namespace std; | 47 | using namespace std; |
48 | 48 | ||
49 | static const char progName[] = "kdecalendar"; | 49 | static const char progName[] = "kdecalendar"; |
50 | static const char progDisplay[] = "KDE_Addressbook"; | 50 | static const char progDisplay[] = "KDE_Addressbook"; |
51 | static const char progVersion[] = "33.1/3"; | 51 | static const char progVersion[] = "33.1/3"; |
52 | static const char progDesc[] = "A command line interface to KDE addressbooks"; | 52 | static const char progDesc[] = "A command line interface to KDE addressbooks"; |
53 | 53 | ||
54 | 54 | ||
55 | static KCmdLineOptions options[] = | 55 | static KCmdLineOptions options[] = |
56 | { | 56 | { |
57 | { "dump", | 57 | { "dump", |
58 | I18N_NOOP( "Dumps addressbook" ), 0 }, | 58 | I18N_NOOP( "Dumps addressbook" ), 0 }, |
59 | { "read", | 59 | { "read", |
60 | I18N_NOOP( "Reads addressbook" ), 0 }, | 60 | I18N_NOOP( "Reads addressbook" ), 0 }, |
61 | KCmdLineLastOption | 61 | KCmdLineLastOption |
62 | }; | 62 | }; |
63 | 63 | ||
64 | int main( int argc, char *argv[] ) | 64 | int main( int argc, char *argv[] ) |
65 | { | 65 | { |
66 | KAboutData aboutData( | 66 | KAboutData aboutData( |
67 | progName, // internal program name | 67 | progName, // internal program name |
68 | I18N_NOOP( progDisplay ), // displayable program name. | 68 | I18N_NOOP( progDisplay ), // displayable program name. |
69 | progVersion, // version string | 69 | progVersion, // version string |
70 | I18N_NOOP( progDesc ), // short porgram description | 70 | I18N_NOOP( progDesc ), // short porgram description |
71 | KAboutData::License_GPL, // license type | 71 | KAboutData::License_GPL, // license type |
72 | "(c) 2004, Lutz Rogowski", // copyright statement | 72 | "(c) 2004, Lutz Rogowski", // copyright statement |
73 | 0, // any free form text | 73 | 0, // any free form text |
74 | "", // program home page address | 74 | "", // program home page address |
75 | "bugs.kde.org" // bug report email address | 75 | "bugs.kde.org" // bug report email address |
76 | ); | 76 | ); |
77 | 77 | ||
78 | 78 | ||
79 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options | 79 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options |
80 | // for QApplication/KApplication (no KDE or Qt options) | 80 | // for QApplication/KApplication (no KDE or Qt options) |
81 | KCmdLineArgs::init( argc, argv, &aboutData, true ); | 81 | KCmdLineArgs::init( argc, argv, &aboutData, true ); |
82 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. | 82 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. |
83 | 83 | ||
84 | KInstance ins ( progName ); | 84 | KInstance ins ( progName ); |
85 | 85 | ||
86 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 86 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
87 | 87 | ||
88 | bool read = false; | 88 | bool read = false; |
89 | if ( args->isSet( "read" ) ) { | 89 | if ( args->isSet( "read" ) ) { |
90 | read = true; | 90 | read = true; |
91 | qDebug("read "); | 91 | qDebug("read "); |
92 | } | 92 | } |
93 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 93 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
94 | 94 | ||
95 | KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); | 95 | KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); |
96 | standardAddressBook->setAutomaticSave( false ); | 96 | standardAddressBook->setAutomaticSave( false ); |
97 | qDebug("************************************* "); | 97 | qDebug("************************************* "); |
98 | qDebug("***************kdeABdump************* "); | 98 | qDebug("***************kdeABdump************* "); |
99 | qDebug("************************************* "); | 99 | qDebug("************************************* "); |
100 | if ( !read ) { | 100 | if ( !read ) { |
101 | KABC::AddressBook::Iterator it; | 101 | KABC::AddressBook::Iterator it; |
102 | KABC::VCardConverter converter; | 102 | KABC::VCardConverter converter; |
103 | QString datastream; | 103 | QString datastream; |
104 | for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { | 104 | for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { |
105 | if ( (*it).isEmpty() || ! (*it).resource() ) | 105 | if ( (*it).isEmpty() || ! (*it).resource() ) |
106 | continue; | 106 | continue; |
107 | if ( (*it).resource()->readOnly() ) | ||
108 | continue; | ||
109 | KABC::Addressee a = ( *it ); | 107 | KABC::Addressee a = ( *it ); |
110 | QString vcard = converter.createVCard( a ); | 108 | QString vcard = converter.createVCard( a ); |
111 | vcard += QString("\r\n"); | 109 | vcard += QString("\r\n"); |
112 | datastream += vcard; | 110 | datastream += vcard; |
113 | } | 111 | } |
114 | QFile outFile(fileName); | 112 | QFile outFile(fileName); |
115 | if ( outFile.open(IO_WriteOnly) ) { | 113 | if ( outFile.open(IO_WriteOnly) ) { |
116 | QTextStream t( &outFile ); // use a text stream | 114 | QTextStream t( &outFile ); // use a text stream |
117 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 115 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
118 | t <<datastream; | 116 | t <<datastream; |
119 | t << "\r\n\r\n"; | 117 | t << "\r\n\r\n"; |
120 | outFile.close(); | 118 | outFile.close(); |
121 | } | 119 | } |
122 | } else { | 120 | } else { |
123 | //Addressee::List aList;//parseVCards( const QString& vcard ); | 121 | //Addressee::List aList;//parseVCards( const QString& vcard ); |
124 | KABC::Addressee::List list; | 122 | KABC::Addressee::List list; |
125 | int added = 0, changedC = 0, deleted = 0; | 123 | int added = 0, changedC = 0, deleted = 0; |
126 | QFile file( fileName ); | 124 | QFile file( fileName ); |
127 | if ( file.open( IO_ReadOnly ) ) { | 125 | if ( file.open( IO_ReadOnly ) ) { |
128 | QTextStream t( &file ); // use a text stream | 126 | QTextStream t( &file ); // use a text stream |
129 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 127 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
130 | QString data; | 128 | QString data; |
131 | data = t.read(); | 129 | data = t.read(); |
132 | file.close(); | 130 | file.close(); |
133 | KABC::VCardConverter converter; | 131 | KABC::VCardConverter converter; |
134 | list = converter.parseVCards( data ); | 132 | list = converter.parseVCards( data ); |
135 | qDebug("kdeABdump::file has %d entries", list.count()); | 133 | qDebug("kdeABdump::file has %d entries", list.count()); |
136 | 134 | ||
137 | KABC::Addressee::List::Iterator it; | 135 | KABC::Addressee::List::Iterator it; |
138 | for ( it = list.begin();it != list.end();++it) { | 136 | for ( it = list.begin();it != list.end();++it) { |
139 | (*it).setChanged( true ); | 137 | (*it).setChanged( true ); |
140 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); | 138 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); |
141 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 139 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
142 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); | 140 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); |
143 | if ( changed ) { | 141 | if ( changed ) { |
144 | //qDebug("changed Addressee found! "); | 142 | //qDebug("changed Addressee found! "); |
145 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 143 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
146 | if ( ! std.isEmpty() ) | 144 | if ( ! std.isEmpty() ) |
147 | (*it).setResource(std.resource()); | 145 | (*it).setResource(std.resource()); |
148 | standardAddressBook->insertAddressee( (*it) ); | 146 | standardAddressBook->insertAddressee( (*it) ); |
149 | ++changedC; | 147 | ++changedC; |
150 | } else { | 148 | } else { |
151 | //maybe added? | 149 | //maybe added? |
152 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 150 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
153 | if ( std.isEmpty() ) { | 151 | if ( std.isEmpty() ) { |
154 | standardAddressBook->insertAddressee( (*it) ); | 152 | standardAddressBook->insertAddressee( (*it) ); |
155 | ++added; | 153 | ++added; |
156 | } | 154 | } |
157 | } | 155 | } |
158 | } | 156 | } |
159 | KABC::AddressBook::Iterator itA = standardAddressBook->begin(); | 157 | KABC::AddressBook::Iterator itA = standardAddressBook->begin(); |
160 | KABC::AddressBook::Iterator it2 ; | 158 | KABC::AddressBook::Iterator it2 ; |
161 | while ( itA != standardAddressBook->end() ) { | 159 | while ( itA != standardAddressBook->end() ) { |
162 | bool found = false; | 160 | bool found = false; |
163 | KABC::Addressee::List::Iterator itL; | 161 | KABC::Addressee::List::Iterator itL; |
164 | for ( itL = list.begin();itL != list.end();++itL) { | 162 | for ( itL = list.begin();itL != list.end();++itL) { |
165 | if ( (*itL).uid() == (*itA).uid() ) { | 163 | if ( (*itL).uid() == (*itA).uid() ) { |
166 | found = true; | 164 | found = true; |
167 | break; | 165 | break; |
168 | } | 166 | } |
169 | } | 167 | } |
170 | if ( !found ) { | 168 | if ( !found ) { |
171 | it2 = itA; | 169 | it2 = itA; |
172 | ++itA; | 170 | ++itA; |
173 | standardAddressBook->removeAddressee( it2 ); | 171 | standardAddressBook->removeAddressee( it2 ); |
174 | ++deleted; | 172 | ++deleted; |
175 | } else { | 173 | } else { |
176 | ++itA; | 174 | ++itA; |
177 | } | 175 | } |
178 | } | 176 | } |
179 | 177 | ||
180 | //standardAddressBook->saveAll(); | 178 | //standardAddressBook->saveAll(); |
181 | standardAddressBook->setAutomaticSave( true ); | 179 | standardAddressBook->setAutomaticSave( true ); |
182 | qDebug("************************************* "); | 180 | qDebug("************************************* "); |
183 | qDebug("*************kdeABdump*************** "); | 181 | qDebug("*************kdeABdump*************** "); |
184 | qDebug("************************************* "); | 182 | qDebug("************************************* "); |
185 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); | 183 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); |
186 | } else | 184 | } else |
187 | qDebug("error open file "); | 185 | qDebug("error open file "); |
188 | } | 186 | } |
189 | 187 | ||
190 | delete standardAddressBook; | 188 | delete standardAddressBook; |
191 | //KABC::StdAddressBook::close(); | 189 | //KABC::StdAddressBook::close(); |
192 | //StdAddressBook::mSelf = 0; | 190 | //StdAddressBook::mSelf = 0; |
193 | qDebug("ente "); | 191 | qDebug("ente "); |
194 | return 0; | 192 | return 0; |
195 | } | 193 | } |
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index be1735b..08ccafb 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp | |||
@@ -1,253 +1,253 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * main.cpp * | 2 | * main.cpp * |
3 | * * | 3 | * * |
4 | * | 4 | * |
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 | ******************************************************************************/ | 24 | ******************************************************************************/ |
25 | 25 | ||
26 | #ifdef HAVE_CONFIG_H | 26 | #ifdef HAVE_CONFIG_H |
27 | #include "config.h" | 27 | #include "config.h" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #if TIME_WITH_SYS_TIME | 30 | #if TIME_WITH_SYS_TIME |
31 | # include <sys/time.h> | 31 | # include <sys/time.h> |
32 | # include <time.h> | 32 | # include <time.h> |
33 | #else | 33 | #else |
34 | # if HAVE_SYS_TIME_H | 34 | # if HAVE_SYS_TIME_H |
35 | # include <sys/time.h> | 35 | # include <sys/time.h> |
36 | # else | 36 | # else |
37 | # include <time.h> | 37 | # include <time.h> |
38 | # endif | 38 | # endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #include <kcmdlineargs.h> | 41 | #include <kcmdlineargs.h> |
42 | #include <kaboutdata.h> | 42 | #include <kaboutdata.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <kconfig.h> | 45 | #include <kconfig.h> |
46 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | 48 | ||
49 | #include <libkcal/calformat.h> | 49 | #include <libkcal/calformat.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcelocal.h> | 51 | #include <libkcal/resourcelocal.h> |
52 | #include <libkcal/filestorage.h> | 52 | #include <libkcal/filestorage.h> |
53 | #include <libkcal/icalformat.h> | 53 | #include <libkcal/icalformat.h> |
54 | 54 | ||
55 | #include <qdatetime.h> | 55 | #include <qdatetime.h> |
56 | #include <qfile.h> | 56 | #include <qfile.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qapplication.h> | 58 | #include <qapplication.h> |
59 | 59 | ||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <iostream> | 61 | #include <iostream> |
62 | 62 | ||
63 | using namespace KCal; | 63 | using namespace KCal; |
64 | using namespace std; | 64 | using namespace std; |
65 | 65 | ||
66 | static const char progName[] = "kdecalendar"; | 66 | static const char progName[] = "kdecalendar"; |
67 | static const char progDisplay[] = "KDE_Calendar"; | 67 | static const char progDisplay[] = "KDE_Calendar"; |
68 | static const char progVersion[] = "33.1/3"; | 68 | static const char progVersion[] = "33.1/3"; |
69 | static const char progDesc[] = "A command line interface to KDE calendars"; | 69 | static const char progDesc[] = "A command line interface to KDE calendars"; |
70 | 70 | ||
71 | 71 | ||
72 | static KCmdLineOptions options[] = | 72 | static KCmdLineOptions options[] = |
73 | { | 73 | { |
74 | { "dump", | 74 | { "dump", |
75 | I18N_NOOP( "Dumps calendar" ), 0 }, | 75 | I18N_NOOP( "Dumps calendar" ), 0 }, |
76 | { "read", | 76 | { "read", |
77 | I18N_NOOP( "Reads calendar" ), 0 }, | 77 | I18N_NOOP( "Reads calendar" ), 0 }, |
78 | KCmdLineLastOption | 78 | KCmdLineLastOption |
79 | }; | 79 | }; |
80 | 80 | ||
81 | int main( int argc, char *argv[] ) | 81 | int main( int argc, char *argv[] ) |
82 | { | 82 | { |
83 | KAboutData aboutData( | 83 | KAboutData aboutData( |
84 | progName, // internal program name | 84 | progName, // internal program name |
85 | I18N_NOOP( progDisplay ), // displayable program name. | 85 | I18N_NOOP( progDisplay ), // displayable program name. |
86 | progVersion, // version string | 86 | progVersion, // version string |
87 | I18N_NOOP( progDesc ), // short porgram description | 87 | I18N_NOOP( progDesc ), // short porgram description |
88 | KAboutData::License_GPL, // license type | 88 | KAboutData::License_GPL, // license type |
89 | "(c) 2004, Lutz Rogowski", // copyright statement | 89 | "(c) 2004, Lutz Rogowski", // copyright statement |
90 | 0, // any free form text | 90 | 0, // any free form text |
91 | "", // program home page address | 91 | "", // program home page address |
92 | "bugs.kde.org" // bug report email address | 92 | "bugs.kde.org" // bug report email address |
93 | ); | 93 | ); |
94 | 94 | ||
95 | 95 | ||
96 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options | 96 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options |
97 | // for QApplication/KApplication (no KDE or Qt options) | 97 | // for QApplication/KApplication (no KDE or Qt options) |
98 | KCmdLineArgs::init( argc, argv, &aboutData, true ); | 98 | KCmdLineArgs::init( argc, argv, &aboutData, true ); |
99 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. | 99 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. |
100 | 100 | ||
101 | KInstance ins ( progName ); | 101 | KInstance ins ( progName ); |
102 | 102 | ||
103 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 103 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
104 | 104 | ||
105 | bool read = false; | 105 | bool read = false; |
106 | if ( args->isSet( "read" ) ) { | 106 | if ( args->isSet( "read" ) ) { |
107 | read = true; | 107 | read = true; |
108 | qDebug("read "); | 108 | qDebug("read "); |
109 | } | 109 | } |
110 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 110 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
111 | CalendarResources *calendarResource = 0; | 111 | CalendarResources *calendarResource = 0; |
112 | CalendarLocal *localCalendar = 0; | 112 | CalendarLocal *localCalendar = 0; |
113 | KConfig c( locate( "config", "korganizerrc" ) ); | 113 | KConfig c( locate( "config", "korganizerrc" ) ); |
114 | c.setGroup( "Time & Date" ); | 114 | c.setGroup( "Time & Date" ); |
115 | QString tz = c.readEntry( "TimeZoneId" ); | 115 | QString tz = c.readEntry( "TimeZoneId" ); |
116 | calendarResource = new CalendarResources( tz ); | 116 | calendarResource = new CalendarResources( tz ); |
117 | calendarResource->readConfig(); | 117 | calendarResource->readConfig(); |
118 | calendarResource->load(); | 118 | calendarResource->load(); |
119 | qDebug("************************************* "); | 119 | qDebug("************************************* "); |
120 | qDebug("**************kdecaldump************* "); | 120 | qDebug("**************kdecaldump************* "); |
121 | qDebug("************************************* "); | 121 | qDebug("************************************* "); |
122 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); | 122 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); |
123 | 123 | ||
124 | if ( !read ) { | 124 | if ( !read ) { |
125 | localCalendar = new CalendarLocal(); | 125 | localCalendar = new CalendarLocal(); |
126 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 126 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
127 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 127 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
128 | Incidence::List::ConstIterator it; | 128 | Incidence::List::ConstIterator it; |
129 | int num = 0; | 129 | int num = 0; |
130 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 130 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
131 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 131 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
132 | if ( re && !re->readOnly() ) { | 132 | if ( re && /*!re->readOnly() now readonly syncing possible */) { |
133 | ++num; | 133 | ++num; |
134 | Incidence* cl = (*it)->clone(); | 134 | Incidence* cl = (*it)->clone(); |
135 | cl->setLastModified( (*it)->lastModified() ); | 135 | cl->setLastModified( (*it)->lastModified() ); |
136 | if ( cl->type() == "Journal" ) | 136 | if ( cl->type() == "Journal" ) |
137 | localCalendar->addJournal( (Journal *) cl ); | 137 | localCalendar->addJournal( (Journal *) cl ); |
138 | else if ( cl->type() == "Todo" ) | 138 | else if ( cl->type() == "Todo" ) |
139 | localCalendar->addTodo( (Todo *) cl ); | 139 | localCalendar->addTodo( (Todo *) cl ); |
140 | else if ( cl->type() == "Event" ) | 140 | else if ( cl->type() == "Event" ) |
141 | localCalendar->addEvent( (Event *) cl ); | 141 | localCalendar->addEvent( (Event *) cl ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | FileStorage* storage = new FileStorage( calendarResource ); | 145 | FileStorage* storage = new FileStorage( calendarResource ); |
146 | storage->setFileName( fileName ); | 146 | storage->setFileName( fileName ); |
147 | storage->setSaveFormat( new ICalFormat() ); | 147 | storage->setSaveFormat( new ICalFormat() ); |
148 | storage->save(); | 148 | storage->save(); |
149 | delete storage; | 149 | delete storage; |
150 | qDebug("************************************* "); | 150 | qDebug("************************************* "); |
151 | qDebug("************kdecaldump*************** "); | 151 | qDebug("************kdecaldump*************** "); |
152 | qDebug("************************************* "); | 152 | qDebug("************************************* "); |
153 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); | 153 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); |
154 | 154 | ||
155 | } else { | 155 | } else { |
156 | qDebug("************load"); | 156 | qDebug("************load"); |
157 | localCalendar = new CalendarLocal(); | 157 | localCalendar = new CalendarLocal(); |
158 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 158 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
159 | FileStorage* storage = new FileStorage( localCalendar ); | 159 | FileStorage* storage = new FileStorage( localCalendar ); |
160 | storage->setFileName( fileName ); | 160 | storage->setFileName( fileName ); |
161 | int num = 0; | 161 | int num = 0; |
162 | int del = 0; | 162 | int del = 0; |
163 | int add = 0; | 163 | int add = 0; |
164 | if ( storage->load() ) { | 164 | if ( storage->load() ) { |
165 | qDebug("***********loaded!"); | 165 | qDebug("***********loaded!"); |
166 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); | 166 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); |
167 | Incidence::List::ConstIterator it; | 167 | Incidence::List::ConstIterator it; |
168 | for( it = newInc.begin(); it != newInc.end(); ++it ) { | 168 | for( it = newInc.begin(); it != newInc.end(); ++it ) { |
169 | if ( (*it)->pilotId() > 1 ) { //changed | 169 | if ( (*it)->pilotId() > 1 ) { //changed |
170 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); | 170 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); |
171 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); | 171 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
172 | ResourceCalendar * res = 0; | 172 | ResourceCalendar * res = 0; |
173 | if ( incOld ) | 173 | if ( incOld ) |
174 | res = calendarResource->resource( incOld ); | 174 | res = calendarResource->resource( incOld ); |
175 | if ( res ) { | 175 | if ( res ) { |
176 | Incidence* cl = (*it)->clone(); | 176 | Incidence* cl = (*it)->clone(); |
177 | cl->setPilotId( incOld->pilotId() ); | 177 | cl->setPilotId( incOld->pilotId() ); |
178 | ++num; | 178 | ++num; |
179 | if ( incOld->type() == "Journal" ) | 179 | if ( incOld->type() == "Journal" ) |
180 | calendarResource->deleteJournal( (Journal *) incOld ); | 180 | calendarResource->deleteJournal( (Journal *) incOld ); |
181 | else if ( incOld->type() == "Todo" ) | 181 | else if ( incOld->type() == "Todo" ) |
182 | calendarResource->deleteTodo( (Todo *) incOld ); | 182 | calendarResource->deleteTodo( (Todo *) incOld ); |
183 | else if ( incOld->type() == "Event" ) | 183 | else if ( incOld->type() == "Event" ) |
184 | calendarResource->deleteEvent( (Event *) incOld ); | 184 | calendarResource->deleteEvent( (Event *) incOld ); |
185 | qDebug("*********change incidence %s ",cl->summary().latin1()); | 185 | qDebug("*********change incidence %s ",cl->summary().latin1()); |
186 | if ( cl->type() == "Journal" ) | 186 | if ( cl->type() == "Journal" ) |
187 | calendarResource->addJournal( (Journal *) cl, res ); | 187 | calendarResource->addJournal( (Journal *) cl, res ); |
188 | else if ( cl->type() == "Todo" ) | 188 | else if ( cl->type() == "Todo" ) |
189 | calendarResource->addTodo( (Todo *) cl, res ); | 189 | calendarResource->addTodo( (Todo *) cl, res ); |
190 | else if ( cl->type() == "Event" ) | 190 | else if ( cl->type() == "Event" ) |
191 | calendarResource->addEvent( (Event *) cl, res ); | 191 | calendarResource->addEvent( (Event *) cl, res ); |
192 | 192 | ||
193 | } else { | 193 | } else { |
194 | Incidence* cl = (*it)->clone(); | 194 | Incidence* cl = (*it)->clone(); |
195 | qDebug("*********add incidence %s ",cl->summary().latin1()); | 195 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
196 | calendarResource->addIncidence( cl ); | 196 | calendarResource->addIncidence( cl ); |
197 | ++add; | 197 | ++add; |
198 | } | 198 | } |
199 | } else { // maybe added | 199 | } else { // maybe added |
200 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); | 200 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
201 | if ( !incOld ) { //added | 201 | if ( !incOld ) { //added |
202 | Incidence* cl = (*it)->clone(); | 202 | Incidence* cl = (*it)->clone(); |
203 | qDebug("*********add incidence %s ",cl->summary().latin1()); | 203 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
204 | calendarResource->addIncidence( cl ); | 204 | calendarResource->addIncidence( cl ); |
205 | ++add; | 205 | ++add; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 209 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
210 | 210 | ||
211 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 211 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
212 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 212 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
213 | if ( re && !re->readOnly() ) { | 213 | if ( re && !re->readOnly() ) { |
214 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); | 214 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); |
215 | if ( !cl ) { | 215 | if ( !cl ) { |
216 | ++del; | 216 | ++del; |
217 | cl = (*it); | 217 | cl = (*it); |
218 | if ( cl->type() == "Journal" ) | 218 | if ( cl->type() == "Journal" ) |
219 | calendarResource->deleteJournal( (Journal *) cl ); | 219 | calendarResource->deleteJournal( (Journal *) cl ); |
220 | else if ( cl->type() == "Todo" ) | 220 | else if ( cl->type() == "Todo" ) |
221 | calendarResource->deleteTodo( (Todo *) cl ); | 221 | calendarResource->deleteTodo( (Todo *) cl ); |
222 | else if ( cl->type() == "Event" ) | 222 | else if ( cl->type() == "Event" ) |
223 | calendarResource->deleteEvent( (Event *) cl ); | 223 | calendarResource->deleteEvent( (Event *) cl ); |
224 | //QDateTime lm = cl->lastModified(); | 224 | //QDateTime lm = cl->lastModified(); |
225 | //cl->setResources( (*it)->resources() ); | 225 | //cl->setResources( (*it)->resources() ); |
226 | //cl->setLastModified(lm); | 226 | //cl->setLastModified(lm); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | calendarResource->save(); | 231 | calendarResource->save(); |
232 | qDebug("************************************* "); | 232 | qDebug("************************************* "); |
233 | qDebug("************kdecaldump*************** "); | 233 | qDebug("************kdecaldump*************** "); |
234 | qDebug("************************************* "); | 234 | qDebug("************************************* "); |
235 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); | 235 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); |
236 | 236 | ||
237 | } else | 237 | } else |
238 | qDebug("ERROR loading file %s",fileName.latin1() ); | 238 | qDebug("ERROR loading file %s",fileName.latin1() ); |
239 | 239 | ||
240 | } | 240 | } |
241 | 241 | ||
242 | if ( localCalendar ) { | 242 | if ( localCalendar ) { |
243 | localCalendar->close(); | 243 | localCalendar->close(); |
244 | delete localCalendar; | 244 | delete localCalendar; |
245 | } | 245 | } |
246 | if ( calendarResource ) { | 246 | if ( calendarResource ) { |
247 | calendarResource->close(); | 247 | calendarResource->close(); |
248 | delete calendarResource; | 248 | delete calendarResource; |
249 | } | 249 | } |
250 | 250 | ||
251 | qDebug("ente "); | 251 | qDebug("ente "); |
252 | return 0; | 252 | return 0; |
253 | } | 253 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 3d4acb7..f8bfc8b 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,497 +1,499 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This 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 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | 41 | ||
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | #include <libkcal/calendar.h> | 43 | #include <libkcal/calendar.h> |
44 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <libkcal/vcalformat.h> | 46 | #include <libkcal/vcalformat.h> |
47 | #include <libkcal/recurrence.h> | 47 | #include <libkcal/recurrence.h> |
48 | #include <libkcal/filestorage.h> | 48 | #include <libkcal/filestorage.h> |
49 | #include <libkdepim/categoryselectdialog.h> | 49 | #include <libkdepim/categoryselectdialog.h> |
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | #else | 52 | #else |
53 | #include <qapplication.h> | 53 | #include <qapplication.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef KORG_NOPRINTER | 56 | #ifndef KORG_NOPRINTER |
57 | #include "calprinter.h" | 57 | #include "calprinter.h" |
58 | #endif | 58 | #endif |
59 | #include "koglobals.h" | 59 | #include "koglobals.h" |
60 | #include "koprefs.h" | 60 | #include "koprefs.h" |
61 | #include "kfiledialog.h" | 61 | #include "kfiledialog.h" |
62 | 62 | ||
63 | #include "kolistview.h" | 63 | #include "kolistview.h" |
64 | 64 | ||
65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
66 | { | 66 | { |
67 | mItem = item; | 67 | mItem = item; |
68 | mDate = date; | 68 | mDate = date; |
69 | } | 69 | } |
70 | 70 | ||
71 | ListItemVisitor::~ListItemVisitor() | 71 | ListItemVisitor::~ListItemVisitor() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | bool ListItemVisitor::visit(Event *e) | 75 | bool ListItemVisitor::visit(Event *e) |
76 | { | 76 | { |
77 | 77 | ||
78 | bool ok = false; | 78 | bool ok = false; |
79 | QString start, end; | 79 | QString start, end; |
80 | QDate ds, de; | ||
80 | if ( e->doesRecur() ) { | 81 | if ( e->doesRecur() ) { |
81 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 82 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
82 | if ( ok ) { | 83 | if ( ok ) { |
83 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 84 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
84 | start = KGlobal::locale()->formatDate(d,true); | 85 | start = KGlobal::locale()->formatDate(ds,true); |
85 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 86 | de = ds.addDays( days); |
87 | end = KGlobal::locale()->formatDate(de,true); | ||
86 | } | 88 | } |
87 | 89 | ||
88 | } | 90 | } |
89 | if ( ! ok ) { | 91 | if ( ! ok ) { |
90 | start =e->dtStartDateStr(); | 92 | start =e->dtStartDateStr(); |
91 | end = e->dtEndDateStr(); | 93 | end = e->dtEndDateStr(); |
94 | ds = e->dtStart().date(); | ||
95 | de = e->dtEnd().date(); | ||
92 | } | 96 | } |
93 | mItem->setText(0,e->summary()); | 97 | mItem->setText(0,e->summary()); |
94 | mItem->setText(1,start); | 98 | mItem->setText(1,start); |
95 | mItem->setText(2,e->dtStartTimeStr()); | 99 | mItem->setText(2,e->dtStartTimeStr()); |
96 | mItem->setText(3,end); | 100 | mItem->setText(3,end); |
97 | mItem->setText(4,e->dtEndTimeStr()); | 101 | mItem->setText(4,e->dtEndTimeStr()); |
98 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 102 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
99 | mItem->setText(6, e->recurrence()->recurrenceText()); | 103 | mItem->setText(6, e->recurrence()->recurrenceText()); |
100 | mItem->setText(7,"---"); | 104 | mItem->setText(7,"---"); |
101 | mItem->setText(8,"---"); | 105 | mItem->setText(8,"---"); |
102 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 106 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
103 | mItem->setText(10,e->categoriesStr()); | 107 | mItem->setText(10,e->categoriesStr()); |
104 | 108 | ||
105 | QString key; | 109 | QString key; |
106 | QDate d = e->dtStart().date(); | ||
107 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 110 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
108 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 111 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
109 | mItem->setSortKey(1,key); | 112 | mItem->setSortKey(1,key); |
110 | 113 | ||
111 | d = e->dtEnd().date(); | ||
112 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 114 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
113 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 115 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
114 | mItem->setSortKey(3,key); | 116 | mItem->setSortKey(3,key); |
115 | 117 | ||
116 | return true; | 118 | return true; |
117 | } | 119 | } |
118 | 120 | ||
119 | bool ListItemVisitor::visit(Todo *t) | 121 | bool ListItemVisitor::visit(Todo *t) |
120 | { | 122 | { |
121 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 123 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
122 | if (t->hasStartDate()) { | 124 | if (t->hasStartDate()) { |
123 | mItem->setText(1,t->dtStartDateStr()); | 125 | mItem->setText(1,t->dtStartDateStr()); |
124 | if (t->doesFloat()) { | 126 | if (t->doesFloat()) { |
125 | mItem->setText(2,"---"); | 127 | mItem->setText(2,"---"); |
126 | } else { | 128 | } else { |
127 | mItem->setText(2,t->dtStartTimeStr()); | 129 | mItem->setText(2,t->dtStartTimeStr()); |
128 | } | 130 | } |
129 | } else { | 131 | } else { |
130 | mItem->setText(1,"---"); | 132 | mItem->setText(1,"---"); |
131 | mItem->setText(2,"---"); | 133 | mItem->setText(2,"---"); |
132 | } | 134 | } |
133 | mItem->setText(3,"---"); | 135 | mItem->setText(3,"---"); |
134 | mItem->setText(4,"---"); | 136 | mItem->setText(4,"---"); |
135 | mItem->setText(5,"---"); | 137 | mItem->setText(5,"---"); |
136 | mItem->setText(6,"---"); | 138 | mItem->setText(6,"---"); |
137 | if (t->hasDueDate()) { | 139 | if (t->hasDueDate()) { |
138 | mItem->setText(7,t->dtDueDateStr()); | 140 | mItem->setText(7,t->dtDueDateStr()); |
139 | if (t->doesFloat()) { | 141 | if (t->doesFloat()) { |
140 | mItem->setText(8,"---"); | 142 | mItem->setText(8,"---"); |
141 | } else { | 143 | } else { |
142 | mItem->setText(8,t->dtDueTimeStr()); | 144 | mItem->setText(8,t->dtDueTimeStr()); |
143 | } | 145 | } |
144 | } else { | 146 | } else { |
145 | mItem->setText(7,"---"); | 147 | mItem->setText(7,"---"); |
146 | mItem->setText(8,"---"); | 148 | mItem->setText(8,"---"); |
147 | } | 149 | } |
148 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 150 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
149 | mItem->setText(10,t->categoriesStr()); | 151 | mItem->setText(10,t->categoriesStr()); |
150 | 152 | ||
151 | QString key; | 153 | QString key; |
152 | QDate d; | 154 | QDate d; |
153 | if (t->hasDueDate()) { | 155 | if (t->hasDueDate()) { |
154 | d = t->dtDue().date(); | 156 | d = t->dtDue().date(); |
155 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 157 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
156 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 158 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
157 | mItem->setSortKey(7,key); | 159 | mItem->setSortKey(7,key); |
158 | } | 160 | } |
159 | if ( t->hasStartDate() ) { | 161 | if ( t->hasStartDate() ) { |
160 | d = t->dtStart().date(); | 162 | d = t->dtStart().date(); |
161 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 163 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
162 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 164 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
163 | mItem->setSortKey(1,key); | 165 | mItem->setSortKey(1,key); |
164 | } | 166 | } |
165 | return true; | 167 | return true; |
166 | } | 168 | } |
167 | 169 | ||
168 | bool ListItemVisitor::visit(Journal * j) | 170 | bool ListItemVisitor::visit(Journal * j) |
169 | { | 171 | { |
170 | QString des = j->description().left(50); | 172 | QString des = j->description().left(50); |
171 | des = des.simplifyWhiteSpace (); | 173 | des = des.simplifyWhiteSpace (); |
172 | des.replace (QRegExp ("\\n"),"" ); | 174 | des.replace (QRegExp ("\\n"),"" ); |
173 | des.replace (QRegExp ("\\r"),"" ); | 175 | des.replace (QRegExp ("\\r"),"" ); |
174 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | 176 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); |
175 | mItem->setText(1,j->dtStartDateStr()); | 177 | mItem->setText(1,j->dtStartDateStr()); |
176 | mItem->setText(2,"---"); | 178 | mItem->setText(2,"---"); |
177 | mItem->setText(3,"---"); | 179 | mItem->setText(3,"---"); |
178 | mItem->setText(4,"---"); | 180 | mItem->setText(4,"---"); |
179 | mItem->setText(5,"---"); | 181 | mItem->setText(5,"---"); |
180 | mItem->setText(6,"---"); | 182 | mItem->setText(6,"---"); |
181 | mItem->setText(7,j->dtStartDateStr()); | 183 | mItem->setText(7,j->dtStartDateStr()); |
182 | mItem->setText(8,"---"); | 184 | mItem->setText(8,"---"); |
183 | mItem->setText(9,"---"); | 185 | mItem->setText(9,"---"); |
184 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 186 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
185 | 187 | ||
186 | QString key; | 188 | QString key; |
187 | QDate d = j->dtStart().date(); | 189 | QDate d = j->dtStart().date(); |
188 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 190 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
189 | mItem->setSortKey(1,key); | 191 | mItem->setSortKey(1,key); |
190 | mItem->setSortKey(7,key); | 192 | mItem->setSortKey(7,key); |
191 | 193 | ||
192 | return true; | 194 | return true; |
193 | } | 195 | } |
194 | 196 | ||
195 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 197 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
196 | const char *name) | 198 | const char *name) |
197 | : KOEventView(calendar, parent, name) | 199 | : KOEventView(calendar, parent, name) |
198 | { | 200 | { |
199 | mActiveItem = 0; | 201 | mActiveItem = 0; |
200 | mListView = new KOListViewListView(this); | 202 | mListView = new KOListViewListView(this); |
201 | mListView->addColumn(i18n("Summary")); | 203 | mListView->addColumn(i18n("Summary")); |
202 | mListView->addColumn(i18n("Start Date")); | 204 | mListView->addColumn(i18n("Start Date")); |
203 | mListView->addColumn(i18n("Start Time")); | 205 | mListView->addColumn(i18n("Start Time")); |
204 | mListView->addColumn(i18n("End Date")); | 206 | mListView->addColumn(i18n("End Date")); |
205 | mListView->addColumn(i18n("End Time")); | 207 | mListView->addColumn(i18n("End Time")); |
206 | mListView->addColumn(i18n("Alarm")); // alarm set? | 208 | mListView->addColumn(i18n("Alarm")); // alarm set? |
207 | mListView->addColumn(i18n("Recurs")); // recurs? | 209 | mListView->addColumn(i18n("Recurs")); // recurs? |
208 | mListView->addColumn(i18n("Due Date")); | 210 | mListView->addColumn(i18n("Due Date")); |
209 | mListView->addColumn(i18n("Due Time")); | 211 | mListView->addColumn(i18n("Due Time")); |
210 | mListView->addColumn(i18n("Cancelled")); | 212 | mListView->addColumn(i18n("Cancelled")); |
211 | mListView->addColumn(i18n("Categories")); | 213 | mListView->addColumn(i18n("Categories")); |
212 | 214 | ||
213 | mListView->setColumnAlignment(0,AlignLeft); | 215 | mListView->setColumnAlignment(0,AlignLeft); |
214 | mListView->setColumnAlignment(1,AlignLeft); | 216 | mListView->setColumnAlignment(1,AlignLeft); |
215 | mListView->setColumnAlignment(2,AlignHCenter); | 217 | mListView->setColumnAlignment(2,AlignHCenter); |
216 | mListView->setColumnAlignment(3,AlignLeft); | 218 | mListView->setColumnAlignment(3,AlignLeft); |
217 | mListView->setColumnAlignment(4,AlignHCenter); | 219 | mListView->setColumnAlignment(4,AlignHCenter); |
218 | mListView->setColumnAlignment(5,AlignLeft); | 220 | mListView->setColumnAlignment(5,AlignLeft); |
219 | mListView->setColumnAlignment(6,AlignLeft); | 221 | mListView->setColumnAlignment(6,AlignLeft); |
220 | mListView->setColumnAlignment(7,AlignLeft); | 222 | mListView->setColumnAlignment(7,AlignLeft); |
221 | mListView->setColumnAlignment(8,AlignLeft); | 223 | mListView->setColumnAlignment(8,AlignLeft); |
222 | mListView->setColumnAlignment(9,AlignLeft); | 224 | mListView->setColumnAlignment(9,AlignLeft); |
223 | mListView->setColumnAlignment(10,AlignLeft); | 225 | mListView->setColumnAlignment(10,AlignLeft); |
224 | 226 | ||
225 | int iii = 0; | 227 | int iii = 0; |
226 | for ( iii = 0; iii< 10 ; ++iii ) | 228 | for ( iii = 0; iii< 10 ; ++iii ) |
227 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 229 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
228 | 230 | ||
229 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 231 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
230 | layoutTop->addWidget(mListView); | 232 | layoutTop->addWidget(mListView); |
231 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 233 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
232 | mPopupMenu = eventPopup(); | 234 | mPopupMenu = eventPopup(); |
233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 235 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
234 | i18n("Select all"),this, | 236 | i18n("Select all"),this, |
235 | SLOT(allSelection()),true); | 237 | SLOT(allSelection()),true); |
236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 238 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
237 | i18n("Deselect All"),this, | 239 | i18n("Deselect All"),this, |
238 | SLOT(clearSelection()),true); | 240 | SLOT(clearSelection()),true); |
239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 241 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
240 | i18n("Delete all selected"),this, | 242 | i18n("Delete all selected"),this, |
241 | SLOT(deleteAll()),true); | 243 | SLOT(deleteAll()),true); |
242 | mPopupMenu->insertSeparator(); | 244 | mPopupMenu->insertSeparator(); |
243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 245 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
244 | i18n("Save selected to file..."),this, | 246 | i18n("Save selected to file..."),this, |
245 | SLOT(saveToFile()),true); | 247 | SLOT(saveToFile()),true); |
246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 248 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
247 | i18n("Save Journal/Description..."),this, | 249 | i18n("Save Journal/Description..."),this, |
248 | SLOT(saveDescriptionToFile()),true); | 250 | SLOT(saveDescriptionToFile()),true); |
249 | mPopupMenu->insertSeparator(); | 251 | mPopupMenu->insertSeparator(); |
250 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 252 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
251 | i18n("Add Categ. to selected..."),this, | 253 | i18n("Add Categ. to selected..."),this, |
252 | SLOT(addCat()),true); | 254 | SLOT(addCat()),true); |
253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 255 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
254 | i18n("Set Categ. for selected..."),this, | 256 | i18n("Set Categ. for selected..."),this, |
255 | SLOT(setCat()),true); | 257 | SLOT(setCat()),true); |
256 | mPopupMenu->insertSeparator(); | 258 | mPopupMenu->insertSeparator(); |
257 | 259 | ||
258 | 260 | ||
259 | #ifndef DESKTOP_VERSION | 261 | #ifndef DESKTOP_VERSION |
260 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 262 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
261 | i18n("Beam selected via IR"),this, | 263 | i18n("Beam selected via IR"),this, |
262 | SLOT(beamSelected()),true); | 264 | SLOT(beamSelected()),true); |
263 | #endif | 265 | #endif |
264 | /* | 266 | /* |
265 | mPopupMenu = new QPopupMenu; | 267 | mPopupMenu = new QPopupMenu; |
266 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 268 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
267 | SLOT (editEvent())); | 269 | SLOT (editEvent())); |
268 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 270 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
269 | SLOT (deleteEvent())); | 271 | SLOT (deleteEvent())); |
270 | mPopupMenu->insertSeparator(); | 272 | mPopupMenu->insertSeparator(); |
271 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 273 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
272 | SLOT(showDates())); | 274 | SLOT(showDates())); |
273 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 275 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
274 | SLOT(hideDates())); | 276 | SLOT(hideDates())); |
275 | */ | 277 | */ |
276 | QObject::connect(mListView,SIGNAL( newEvent()), | 278 | QObject::connect(mListView,SIGNAL( newEvent()), |
277 | this,SIGNAL(signalNewEvent())); | 279 | this,SIGNAL(signalNewEvent())); |
278 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 280 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
279 | this,SLOT(defaultItemAction(QListViewItem *))); | 281 | this,SLOT(defaultItemAction(QListViewItem *))); |
280 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 282 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
281 | const QPoint &, int )), | 283 | const QPoint &, int )), |
282 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 284 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
283 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 285 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
284 | SLOT(processSelectionChange(QListViewItem *))); | 286 | SLOT(processSelectionChange(QListViewItem *))); |
285 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 287 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
286 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 288 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
287 | 289 | ||
288 | readSettings(KOGlobals::config(),"KOListView Layout"); | 290 | readSettings(KOGlobals::config(),"KOListView Layout"); |
289 | } | 291 | } |
290 | 292 | ||
291 | KOListView::~KOListView() | 293 | KOListView::~KOListView() |
292 | { | 294 | { |
293 | delete mPopupMenu; | 295 | delete mPopupMenu; |
294 | } | 296 | } |
295 | 297 | ||
296 | void KOListView::updateList() | 298 | void KOListView::updateList() |
297 | { | 299 | { |
298 | // qDebug(" KOListView::updateList() "); | 300 | // qDebug(" KOListView::updateList() "); |
299 | 301 | ||
300 | } | 302 | } |
301 | 303 | ||
302 | void KOListView::addCat( ) | 304 | void KOListView::addCat( ) |
303 | { | 305 | { |
304 | setCategories( false ); | 306 | setCategories( false ); |
305 | } | 307 | } |
306 | void KOListView::setCat() | 308 | void KOListView::setCat() |
307 | { | 309 | { |
308 | setCategories( true ); | 310 | setCategories( true ); |
309 | } | 311 | } |
310 | void KOListView::setCategories( bool removeOld ) | 312 | void KOListView::setCategories( bool removeOld ) |
311 | { | 313 | { |
312 | 314 | ||
313 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 315 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
314 | if (! csd->exec()) { | 316 | if (! csd->exec()) { |
315 | delete csd; | 317 | delete csd; |
316 | return; | 318 | return; |
317 | } | 319 | } |
318 | QStringList catList = csd->selectedCategories(); | 320 | QStringList catList = csd->selectedCategories(); |
319 | delete csd; | 321 | delete csd; |
320 | // if ( catList.count() == 0 ) | 322 | // if ( catList.count() == 0 ) |
321 | // return; | 323 | // return; |
322 | catList.sort(); | 324 | catList.sort(); |
323 | QString categoriesStr = catList.join(","); | 325 | QString categoriesStr = catList.join(","); |
324 | int i; | 326 | int i; |
325 | QStringList itemList; | 327 | QStringList itemList; |
326 | QPtrList<KOListViewItem> sel ; | 328 | QPtrList<KOListViewItem> sel ; |
327 | QListViewItem *qitem = mListView->firstChild (); | 329 | QListViewItem *qitem = mListView->firstChild (); |
328 | while ( qitem ) { | 330 | while ( qitem ) { |
329 | if ( qitem->isSelected() ) { | 331 | if ( qitem->isSelected() ) { |
330 | sel.append(((KOListViewItem *)qitem)); | 332 | sel.append(((KOListViewItem *)qitem)); |
331 | } | 333 | } |
332 | qitem = qitem->nextSibling(); | 334 | qitem = qitem->nextSibling(); |
333 | } | 335 | } |
334 | KOListViewItem * item, *temp; | 336 | KOListViewItem * item, *temp; |
335 | item = sel.first(); | 337 | item = sel.first(); |
336 | Incidence* inc; | 338 | Incidence* inc; |
337 | while ( item ) { | 339 | while ( item ) { |
338 | inc = item->data(); | 340 | inc = item->data(); |
339 | if ( removeOld ) { | 341 | if ( removeOld ) { |
340 | inc->setCategories( categoriesStr ); | 342 | inc->setCategories( categoriesStr ); |
341 | } else { | 343 | } else { |
342 | itemList = QStringList::split (",", inc->categoriesStr() ); | 344 | itemList = QStringList::split (",", inc->categoriesStr() ); |
343 | for( i = 0; i< catList.count(); ++i ) { | 345 | for( i = 0; i< catList.count(); ++i ) { |
344 | if ( !itemList.contains (catList[i])) | 346 | if ( !itemList.contains (catList[i])) |
345 | itemList.append( catList[i] ); | 347 | itemList.append( catList[i] ); |
346 | } | 348 | } |
347 | itemList.sort(); | 349 | itemList.sort(); |
348 | inc->setCategories( itemList.join(",") ); | 350 | inc->setCategories( itemList.join(",") ); |
349 | } | 351 | } |
350 | temp = item; | 352 | temp = item; |
351 | item = sel.next(); | 353 | item = sel.next(); |
352 | mUidDict.remove( inc->uid() ); | 354 | mUidDict.remove( inc->uid() ); |
353 | delete temp;; | 355 | delete temp;; |
354 | addIncidence( inc ); | 356 | addIncidence( inc ); |
355 | } | 357 | } |
356 | } | 358 | } |
357 | 359 | ||
358 | void KOListView::beamSelected() | 360 | void KOListView::beamSelected() |
359 | { | 361 | { |
360 | int icount = 0; | 362 | int icount = 0; |
361 | QPtrList<Incidence> delSel ; | 363 | QPtrList<Incidence> delSel ; |
362 | QListViewItem *item = mListView->firstChild (); | 364 | QListViewItem *item = mListView->firstChild (); |
363 | while ( item ) { | 365 | while ( item ) { |
364 | if ( item->isSelected() ) { | 366 | if ( item->isSelected() ) { |
365 | delSel.append(((KOListViewItem *)item)->data()); | 367 | delSel.append(((KOListViewItem *)item)->data()); |
366 | ++icount; | 368 | ++icount; |
367 | } | 369 | } |
368 | 370 | ||
369 | item = item->nextSibling(); | 371 | item = item->nextSibling(); |
370 | } | 372 | } |
371 | if ( icount ) { | 373 | if ( icount ) { |
372 | emit beamIncidenceList( delSel ); | 374 | emit beamIncidenceList( delSel ); |
373 | return; | 375 | return; |
374 | QString fn ; | 376 | QString fn ; |
375 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 377 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
376 | QString mes; | 378 | QString mes; |
377 | bool createbup = true; | 379 | bool createbup = true; |
378 | if ( createbup ) { | 380 | if ( createbup ) { |
379 | QString description = "\n"; | 381 | QString description = "\n"; |
380 | CalendarLocal* cal = new CalendarLocal(); | 382 | CalendarLocal* cal = new CalendarLocal(); |
381 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 383 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
382 | Incidence *incidence = delSel.first(); | 384 | Incidence *incidence = delSel.first(); |
383 | while ( incidence ) { | 385 | while ( incidence ) { |
384 | Incidence *in = incidence->clone(); | 386 | Incidence *in = incidence->clone(); |
385 | description += in->summary() + "\n"; | 387 | description += in->summary() + "\n"; |
386 | cal->addIncidence( in ); | 388 | cal->addIncidence( in ); |
387 | incidence = delSel.next(); | 389 | incidence = delSel.next(); |
388 | } | 390 | } |
389 | FileStorage storage( cal, fn, new VCalFormat ); | 391 | FileStorage storage( cal, fn, new VCalFormat ); |
390 | storage.save(); | 392 | storage.save(); |
391 | delete cal; | 393 | delete cal; |
392 | mes = i18n("KO/Pi: Ready for beaming"); | 394 | mes = i18n("KO/Pi: Ready for beaming"); |
393 | topLevelWidget()->setCaption(mes); | 395 | topLevelWidget()->setCaption(mes); |
394 | 396 | ||
395 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
396 | Ir *ir = new Ir( this ); | 398 | Ir *ir = new Ir( this ); |
397 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 399 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
398 | ir->send( fn, description, "text/x-vCalendar" ); | 400 | ir->send( fn, description, "text/x-vCalendar" ); |
399 | #endif | 401 | #endif |
400 | } | 402 | } |
401 | } | 403 | } |
402 | } | 404 | } |
403 | void KOListView::beamDone( Ir *ir ) | 405 | void KOListView::beamDone( Ir *ir ) |
404 | { | 406 | { |
405 | #ifndef DESKTOP_VERSION | 407 | #ifndef DESKTOP_VERSION |
406 | delete ir; | 408 | delete ir; |
407 | #endif | 409 | #endif |
408 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 410 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
409 | } | 411 | } |
410 | 412 | ||
411 | void KOListView::saveDescriptionToFile() | 413 | void KOListView::saveDescriptionToFile() |
412 | { | 414 | { |
413 | 415 | ||
414 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 416 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
415 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 417 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
416 | i18n("Continue"), i18n("Cancel"), 0, | 418 | i18n("Continue"), i18n("Cancel"), 0, |
417 | 0, 1 ); | 419 | 0, 1 ); |
418 | if ( result != 0 ) { | 420 | if ( result != 0 ) { |
419 | return; | 421 | return; |
420 | } | 422 | } |
421 | int icount = 0; | 423 | int icount = 0; |
422 | QPtrList<Incidence> delSel ; | 424 | QPtrList<Incidence> delSel ; |
423 | QListViewItem *item = mListView->firstChild (); | 425 | QListViewItem *item = mListView->firstChild (); |
424 | while ( item ) { | 426 | while ( item ) { |
425 | if ( item->isSelected() ) { | 427 | if ( item->isSelected() ) { |
426 | delSel.append(((KOListViewItem *)item)->data()); | 428 | delSel.append(((KOListViewItem *)item)->data()); |
427 | ++icount; | 429 | ++icount; |
428 | } | 430 | } |
429 | 431 | ||
430 | item = item->nextSibling(); | 432 | item = item->nextSibling(); |
431 | } | 433 | } |
432 | if ( icount ) { | 434 | if ( icount ) { |
433 | QString fn = KOPrefs::instance()->mLastSaveFile; | 435 | QString fn = KOPrefs::instance()->mLastSaveFile; |
434 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 436 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
435 | 437 | ||
436 | if ( fn == "" ) | 438 | if ( fn == "" ) |
437 | return; | 439 | return; |
438 | QFileInfo info; | 440 | QFileInfo info; |
439 | info.setFile( fn ); | 441 | info.setFile( fn ); |
440 | QString mes; | 442 | QString mes; |
441 | bool createbup = true; | 443 | bool createbup = true; |
442 | if ( info. exists() ) { | 444 | if ( info. exists() ) { |
443 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 445 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
444 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 446 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
445 | i18n("Overwrite!"), i18n("Cancel"), 0, | 447 | i18n("Overwrite!"), i18n("Cancel"), 0, |
446 | 0, 1 ); | 448 | 0, 1 ); |
447 | if ( result != 0 ) { | 449 | if ( result != 0 ) { |
448 | createbup = false; | 450 | createbup = false; |
449 | } | 451 | } |
450 | } | 452 | } |
451 | if ( createbup ) { | 453 | if ( createbup ) { |
452 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 454 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
453 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 455 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
454 | Incidence *incidence = delSel.first(); | 456 | Incidence *incidence = delSel.first(); |
455 | icount = 0; | 457 | icount = 0; |
456 | while ( incidence ) { | 458 | while ( incidence ) { |
457 | if ( incidence->type() == "Journal" ) { | 459 | if ( incidence->type() == "Journal" ) { |
458 | text += "\n************************************\n"; | 460 | text += "\n************************************\n"; |
459 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 461 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
460 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 462 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
461 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 463 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
462 | ++icount; | 464 | ++icount; |
463 | 465 | ||
464 | } else { | 466 | } else { |
465 | if ( !incidence->description().isEmpty() ) { | 467 | if ( !incidence->description().isEmpty() ) { |
466 | text += "\n************************************\n"; | 468 | text += "\n************************************\n"; |
467 | if ( incidence->type() == "Todo" ) | 469 | if ( incidence->type() == "Todo" ) |
468 | text += i18n("To-Do: "); | 470 | text += i18n("To-Do: "); |
469 | text += incidence->summary(); | 471 | text += incidence->summary(); |
470 | if ( incidence->hasStartDate() ) | 472 | if ( incidence->hasStartDate() ) |
471 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 473 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
472 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 474 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
473 | if ( !incidence->location().isEmpty() ) | 475 | if ( !incidence->location().isEmpty() ) |
474 | text += "\n" +i18n("Location: ") + incidence->location(); | 476 | text += "\n" +i18n("Location: ") + incidence->location(); |
475 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 477 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
476 | ++icount; | 478 | ++icount; |
477 | 479 | ||
478 | } | 480 | } |
479 | } | 481 | } |
480 | incidence = delSel.next(); | 482 | incidence = delSel.next(); |
481 | } | 483 | } |
482 | QFile file( fn ); | 484 | QFile file( fn ); |
483 | if (!file.open( IO_WriteOnly ) ) { | 485 | if (!file.open( IO_WriteOnly ) ) { |
484 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 486 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
485 | return; | 487 | return; |
486 | } | 488 | } |
487 | QTextStream ts( &file ); | 489 | QTextStream ts( &file ); |
488 | ts << text; | 490 | ts << text; |
489 | file.close(); | 491 | file.close(); |
490 | //qDebug("%s ", text.latin1()); | 492 | //qDebug("%s ", text.latin1()); |
491 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 493 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
492 | KOPrefs::instance()->mLastSaveFile = fn; | 494 | KOPrefs::instance()->mLastSaveFile = fn; |
493 | topLevelWidget()->setCaption(mes); | 495 | topLevelWidget()->setCaption(mes); |
494 | } | 496 | } |
495 | } | 497 | } |
496 | } | 498 | } |
497 | void KOListView::saveToFile() | 499 | void KOListView::saveToFile() |
@@ -1 +1 @@ | |||
version = "1.9.16"; | version = "1.9.17"; | ||