summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-12-13 12:35:00 (UTC)
committer zautrix <zautrix>2004-12-13 12:35:00 (UTC)
commit7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (unidiff)
treec7610e0e25020f19af82ac6257c2debab2638316
parent17b25691f0332e648dd1d800e89ccf4e1da8955d (diff)
downloadkdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip
kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz
kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2
many bugfixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt10
-rw-r--r--kaddressbook/kabcore.cpp11
-rw-r--r--kaddressbook/viewmanager.cpp11
-rw-r--r--kmicromail/libmailwrapper/settings.cpp2
-rw-r--r--kmicromail/opiemail.cpp27
-rw-r--r--kmicromail/opiemail.h2
-rw-r--r--kmicromail/viewmail.cpp5
-rw-r--r--kmicromail/viewmail.h1
-rw-r--r--korganizer/calendarview.cpp24
-rw-r--r--qtcompat/qinputdialog.cpp7
10 files changed, 80 insertions, 20 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 46d59a3..ec75fad 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,639 +1,649 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 1.9.15 ************ 3********** VERSION 1.9.15 ************
4 4
5Usebilty enhancements in KO/Pi: 5Usebilty enhancements in KO/Pi:
6When clicking on the date in a month view cell, the day view is shown. 6When clicking on the date in a month view cell, the day view is shown.
7Old behaviour was, that the "new event" dialog popped up. 7Old behaviour was, that the "new event" dialog popped up.
8 8
9Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). 9Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu).
10That means, you can restore the latest 10That means, you can restore the latest
11event/todo/journal you have deleted. 11event/todo/journal you have deleted.
12A journal is deleted, if you clear all the text of the journal. 12A journal is deleted, if you clear all the text of the journal.
13 13
14Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14.
15
16KA/Pi starting in 480x640 resolution:
17Hide the filter action in toolbar
18and added icons for undo/delete/redo in toolbar.
19
20Change in OM/Pi ViewMail dialog:
21When clicking on the "delete" icon the mail is deleted after confirmation as usual. But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any).
22
23Fixed a crash when deleting mail-accounts in OM/Pi.
14 24
15 25
16********** VERSION 1.9.14 ************ 26********** VERSION 1.9.14 ************
17 27
18Fixed some problems with the dialog sizes when switching 28Fixed some problems with the dialog sizes when switching
19portrait/landscape mode on 640x480 PDA display. 29portrait/landscape mode on 640x480 PDA display.
20 30
21Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. 31Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi.
22 32
23Fixed an ugly bug in KOpieMail: 33Fixed an ugly bug in KOpieMail:
24KOpieMail was not able to write files (mails) to MSDOS file system, 34KOpieMail was not able to write files (mails) to MSDOS file system,
25like on an usual preformatted SD card. That should work now. 35like on an usual preformatted SD card. That should work now.
26To save your mail data on the Sd card do the following: 36To save your mail data on the Sd card do the following:
27Create a dir on the SD card: 37Create a dir on the SD card:
28mkdir /mnt/card/localmail 38mkdir /mnt/card/localmail
29Go to your home dir: 39Go to your home dir:
30cd 40cd
31Go to kopiemail data storage dir: 41Go to kopiemail data storage dir:
32cd kdepim/apps/kopiemail 42cd kdepim/apps/kopiemail
33Create a symlink to the SD card: 43Create a symlink to the SD card:
34ls -s /mnt/card/localmail 44ls -s /mnt/card/localmail
35Now KOpieMail will store all mails on the SD card. 45Now KOpieMail will store all mails on the SD card.
36 46
37KO/Pi Monthview: 47KO/Pi Monthview:
38Now "Go to Today" selects the current month from day 1-end, 48Now "Go to Today" selects the current month from day 1-end,
39not the current date + some days. 49not the current date + some days.
40I.e. "Go to Today" shows now always 50I.e. "Go to Today" shows now always
41the current month with first day of month in the first row. 51the current month with first day of month in the first row.
42 52
43Added missing German translation. 53Added missing German translation.
44 54
45Fixed icons of executeable on Wintendo. 55Fixed icons of executeable on Wintendo.
46 56
47Added a "Show next Mail" button to the OM/Pi 57Added a "Show next Mail" button to the OM/Pi
48mail viewer such that the mail below the current mail 58mail viewer such that the mail below the current mail
49in the mail list view of the current folder 59in the mail list view of the current folder
50can be read with a single click. 60can be read with a single click.
51 61
52 62
53********** VERSION 1.9.13 ************ 63********** VERSION 1.9.13 ************
54 64
55Fixed nasty PwM/Pi file reading bug, when 65Fixed nasty PwM/Pi file reading bug, when
56the used hash algo of file is different then the global 66the used hash algo of file is different then the global
57hash algo. 67hash algo.
58 68
59Added KA/Pi support for opie mailit mailapplication. 69Added KA/Pi support for opie mailit mailapplication.
60 70
61Fixed some bugs in OM/Pi. 71Fixed some bugs in OM/Pi.
62Now character conversion tables are available for the Zaurus 72Now character conversion tables are available for the Zaurus
63to make OM/Pi working properly. 73to make OM/Pi working properly.
64To get the character conversion in OM/Pi working, please download 74To get the character conversion in OM/Pi working, please download
65at the sourceforge project site the package 75at the sourceforge project site the package
66sr-character-conversion_SharpROM_arm.ipk.zip 76sr-character-conversion_SharpROM_arm.ipk.zip
67(or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) 77(or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms)
68from the section "general files for KDE/Pim" 78from the section "general files for KDE/Pim"
69Instructions how to install this package are in a ReadMe in this file. 79Instructions how to install this package are in a ReadMe in this file.
70 80
71 81
72Fixed the orientation change problem in KA/Pi when switching 82Fixed the orientation change problem in KA/Pi when switching
73portrait/landscape mode. 83portrait/landscape mode.
74 84
75French translation available for KA/Pi and OM/Pi. 85French translation available for KA/Pi and OM/Pi.
76 86
77Fixed some problems with categories in KO/Pi in DTM sync. 87Fixed some problems with categories in KO/Pi in DTM sync.
78 88
79Added selection dialog for export to phone in KA/Pi. 89Added selection dialog for export to phone in KA/Pi.
80 90
81If in KO/Pi is an attendee selected to add to a meeting and this 91If in KO/Pi is an attendee selected to add to a meeting and this
82attendee is already in the list of attendees, this person is not added 92attendee is already in the list of attendees, this person is not added
83again. 93again.
84 94
85Some menu cleanup in KA/Pi. 95Some menu cleanup in KA/Pi.
86 96
87********** VERSION 1.9.12 ************ 97********** VERSION 1.9.12 ************
88 98
89Fix for the bug in KO/Pi What's Next view of version 1.9.11. 99Fix for the bug in KO/Pi What's Next view of version 1.9.11.
90 100
91Bugfix: Licence file is now shown again. 101Bugfix: Licence file is now shown again.
92 102
93OM/Pi now supports Unicode (utf8 charset). 103OM/Pi now supports Unicode (utf8 charset).
94Fixed some bugs in OM/Pi. 104Fixed some bugs in OM/Pi.
95 105
96KA/Pi has more German translation. 106KA/Pi has more German translation.
97 107
98 108
99********** VERSION 1.9.11 ************ 109********** VERSION 1.9.11 ************
100 110
101Fixed several problems in PWM/Pi, like 111Fixed several problems in PWM/Pi, like
102asking the user, if unsaved changed are pending 112asking the user, if unsaved changed are pending
103when closing the app. 113when closing the app.
104And PwM/Pi handles now different texts for the 114And PwM/Pi handles now different texts for the
105fields Description, Username, Password, configurable per category. 115fields Description, Username, Password, configurable per category.
106 116
107Fixed a crash in KO/Pi , when importing/loading vcs files 117Fixed a crash in KO/Pi , when importing/loading vcs files
108which have an entry with an attendee with state: 118which have an entry with an attendee with state:
109NEEDS ACTION 119NEEDS ACTION
110 120
111Fixed some problems in the German translation of OM/Pi, 121Fixed some problems in the German translation of OM/Pi,
112which makes some dialogs not fitting on the screen 122which makes some dialogs not fitting on the screen
113of the Z 5500. 123of the Z 5500.
114 124
115Fixed Qtopia crash, when disabling/deinstalling 125Fixed Qtopia crash, when disabling/deinstalling
116KO/Pi alarm applet. 126KO/Pi alarm applet.
117 127
118Implemented direct KDE<->KA/Pi sync for KA/Pi running 128Implemented direct KDE<->KA/Pi sync for KA/Pi running
119on Linux desktop. 129on Linux desktop.
120 130
121Added feature "remove sync info" to sync menu. 131Added feature "remove sync info" to sync menu.
122 132
123Tweaked the KO/Pi What's next view a bit, added 133Tweaked the KO/Pi What's next view a bit, added
124setting to hide events that are done. 134setting to hide events that are done.
125 135
126Disabled "beam receive enabled" on startup to 136Disabled "beam receive enabled" on startup to
127avoid problems if Fastload is enabled. 137avoid problems if Fastload is enabled.
128Please set "beam receive enabled", 138Please set "beam receive enabled",
129if you want to receive data via IR. 139if you want to receive data via IR.
130 140
131Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running 141Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running
132on Linux desktop. 142on Linux desktop.
133 143
134Made in KA/Pi scrolling possible, if details view is selected. 144Made in KA/Pi scrolling possible, if details view is selected.
135(The keyboard focus is set automatically to the search line) 145(The keyboard focus is set automatically to the search line)
136 146
137Fixed a bug in DMT sync, that a new entry in DTM was added 147Fixed a bug in DMT sync, that a new entry in DTM was added
138on every sync to Kx/Pi. 148on every sync to Kx/Pi.
139 149
140Fixed missing writing of KA/Pi categories to DMT entries when syncing. 150Fixed missing writing of KA/Pi categories to DMT entries when syncing.
141 151
142Fixed a bug in DMT sync with todos created in KO/Pi containing 152Fixed a bug in DMT sync with todos created in KO/Pi containing
143non-latin1 characters. 153non-latin1 characters.
144 154
145Rearranged package contents of Sharp-ipks and made all 155Rearranged package contents of Sharp-ipks and made all
146packages installable on SD again. 156packages installable on SD again.
147 157
148Fixed the writing of addressbook data in DTM sync. 158Fixed the writing of addressbook data in DTM sync.
149Empty fields in KA/Pi were not removed. 159Empty fields in KA/Pi were not removed.
150 160
151Added better category handling in KA/Pi: 161Added better category handling in KA/Pi:
152Added item 162Added item
153Edit Categories and 163Edit Categories and
154Manage new categories 164Manage new categories
155to the settings menu. 165to the settings menu.
156Possible to configure a view to display categories. 166Possible to configure a view to display categories.
157 167
158Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. 168Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu.
159 169
160Fixed displaying of "free" days and time in KO Monthview and Agendaview. 170Fixed displaying of "free" days and time in KO Monthview and Agendaview.
161 171
162... and many other bugfixes. 172... and many other bugfixes.
163 173
164********** VERSION 1.9.10 ************ 174********** VERSION 1.9.10 ************
165 175
166Many internal small bugfixes. 176Many internal small bugfixes.
167And fix of the "big" bug in KO/Pi, 177And fix of the "big" bug in KO/Pi,
168that after Syncing the appointments had an offset by several hours. 178that after Syncing the appointments had an offset by several hours.
169That was a problem with the internal timezone setting, 179That was a problem with the internal timezone setting,
170introduced by the changed timezone configuration settings. 180introduced by the changed timezone configuration settings.
171 181
172German translation for OM/Pi is now available. 182German translation for OM/Pi is now available.
173 183
174 184
175********** VERSION 1.9.9 ************ 185********** VERSION 1.9.9 ************
176 186
177KDE-Pim/Pi has a new Member! 187KDE-Pim/Pi has a new Member!
178It is called PWM/Pi (Passwordmanager/platform-independent) 188It is called PWM/Pi (Passwordmanager/platform-independent)
179and it is available for the Zaurus. 189and it is available for the Zaurus.
180It is planned, that it will be available later for Windows. 190It is planned, that it will be available later for Windows.
181(And for Linux, of course). 191(And for Linux, of course).
182It is a port of the Passwordmanager of KDE. 192It is a port of the Passwordmanager of KDE.
183It will need the MicroKDElibs to run. 193It will need the MicroKDElibs to run.
184 194
185Made loading of addressbooks in KA/Pi up to 7 times faster! 195Made loading of addressbooks in KA/Pi up to 7 times faster!
186The bigger your addressbook file, the more starting speed 196The bigger your addressbook file, the more starting speed
187will you gain. (relatively) 197will you gain. (relatively)
188 198
189The Qtopia addressbook connector is now platform independend 199The Qtopia addressbook connector is now platform independend
190as well and should work on any platform for importing/exporting 200as well and should work on any platform for importing/exporting
191Qtopia and Opie XML files. 201Qtopia and Opie XML files.
192 202
193Added a +30min feature to the timezone settings to make 203Added a +30min feature to the timezone settings to make
194KDE-Pim/Pi useable in Australia and other parts on the 204KDE-Pim/Pi useable in Australia and other parts on the
195world with strange timezones ;-) 205world with strange timezones ;-)
196 206
197German "Umlaute" should now be sorted correctly on the Z in KA/Pi. 207German "Umlaute" should now be sorted correctly on the Z in KA/Pi.
198 208
199It is now possible to disable the 209It is now possible to disable the
200"receive data via infrared" feature, such that syncing with 210"receive data via infrared" feature, such that syncing with
201Outlook is now possible again with Kx/Pi runing. 211Outlook is now possible again with Kx/Pi runing.
202Please disable it, before syncing Sharp DTM with Outlook. 212Please disable it, before syncing Sharp DTM with Outlook.
203For your convenience, the "receive data via infrared" feature 213For your convenience, the "receive data via infrared" feature
204is disabled automatically, if you sync Kx/Pi with DTM. 214is disabled automatically, if you sync Kx/Pi with DTM.
205You have to enable it again manually after syncing. 215You have to enable it again manually after syncing.
206Enabling this feature makes it impossible to start the 216Enabling this feature makes it impossible to start the
207Sharp DTM apps. If this feature is enabled, you will only get the 217Sharp DTM apps. If this feature is enabled, you will only get the
208alarm notification from KO/Pi and not from the Sharp calendar. 218alarm notification from KO/Pi and not from the Sharp calendar.
209This is very useful if you sync KO/Pi with Sharp DTM, 219This is very useful if you sync KO/Pi with Sharp DTM,
210because after syncing you usually would get notified about 220because after syncing you usually would get notified about
211an alarm by KO/Pi and the Sharp Calendar. 221an alarm by KO/Pi and the Sharp Calendar.
212 222
213Together with the Linux desktop version of KO/Pi 223Together with the Linux desktop version of KO/Pi
214it is now possible to sync KO/Pi on the Zaurus 224it is now possible to sync KO/Pi on the Zaurus
215with the complete KDE-desktop (3.3 or later) 225with the complete KDE-desktop (3.3 or later)
216calendar data easily. 226calendar data easily.
217That makes it possible to sync the Z with one 227That makes it possible to sync the Z with one
218click of a mouse with the KDE-Desktop. 228click of a mouse with the KDE-Desktop.
219This feature it available for all Zaurus platforms KO/Pi 229This feature it available for all Zaurus platforms KO/Pi
220is running on. 230is running on.
221The only thing needed is a running KO/Pi on Linux and 231The only thing needed is a running KO/Pi on Linux and
222a compiled version of the small 232a compiled version of the small
223KDE-Pim/Pi<->KDE-Desktop access command line program, 233KDE-Pim/Pi<->KDE-Desktop access command line program,
224which is in the KDE-Pim/Pi sources available. 234which is in the KDE-Pim/Pi sources available.
225 235
226The "KDE-desktop" syncing feature for KA/Pi will follow 236The "KDE-desktop" syncing feature for KA/Pi will follow
227in the next releases. 237in the next releases.
228 238
229Fixed the vcard export bug, which had the version 1.9.8. 239Fixed the vcard export bug, which had the version 1.9.8.
230 240
231Added missing GERMAN translation to KO/Pi. 241Added missing GERMAN translation to KO/Pi.
232Hi PsionX, could you add the missing french translation?Thx! 242Hi PsionX, could you add the missing french translation?Thx!
233 243
234Translation files for KA/Pi are available as well. 244Translation files for KA/Pi are available as well.
235GERMAN translation will be available in the next release. 245GERMAN translation will be available in the next release.
236PsionX ( yres, you again ;-) ), could you start translating 246PsionX ( yres, you again ;-) ), could you start translating
237KA/Pi? Thx! 247KA/Pi? Thx!
238 248
239You can download the version 1.9.9 at 249You can download the version 1.9.9 at
240 250
241http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 251http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604
242 252
243Note: 253Note:
244To run the mail program OM/Pi you need libopenssl. 254To run the mail program OM/Pi you need libopenssl.
245A link to a download loaction is available at 255A link to a download loaction is available at
246ZSI at www.killefiz.de 256ZSI at www.killefiz.de
247 257
248 258
249********** VERSION 1.9.8 ************ 259********** VERSION 1.9.8 ************
250 260
251Fixed character decoding in OM/Pi. 261Fixed character decoding in OM/Pi.
252(e.g. German "Umlaute" were not displayed properly.) 262(e.g. German "Umlaute" were not displayed properly.)
253 263
254Made is possible to reparent todos in KO/Pi. 264Made is possible to reparent todos in KO/Pi.
255Use contextmenu or keys (look at Help-Keys + Colors) for that. 265Use contextmenu or keys (look at Help-Keys + Colors) for that.
256 266
257Added the missing Sync-Howto and WhatsNew to the packages. 267Added the missing Sync-Howto and WhatsNew to the packages.
258 268
259KO/Pi on Linux desktop can now sync with KDE desktop. 269KO/Pi on Linux desktop can now sync with KDE desktop.
260That means: When using KO/Pi on Linux desktop for syncing with 270That means: When using KO/Pi on Linux desktop for syncing with
261KDE desktop and the Zaurus, the Zaurus can be synced now 271KDE desktop and the Zaurus, the Zaurus can be synced now
262with all KDE-Calendar resources, not only with one local file. 272with all KDE-Calendar resources, not only with one local file.
263(That makes it possible to sync the Zaurus with the 273(That makes it possible to sync the Zaurus with the
264calendar data on a Kolab server) 274calendar data on a Kolab server)
265 275
266KA/Pi syncing with KDE desktop will be available in the next version. 276KA/Pi syncing with KDE desktop will be available in the next version.
267 277
268 278
269********** VERSION 1.9.7 ************ 279********** VERSION 1.9.7 ************
270 280
271KO/Pi - KA/Pi on Windows: 281KO/Pi - KA/Pi on Windows:
272Now a directory can be defined by the user, where the 282Now a directory can be defined by the user, where the
273application/config data should be saved. 283application/config data should be saved.
274 Define your desired path in the evironment variable 284 Define your desired path in the evironment variable
275 MICROKDEHOME 285 MICROKDEHOME
276 before starting KO/Pi or KA/Pi. 286 before starting KO/Pi or KA/Pi.
277 287
278An easy Kx/Pi to Kx/Pi syncing is now possible 288An easy Kx/Pi to Kx/Pi syncing is now possible
279(it is called Pi-Sync) via network. 289(it is called Pi-Sync) via network.
280Please look at the Sync Howto. 290Please look at the Sync Howto.
281 291
282Exporting of calendar data and contacts to mobile phones is now possible. 292Exporting of calendar data and contacts to mobile phones is now possible.
283The SyncHowto is updated with information howto 293The SyncHowto is updated with information howto
284access/sync mobile phones. 294access/sync mobile phones.
285Please look at the Sync Howto. 295Please look at the Sync Howto.
286 296
287Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. 297Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly.
288Please disable Fastload for the original contact/calendar applications 298Please disable Fastload for the original contact/calendar applications
289and close them. 299and close them.
290KO/Pi and KA/Pi must be running in order to receive the data. 300KO/Pi and KA/Pi must be running in order to receive the data.
291(KO/Pi and KA/Pi are always running if Fastload for them is enabled!) 301(KO/Pi and KA/Pi are always running if Fastload for them is enabled!)
292 302
293In the KA/Pi details view are now the preferred tel. numbers displayed on top 303In the KA/Pi details view are now the preferred tel. numbers displayed on top
294of the other data ( emails/tel.numbers/addresses) 304of the other data ( emails/tel.numbers/addresses)
295 305
296Fixed some syncing problems in KA/Pi. 306Fixed some syncing problems in KA/Pi.
297 307
298Added font settings for the KA/Pi details view. 308Added font settings for the KA/Pi details view.
299Added fields "children's name" and "gender" to KA/Pi. 309Added fields "children's name" and "gender" to KA/Pi.
300 310
301Made searching in KA/Pi better: 311Made searching in KA/Pi better:
302Now the first item in a view is selected after a search automatically and 312Now the first item in a view is selected after a search automatically and
303the views can be scrolled up/down when the search input field has the keyboard focus. 313the views can be scrolled up/down when the search input field has the keyboard focus.
304 314
305And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. 315And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi.
306 316
307 317
308********** VERSION 1.9.6 ************ 318********** VERSION 1.9.6 ************
309 319
310Changes in the external application communication on the Zaurus 320Changes in the external application communication on the Zaurus
311in order to use less RAM when the apps are running. 321in order to use less RAM when the apps are running.
312First syncing of addressbooks (KA/Pi) is possible. 322First syncing of addressbooks (KA/Pi) is possible.
313 323
314 324
315********** VERSION 1.9.5a ************ 325********** VERSION 1.9.5a ************
316 326
317Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. 327Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5.
318Fixed some small bugs. 328Fixed some small bugs.
319KA/Pi shows now the birthday in summary view. 329KA/Pi shows now the birthday in summary view.
320Now OM/Pi and KA/Pi are using the date format defined in KO/Pi 330Now OM/Pi and KA/Pi are using the date format defined in KO/Pi
321for displaying dates. 331for displaying dates.
322 332
323 333
324********** VERSION 1.9.5 ************ 334********** VERSION 1.9.5 ************
325 335
326There is still no Addressbook syncing! 336There is still no Addressbook syncing!
327 337
328New in 1.9.5: 338New in 1.9.5:
329 339
330Many bugfixes. 340Many bugfixes.
331Better searching in KA/Pi. 341Better searching in KA/Pi.
332You can configure in KA/Pi if you want to search only after 342You can configure in KA/Pi if you want to search only after
333<return> key pressed. 343<return> key pressed.
334 344
335Better mail downloading in OM/Pi. 345Better mail downloading in OM/Pi.
336 346
337First experimental alpha version of sync of KO/Pi with mobile phones. 347First experimental alpha version of sync of KO/Pi with mobile phones.
338See gammu documentation for supported phones. 348See gammu documentation for supported phones.
339You 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. 349You 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.
340Quick hint how to use: 350Quick hint how to use:
341NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! 351NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL!
342Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. 352Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp.
343Create syncprofile - mobile device 353Create syncprofile - mobile device
344Remove entry for model. (Leave empty ). 354Remove entry for model. (Leave empty ).
345Enable infrared on Zaurus and your Phone. 355Enable infrared on Zaurus and your Phone.
346Sync. 356Sync.
347To get a more detailed log, start kopi from konsole. 357To get a more detailed log, start kopi from konsole.
348 358
349********** VERSION 1.9.4 ************ 359********** VERSION 1.9.4 ************
350 360
351This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. 361This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus.
352 362
353WARNING: 363WARNING:
354PLEASE BACKUP ALL YOUR DATA! 364PLEASE BACKUP ALL YOUR DATA!
355We have changed a lot and maybe there are some unknown problems. 365We have changed a lot and maybe there are some unknown problems.
356 366
357SYNC HANDLING HAS CHANGED! 367SYNC HANDLING HAS CHANGED!
358Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 368Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
359(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 369(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
360 370
361You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. 371You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs.
362If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. 372If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well.
363 373
364As programs are available: 374As programs are available:
365KO/Pi (korganizer ipk) - a calendar program. 375KO/Pi (korganizer ipk) - a calendar program.
366KA/Pi (kaddressbook ipk ) - an addressbook 376KA/Pi (kaddressbook ipk ) - an addressbook
367OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. 377OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support.
368 378
369An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. 379An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode.
370(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) 380(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia)
371 381
372All the applications are installed in a "Pim" TAB. 382All the applications are installed in a "Pim" TAB.
373If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk 383If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk
374 384
375All the application are integrated. 385All the application are integrated.
376Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. 386Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail.
377 387
378HINT: 388HINT:
379If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. 389If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number.
380 390
381What's new? 391What's new?
382 392
383SYNC HANDLING HAS CHANGED! 393SYNC HANDLING HAS CHANGED!
384Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 394Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
385(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 395(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
386 396
387New in OM/Pi: 397New in OM/Pi:
388When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. 398When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails.
389 399
390New in KO/Pi: 400New in KO/Pi:
391French is now available for KO/Pi. 401French is now available for KO/Pi.
392Choose menu:Actions - Configure:TAB locale 402Choose menu:Actions - Configure:TAB locale
393Syncing has changed. 403Syncing has changed.
394Phone sync available soon. 404Phone sync available soon.
395Not much changes, I cannot remember them ... 405Not much changes, I cannot remember them ...
396 406
397New in KA/Pi: 407New in KA/Pi:
398Beaming possible. 408Beaming possible.
399Sharp DTM readonly access possible( create a new DTM resource ); 409Sharp DTM readonly access possible( create a new DTM resource );
400Better searching possible. 410Better searching possible.
401Search is performed only after pressing the return key. 411Search is performed only after pressing the return key.
402Use wildcard * to specify parts of a name. 412Use wildcard * to specify parts of a name.
403 413
404Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . 414Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * .
405 415
406A big improvement is the new management of the contact access. 416A big improvement is the new management of the contact access.
407In version 1.9.3, every application was using their own addressbook access data. 417In version 1.9.3, every application was using their own addressbook access data.
408That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. 418That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi.
409That was wasting of memory, if you had several hundreds of contacts. 419That was wasting of memory, if you had several hundreds of contacts.
410 420
411Now only KA/Pi accesses the addressbook. 421Now only KA/Pi accesses the addressbook.
412If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. 422If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them.
413If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. 423If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly.
414That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. 424That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first.
415 425
416New in the KO/Pi alarm applet: 426New in the KO/Pi alarm applet:
417Configure your own timer popup menu! 427Configure your own timer popup menu!
418(Text and minutes for timer countdown) 428(Text and minutes for timer countdown)
419Just edit the file 429Just edit the file
420(yourhomedir)/.kopialarmtimerrc 430(yourhomedir)/.kopialarmtimerrc
421and start/stop a timer to get a new menu with the data of this file. 431and start/stop a timer to get a new menu with the data of this file.
422 432
423********** VERSION 1.9.3 ************ 433********** VERSION 1.9.3 ************
4241) 4341)
425Now KO/Pi on Windows imports directly the calendar data of 435Now KO/Pi on Windows imports directly the calendar data of
426an installed Outlook. Should work with OL version >= 2000. 436an installed Outlook. Should work with OL version >= 2000.
427 437
428********** VERSION 1.9.2 ************ 438********** VERSION 1.9.2 ************
4291) 4391)
430KDE-Pim/Pi has got a new member: 440KDE-Pim/Pi has got a new member:
431KmicroMail (KM/Pi) is a mail program, 441KmicroMail (KM/Pi) is a mail program,
432which can handle IMAP and POP mail access. 442which can handle IMAP and POP mail access.
433It is based on Opie-Mail v3. 443It is based on Opie-Mail v3.
434All dependencies to the Opie libraries ar removed, 444All dependencies to the Opie libraries ar removed,
435such that no additional Opie lib is needed. 445such that no additional Opie lib is needed.
436It is already integrated in KO/Pi and KA/Pi. 446It is already integrated in KO/Pi and KA/Pi.
437It it now available for the Zaurus,probably it 447It it now available for the Zaurus,probably it
438will be available for other platforms later. 448will be available for other platforms later.
439Hint: 449Hint:
440Create your own contact (name + email) 450Create your own contact (name + email)
441in KA/Pi, select this contact and choose menu: 451in KA/Pi, select this contact and choose menu:
442Settings - Set Who Am I. 452Settings - Set Who Am I.
443Now the settings of this contact are used as 453Now the settings of this contact are used as
444the sender data in KM/Pi. 454the sender data in KM/Pi.
4452) 4552)
446KDE-Pim/Pi is split up in five different 456KDE-Pim/Pi is split up in five different
447packages now precompiled for Sharp Zaurus: 457packages now precompiled for Sharp Zaurus:
448--kmicrokdelibs_1.9.2_arm.ipk 458--kmicrokdelibs_1.9.2_arm.ipk
449The libs are needed for any 459The libs are needed for any
450of the following programs: 460of the following programs:
451--kaddressbook_1.9.2_arm.ipk 461--kaddressbook_1.9.2_arm.ipk
452--kmicromail_1.9.2_arm.ipk 462--kmicromail_1.9.2_arm.ipk
453--korganizer_1.9.2_arm.ipk 463--korganizer_1.9.2_arm.ipk
454Independ from that, there is the alarm applet 464Independ from that, there is the alarm applet
455available for KO/Pi, which also offers 465available for KO/Pi, which also offers
456quick access for a new mail or 466quick access for a new mail or
457showing the addressbook.: 467showing the addressbook.:
458--korganizer-alarm_1.9.2_arm.ipk 468--korganizer-alarm_1.9.2_arm.ipk
459Independend means, that the alarm applet 469Independend means, that the alarm applet
460does not need any of the libs or programs above to run. 470does not need any of the libs or programs above to run.
461But it would be quite useless without these programs. 471But it would be quite useless without these programs.
462NOTE: 472NOTE:
463If you get a 473If you get a
464"This application depends on other programs" 474"This application depends on other programs"
465during installation of 475during installation of
466--kmicrokdelibs_1.9.2_arm.ipk 476--kmicrokdelibs_1.9.2_arm.ipk
467you probably do not have to care about that. 477you probably do not have to care about that.
468kmicrokdelibs_1.9.2 will come with some 478kmicrokdelibs_1.9.2 will come with some
469resource plugins, which needs additional libraries. 479resource plugins, which needs additional libraries.
470(E.g. libopie1, if you want to use the 480(E.g. libopie1, if you want to use the
471opie resource connector in KA/Pi). 481opie resource connector in KA/Pi).
472If you do not have this libraries installed, 482If you do not have this libraries installed,
473you simply cannot use the resource. 483you simply cannot use the resource.
474To make it clear: 484To make it clear:
475If the libraries are missing, the applications 485If the libraries are missing, the applications
476using kmicrokdelibs will start, 486using kmicrokdelibs will start,
477because the resources are plugins. 487because the resources are plugins.
4783) 4883)
479KO/Pi and friends are now installable on SD-Card! 489KO/Pi and friends are now installable on SD-Card!
480It is recommended to install all libs and apps 490It is recommended to install all libs and apps
481on the SD card or all in the internal storage. 491on the SD card or all in the internal storage.
482There may be problems, if this is mixed. 492There may be problems, if this is mixed.
4834) 4934)
484Fixed two bugs in the alarm notification on Windows. 494Fixed two bugs in the alarm notification on Windows.
4855) 4955)
486Great improvement! 496Great improvement!
487KO/Pi uses now the latest version of libical. 497KO/Pi uses now the latest version of libical.
488Libical is the library which actually reads 498Libical is the library which actually reads
489the calendar files and extract the data from it. 499the calendar files and extract the data from it.
490With the old version, there were problems 500With the old version, there were problems
491(crashes or program hangs) when licical did read 501(crashes or program hangs) when licical did read
492files, which were not stored from KO/Pi. 502files, which were not stored from KO/Pi.
493I do not know, if the new libical works perfect, 503I do not know, if the new libical works perfect,
494but actually it works much better than 504but actually it works much better than
495the old version. 505the old version.
496There are no problems with compatibility with 506There are no problems with compatibility with
497old calendar files of KO/Pi, of course! 507old calendar files of KO/Pi, of course!
4986) 5086)
499New in KA/Pi: 509New in KA/Pi:
500Opie addressbook resource connector available! 510Opie addressbook resource connector available!
501You will need libopie1 and the opie addressbook, 511You will need libopie1 and the opie addressbook,
502of course. 512of course.
503With the Opie addressbook resource connector, 513With the Opie addressbook resource connector,
504you can access the Opie addressbook readonly in KA/Pi. 514you can access the Opie addressbook readonly in KA/Pi.
505If you want to edit or import the data into KA/Pi, 515If you want to edit or import the data into KA/Pi,
506do this: 516do this:
507a) Create an Opie resource. 517a) Create an Opie resource.
508 (Menu: Settings-Configure Resources). 518 (Menu: Settings-Configure Resources).
509After configuration and restarting KA/Pi you should see 519After configuration and restarting KA/Pi you should see
510the Opie contacts in KA/Pi. 520the Opie contacts in KA/Pi.
511b) Select some or all Opie contacts. 521b) Select some or all Opie contacts.
512(NOTE: +++++ 522(NOTE: +++++
513To know exactly, what contacts are Opie contacts, 523To know exactly, what contacts are Opie contacts,
514do this: Choose menu: 524do this: Choose menu:
515View-Modify View - TAB Fields. 525View-Modify View - TAB Fields.
516Select in the above list "Resource" and click 526Select in the above list "Resource" and click
517down arrow to add it to the "Selected fields". 527down arrow to add it to the "Selected fields".
518Click OK. 528Click OK.
519Now you have a new column "Resource" in your list, 529Now you have a new column "Resource" in your list,
520where you can see, what an Opie resource is. 530where you can see, what an Opie resource is.
521++++ NOTE end.) 531++++ NOTE end.)
522Ok, we do have now some Opie contacts seleted. 532Ok, we do have now some Opie contacts seleted.
523(Use SHIFT or CTRL key in order to multiple select). 533(Use SHIFT or CTRL key in order to multiple select).
524c) Choose menu: Edit-Copy. 534c) Choose menu: Edit-Copy.
525d) Choose menu: Edit-Paste. 535d) Choose menu: Edit-Paste.
526e) Select the resource, you want to add the contacts to. 536e) Select the resource, you want to add the contacts to.
527Congrats! Now you have read/write access to the copied 537Congrats! Now you have read/write access to the copied
528opie contacts as "real" KA/Pi contacts. 538opie contacts as "real" KA/Pi contacts.
529 539
530 540
531********** VERSION 1.9.1 ************ 541********** VERSION 1.9.1 ************
5321) 5421)
533 +++ IMPORTANT 1 +++ 543 +++ IMPORTANT 1 +++
534 544
535The storing place of the default calendar 545The storing place of the default calendar
536file has changed! 546file has changed!
537The default calendar file was 547The default calendar file was
538Applications/korganizer/mycalendar.ics 548Applications/korganizer/mycalendar.ics
539on Zaurus and 549on Zaurus and
540(yourHomeDir)/korganizer/mycalendar.ics 550(yourHomeDir)/korganizer/mycalendar.ics
541on Windows/Linux desktop. Now it is 551on Windows/Linux desktop. Now it is
542(yourHomeDir)/kdepim/korganizer/mycalendar.ics 552(yourHomeDir)/kdepim/korganizer/mycalendar.ics
543on Zaurus, Windows and Linux. 553on Zaurus, Windows and Linux.
544To load the old file, choose menu 554To load the old file, choose menu
545File-Load calendar backup. 555File-Load calendar backup.
546(It should be loaded automatically 556(It should be loaded automatically
547at startup with a warning message displayed). 557at startup with a warning message displayed).
548The place of the configuration file has changed too. 558The place of the configuration file has changed too.
549If you want to use your old KO/Pi config, 559If you want to use your old KO/Pi config,
550copy it to 560copy it to
551(yourHomeDir)/kdepim/config/korganizerrc 561(yourHomeDir)/kdepim/config/korganizerrc
552Please read VERSION 1.9.0 - topic 3) as well! 562Please read VERSION 1.9.0 - topic 3) as well!
553 563
554 +++ IMPORTANT 2 +++ 564 +++ IMPORTANT 2 +++
555 565
556Because of the new paths, you will need 566Because of the new paths, you will need
557a new version of the KO/Pi alarm applet 567a new version of the KO/Pi alarm applet
558for Zaurus. 568for Zaurus.
559Use version >= 1.9.1 569Use version >= 1.9.1
560 570
5612) 5712)
562Now the QWhat'sThis Icon works for items 572Now the QWhat'sThis Icon works for items
563in the month view as well. 573in the month view as well.
564(See VERSION 1.7.8 Topic 1) ). 574(See VERSION 1.7.8 Topic 1) ).
5653) 5753)
566You can import birtsdays/anniversaries 576You can import birtsdays/anniversaries
567from KA/Pi into KO/Pi. 577from KA/Pi into KO/Pi.
568Choose menu File-Import birthdays. 578Choose menu File-Import birthdays.
569If you import twice, already imported items 579If you import twice, already imported items
570will not be imported again, if they 580will not be imported again, if they
571have not been changed in KO/Pi. 581have not been changed in KO/Pi.
5724) 5824)
573When syncing with sharp DTM, now a progress 583When syncing with sharp DTM, now a progress
574is shown, when the data is written back. 584is shown, when the data is written back.
575If there is much data in KO/Pi and no data 585If there is much data in KO/Pi and no data
576in DTM, that can take a long time. 586in DTM, that can take a long time.
577(But only for the first time ). 587(But only for the first time ).
5785) 5885)
579In the search dialog, you can search 589In the search dialog, you can search
580now for the name/email of an attendee 590now for the name/email of an attendee
581of an event/todo. 591of an event/todo.
582To get more space for displaying 592To get more space for displaying
583search results, the buttons 593search results, the buttons
584for "search" and "close" on the 594for "search" and "close" on the
585bottom are removed in the PDA version. 595bottom are removed in the PDA version.
586You have to click OK in the top right 596You have to click OK in the top right
587corner to do a search. 597corner to do a search.
5886) 5986)
589Now it is possible to disable the displaying 599Now it is possible to disable the displaying
590of todo items in the Allday part of the Agenda. 600of todo items in the Allday part of the Agenda.
591Choose Menu Action-Configure, 601Choose Menu Action-Configure,
592TAB Todo View, checkbox 602TAB Todo View, checkbox
593"Allday Agenda view shows todos" 603"Allday Agenda view shows todos"
5947) 6047)
595If FastLoad is enabled, now the settings and the 605If FastLoad is enabled, now the settings and the
596calendar data are saved, when KO/Pi is closed. 606calendar data are saved, when KO/Pi is closed.
597(If no Fastload is enabled, KO/Pi saves 607(If no Fastload is enabled, KO/Pi saves
598the data as well, of course) 608the data as well, of course)
5998) 6098)
600The Agenda View has a minimize-splitter now, 610The Agenda View has a minimize-splitter now,
601such that the height of the allday part can be 611such that the height of the allday part can be
602changed quickly. 612changed quickly.
603 613
604********** VERSION 1.9.0 ************ 614********** VERSION 1.9.0 ************
6051) 6151)
606KO/Pi is now merged with the new microKDE from KA/Pi. 616KO/Pi is now merged with the new microKDE from KA/Pi.
607KO/Pi accesses now KA/Pi as the addressbook. 617KO/Pi accesses now KA/Pi as the addressbook.
608The other ddressbook-plugins are not working any longer. 618The other ddressbook-plugins are not working any longer.
609(It is planned, that later KA/Pi itself uses these plugins) 619(It is planned, that later KA/Pi itself uses these plugins)
610New versions of KO/Pi are only available 620New versions of KO/Pi are only available
611together with KA/Pi as the KDE-Pim/Pi package. 621together with KA/Pi as the KDE-Pim/Pi package.
6122) 6222)
613If you click on an attendee of a meeting in the 623If you click on an attendee of a meeting in the
614event viewer, a detailed summary of the 624event viewer, a detailed summary of the
615attendee is shown. 625attendee is shown.
6163) 6263)
617The place of the configuration file has changed. 627The place of the configuration file has changed.
618If you want to use your old KO/Pi config, copy 628If you want to use your old KO/Pi config, copy
619Applications/korganizer/config_korganizerrc 629Applications/korganizer/config_korganizerrc
620to 630to
621Applications/korganizer/config/korganizerrc 631Applications/korganizer/config/korganizerrc
622 632
623********** VERSION 1.7.8 ************ 633********** VERSION 1.7.8 ************
6241) 6341)
625Now the QWhat'sThis ist working. 635Now the QWhat'sThis ist working.
626Enable the QWhat'sThis icon in the toolbar. 636Enable the QWhat'sThis icon in the toolbar.
627(You have to restart to reload the changed toolbar config). 637(You have to restart to reload the changed toolbar config).
628Now click on the QWhat'sThis Icon 638Now click on the QWhat'sThis Icon
629in the top right corner of KO/Pi. 639in the top right corner of KO/Pi.
630Then click on an item in the Agenda View: 640Then click on an item in the Agenda View:
631You will get a detailed display of the items content. 641You will get a detailed display of the items content.
6322) 6422)
633Some other very minor changes. 643Some other very minor changes.
634But I have forgotten the details ... 644But I have forgotten the details ...
635For that reason I start this log here: 645For that reason I start this log here:
636To document my changes, when I am doing it. 646To document my changes, when I am doing it.
637 647
638********** VERSION 1.7.7 ************ 648********** VERSION 1.7.7 ************
639Stable Version of KO/Pi 649Stable Version of KO/Pi
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index b7edccd..f6bdda4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3178 +1,3181 @@
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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include <kcmultidialog.h> 154#include <kcmultidialog.h>
155 155
156#ifdef _WIN32_ 156#ifdef _WIN32_
157 157
158#include "kaimportoldialog.h" 158#include "kaimportoldialog.h"
159#else 159#else
160#include <unistd.h> 160#include <unistd.h>
161#endif 161#endif
162// sync includes 162// sync includes
163#include <libkdepim/ksyncprofile.h> 163#include <libkdepim/ksyncprofile.h>
164#include <libkdepim/ksyncprefsdialog.h> 164#include <libkdepim/ksyncprefsdialog.h>
165 165
166 166
167class KABCatPrefs : public QDialog 167class KABCatPrefs : public QDialog
168{ 168{
169 public: 169 public:
170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
171 QDialog( parent, name, true ) 171 QDialog( parent, name, true )
172 { 172 {
173 setCaption( i18n("Manage new Categories") ); 173 setCaption( i18n("Manage new Categories") );
174 QVBoxLayout* lay = new QVBoxLayout( this ); 174 QVBoxLayout* lay = new QVBoxLayout( this );
175 lay->setSpacing( 3 ); 175 lay->setSpacing( 3 );
176 lay->setMargin( 3 ); 176 lay->setMargin( 3 );
177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
178 lay->addWidget( lab ); 178 lay->addWidget( lab );
179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
180 lay->addWidget( format ); 180 lay->addWidget( format );
181 format->setExclusive ( true ) ; 181 format->setExclusive ( true ) ;
182 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 182 addCatBut = new QRadioButton(i18n("Add to category list"), format );
183 new QRadioButton(i18n("Remove from addressees"), format ); 183 new QRadioButton(i18n("Remove from addressees"), format );
184 addCatBut->setChecked( true ); 184 addCatBut->setChecked( true );
185 QPushButton * ok = new QPushButton( i18n("OK"), this ); 185 QPushButton * ok = new QPushButton( i18n("OK"), this );
186 lay->addWidget( ok ); 186 lay->addWidget( ok );
187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
188 lay->addWidget( cancel ); 188 lay->addWidget( cancel );
189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
191 resize( 200, 200 ); 191 resize( 200, 200 );
192 } 192 }
193 193
194 bool addCat() { return addCatBut->isChecked(); } 194 bool addCat() { return addCatBut->isChecked(); }
195private: 195private:
196 QRadioButton* addCatBut; 196 QRadioButton* addCatBut;
197}; 197};
198 198
199 199
200 200
201class KAex2phonePrefs : public QDialog 201class KAex2phonePrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Export to phone options") ); 207 setCaption( i18n("Export to phone options") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel *lab; 211 QLabel *lab;
212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
213 lab->setAlignment (AlignHCenter ); 213 lab->setAlignment (AlignHCenter );
214 QHBox* temphb; 214 QHBox* temphb;
215 temphb = new QHBox( this ); 215 temphb = new QHBox( this );
216 new QLabel( i18n("I/O device: "), temphb ); 216 new QLabel( i18n("I/O device: "), temphb );
217 mPhoneDevice = new QLineEdit( temphb); 217 mPhoneDevice = new QLineEdit( temphb);
218 lay->addWidget( temphb ); 218 lay->addWidget( temphb );
219 temphb = new QHBox( this ); 219 temphb = new QHBox( this );
220 new QLabel( i18n("Connection: "), temphb ); 220 new QLabel( i18n("Connection: "), temphb );
221 mPhoneConnection = new QLineEdit( temphb); 221 mPhoneConnection = new QLineEdit( temphb);
222 lay->addWidget( temphb ); 222 lay->addWidget( temphb );
223 temphb = new QHBox( this ); 223 temphb = new QHBox( this );
224 new QLabel( i18n("Model(opt.): "), temphb ); 224 new QLabel( i18n("Model(opt.): "), temphb );
225 mPhoneModel = new QLineEdit( temphb); 225 mPhoneModel = new QLineEdit( temphb);
226 lay->addWidget( temphb ); 226 lay->addWidget( temphb );
227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
228 // lay->addWidget( mWriteToSim ); 228 // lay->addWidget( mWriteToSim );
229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
230 lab->setAlignment (AlignHCenter ); 230 lab->setAlignment (AlignHCenter );
231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
232 lay->addWidget( ok ); 232 lay->addWidget( ok );
233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
234 lay->addWidget( cancel ); 234 lay->addWidget( cancel );
235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
237 resize( 220, 240 ); 237 resize( 220, 240 );
238 238
239 } 239 }
240 240
241public: 241public:
242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
243 QCheckBox* mWriteToSim; 243 QCheckBox* mWriteToSim;
244}; 244};
245 245
246 246
247bool pasteWithNewUid = true; 247bool pasteWithNewUid = true;
248 248
249#ifdef KAB_EMBEDDED 249#ifdef KAB_EMBEDDED
250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
254#else //KAB_EMBEDDED 254#else //KAB_EMBEDDED
255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
258 mReadWrite( readWrite ), mModified( false ) 258 mReadWrite( readWrite ), mModified( false )
259#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
260{ 260{
261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
262 // syncManager->setBlockSave(false); 262 // syncManager->setBlockSave(false);
263 mMiniSplitter = 0; 263 mMiniSplitter = 0;
264 mExtensionBarSplitter = 0; 264 mExtensionBarSplitter = 0;
265 mIsPart = !parent->inherits( "KAddressBookMain" ); 265 mIsPart = !parent->inherits( "KAddressBookMain" );
266 mAddressBook = KABC::StdAddressBook::self(); 266 mAddressBook = KABC::StdAddressBook::self();
267 KABC::StdAddressBook::setAutomaticSave( false ); 267 KABC::StdAddressBook::setAutomaticSave( false );
268 268
269#ifndef KAB_EMBEDDED 269#ifndef KAB_EMBEDDED
270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
271#endif //KAB_EMBEDDED 271#endif //KAB_EMBEDDED
272 272
273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
274 SLOT( addressBookChanged() ) ); 274 SLOT( addressBookChanged() ) );
275 275
276#if 0 276#if 0
277 // LP moved to addressbook init method 277 // LP moved to addressbook init method
278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
279 "X-Department", "KADDRESSBOOK" ); 279 "X-Department", "KADDRESSBOOK" );
280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
281 "X-Profession", "KADDRESSBOOK" ); 281 "X-Profession", "KADDRESSBOOK" );
282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
283 "X-AssistantsName", "KADDRESSBOOK" ); 283 "X-AssistantsName", "KADDRESSBOOK" );
284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
285 "X-ManagersName", "KADDRESSBOOK" ); 285 "X-ManagersName", "KADDRESSBOOK" );
286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
287 "X-SpousesName", "KADDRESSBOOK" ); 287 "X-SpousesName", "KADDRESSBOOK" );
288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
289 "X-Office", "KADDRESSBOOK" ); 289 "X-Office", "KADDRESSBOOK" );
290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
291 "X-IMAddress", "KADDRESSBOOK" ); 291 "X-IMAddress", "KADDRESSBOOK" );
292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
293 "X-Anniversary", "KADDRESSBOOK" ); 293 "X-Anniversary", "KADDRESSBOOK" );
294 294
295 //US added this field to become compatible with Opie/qtopia addressbook 295 //US added this field to become compatible with Opie/qtopia addressbook
296 // values can be "female" or "male" or "". An empty field represents undefined. 296 // values can be "female" or "male" or "". An empty field represents undefined.
297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
298 "X-Gender", "KADDRESSBOOK" ); 298 "X-Gender", "KADDRESSBOOK" );
299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
300 "X-Children", "KADDRESSBOOK" ); 300 "X-Children", "KADDRESSBOOK" );
301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
302 "X-FreeBusyUrl", "KADDRESSBOOK" ); 302 "X-FreeBusyUrl", "KADDRESSBOOK" );
303#endif 303#endif
304 initGUI(); 304 initGUI();
305 305
306 mIncSearchWidget->setFocus(); 306 mIncSearchWidget->setFocus();
307 307
308 308
309 connect( mViewManager, SIGNAL( selected( const QString& ) ), 309 connect( mViewManager, SIGNAL( selected( const QString& ) ),
310 SLOT( setContactSelected( const QString& ) ) ); 310 SLOT( setContactSelected( const QString& ) ) );
311 connect( mViewManager, SIGNAL( executed( const QString& ) ), 311 connect( mViewManager, SIGNAL( executed( const QString& ) ),
312 SLOT( executeContact( const QString& ) ) ); 312 SLOT( executeContact( const QString& ) ) );
313 313
314 connect( mViewManager, SIGNAL( deleteRequest( ) ), 314 connect( mViewManager, SIGNAL( deleteRequest( ) ),
315 SLOT( deleteContacts( ) ) ); 315 SLOT( deleteContacts( ) ) );
316 connect( mViewManager, SIGNAL( modified() ), 316 connect( mViewManager, SIGNAL( modified() ),
317 SLOT( setModified() ) ); 317 SLOT( setModified() ) );
318 318
319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
321 321
322 connect( mXXPortManager, SIGNAL( modified() ), 322 connect( mXXPortManager, SIGNAL( modified() ),
323 SLOT( setModified() ) ); 323 SLOT( setModified() ) );
324 324
325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
326 SLOT( incrementalSearch( const QString& ) ) ); 326 SLOT( incrementalSearch( const QString& ) ) );
327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
328 mJumpButtonBar, SLOT( recreateButtons() ) ); 328 mJumpButtonBar, SLOT( recreateButtons() ) );
329 329
330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
331 SLOT( sendMail( const QString& ) ) ); 331 SLOT( sendMail( const QString& ) ) );
332 332
333 333
334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
338 338
339 339
340#ifndef KAB_EMBEDDED 340#ifndef KAB_EMBEDDED
341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
342 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 342 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
343 343
344 connect( mDetails, SIGNAL( browse( const QString& ) ), 344 connect( mDetails, SIGNAL( browse( const QString& ) ),
345 SLOT( browse( const QString& ) ) ); 345 SLOT( browse( const QString& ) ) );
346 346
347 347
348 mAddressBookService = new KAddressBookService( this ); 348 mAddressBookService = new KAddressBookService( this );
349 349
350#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
351 351
352 mMessageTimer = new QTimer( this ); 352 mMessageTimer = new QTimer( this );
353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
354 mEditorDialog = 0; 354 mEditorDialog = 0;
355 createAddresseeEditorDialog( this ); 355 createAddresseeEditorDialog( this );
356 setModified( false ); 356 setModified( false );
357 mBRdisabled = false; 357 mBRdisabled = false;
358#ifndef DESKTOP_VERSION 358#ifndef DESKTOP_VERSION
359 infrared = 0; 359 infrared = 0;
360#endif 360#endif
361 //toggleBeamReceive( ); 361 //toggleBeamReceive( );
362 //mMainWindow->toolBar()->show(); 362 //mMainWindow->toolBar()->show();
363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
364 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 364 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
365} 365}
366 366
367void KABCore::updateToolBar() 367void KABCore::updateToolBar()
368{ 368{
369 static int iii = 0; 369 static int iii = 0;
370 ++iii; 370 ++iii;
371 mMainWindow->toolBar()->repaintMe(); 371 mMainWindow->toolBar()->repaintMe();
372 if ( iii < 5 ) 372 if ( iii < 5 )
373 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 373 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
374} 374}
375KABCore::~KABCore() 375KABCore::~KABCore()
376{ 376{
377 // save(); 377 // save();
378 //saveSettings(); 378 //saveSettings();
379 //KABPrefs::instance()->writeConfig(); 379 //KABPrefs::instance()->writeConfig();
380 delete AddresseeConfig::instance(); 380 delete AddresseeConfig::instance();
381 mAddressBook = 0; 381 mAddressBook = 0;
382 KABC::StdAddressBook::close(); 382 KABC::StdAddressBook::close();
383 383
384 delete syncManager; 384 delete syncManager;
385#ifndef DESKTOP_VERSION 385#ifndef DESKTOP_VERSION
386 if ( infrared ) 386 if ( infrared )
387 delete infrared; 387 delete infrared;
388#endif 388#endif
389} 389}
390void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 390void KABCore::receive( const QCString& cmsg, const QByteArray& data )
391{ 391{
392 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 392 qDebug("KA: QCOP message received: %s ", cmsg.data() );
393 if ( cmsg == "setDocument(QString)" ) { 393 if ( cmsg == "setDocument(QString)" ) {
394 QDataStream stream( data, IO_ReadOnly ); 394 QDataStream stream( data, IO_ReadOnly );
395 QString fileName; 395 QString fileName;
396 stream >> fileName; 396 stream >> fileName;
397 recieve( fileName ); 397 recieve( fileName );
398 return; 398 return;
399 } 399 }
400} 400}
401void KABCore::toggleBeamReceive( ) 401void KABCore::toggleBeamReceive( )
402{ 402{
403 if ( mBRdisabled ) 403 if ( mBRdisabled )
404 return; 404 return;
405#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
406 if ( infrared ) { 406 if ( infrared ) {
407 qDebug("AB disable BeamReceive "); 407 qDebug("AB disable BeamReceive ");
408 delete infrared; 408 delete infrared;
409 infrared = 0; 409 infrared = 0;
410 mActionBR->setChecked(false); 410 mActionBR->setChecked(false);
411 return; 411 return;
412 } 412 }
413 qDebug("AB enable BeamReceive "); 413 qDebug("AB enable BeamReceive ");
414 mActionBR->setChecked(true); 414 mActionBR->setChecked(true);
415 415
416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
418#endif 418#endif
419} 419}
420 420
421 421
422void KABCore::disableBR(bool b) 422void KABCore::disableBR(bool b)
423{ 423{
424#ifndef DESKTOP_VERSION 424#ifndef DESKTOP_VERSION
425 if ( b ) { 425 if ( b ) {
426 if ( infrared ) { 426 if ( infrared ) {
427 toggleBeamReceive( ); 427 toggleBeamReceive( );
428 } 428 }
429 mBRdisabled = true; 429 mBRdisabled = true;
430 } else { 430 } else {
431 if ( mBRdisabled ) { 431 if ( mBRdisabled ) {
432 mBRdisabled = false; 432 mBRdisabled = false;
433 //toggleBeamReceive( ); 433 //toggleBeamReceive( );
434 } 434 }
435 } 435 }
436#endif 436#endif
437 437
438} 438}
439void KABCore::recieve( QString fn ) 439void KABCore::recieve( QString fn )
440{ 440{
441 //qDebug("KABCore::recieve "); 441 //qDebug("KABCore::recieve ");
442 int count = mAddressBook->importFromFile( fn, true ); 442 int count = mAddressBook->importFromFile( fn, true );
443 if ( count ) 443 if ( count )
444 setModified( true ); 444 setModified( true );
445 mViewManager->refreshView(); 445 mViewManager->refreshView();
446 message(i18n("%1 contact(s) received!").arg( count )); 446 message(i18n("%1 contact(s) received!").arg( count ));
447 topLevelWidget()->showMaximized(); 447 topLevelWidget()->showMaximized();
448 topLevelWidget()->raise(); 448 topLevelWidget()->raise();
449} 449}
450void KABCore::restoreSettings() 450void KABCore::restoreSettings()
451{ 451{
452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
453 453
454 bool state; 454 bool state;
455 455
456 if (mMultipleViewsAtOnce) 456 if (mMultipleViewsAtOnce)
457 state = KABPrefs::instance()->mDetailsPageVisible; 457 state = KABPrefs::instance()->mDetailsPageVisible;
458 else 458 else
459 state = false; 459 state = false;
460 460
461 mActionDetails->setChecked( state ); 461 mActionDetails->setChecked( state );
462 setDetailsVisible( state ); 462 setDetailsVisible( state );
463 463
464 state = KABPrefs::instance()->mJumpButtonBarVisible; 464 state = KABPrefs::instance()->mJumpButtonBarVisible;
465 465
466 mActionJumpBar->setChecked( state ); 466 mActionJumpBar->setChecked( state );
467 setJumpButtonBarVisible( state ); 467 setJumpButtonBarVisible( state );
468/*US 468/*US
469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
470 if ( splitterSize.count() == 0 ) { 470 if ( splitterSize.count() == 0 ) {
471 splitterSize.append( width() / 2 ); 471 splitterSize.append( width() / 2 );
472 splitterSize.append( width() / 2 ); 472 splitterSize.append( width() / 2 );
473 } 473 }
474 mMiniSplitter->setSizes( splitterSize ); 474 mMiniSplitter->setSizes( splitterSize );
475 if ( mExtensionBarSplitter ) { 475 if ( mExtensionBarSplitter ) {
476 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 476 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
477 if ( splitterSize.count() == 0 ) { 477 if ( splitterSize.count() == 0 ) {
478 splitterSize.append( width() / 2 ); 478 splitterSize.append( width() / 2 );
479 splitterSize.append( width() / 2 ); 479 splitterSize.append( width() / 2 );
480 } 480 }
481 mExtensionBarSplitter->setSizes( splitterSize ); 481 mExtensionBarSplitter->setSizes( splitterSize );
482 482
483 } 483 }
484*/ 484*/
485 mViewManager->restoreSettings(); 485 mViewManager->restoreSettings();
486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
487 mExtensionManager->restoreSettings(); 487 mExtensionManager->restoreSettings();
488#ifdef DESKTOP_VERSION 488#ifdef DESKTOP_VERSION
489 int wid = width(); 489 int wid = width();
490 if ( wid < 10 ) 490 if ( wid < 10 )
491 wid = 400; 491 wid = 400;
492#else 492#else
493 int wid = QApplication::desktop()->width(); 493 int wid = QApplication::desktop()->width();
494 if ( wid < 640 ) 494 if ( wid < 640 )
495 wid = QApplication::desktop()->height(); 495 wid = QApplication::desktop()->height();
496#endif 496#endif
497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
498 if ( true /*splitterSize.count() == 0*/ ) { 498 if ( true /*splitterSize.count() == 0*/ ) {
499 splitterSize.append( wid / 2 ); 499 splitterSize.append( wid / 2 );
500 splitterSize.append( wid / 2 ); 500 splitterSize.append( wid / 2 );
501 } 501 }
502 mMiniSplitter->setSizes( splitterSize ); 502 mMiniSplitter->setSizes( splitterSize );
503 if ( mExtensionBarSplitter ) { 503 if ( mExtensionBarSplitter ) {
504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
505 if ( true /*splitterSize.count() == 0*/ ) { 505 if ( true /*splitterSize.count() == 0*/ ) {
506 splitterSize.append( wid / 2 ); 506 splitterSize.append( wid / 2 );
507 splitterSize.append( wid / 2 ); 507 splitterSize.append( wid / 2 );
508 } 508 }
509 mExtensionBarSplitter->setSizes( splitterSize ); 509 mExtensionBarSplitter->setSizes( splitterSize );
510 510
511 } 511 }
512 512
513 513
514} 514}
515 515
516void KABCore::saveSettings() 516void KABCore::saveSettings()
517{ 517{
518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
519 if ( mExtensionBarSplitter ) 519 if ( mExtensionBarSplitter )
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
523#ifndef KAB_EMBEDDED 523#ifndef KAB_EMBEDDED
524 524
525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
527#endif //KAB_EMBEDDED 527#endif //KAB_EMBEDDED
528 mExtensionManager->saveSettings(); 528 mExtensionManager->saveSettings();
529 mViewManager->saveSettings(); 529 mViewManager->saveSettings();
530 530
531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
532} 532}
533 533
534KABC::AddressBook *KABCore::addressBook() const 534KABC::AddressBook *KABCore::addressBook() const
535{ 535{
536 return mAddressBook; 536 return mAddressBook;
537} 537}
538 538
539KConfig *KABCore::config() 539KConfig *KABCore::config()
540{ 540{
541#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
542 return KABPrefs::instance()->config(); 542 return KABPrefs::instance()->config();
543#else //KAB_EMBEDDED 543#else //KAB_EMBEDDED
544 return KABPrefs::instance()->getConfig(); 544 return KABPrefs::instance()->getConfig();
545#endif //KAB_EMBEDDED 545#endif //KAB_EMBEDDED
546} 546}
547 547
548KActionCollection *KABCore::actionCollection() const 548KActionCollection *KABCore::actionCollection() const
549{ 549{
550 return mGUIClient->actionCollection(); 550 return mGUIClient->actionCollection();
551} 551}
552 552
553KABC::Field *KABCore::currentSearchField() const 553KABC::Field *KABCore::currentSearchField() const
554{ 554{
555 if (mIncSearchWidget) 555 if (mIncSearchWidget)
556 return mIncSearchWidget->currentField(); 556 return mIncSearchWidget->currentField();
557 else 557 else
558 return 0; 558 return 0;
559} 559}
560 560
561QStringList KABCore::selectedUIDs() const 561QStringList KABCore::selectedUIDs() const
562{ 562{
563 return mViewManager->selectedUids(); 563 return mViewManager->selectedUids();
564} 564}
565 565
566KABC::Resource *KABCore::requestResource( QWidget *parent ) 566KABC::Resource *KABCore::requestResource( QWidget *parent )
567{ 567{
568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
569 569
570 QPtrList<KRES::Resource> kresResources; 570 QPtrList<KRES::Resource> kresResources;
571 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 571 QPtrListIterator<KABC::Resource> resIt( kabcResources );
572 KABC::Resource *resource; 572 KABC::Resource *resource;
573 while ( ( resource = resIt.current() ) != 0 ) { 573 while ( ( resource = resIt.current() ) != 0 ) {
574 ++resIt; 574 ++resIt;
575 if ( !resource->readOnly() ) { 575 if ( !resource->readOnly() ) {
576 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 576 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
577 if ( res ) 577 if ( res )
578 kresResources.append( res ); 578 kresResources.append( res );
579 } 579 }
580 } 580 }
581 581
582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
583 return static_cast<KABC::Resource*>( res ); 583 return static_cast<KABC::Resource*>( res );
584} 584}
585 585
586#ifndef KAB_EMBEDDED 586#ifndef KAB_EMBEDDED
587KAboutData *KABCore::createAboutData() 587KAboutData *KABCore::createAboutData()
588#else //KAB_EMBEDDED 588#else //KAB_EMBEDDED
589void KABCore::createAboutData() 589void KABCore::createAboutData()
590#endif //KAB_EMBEDDED 590#endif //KAB_EMBEDDED
591{ 591{
592#ifndef KAB_EMBEDDED 592#ifndef KAB_EMBEDDED
593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
594 "3.1", I18N_NOOP( "The KDE Address Book" ), 594 "3.1", I18N_NOOP( "The KDE Address Book" ),
595 KAboutData::License_GPL_V2, 595 KAboutData::License_GPL_V2,
596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
599 about->addAuthor( "Cornelius Schumacher", 599 about->addAuthor( "Cornelius Schumacher",
600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
601 "schumacher@kde.org" ); 601 "schumacher@kde.org" );
602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
603 "mpilone@slac.com" ); 603 "mpilone@slac.com" );
604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
607 "michel@klaralvdalens-datakonsult.se" ); 607 "michel@klaralvdalens-datakonsult.se" );
608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
609 "hansen@kde.org" ); 609 "hansen@kde.org" );
610 610
611 return about; 611 return about;
612#endif //KAB_EMBEDDED 612#endif //KAB_EMBEDDED
613 613
614 QString version; 614 QString version;
615#include <../version> 615#include <../version>
616 QMessageBox::about( this, "About KAddressbook/Pi", 616 QMessageBox::about( this, "About KAddressbook/Pi",
617 "KAddressbook/Platform-independent\n" 617 "KAddressbook/Platform-independent\n"
618 "(KA/Pi) " +version + " - " + 618 "(KA/Pi) " +version + " - " +
619#ifdef DESKTOP_VERSION 619#ifdef DESKTOP_VERSION
620 "Desktop Edition\n" 620 "Desktop Edition\n"
621#else 621#else
622 "PDA-Edition\n" 622 "PDA-Edition\n"
623 "for: Zaurus 5500 / 7x0 / 8x0\n" 623 "for: Zaurus 5500 / 7x0 / 8x0\n"
624#endif 624#endif
625 625
626 "(c) 2004 Ulf Schenk\n" 626 "(c) 2004 Ulf Schenk\n"
627 "(c) 2004 Lutz Rogowski\n" 627 "(c) 2004 Lutz Rogowski\n"
628 "(c) 1997-2003, The KDE PIM Team\n" 628 "(c) 1997-2003, The KDE PIM Team\n"
629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
630 "Don Sanders Original author\n" 630 "Don Sanders Original author\n"
631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
633 "Greg Stern DCOP interface\n" 633 "Greg Stern DCOP interface\n"
634 "Mark Westcot Contact pinning\n" 634 "Mark Westcot Contact pinning\n"
635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
637#ifdef _WIN32_ 637#ifdef _WIN32_
638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
639#endif 639#endif
640 ); 640 );
641} 641}
642 642
643void KABCore::setContactSelected( const QString &uid ) 643void KABCore::setContactSelected( const QString &uid )
644{ 644{
645 KABC::Addressee addr = mAddressBook->findByUid( uid ); 645 KABC::Addressee addr = mAddressBook->findByUid( uid );
646 if ( !mDetails->isHidden() ) 646 if ( !mDetails->isHidden() )
647 mDetails->setAddressee( addr ); 647 mDetails->setAddressee( addr );
648 648
649 if ( !addr.isEmpty() ) { 649 if ( !addr.isEmpty() ) {
650 emit contactSelected( addr.formattedName() ); 650 emit contactSelected( addr.formattedName() );
651 KABC::Picture pic = addr.photo(); 651 KABC::Picture pic = addr.photo();
652 if ( pic.isIntern() ) { 652 if ( pic.isIntern() ) {
653//US emit contactSelected( pic.data() ); 653//US emit contactSelected( pic.data() );
654//US instead use: 654//US instead use:
655 QPixmap px; 655 QPixmap px;
656 if (pic.data().isNull() != true) 656 if (pic.data().isNull() != true)
657 { 657 {
658 px.convertFromImage(pic.data()); 658 px.convertFromImage(pic.data());
659 } 659 }
660 660
661 emit contactSelected( px ); 661 emit contactSelected( px );
662 } 662 }
663 } 663 }
664 664
665 665
666 mExtensionManager->setSelectionChanged(); 666 mExtensionManager->setSelectionChanged();
667 667
668 // update the actions 668 // update the actions
669 bool selected = !uid.isEmpty(); 669 bool selected = !uid.isEmpty();
670 670
671 if ( mReadWrite ) { 671 if ( mReadWrite ) {
672 mActionCut->setEnabled( selected ); 672 mActionCut->setEnabled( selected );
673 mActionPaste->setEnabled( selected ); 673 mActionPaste->setEnabled( selected );
674 } 674 }
675 675
676 mActionCopy->setEnabled( selected ); 676 mActionCopy->setEnabled( selected );
677 mActionDelete->setEnabled( selected ); 677 mActionDelete->setEnabled( selected );
678 mActionEditAddressee->setEnabled( selected ); 678 mActionEditAddressee->setEnabled( selected );
679 mActionMail->setEnabled( selected ); 679 mActionMail->setEnabled( selected );
680 mActionMailVCard->setEnabled( selected ); 680 mActionMailVCard->setEnabled( selected );
681 //if (mActionBeam) 681 //if (mActionBeam)
682 //mActionBeam->setEnabled( selected ); 682 //mActionBeam->setEnabled( selected );
683 mActionWhoAmI->setEnabled( selected ); 683 mActionWhoAmI->setEnabled( selected );
684} 684}
685 685
686void KABCore::sendMail() 686void KABCore::sendMail()
687{ 687{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 688 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 689}
690 690
691void KABCore::sendMail( const QString& emaillist ) 691void KABCore::sendMail( const QString& emaillist )
692{ 692{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 694 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 696 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 697 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 698}
699 699
700 700
701 701
702void KABCore::mailVCard() 702void KABCore::mailVCard()
703{ 703{
704 QStringList uids = mViewManager->selectedUids(); 704 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 705 if ( !uids.isEmpty() )
706 mailVCard( uids ); 706 mailVCard( uids );
707} 707}
708 708
709void KABCore::mailVCard( const QStringList& uids ) 709void KABCore::mailVCard( const QStringList& uids )
710{ 710{
711 QStringList urls; 711 QStringList urls;
712 712
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 714
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 715 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 716
717 717
718 718
719 QDir().mkdir( dirName, true ); 719 QDir().mkdir( dirName, true );
720 720
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 722 KABC::Addressee a = mAddressBook->findByUid( *it );
723 723
724 if ( a.isEmpty() ) 724 if ( a.isEmpty() )
725 continue; 725 continue;
726 726
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 727 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 728
729 QString fileName = dirName + "/" + name; 729 QString fileName = dirName + "/" + name;
730 730
731 QFile outFile(fileName); 731 QFile outFile(fileName);
732 732
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 734 KABC::VCardConverter converter;
735 QString vcard; 735 QString vcard;
736 736
737 converter.addresseeToVCard( a, vcard ); 737 converter.addresseeToVCard( a, vcard );
738 738
739 QTextStream t( &outFile ); // use a text stream 739 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 740 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 741 t << vcard;
742 742
743 outFile.close(); 743 outFile.close();
744 744
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*/
765void KABCore::beamMySelf() 765void 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}
780void KABCore::updateMainWindow() 780void KABCore::updateMainWindow()
781{ 781{
782 782
783 mMainWindow->showMaximized(); 783 mMainWindow->showMaximized();
784 mMainWindow->update(); 784 mMainWindow->update();
785} 785}
786void KABCore::resizeEvent(QResizeEvent* e ) 786void KABCore::resizeEvent(QResizeEvent* e )
787{ 787{
788 if ( !mMiniSplitter ) 788 if ( !mMiniSplitter )
789 return; 789 return;
790 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
790 if ( QApplication::desktop()->width() >= 480 ) { 791 if ( QApplication::desktop()->width() >= 480 ) {
791 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 792 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
792 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 793 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
793 mMiniSplitter->setOrientation( Qt::Horizontal); 794 mMiniSplitter->setOrientation( Qt::Horizontal);
794 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
795 if ( QApplication::desktop()->width() <= 640 ) { 796 if ( QApplication::desktop()->width() <= 640 ) {
796 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 797 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
797 mViewManager->getFilterAction()->setComboWidth( 150 ); 798 mViewManager->getFilterAction()->setComboWidth( 150 );
798 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 799 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
799 } 800 }
800 } 801 }
801 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 802 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
802 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 803 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
803 mMiniSplitter->setOrientation( Qt::Vertical ); 804 mMiniSplitter->setOrientation( Qt::Vertical );
804 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 805 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
805 if ( QApplication::desktop()->width() <= 640 ) { 806 if ( QApplication::desktop()->width() <= 640 ) {
806 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 807 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
807 mMainWindow->showMinimized(); 808 mMainWindow->showMinimized();
808 mViewManager->getFilterAction()->setComboWidth( 0 ); 809 mViewManager->getFilterAction()->setComboWidth( 0 );
809 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 810 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
810 } 811 }
811 } 812 }
812 } 813 }
813 } 814 }
814 815
815} 816}
816void KABCore::export2phone() 817void KABCore::export2phone()
817{ 818{
818 819
819 QStringList uids; 820 QStringList uids;
820 XXPortSelectDialog dlg( this, false, this ); 821 XXPortSelectDialog dlg( this, false, this );
821 if ( dlg.exec() ) 822 if ( dlg.exec() )
822 uids = dlg.uids(); 823 uids = dlg.uids();
823 else 824 else
824 return; 825 return;
825 if ( uids.isEmpty() ) 826 if ( uids.isEmpty() )
826 return; 827 return;
827 // qDebug("count %d ", uids.count()); 828 // qDebug("count %d ", uids.count());
828 829
829 KAex2phonePrefs ex2phone; 830 KAex2phonePrefs ex2phone;
830 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 831 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
831 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 832 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
832 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 833 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
833 834
834 if ( !ex2phone.exec() ) { 835 if ( !ex2phone.exec() ) {
835 return; 836 return;
836 } 837 }
837 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 838 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
838 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 839 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
839 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 840 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
840 841
841 842
842 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 843 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
843 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 844 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
844 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 845 KPimGlobalPrefs::instance()->mEx2PhoneModel );
845 846
846 QString fileName = getPhoneFile(); 847 QString fileName = getPhoneFile();
847 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 848 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
848 return; 849 return;
849 850
850 message(i18n("Exporting to phone...")); 851 message(i18n("Exporting to phone..."));
851 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 852 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
852 853
853} 854}
854QString KABCore::getPhoneFile() 855QString KABCore::getPhoneFile()
855{ 856{
856#ifdef DESKTOP_VERSION 857#ifdef DESKTOP_VERSION
857 return locateLocal("tmp", "phonefile.vcf"); 858 return locateLocal("tmp", "phonefile.vcf");
858#else 859#else
859 return "/tmp/phonefile.vcf"; 860 return "/tmp/phonefile.vcf";
860#endif 861#endif
861 862
862} 863}
863void KABCore::writeToPhone( ) 864void KABCore::writeToPhone( )
864{ 865{
865 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 866 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
866 message(i18n("Export to phone finished!")); 867 message(i18n("Export to phone finished!"));
867 else 868 else
868 qDebug(i18n("Error exporting to phone")); 869 qDebug(i18n("Error exporting to phone"));
869} 870}
870void KABCore::beamVCard() 871void KABCore::beamVCard()
871{ 872{
872 QStringList uids; 873 QStringList uids;
873 XXPortSelectDialog dlg( this, false, this ); 874 XXPortSelectDialog dlg( this, false, this );
874 if ( dlg.exec() ) 875 if ( dlg.exec() )
875 uids = dlg.uids(); 876 uids = dlg.uids();
876 else 877 else
877 return; 878 return;
878 if ( uids.isEmpty() ) 879 if ( uids.isEmpty() )
879 return; 880 return;
880 beamVCard( uids ); 881 beamVCard( uids );
881} 882}
882 883
883 884
884void KABCore::beamVCard(const QStringList& uids) 885void KABCore::beamVCard(const QStringList& uids)
885{ 886{
886 887
887 // LR: we should use the /tmp dir on the Zaurus, 888 // LR: we should use the /tmp dir on the Zaurus,
888 // because: /tmp = RAM, (HOME)/kdepim = flash memory 889 // because: /tmp = RAM, (HOME)/kdepim = flash memory
889 890
890#ifdef DESKTOP_VERSION 891#ifdef DESKTOP_VERSION
891 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 892 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
892#else 893#else
893 QString fileName = "/tmp/kapibeamfile.vcf"; 894 QString fileName = "/tmp/kapibeamfile.vcf";
894#endif 895#endif
895 896
896 KABC::VCardConverter converter; 897 KABC::VCardConverter converter;
897 QString description; 898 QString description;
898 QString datastream; 899 QString datastream;
899 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 900 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
900 KABC::Addressee a = mAddressBook->findByUid( *it ); 901 KABC::Addressee a = mAddressBook->findByUid( *it );
901 902
902 if ( a.isEmpty() ) 903 if ( a.isEmpty() )
903 continue; 904 continue;
904 905
905 if (description.isEmpty()) 906 if (description.isEmpty())
906 description = a.formattedName(); 907 description = a.formattedName();
907 908
908 QString vcard; 909 QString vcard;
909 converter.addresseeToVCard( a, vcard ); 910 converter.addresseeToVCard( a, vcard );
910 int start = 0; 911 int start = 0;
911 int next; 912 int next;
912 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 913 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
913 int semi = vcard.find(";", next); 914 int semi = vcard.find(";", next);
914 int dopp = vcard.find(":", next); 915 int dopp = vcard.find(":", next);
915 int sep; 916 int sep;
916 if ( semi < dopp && semi >= 0 ) 917 if ( semi < dopp && semi >= 0 )
917 sep = semi ; 918 sep = semi ;
918 else 919 else
919 sep = dopp; 920 sep = dopp;
920 datastream +=vcard.mid( start, next - start); 921 datastream +=vcard.mid( start, next - start);
921 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 922 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
922 start = sep; 923 start = sep;
923 } 924 }
924 datastream += vcard.mid( start,vcard.length() ); 925 datastream += vcard.mid( start,vcard.length() );
925 } 926 }
926#ifndef DESKTOP_VERSION 927#ifndef DESKTOP_VERSION
927 QFile outFile(fileName); 928 QFile outFile(fileName);
928 if ( outFile.open(IO_WriteOnly) ) { 929 if ( outFile.open(IO_WriteOnly) ) {
929 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 930 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
930 QTextStream t( &outFile ); // use a text stream 931 QTextStream t( &outFile ); // use a text stream
931 //t.setEncoding( QTextStream::UnicodeUTF8 ); 932 //t.setEncoding( QTextStream::UnicodeUTF8 );
932 t.setEncoding( QTextStream::Latin1 ); 933 t.setEncoding( QTextStream::Latin1 );
933 t <<datastream.latin1(); 934 t <<datastream.latin1();
934 outFile.close(); 935 outFile.close();
935 Ir *ir = new Ir( this ); 936 Ir *ir = new Ir( this );
936 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 937 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
937 ir->send( fileName, description, "text/x-vCard" ); 938 ir->send( fileName, description, "text/x-vCard" );
938 } else { 939 } else {
939 qDebug("Error open temp beam file "); 940 qDebug("Error open temp beam file ");
940 return; 941 return;
941 } 942 }
942#endif 943#endif
943 944
944} 945}
945 946
946void KABCore::beamDone( Ir *ir ) 947void KABCore::beamDone( Ir *ir )
947{ 948{
948#ifndef DESKTOP_VERSION 949#ifndef DESKTOP_VERSION
949 delete ir; 950 delete ir;
950#endif 951#endif
951 topLevelWidget()->raise(); 952 topLevelWidget()->raise();
952 message( i18n("Beaming finished!") ); 953 message( i18n("Beaming finished!") );
953} 954}
954 955
955 956
956void KABCore::browse( const QString& url ) 957void KABCore::browse( const QString& url )
957{ 958{
958#ifndef KAB_EMBEDDED 959#ifndef KAB_EMBEDDED
959 kapp->invokeBrowser( url ); 960 kapp->invokeBrowser( url );
960#else //KAB_EMBEDDED 961#else //KAB_EMBEDDED
961 qDebug("KABCore::browse must be fixed"); 962 qDebug("KABCore::browse must be fixed");
962#endif //KAB_EMBEDDED 963#endif //KAB_EMBEDDED
963} 964}
964 965
965void KABCore::selectAllContacts() 966void KABCore::selectAllContacts()
966{ 967{
967 mViewManager->setSelected( QString::null, true ); 968 mViewManager->setSelected( QString::null, true );
968} 969}
969 970
970void KABCore::deleteContacts() 971void KABCore::deleteContacts()
971{ 972{
972 QStringList uidList = mViewManager->selectedUids(); 973 QStringList uidList = mViewManager->selectedUids();
973 deleteContacts( uidList ); 974 deleteContacts( uidList );
974} 975}
975 976
976void KABCore::deleteContacts( const QStringList &uids ) 977void KABCore::deleteContacts( const QStringList &uids )
977{ 978{
978 if ( uids.count() > 0 ) { 979 if ( uids.count() > 0 ) {
979 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 980 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
980 UndoStack::instance()->push( command ); 981 UndoStack::instance()->push( command );
981 RedoStack::instance()->clear(); 982 RedoStack::instance()->clear();
982 983
983 // now if we deleted anything, refresh 984 // now if we deleted anything, refresh
984 setContactSelected( QString::null ); 985 setContactSelected( QString::null );
985 setModified( true ); 986 setModified( true );
986 } 987 }
987} 988}
988 989
989void KABCore::copyContacts() 990void KABCore::copyContacts()
990{ 991{
991 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 992 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
992 993
993 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 994 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
994 995
995 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 996 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
996 997
997 QClipboard *cb = QApplication::clipboard(); 998 QClipboard *cb = QApplication::clipboard();
998 cb->setText( clipText ); 999 cb->setText( clipText );
999} 1000}
1000 1001
1001void KABCore::cutContacts() 1002void KABCore::cutContacts()
1002{ 1003{
1003 QStringList uidList = mViewManager->selectedUids(); 1004 QStringList uidList = mViewManager->selectedUids();
1004 1005
1005//US if ( uidList.size() > 0 ) { 1006//US if ( uidList.size() > 0 ) {
1006 if ( uidList.count() > 0 ) { 1007 if ( uidList.count() > 0 ) {
1007 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1008 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1008 UndoStack::instance()->push( command ); 1009 UndoStack::instance()->push( command );
1009 RedoStack::instance()->clear(); 1010 RedoStack::instance()->clear();
1010 1011
1011 setModified( true ); 1012 setModified( true );
1012 } 1013 }
1013} 1014}
1014 1015
1015void KABCore::pasteContacts() 1016void KABCore::pasteContacts()
1016{ 1017{
1017 QClipboard *cb = QApplication::clipboard(); 1018 QClipboard *cb = QApplication::clipboard();
1018 1019
1019 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1020 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1020 1021
1021 pasteContacts( list ); 1022 pasteContacts( list );
1022} 1023}
1023 1024
1024void KABCore::pasteContacts( KABC::Addressee::List &list ) 1025void KABCore::pasteContacts( KABC::Addressee::List &list )
1025{ 1026{
1026 KABC::Resource *resource = requestResource( this ); 1027 KABC::Resource *resource = requestResource( this );
1027 KABC::Addressee::List::Iterator it; 1028 KABC::Addressee::List::Iterator it;
1028 for ( it = list.begin(); it != list.end(); ++it ) 1029 for ( it = list.begin(); it != list.end(); ++it )
1029 (*it).setResource( resource ); 1030 (*it).setResource( resource );
1030 1031
1031 PwPasteCommand *command = new PwPasteCommand( this, list ); 1032 PwPasteCommand *command = new PwPasteCommand( this, list );
1032 UndoStack::instance()->push( command ); 1033 UndoStack::instance()->push( command );
1033 RedoStack::instance()->clear(); 1034 RedoStack::instance()->clear();
1034 1035
1035 setModified( true ); 1036 setModified( true );
1036} 1037}
1037 1038
1038void KABCore::setWhoAmI() 1039void KABCore::setWhoAmI()
1039{ 1040{
1040 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1041 1042
1042 if ( addrList.count() > 1 ) { 1043 if ( addrList.count() > 1 ) {
1043 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1044 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1044 return; 1045 return;
1045 } 1046 }
1046 1047
1047 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>" ) );
1048 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1049 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1049 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1050 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1050} 1051}
1051void KABCore::editCategories() 1052void KABCore::editCategories()
1052{ 1053{
1053 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1054 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1054 dlg.exec(); 1055 dlg.exec();
1055} 1056}
1056void KABCore::setCategories() 1057void KABCore::setCategories()
1057{ 1058{
1058 1059
1059 QStringList uids; 1060 QStringList uids;
1060 XXPortSelectDialog dlgx( this, false, this ); 1061 XXPortSelectDialog dlgx( this, false, this );
1061 if ( dlgx.exec() ) 1062 if ( dlgx.exec() )
1062 uids = dlgx.uids(); 1063 uids = dlgx.uids();
1063 else 1064 else
1064 return; 1065 return;
1065 if ( uids.isEmpty() ) 1066 if ( uids.isEmpty() )
1066 return; 1067 return;
1067 // qDebug("count %d ", uids.count()); 1068 // qDebug("count %d ", uids.count());
1068 1069
1069 1070
1070 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1071 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1071 if ( !dlg.exec() ) { 1072 if ( !dlg.exec() ) {
1072 message( i18n("Setting categories cancelled") ); 1073 message( i18n("Setting categories cancelled") );
1073 return; 1074 return;
1074 } 1075 }
1075 bool merge = false; 1076 bool merge = false;
1076 QString msg = i18n( "Merge with existing categories?" ); 1077 QString msg = i18n( "Merge with existing categories?" );
1077 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1078 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1078 merge = true; 1079 merge = true;
1079 1080
1080 message( i18n("Setting categories ... please wait!") ); 1081 message( i18n("Setting categories ... please wait!") );
1081 QStringList categories = dlg.selectedCategories(); 1082 QStringList categories = dlg.selectedCategories();
1082 1083
1083 //QStringList uids = mViewManager->selectedUids(); 1084 //QStringList uids = mViewManager->selectedUids();
1084 QStringList::Iterator it; 1085 QStringList::Iterator it;
1085 for ( it = uids.begin(); it != uids.end(); ++it ) { 1086 for ( it = uids.begin(); it != uids.end(); ++it ) {
1086 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1087 KABC::Addressee addr = mAddressBook->findByUid( *it );
1087 if ( !addr.isEmpty() ) { 1088 if ( !addr.isEmpty() ) {
1088 if ( !merge ) 1089 if ( !merge )
1089 addr.setCategories( categories ); 1090 addr.setCategories( categories );
1090 else { 1091 else {
1091 QStringList addrCategories = addr.categories(); 1092 QStringList addrCategories = addr.categories();
1092 QStringList::Iterator catIt; 1093 QStringList::Iterator catIt;
1093 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1094 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1094 if ( !addrCategories.contains( *catIt ) ) 1095 if ( !addrCategories.contains( *catIt ) )
1095 addrCategories.append( *catIt ); 1096 addrCategories.append( *catIt );
1096 } 1097 }
1097 addr.setCategories( addrCategories ); 1098 addr.setCategories( addrCategories );
1098 } 1099 }
1099 mAddressBook->insertAddressee( addr ); 1100 mAddressBook->insertAddressee( addr );
1100 } 1101 }
1101 } 1102 }
1102 1103
1103 if ( uids.count() > 0 ) 1104 if ( uids.count() > 0 )
1104 setModified( true ); 1105 setModified( true );
1105 message( i18n("Setting categories completed!") ); 1106 message( i18n("Setting categories completed!") );
1106} 1107}
1107 1108
1108void KABCore::setSearchFields( const KABC::Field::List &fields ) 1109void KABCore::setSearchFields( const KABC::Field::List &fields )
1109{ 1110{
1110 mIncSearchWidget->setFields( fields ); 1111 mIncSearchWidget->setFields( fields );
1111} 1112}
1112 1113
1113void KABCore::incrementalSearch( const QString& text ) 1114void KABCore::incrementalSearch( const QString& text )
1114{ 1115{
1115 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1116 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1116} 1117}
1117 1118
1118void KABCore::setModified() 1119void KABCore::setModified()
1119{ 1120{
1120 setModified( true ); 1121 setModified( true );
1121} 1122}
1122 1123
1123void KABCore::setModifiedWOrefresh() 1124void KABCore::setModifiedWOrefresh()
1124{ 1125{
1125 // qDebug("KABCore::setModifiedWOrefresh() "); 1126 // qDebug("KABCore::setModifiedWOrefresh() ");
1126 mModified = true; 1127 mModified = true;
1127 mActionSave->setEnabled( mModified ); 1128 mActionSave->setEnabled( mModified );
1128#ifdef DESKTOP_VERSION 1129#ifdef DESKTOP_VERSION
1129 mDetails->refreshView(); 1130 mDetails->refreshView();
1130#endif 1131#endif
1131 1132
1132} 1133}
1133void KABCore::setModified( bool modified ) 1134void KABCore::setModified( bool modified )
1134{ 1135{
1135 mModified = modified; 1136 mModified = modified;
1136 mActionSave->setEnabled( mModified ); 1137 mActionSave->setEnabled( mModified );
1137 1138
1138 if ( modified ) 1139 if ( modified )
1139 mJumpButtonBar->recreateButtons(); 1140 mJumpButtonBar->recreateButtons();
1140 1141
1141 mViewManager->refreshView(); 1142 mViewManager->refreshView();
1142 mDetails->refreshView(); 1143 mDetails->refreshView();
1143 1144
1144} 1145}
1145 1146
1146bool KABCore::modified() const 1147bool KABCore::modified() const
1147{ 1148{
1148 return mModified; 1149 return mModified;
1149} 1150}
1150 1151
1151void KABCore::contactModified( const KABC::Addressee &addr ) 1152void KABCore::contactModified( const KABC::Addressee &addr )
1152{ 1153{
1153 1154
1154 Command *command = 0; 1155 Command *command = 0;
1155 QString uid; 1156 QString uid;
1156 1157
1157 // check if it exists already 1158 // check if it exists already
1158 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1159 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1159 if ( origAddr.isEmpty() ) 1160 if ( origAddr.isEmpty() )
1160 command = new PwNewCommand( mAddressBook, addr ); 1161 command = new PwNewCommand( mAddressBook, addr );
1161 else { 1162 else {
1162 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1163 command = new PwEditCommand( mAddressBook, origAddr, addr );
1163 uid = addr.uid(); 1164 uid = addr.uid();
1164 } 1165 }
1165 1166
1166 UndoStack::instance()->push( command ); 1167 UndoStack::instance()->push( command );
1167 RedoStack::instance()->clear(); 1168 RedoStack::instance()->clear();
1168 1169
1169 setModified( true ); 1170 setModified( true );
1170} 1171}
1171 1172
1172void KABCore::newContact() 1173void KABCore::newContact()
1173{ 1174{
1174 1175
1175 1176
1176 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1177 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1177 1178
1178 QPtrList<KRES::Resource> kresResources; 1179 QPtrList<KRES::Resource> kresResources;
1179 QPtrListIterator<KABC::Resource> it( kabcResources ); 1180 QPtrListIterator<KABC::Resource> it( kabcResources );
1180 KABC::Resource *resource; 1181 KABC::Resource *resource;
1181 while ( ( resource = it.current() ) != 0 ) { 1182 while ( ( resource = it.current() ) != 0 ) {
1182 ++it; 1183 ++it;
1183 if ( !resource->readOnly() ) { 1184 if ( !resource->readOnly() ) {
1184 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1185 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1185 if ( res ) 1186 if ( res )
1186 kresResources.append( res ); 1187 kresResources.append( res );
1187 } 1188 }
1188 } 1189 }
1189 1190
1190 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1191 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1191 resource = static_cast<KABC::Resource*>( res ); 1192 resource = static_cast<KABC::Resource*>( res );
1192 1193
1193 if ( resource ) { 1194 if ( resource ) {
1194 KABC::Addressee addr; 1195 KABC::Addressee addr;
1195 addr.setResource( resource ); 1196 addr.setResource( resource );
1196 mEditorDialog->setAddressee( addr ); 1197 mEditorDialog->setAddressee( addr );
1197 KApplication::execDialog ( mEditorDialog ); 1198 KApplication::execDialog ( mEditorDialog );
1198 1199
1199 } else 1200 } else
1200 return; 1201 return;
1201 1202
1202 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1203 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1203 1204
1204 1205
1205} 1206}
1206 1207
1207void KABCore::addEmail( QString aStr ) 1208void KABCore::addEmail( QString aStr )
1208{ 1209{
1209#ifndef KAB_EMBEDDED 1210#ifndef KAB_EMBEDDED
1210 QString fullName, email; 1211 QString fullName, email;
1211 1212
1212 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1213 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1213 1214
1214 // Try to lookup the addressee matching the email address 1215 // Try to lookup the addressee matching the email address
1215 bool found = false; 1216 bool found = false;
1216 QStringList emailList; 1217 QStringList emailList;
1217 KABC::AddressBook::Iterator it; 1218 KABC::AddressBook::Iterator it;
1218 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1219 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1219 emailList = (*it).emails(); 1220 emailList = (*it).emails();
1220 if ( emailList.contains( email ) > 0 ) { 1221 if ( emailList.contains( email ) > 0 ) {
1221 found = true; 1222 found = true;
1222 (*it).setNameFromString( fullName ); 1223 (*it).setNameFromString( fullName );
1223 editContact( (*it).uid() ); 1224 editContact( (*it).uid() );
1224 } 1225 }
1225 } 1226 }
1226 1227
1227 if ( !found ) { 1228 if ( !found ) {
1228 KABC::Addressee addr; 1229 KABC::Addressee addr;
1229 addr.setNameFromString( fullName ); 1230 addr.setNameFromString( fullName );
1230 addr.insertEmail( email, true ); 1231 addr.insertEmail( email, true );
1231 1232
1232 mAddressBook->insertAddressee( addr ); 1233 mAddressBook->insertAddressee( addr );
1233 mViewManager->refreshView( addr.uid() ); 1234 mViewManager->refreshView( addr.uid() );
1234 editContact( addr.uid() ); 1235 editContact( addr.uid() );
1235 } 1236 }
1236#else //KAB_EMBEDDED 1237#else //KAB_EMBEDDED
1237 qDebug("KABCore::addEmail finsih method"); 1238 qDebug("KABCore::addEmail finsih method");
1238#endif //KAB_EMBEDDED 1239#endif //KAB_EMBEDDED
1239} 1240}
1240 1241
1241void KABCore::importVCard( const KURL &url, bool showPreview ) 1242void KABCore::importVCard( const KURL &url, bool showPreview )
1242{ 1243{
1243 mXXPortManager->importVCard( url, showPreview ); 1244 mXXPortManager->importVCard( url, showPreview );
1244} 1245}
1245void KABCore::importFromOL() 1246void KABCore::importFromOL()
1246{ 1247{
1247#ifdef _WIN32_ 1248#ifdef _WIN32_
1248 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1249 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1249 idgl->exec(); 1250 idgl->exec();
1250 KABC::Addressee::List list = idgl->getAddressList(); 1251 KABC::Addressee::List list = idgl->getAddressList();
1251 if ( list.count() > 0 ) { 1252 if ( list.count() > 0 ) {
1252 KABC::Addressee::List listNew; 1253 KABC::Addressee::List listNew;
1253 KABC::Addressee::List listExisting; 1254 KABC::Addressee::List listExisting;
1254 KABC::Addressee::List::Iterator it; 1255 KABC::Addressee::List::Iterator it;
1255 KABC::AddressBook::Iterator iter; 1256 KABC::AddressBook::Iterator iter;
1256 for ( it = list.begin(); it != list.end(); ++it ) { 1257 for ( it = list.begin(); it != list.end(); ++it ) {
1257 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1258 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1258 listNew.append( (*it) ); 1259 listNew.append( (*it) );
1259 else 1260 else
1260 listExisting.append( (*it) ); 1261 listExisting.append( (*it) );
1261 } 1262 }
1262 if ( listExisting.count() > 0 ) 1263 if ( listExisting.count() > 0 )
1263 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1264 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1264 if ( listNew.count() > 0 ) { 1265 if ( listNew.count() > 0 ) {
1265 pasteWithNewUid = false; 1266 pasteWithNewUid = false;
1266 pasteContacts( listNew ); 1267 pasteContacts( listNew );
1267 pasteWithNewUid = true; 1268 pasteWithNewUid = true;
1268 } 1269 }
1269 } 1270 }
1270 delete idgl; 1271 delete idgl;
1271#endif 1272#endif
1272} 1273}
1273 1274
1274void KABCore::importVCard( const QString &vCard, bool showPreview ) 1275void KABCore::importVCard( const QString &vCard, bool showPreview )
1275{ 1276{
1276 mXXPortManager->importVCard( vCard, showPreview ); 1277 mXXPortManager->importVCard( vCard, showPreview );
1277} 1278}
1278 1279
1279//US added a second method without defaultparameter 1280//US added a second method without defaultparameter
1280void KABCore::editContact2() { 1281void KABCore::editContact2() {
1281 editContact( QString::null ); 1282 editContact( QString::null );
1282} 1283}
1283 1284
1284void KABCore::editContact( const QString &uid ) 1285void KABCore::editContact( const QString &uid )
1285{ 1286{
1286 1287
1287 if ( mExtensionManager->isQuickEditVisible() ) 1288 if ( mExtensionManager->isQuickEditVisible() )
1288 return; 1289 return;
1289 1290
1290 // First, locate the contact entry 1291 // First, locate the contact entry
1291 QString localUID = uid; 1292 QString localUID = uid;
1292 if ( localUID.isNull() ) { 1293 if ( localUID.isNull() ) {
1293 QStringList uidList = mViewManager->selectedUids(); 1294 QStringList uidList = mViewManager->selectedUids();
1294 if ( uidList.count() > 0 ) 1295 if ( uidList.count() > 0 )
1295 localUID = *( uidList.at( 0 ) ); 1296 localUID = *( uidList.at( 0 ) );
1296 } 1297 }
1297 1298
1298 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1299 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1299 if ( !addr.isEmpty() ) { 1300 if ( !addr.isEmpty() ) {
1300 mEditorDialog->setAddressee( addr ); 1301 mEditorDialog->setAddressee( addr );
1301 KApplication::execDialog ( mEditorDialog ); 1302 KApplication::execDialog ( mEditorDialog );
1302 } 1303 }
1303} 1304}
1304 1305
1305/** 1306/**
1306 Shows or edits the detail view for the given uid. If the uid is QString::null, 1307 Shows or edits the detail view for the given uid. If the uid is QString::null,
1307 the method will try to find a selected addressee in the view. 1308 the method will try to find a selected addressee in the view.
1308 */ 1309 */
1309void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1310void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1310{ 1311{
1311 if ( mMultipleViewsAtOnce ) 1312 if ( mMultipleViewsAtOnce )
1312 { 1313 {
1313 editContact( uid ); 1314 editContact( uid );
1314 } 1315 }
1315 else 1316 else
1316 { 1317 {
1317 setDetailsVisible( true ); 1318 setDetailsVisible( true );
1318 mActionDetails->setChecked(true); 1319 mActionDetails->setChecked(true);
1319 } 1320 }
1320 1321
1321} 1322}
1322 1323
1323void KABCore::save() 1324void KABCore::save()
1324{ 1325{
1325 if (syncManager->blockSave()) 1326 if (syncManager->blockSave())
1326 return; 1327 return;
1327 if ( !mModified ) 1328 if ( !mModified )
1328 return; 1329 return;
1329 1330
1330 syncManager->setBlockSave(true); 1331 syncManager->setBlockSave(true);
1331 QString text = i18n( "There was an error while attempting to save\n the " 1332 QString text = i18n( "There was an error while attempting to save\n the "
1332 "address book. Please check that some \nother application is " 1333 "address book. Please check that some \nother application is "
1333 "not using it. " ); 1334 "not using it. " );
1334 message(i18n("Saving addressbook ... ")); 1335 message(i18n("Saving addressbook ... "));
1335#ifndef KAB_EMBEDDED 1336#ifndef KAB_EMBEDDED
1336 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1337 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1337 if ( !b || !b->save() ) { 1338 if ( !b || !b->save() ) {
1338 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1339 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1339 } 1340 }
1340#else //KAB_EMBEDDED 1341#else //KAB_EMBEDDED
1341 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1342 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1342 if ( !b || !b->save() ) { 1343 if ( !b || !b->save() ) {
1343 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1344 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1344 } 1345 }
1345#endif //KAB_EMBEDDED 1346#endif //KAB_EMBEDDED
1346 1347
1347 message(i18n("Addressbook saved!")); 1348 message(i18n("Addressbook saved!"));
1348 setModified( false ); 1349 setModified( false );
1349 syncManager->setBlockSave(false); 1350 syncManager->setBlockSave(false);
1350} 1351}
1351 1352
1352 1353
1353void KABCore::undo() 1354void KABCore::undo()
1354{ 1355{
1355 UndoStack::instance()->undo(); 1356 UndoStack::instance()->undo();
1356 1357
1357 // Refresh the view 1358 // Refresh the view
1358 mViewManager->refreshView(); 1359 mViewManager->refreshView();
1359} 1360}
1360 1361
1361void KABCore::redo() 1362void KABCore::redo()
1362{ 1363{
1363 RedoStack::instance()->redo(); 1364 RedoStack::instance()->redo();
1364 1365
1365 // Refresh the view 1366 // Refresh the view
1366 mViewManager->refreshView(); 1367 mViewManager->refreshView();
1367} 1368}
1368 1369
1369void KABCore::setJumpButtonBarVisible( bool visible ) 1370void KABCore::setJumpButtonBarVisible( bool visible )
1370{ 1371{
1371 if (mMultipleViewsAtOnce) 1372 if (mMultipleViewsAtOnce)
1372 { 1373 {
1373 if ( visible ) 1374 if ( visible )
1374 mJumpButtonBar->show(); 1375 mJumpButtonBar->show();
1375 else 1376 else
1376 mJumpButtonBar->hide(); 1377 mJumpButtonBar->hide();
1377 } 1378 }
1378 else 1379 else
1379 { 1380 {
1380 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1381 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1381 if (mViewManager->isVisible()) 1382 if (mViewManager->isVisible())
1382 { 1383 {
1383 if ( visible ) 1384 if ( visible )
1384 mJumpButtonBar->show(); 1385 mJumpButtonBar->show();
1385 else 1386 else
1386 mJumpButtonBar->hide(); 1387 mJumpButtonBar->hide();
1387 } 1388 }
1388 else 1389 else
1389 { 1390 {
1390 mJumpButtonBar->hide(); 1391 mJumpButtonBar->hide();
1391 } 1392 }
1392 } 1393 }
1393} 1394}
1394 1395
1395 1396
1396void KABCore::setDetailsToState() 1397void KABCore::setDetailsToState()
1397{ 1398{
1398 setDetailsVisible( mActionDetails->isChecked() ); 1399 setDetailsVisible( mActionDetails->isChecked() );
1399} 1400}
1400void KABCore::setDetailsToggle() 1401void KABCore::setDetailsToggle()
1401{ 1402{
1402 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1403 mActionDetails->setChecked( !mActionDetails->isChecked() );
1403 setDetailsToState(); 1404 setDetailsToState();
1404} 1405}
1405 1406
1406 1407
1407 1408
1408void KABCore::setDetailsVisible( bool visible ) 1409void KABCore::setDetailsVisible( bool visible )
1409{ 1410{
1410 if (visible && mDetails->isHidden()) 1411 if (visible && mDetails->isHidden())
1411 { 1412 {
1412 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1413 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1413 if ( addrList.count() > 0 ) 1414 if ( addrList.count() > 0 )
1414 mDetails->setAddressee( addrList[ 0 ] ); 1415 mDetails->setAddressee( addrList[ 0 ] );
1415 } 1416 }
1416 1417
1417 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1418 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1418 // the listview and the detailview. We do that by changing the splitbar size. 1419 // the listview and the detailview. We do that by changing the splitbar size.
1419 if (mMultipleViewsAtOnce) 1420 if (mMultipleViewsAtOnce)
1420 { 1421 {
1421 if ( visible ) 1422 if ( visible )
1422 mDetails->show(); 1423 mDetails->show();
1423 else 1424 else
1424 mDetails->hide(); 1425 mDetails->hide();
1425 } 1426 }
1426 else 1427 else
1427 { 1428 {
1428 if ( visible ) { 1429 if ( visible ) {
1429 mViewManager->hide(); 1430 mViewManager->hide();
1430 mDetails->show(); 1431 mDetails->show();
1431 mIncSearchWidget->setFocus(); 1432 mIncSearchWidget->setFocus();
1432 } 1433 }
1433 else { 1434 else {
1434 mViewManager->show(); 1435 mViewManager->show();
1435 mDetails->hide(); 1436 mDetails->hide();
1436 mViewManager->setFocusAV(); 1437 mViewManager->setFocusAV();
1437 } 1438 }
1438 setJumpButtonBarVisible( !visible ); 1439 setJumpButtonBarVisible( !visible );
1439 } 1440 }
1440 1441
1441} 1442}
1442 1443
1443void KABCore::extensionChanged( int id ) 1444void KABCore::extensionChanged( int id )
1444{ 1445{
1445 //change the details view only for non desktop systems 1446 //change the details view only for non desktop systems
1446#ifndef DESKTOP_VERSION 1447#ifndef DESKTOP_VERSION
1447 1448
1448 if (id == 0) 1449 if (id == 0)
1449 { 1450 {
1450 //the user disabled the extension. 1451 //the user disabled the extension.
1451 1452
1452 if (mMultipleViewsAtOnce) 1453 if (mMultipleViewsAtOnce)
1453 { // enable detailsview again 1454 { // enable detailsview again
1454 setDetailsVisible( true ); 1455 setDetailsVisible( true );
1455 mActionDetails->setChecked( true ); 1456 mActionDetails->setChecked( true );
1456 } 1457 }
1457 else 1458 else
1458 { //go back to the listview 1459 { //go back to the listview
1459 setDetailsVisible( false ); 1460 setDetailsVisible( false );
1460 mActionDetails->setChecked( false ); 1461 mActionDetails->setChecked( false );
1461 mActionDetails->setEnabled(true); 1462 mActionDetails->setEnabled(true);
1462 } 1463 }
1463 1464
1464 } 1465 }
1465 else 1466 else
1466 { 1467 {
1467 //the user enabled the extension. 1468 //the user enabled the extension.
1468 setDetailsVisible( false ); 1469 setDetailsVisible( false );
1469 mActionDetails->setChecked( false ); 1470 mActionDetails->setChecked( false );
1470 1471
1471 if (!mMultipleViewsAtOnce) 1472 if (!mMultipleViewsAtOnce)
1472 { 1473 {
1473 mActionDetails->setEnabled(false); 1474 mActionDetails->setEnabled(false);
1474 } 1475 }
1475 1476
1476 mExtensionManager->setSelectionChanged(); 1477 mExtensionManager->setSelectionChanged();
1477 1478
1478 } 1479 }
1479 1480
1480#endif// DESKTOP_VERSION 1481#endif// DESKTOP_VERSION
1481 1482
1482} 1483}
1483 1484
1484 1485
1485void KABCore::extensionModified( const KABC::Addressee::List &list ) 1486void KABCore::extensionModified( const KABC::Addressee::List &list )
1486{ 1487{
1487 1488
1488 if ( list.count() != 0 ) { 1489 if ( list.count() != 0 ) {
1489 KABC::Addressee::List::ConstIterator it; 1490 KABC::Addressee::List::ConstIterator it;
1490 for ( it = list.begin(); it != list.end(); ++it ) 1491 for ( it = list.begin(); it != list.end(); ++it )
1491 mAddressBook->insertAddressee( *it ); 1492 mAddressBook->insertAddressee( *it );
1492 if ( list.count() > 1 ) 1493 if ( list.count() > 1 )
1493 setModified(); 1494 setModified();
1494 else 1495 else
1495 setModifiedWOrefresh(); 1496 setModifiedWOrefresh();
1496 } 1497 }
1497 if ( list.count() == 0 ) 1498 if ( list.count() == 0 )
1498 mViewManager->refreshView(); 1499 mViewManager->refreshView();
1499 else 1500 else
1500 mViewManager->refreshView( list[ 0 ].uid() ); 1501 mViewManager->refreshView( list[ 0 ].uid() );
1501 1502
1502 1503
1503 1504
1504} 1505}
1505 1506
1506QString KABCore::getNameByPhone( const QString &phone ) 1507QString KABCore::getNameByPhone( const QString &phone )
1507{ 1508{
1508#ifndef KAB_EMBEDDED 1509#ifndef KAB_EMBEDDED
1509 QRegExp r( "[/*/-/ ]" ); 1510 QRegExp r( "[/*/-/ ]" );
1510 QString localPhone( phone ); 1511 QString localPhone( phone );
1511 1512
1512 bool found = false; 1513 bool found = false;
1513 QString ownerName = ""; 1514 QString ownerName = "";
1514 KABC::AddressBook::Iterator iter; 1515 KABC::AddressBook::Iterator iter;
1515 KABC::PhoneNumber::List::Iterator phoneIter; 1516 KABC::PhoneNumber::List::Iterator phoneIter;
1516 KABC::PhoneNumber::List phoneList; 1517 KABC::PhoneNumber::List phoneList;
1517 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1518 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1518 phoneList = (*iter).phoneNumbers(); 1519 phoneList = (*iter).phoneNumbers();
1519 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1520 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1520 ++phoneIter) { 1521 ++phoneIter) {
1521 // Get rid of separator chars so just the numbers are compared. 1522 // Get rid of separator chars so just the numbers are compared.
1522 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1523 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1523 ownerName = (*iter).formattedName(); 1524 ownerName = (*iter).formattedName();
1524 found = true; 1525 found = true;
1525 } 1526 }
1526 } 1527 }
1527 } 1528 }
1528 1529
1529 return ownerName; 1530 return ownerName;
1530#else //KAB_EMBEDDED 1531#else //KAB_EMBEDDED
1531 qDebug("KABCore::getNameByPhone finsih method"); 1532 qDebug("KABCore::getNameByPhone finsih method");
1532 return ""; 1533 return "";
1533#endif //KAB_EMBEDDED 1534#endif //KAB_EMBEDDED
1534 1535
1535} 1536}
1536 1537
1537void KABCore::openConfigDialog() 1538void KABCore::openConfigDialog()
1538{ 1539{
1539 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1540 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1540 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1541 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1541 ConfigureDialog->addModule(kabcfg ); 1542 ConfigureDialog->addModule(kabcfg );
1542 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1543 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1543 ConfigureDialog->addModule(kdelibcfg ); 1544 ConfigureDialog->addModule(kdelibcfg );
1544 1545
1545 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1546 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1546 this, SLOT( configurationChanged() ) ); 1547 this, SLOT( configurationChanged() ) );
1547 connect( ConfigureDialog, SIGNAL( okClicked() ), 1548 connect( ConfigureDialog, SIGNAL( okClicked() ),
1548 this, SLOT( configurationChanged() ) ); 1549 this, SLOT( configurationChanged() ) );
1549 saveSettings(); 1550 saveSettings();
1550#ifndef DESKTOP_VERSION 1551#ifndef DESKTOP_VERSION
1551 ConfigureDialog->showMaximized(); 1552 ConfigureDialog->showMaximized();
1552#endif 1553#endif
1553 if ( ConfigureDialog->exec() ) 1554 if ( ConfigureDialog->exec() )
1554 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1555 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1555 delete ConfigureDialog; 1556 delete ConfigureDialog;
1556} 1557}
1557 1558
1558void KABCore::openLDAPDialog() 1559void KABCore::openLDAPDialog()
1559{ 1560{
1560#ifndef KAB_EMBEDDED 1561#ifndef KAB_EMBEDDED
1561 if ( !mLdapSearchDialog ) { 1562 if ( !mLdapSearchDialog ) {
1562 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1563 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1564 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1564 SLOT( refreshView() ) ); 1565 SLOT( refreshView() ) );
1565 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1566 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1566 SLOT( setModified() ) ); 1567 SLOT( setModified() ) );
1567 } else 1568 } else
1568 mLdapSearchDialog->restoreSettings(); 1569 mLdapSearchDialog->restoreSettings();
1569 1570
1570 if ( mLdapSearchDialog->isOK() ) 1571 if ( mLdapSearchDialog->isOK() )
1571 mLdapSearchDialog->exec(); 1572 mLdapSearchDialog->exec();
1572#else //KAB_EMBEDDED 1573#else //KAB_EMBEDDED
1573 qDebug("KABCore::openLDAPDialog() finsih method"); 1574 qDebug("KABCore::openLDAPDialog() finsih method");
1574#endif //KAB_EMBEDDED 1575#endif //KAB_EMBEDDED
1575} 1576}
1576 1577
1577void KABCore::print() 1578void KABCore::print()
1578{ 1579{
1579#ifndef KAB_EMBEDDED 1580#ifndef KAB_EMBEDDED
1580 KPrinter printer; 1581 KPrinter printer;
1581 if ( !printer.setup( this ) ) 1582 if ( !printer.setup( this ) )
1582 return; 1583 return;
1583 1584
1584 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1585 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1585 mViewManager->selectedUids(), this ); 1586 mViewManager->selectedUids(), this );
1586 1587
1587 wizard.exec(); 1588 wizard.exec();
1588#else //KAB_EMBEDDED 1589#else //KAB_EMBEDDED
1589 qDebug("KABCore::print() finsih method"); 1590 qDebug("KABCore::print() finsih method");
1590#endif //KAB_EMBEDDED 1591#endif //KAB_EMBEDDED
1591 1592
1592} 1593}
1593 1594
1594 1595
1595void KABCore::addGUIClient( KXMLGUIClient *client ) 1596void KABCore::addGUIClient( KXMLGUIClient *client )
1596{ 1597{
1597 if ( mGUIClient ) 1598 if ( mGUIClient )
1598 mGUIClient->insertChildClient( client ); 1599 mGUIClient->insertChildClient( client );
1599 else 1600 else
1600 KMessageBox::error( this, "no KXMLGUICLient"); 1601 KMessageBox::error( this, "no KXMLGUICLient");
1601} 1602}
1602 1603
1603 1604
1604void KABCore::configurationChanged() 1605void KABCore::configurationChanged()
1605{ 1606{
1606 mExtensionManager->reconfigure(); 1607 mExtensionManager->reconfigure();
1607} 1608}
1608 1609
1609void KABCore::addressBookChanged() 1610void KABCore::addressBookChanged()
1610{ 1611{
1611/*US 1612/*US
1612 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1613 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1613 while ( it.current() ) { 1614 while ( it.current() ) {
1614 if ( it.current()->dirty() ) { 1615 if ( it.current()->dirty() ) {
1615 QString text = i18n( "Data has been changed externally. Unsaved " 1616 QString text = i18n( "Data has been changed externally. Unsaved "
1616 "changes will be lost." ); 1617 "changes will be lost." );
1617 KMessageBox::information( this, text ); 1618 KMessageBox::information( this, text );
1618 } 1619 }
1619 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1620 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1620 ++it; 1621 ++it;
1621 } 1622 }
1622*/ 1623*/
1623 if (mEditorDialog) 1624 if (mEditorDialog)
1624 { 1625 {
1625 if (mEditorDialog->dirty()) 1626 if (mEditorDialog->dirty())
1626 { 1627 {
1627 QString text = i18n( "Data has been changed externally. Unsaved " 1628 QString text = i18n( "Data has been changed externally. Unsaved "
1628 "changes will be lost." ); 1629 "changes will be lost." );
1629 KMessageBox::information( this, text ); 1630 KMessageBox::information( this, text );
1630 } 1631 }
1631 QString currentuid = mEditorDialog->addressee().uid(); 1632 QString currentuid = mEditorDialog->addressee().uid();
1632 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1633 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1633 } 1634 }
1634 mViewManager->refreshView(); 1635 mViewManager->refreshView();
1635// mDetails->refreshView(); 1636// mDetails->refreshView();
1636 1637
1637 1638
1638} 1639}
1639 1640
1640AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1641AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1641 const char *name ) 1642 const char *name )
1642{ 1643{
1643 1644
1644 if ( mEditorDialog == 0 ) { 1645 if ( mEditorDialog == 0 ) {
1645 mEditorDialog = new AddresseeEditorDialog( this, parent, 1646 mEditorDialog = new AddresseeEditorDialog( this, parent,
1646 name ? name : "editorDialog" ); 1647 name ? name : "editorDialog" );
1647 1648
1648 1649
1649 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1650 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1650 SLOT( contactModified( const KABC::Addressee& ) ) ); 1651 SLOT( contactModified( const KABC::Addressee& ) ) );
1651 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1652 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1652 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1653 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1653 } 1654 }
1654 1655
1655 return mEditorDialog; 1656 return mEditorDialog;
1656} 1657}
1657 1658
1658void KABCore::slotEditorDestroyed( const QString &uid ) 1659void KABCore::slotEditorDestroyed( const QString &uid )
1659{ 1660{
1660 //mEditorDict.remove( uid ); 1661 //mEditorDict.remove( uid );
1661} 1662}
1662 1663
1663void KABCore::initGUI() 1664void KABCore::initGUI()
1664{ 1665{
1665#ifndef KAB_EMBEDDED 1666#ifndef KAB_EMBEDDED
1666 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1667 QHBoxLayout *topLayout = new QHBoxLayout( this );
1667 topLayout->setSpacing( KDialogBase::spacingHint() ); 1668 topLayout->setSpacing( KDialogBase::spacingHint() );
1668 1669
1669 mExtensionBarSplitter = new QSplitter( this ); 1670 mExtensionBarSplitter = new QSplitter( this );
1670 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1671 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1671 1672
1672 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1673 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1673 1674
1674 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1675 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1675 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1676 mIncSearchWidget = new IncSearchWidget( viewSpace );
1676 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1677 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1677 SLOT( incrementalSearch( const QString& ) ) ); 1678 SLOT( incrementalSearch( const QString& ) ) );
1678 1679
1679 mViewManager = new ViewManager( this, viewSpace ); 1680 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1681 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1682
1682 mDetails = new ViewContainer( mDetailsSplitter ); 1683 mDetails = new ViewContainer( mDetailsSplitter );
1683 1684
1684 mJumpButtonBar = new JumpButtonBar( this, this ); 1685 mJumpButtonBar = new JumpButtonBar( this, this );
1685 1686
1686 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1687 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1687 1688
1688 topLayout->addWidget( mExtensionBarSplitter ); 1689 topLayout->addWidget( mExtensionBarSplitter );
1689 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1690 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1690 topLayout->addWidget( mJumpButtonBar ); 1691 topLayout->addWidget( mJumpButtonBar );
1691 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1692 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1692 1693
1693 mXXPortManager = new XXPortManager( this, this ); 1694 mXXPortManager = new XXPortManager( this, this );
1694 1695
1695#else //KAB_EMBEDDED 1696#else //KAB_EMBEDDED
1696 //US initialize viewMenu before settingup viewmanager. 1697 //US initialize viewMenu before settingup viewmanager.
1697 // Viewmanager needs this menu to plugin submenues. 1698 // Viewmanager needs this menu to plugin submenues.
1698 viewMenu = new QPopupMenu( this ); 1699 viewMenu = new QPopupMenu( this );
1699 settingsMenu = new QPopupMenu( this ); 1700 settingsMenu = new QPopupMenu( this );
1700 //filterMenu = new QPopupMenu( this ); 1701 //filterMenu = new QPopupMenu( this );
1701 ImportMenu = new QPopupMenu( this ); 1702 ImportMenu = new QPopupMenu( this );
1702 ExportMenu = new QPopupMenu( this ); 1703 ExportMenu = new QPopupMenu( this );
1703 syncMenu = new QPopupMenu( this ); 1704 syncMenu = new QPopupMenu( this );
1704 changeMenu= new QPopupMenu( this ); 1705 changeMenu= new QPopupMenu( this );
1705 beamMenu= new QPopupMenu( this ); 1706 beamMenu= new QPopupMenu( this );
1706 1707
1707//US since we have no splitter for the embedded system, setup 1708//US since we have no splitter for the embedded system, setup
1708// a layout with two frames. One left and one right. 1709// a layout with two frames. One left and one right.
1709 1710
1710 QBoxLayout *topLayout; 1711 QBoxLayout *topLayout;
1711 1712
1712 // = new QHBoxLayout( this ); 1713 // = new QHBoxLayout( this );
1713// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1714// QBoxLayout *topLayout = (QBoxLayout*)layout();
1714 1715
1715// QWidget *mainBox = new QWidget( this ); 1716// QWidget *mainBox = new QWidget( this );
1716// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1717// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1717 1718
1718#ifdef DESKTOP_VERSION 1719#ifdef DESKTOP_VERSION
1719 topLayout = new QHBoxLayout( this ); 1720 topLayout = new QHBoxLayout( this );
1720 1721
1721 1722
1722 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1723 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1723 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1724 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1724 1725
1725 topLayout->addWidget(mMiniSplitter ); 1726 topLayout->addWidget(mMiniSplitter );
1726 1727
1727 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1728 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1728 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1729 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1729 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1730 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1730 mDetails = new ViewContainer( mMiniSplitter ); 1731 mDetails = new ViewContainer( mMiniSplitter );
1731 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1732 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1732#else 1733#else
1733 if ( QApplication::desktop()->width() > 480 ) { 1734 if ( QApplication::desktop()->width() > 480 ) {
1734 topLayout = new QHBoxLayout( this ); 1735 topLayout = new QHBoxLayout( this );
1735 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1736 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1736 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1737 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1737 } else { 1738 } else {
1738 1739
1739 topLayout = new QHBoxLayout( this ); 1740 topLayout = new QHBoxLayout( this );
1740 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1741 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1741 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1742 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1742 } 1743 }
1743 1744
1744 topLayout->addWidget(mMiniSplitter ); 1745 topLayout->addWidget(mMiniSplitter );
1745 mViewManager = new ViewManager( this, mMiniSplitter ); 1746 mViewManager = new ViewManager( this, mMiniSplitter );
1746 mDetails = new ViewContainer( mMiniSplitter ); 1747 mDetails = new ViewContainer( mMiniSplitter );
1747 1748
1748 1749
1749 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1750 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1750#endif 1751#endif
1751 //eh->hide(); 1752 //eh->hide();
1752 // topLayout->addWidget(mExtensionManager ); 1753 // topLayout->addWidget(mExtensionManager );
1753 1754
1754 1755
1755/*US 1756/*US
1756#ifndef KAB_NOSPLITTER 1757#ifndef KAB_NOSPLITTER
1757 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1758 QHBoxLayout *topLayout = new QHBoxLayout( this );
1758//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1759//US topLayout->setSpacing( KDialogBase::spacingHint() );
1759 topLayout->setSpacing( 10 ); 1760 topLayout->setSpacing( 10 );
1760 1761
1761 mDetailsSplitter = new QSplitter( this ); 1762 mDetailsSplitter = new QSplitter( this );
1762 1763
1763 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1764 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1764 1765
1765 mViewManager = new ViewManager( this, viewSpace ); 1766 mViewManager = new ViewManager( this, viewSpace );
1766 viewSpace->setStretchFactor( mViewManager, 1 ); 1767 viewSpace->setStretchFactor( mViewManager, 1 );
1767 1768
1768 mDetails = new ViewContainer( mDetailsSplitter ); 1769 mDetails = new ViewContainer( mDetailsSplitter );
1769 1770
1770 topLayout->addWidget( mDetailsSplitter ); 1771 topLayout->addWidget( mDetailsSplitter );
1771 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1772 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1772#else //KAB_NOSPLITTER 1773#else //KAB_NOSPLITTER
1773 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1774 QHBoxLayout *topLayout = new QHBoxLayout( this );
1774//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1775//US topLayout->setSpacing( KDialogBase::spacingHint() );
1775 topLayout->setSpacing( 10 ); 1776 topLayout->setSpacing( 10 );
1776 1777
1777// mDetailsSplitter = new QSplitter( this ); 1778// mDetailsSplitter = new QSplitter( this );
1778 1779
1779 QVBox *viewSpace = new QVBox( this ); 1780 QVBox *viewSpace = new QVBox( this );
1780 1781
1781 mViewManager = new ViewManager( this, viewSpace ); 1782 mViewManager = new ViewManager( this, viewSpace );
1782 viewSpace->setStretchFactor( mViewManager, 1 ); 1783 viewSpace->setStretchFactor( mViewManager, 1 );
1783 1784
1784 mDetails = new ViewContainer( this ); 1785 mDetails = new ViewContainer( this );
1785 1786
1786 topLayout->addWidget( viewSpace ); 1787 topLayout->addWidget( viewSpace );
1787// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1788// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1788 topLayout->addWidget( mDetails ); 1789 topLayout->addWidget( mDetails );
1789#endif //KAB_NOSPLITTER 1790#endif //KAB_NOSPLITTER
1790*/ 1791*/
1791 1792
1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1793 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1793 syncManager->setBlockSave(false); 1794 syncManager->setBlockSave(false);
1794 1795
1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1796 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1797 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1797 QString sync_file = sentSyncFile(); 1798 QString sync_file = sentSyncFile();
1798 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1799 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1799 syncManager->setDefaultFileName( sync_file ); 1800 syncManager->setDefaultFileName( sync_file );
1800 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1801 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1801 1802
1802#endif //KAB_EMBEDDED 1803#endif //KAB_EMBEDDED
1803 initActions(); 1804 initActions();
1804 1805
1805#ifdef KAB_EMBEDDED 1806#ifdef KAB_EMBEDDED
1806 addActionsManually(); 1807 addActionsManually();
1807 //US make sure the export and import menues are initialized before creating the xxPortManager. 1808 //US make sure the export and import menues are initialized before creating the xxPortManager.
1808 mXXPortManager = new XXPortManager( this, this ); 1809 mXXPortManager = new XXPortManager( this, this );
1809 1810
1810 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1811 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1811 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1812 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1812 // mActionQuit->plug ( mMainWindow->toolBar()); 1813 // mActionQuit->plug ( mMainWindow->toolBar());
1813 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1814 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1814 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1815 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1815 // mIncSearchWidget->hide(); 1816 // mIncSearchWidget->hide();
1816 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1817 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1817 SLOT( incrementalSearch( const QString& ) ) ); 1818 SLOT( incrementalSearch( const QString& ) ) );
1818 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1819 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1819 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1820 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1820 1821
1821 mJumpButtonBar = new JumpButtonBar( this, this ); 1822 mJumpButtonBar = new JumpButtonBar( this, this );
1822 1823
1823 topLayout->addWidget( mJumpButtonBar ); 1824 topLayout->addWidget( mJumpButtonBar );
1824//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1825//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1825 1826
1826// mMainWindow->getIconToolBar()->raise(); 1827// mMainWindow->getIconToolBar()->raise();
1827 1828
1828#endif //KAB_EMBEDDED 1829#endif //KAB_EMBEDDED
1829 1830
1830} 1831}
1831void KABCore::initActions() 1832void KABCore::initActions()
1832{ 1833{
1833//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1834//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1834 1835
1835#ifndef KAB_EMBEDDED 1836#ifndef KAB_EMBEDDED
1836 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1837 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1837 SLOT( clipboardDataChanged() ) ); 1838 SLOT( clipboardDataChanged() ) );
1838#endif //KAB_EMBEDDED 1839#endif //KAB_EMBEDDED
1839 1840
1840 // file menu 1841 // file menu
1841 if ( mIsPart ) { 1842 if ( mIsPart ) {
1842 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1843 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1843 SLOT( sendMail() ), actionCollection(), 1844 SLOT( sendMail() ), actionCollection(),
1844 "kaddressbook_mail" ); 1845 "kaddressbook_mail" );
1845 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1846 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1846 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1847 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1847 1848
1848 } else { 1849 } else {
1849 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1850 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1850 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1851 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1851 } 1852 }
1852 1853
1853 1854
1854 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1855 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1855 SLOT( save() ), actionCollection(), "file_sync" ); 1856 SLOT( save() ), actionCollection(), "file_sync" );
1856 1857
1857 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1858 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1858 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1859 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1859 1860
1860 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1861 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1861 this, SLOT( mailVCard() ), 1862 this, SLOT( mailVCard() ),
1862 actionCollection(), "file_mail_vcard"); 1863 actionCollection(), "file_mail_vcard");
1863 1864
1864 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1865 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1865 SLOT( export2phone() ), actionCollection(), 1866 SLOT( export2phone() ), actionCollection(),
1866 "kaddressbook_ex2phone" ); 1867 "kaddressbook_ex2phone" );
1867 1868
1868 mActionBeamVCard = 0; 1869 mActionBeamVCard = 0;
1869 mActionBeam = 0; 1870 mActionBeam = 0;
1870 1871
1871#ifndef DESKTOP_VERSION 1872#ifndef DESKTOP_VERSION
1872 if ( Ir::supported() ) { 1873 if ( Ir::supported() ) {
1873 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1874 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1874 SLOT( beamVCard() ), actionCollection(), 1875 SLOT( beamVCard() ), actionCollection(),
1875 "kaddressbook_beam_vcard" ); 1876 "kaddressbook_beam_vcard" );
1876 1877
1877 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1878 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1878 SLOT( beamMySelf() ), actionCollection(), 1879 SLOT( beamMySelf() ), actionCollection(),
1879 "kaddressbook_beam_myself" ); 1880 "kaddressbook_beam_myself" );
1880 } 1881 }
1881#endif 1882#endif
1882 1883
1883 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1884 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1884 this, SLOT( editContact2() ), 1885 this, SLOT( editContact2() ),
1885 actionCollection(), "file_properties" ); 1886 actionCollection(), "file_properties" );
1886 1887
1887#ifdef KAB_EMBEDDED 1888#ifdef KAB_EMBEDDED
1888 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1889 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1889 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1890 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1890 mMainWindow, SLOT( exit() ), 1891 mMainWindow, SLOT( exit() ),
1891 actionCollection(), "quit" ); 1892 actionCollection(), "quit" );
1892#endif //KAB_EMBEDDED 1893#endif //KAB_EMBEDDED
1893 1894
1894 // edit menu 1895 // edit menu
1895 if ( mIsPart ) { 1896 if ( mIsPart ) {
1896 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1897 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1897 SLOT( copyContacts() ), actionCollection(), 1898 SLOT( copyContacts() ), actionCollection(),
1898 "kaddressbook_copy" ); 1899 "kaddressbook_copy" );
1899 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1900 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1900 SLOT( cutContacts() ), actionCollection(), 1901 SLOT( cutContacts() ), actionCollection(),
1901 "kaddressbook_cut" ); 1902 "kaddressbook_cut" );
1902 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1903 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1903 SLOT( pasteContacts() ), actionCollection(), 1904 SLOT( pasteContacts() ), actionCollection(),
1904 "kaddressbook_paste" ); 1905 "kaddressbook_paste" );
1905 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1906 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1906 SLOT( selectAllContacts() ), actionCollection(), 1907 SLOT( selectAllContacts() ), actionCollection(),
1907 "kaddressbook_select_all" ); 1908 "kaddressbook_select_all" );
1908 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1909 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1909 SLOT( undo() ), actionCollection(), 1910 SLOT( undo() ), actionCollection(),
1910 "kaddressbook_undo" ); 1911 "kaddressbook_undo" );
1911 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1912 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1912 this, SLOT( redo() ), actionCollection(), 1913 this, SLOT( redo() ), actionCollection(),
1913 "kaddressbook_redo" ); 1914 "kaddressbook_redo" );
1914 } else { 1915 } else {
1915 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1916 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1916 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1917 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1917 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1918 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1918 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1919 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1919 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1920 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1920 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1921 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1921 } 1922 }
1922 1923
1923 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1924 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1924 Key_Delete, this, SLOT( deleteContacts() ), 1925 Key_Delete, this, SLOT( deleteContacts() ),
1925 actionCollection(), "edit_delete" ); 1926 actionCollection(), "edit_delete" );
1926 1927
1927 mActionUndo->setEnabled( false ); 1928 mActionUndo->setEnabled( false );
1928 mActionRedo->setEnabled( false ); 1929 mActionRedo->setEnabled( false );
1929 1930
1930 // settings menu 1931 // settings menu
1931#ifdef KAB_EMBEDDED 1932#ifdef KAB_EMBEDDED
1932//US special menuentry to configure the addressbook resources. On KDE 1933//US special menuentry to configure the addressbook resources. On KDE
1933// you do that through the control center !!! 1934// you do that through the control center !!!
1934 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1935 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1935 SLOT( configureResources() ), actionCollection(), 1936 SLOT( configureResources() ), actionCollection(),
1936 "kaddressbook_configure_resources" ); 1937 "kaddressbook_configure_resources" );
1937#endif //KAB_EMBEDDED 1938#endif //KAB_EMBEDDED
1938 1939
1939 if ( mIsPart ) { 1940 if ( mIsPart ) {
1940 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1941 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1941 SLOT( openConfigDialog() ), actionCollection(), 1942 SLOT( openConfigDialog() ), actionCollection(),
1942 "kaddressbook_configure" ); 1943 "kaddressbook_configure" );
1943 1944
1944 //US not implemented yet 1945 //US not implemented yet
1945 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1946 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1946 // this, SLOT( configureKeyBindings() ), actionCollection(), 1947 // this, SLOT( configureKeyBindings() ), actionCollection(),
1947 // "kaddressbook_configure_shortcuts" ); 1948 // "kaddressbook_configure_shortcuts" );
1948#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1949 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1950 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1950 mActionConfigureToolbars->setEnabled( false ); 1951 mActionConfigureToolbars->setEnabled( false );
1951#endif //KAB_EMBEDDED 1952#endif //KAB_EMBEDDED
1952 1953
1953 } else { 1954 } else {
1954 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1955 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1955 1956
1956 //US not implemented yet 1957 //US not implemented yet
1957 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1958 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1958 } 1959 }
1959 1960
1960 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1961 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1961 actionCollection(), "options_show_jump_bar" ); 1962 actionCollection(), "options_show_jump_bar" );
1962 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1963 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1963 1964
1964 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1965 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1965 actionCollection(), "options_show_details" ); 1966 actionCollection(), "options_show_details" );
1966 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1967 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1967 1968
1968 1969
1969 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1970 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1970 SLOT( toggleBeamReceive() ), actionCollection(), 1971 SLOT( toggleBeamReceive() ), actionCollection(),
1971 "kaddressbook_beam_rec" ); 1972 "kaddressbook_beam_rec" );
1972 1973
1973 1974
1974 // misc 1975 // misc
1975 // only enable LDAP lookup if we can handle the protocol 1976 // only enable LDAP lookup if we can handle the protocol
1976#ifndef KAB_EMBEDDED 1977#ifndef KAB_EMBEDDED
1977 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1978 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1978 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1979 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1979 this, SLOT( openLDAPDialog() ), actionCollection(), 1980 this, SLOT( openLDAPDialog() ), actionCollection(),
1980 "ldap_lookup" ); 1981 "ldap_lookup" );
1981 } 1982 }
1982#else //KAB_EMBEDDED 1983#else //KAB_EMBEDDED
1983 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1984 //qDebug("KABCore::initActions() LDAP has to be implemented");
1984#endif //KAB_EMBEDDED 1985#endif //KAB_EMBEDDED
1985 1986
1986 1987
1987 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1988 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1988 SLOT( setWhoAmI() ), actionCollection(), 1989 SLOT( setWhoAmI() ), actionCollection(),
1989 "set_personal" ); 1990 "set_personal" );
1990 1991
1991 1992
1992 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1993 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1993 SLOT( setCategories() ), actionCollection(), 1994 SLOT( setCategories() ), actionCollection(),
1994 "edit_set_categories" ); 1995 "edit_set_categories" );
1995 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1996 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1996 SLOT( editCategories() ), actionCollection(), 1997 SLOT( editCategories() ), actionCollection(),
1997 "edit__categories" ); 1998 "edit__categories" );
1998 1999
1999 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2000 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2000 SLOT( removeVoice() ), actionCollection(), 2001 SLOT( removeVoice() ), actionCollection(),
2001 "remove_voice" ); 2002 "remove_voice" );
2002 2003
2003 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2004 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2004 SLOT( manageCategories() ), actionCollection(), 2005 SLOT( manageCategories() ), actionCollection(),
2005 "remove_voice" ); 2006 "remove_voice" );
2006 2007
2007 2008
2008 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2009 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2009 SLOT( importFromOL() ), actionCollection(), 2010 SLOT( importFromOL() ), actionCollection(),
2010 "import_OL" ); 2011 "import_OL" );
2011#ifdef KAB_EMBEDDED 2012#ifdef KAB_EMBEDDED
2012 mActionLicence = new KAction( i18n( "Licence" ), 0, 2013 mActionLicence = new KAction( i18n( "Licence" ), 0,
2013 this, SLOT( showLicence() ), actionCollection(), 2014 this, SLOT( showLicence() ), actionCollection(),
2014 "licence_about_data" ); 2015 "licence_about_data" );
2015 mActionFaq = new KAction( i18n( "Faq" ), 0, 2016 mActionFaq = new KAction( i18n( "Faq" ), 0,
2016 this, SLOT( faq() ), actionCollection(), 2017 this, SLOT( faq() ), actionCollection(),
2017 "faq_about_data" ); 2018 "faq_about_data" );
2018 mActionWN = new KAction( i18n( "What's New?" ), 0, 2019 mActionWN = new KAction( i18n( "What's New?" ), 0,
2019 this, SLOT( whatsnew() ), actionCollection(), 2020 this, SLOT( whatsnew() ), actionCollection(),
2020 "wn" ); 2021 "wn" );
2021 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2022 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2022 this, SLOT( synchowto() ), actionCollection(), 2023 this, SLOT( synchowto() ), actionCollection(),
2023 "sync" ); 2024 "sync" );
2024 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2025 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2025 this, SLOT( kdesynchowto() ), actionCollection(), 2026 this, SLOT( kdesynchowto() ), actionCollection(),
2026 "kdesync" ); 2027 "kdesync" );
2027 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2028 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2028 this, SLOT( multisynchowto() ), actionCollection(), 2029 this, SLOT( multisynchowto() ), actionCollection(),
2029 "multisync" ); 2030 "multisync" );
2030 2031
2031 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2032 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2032 this, SLOT( createAboutData() ), actionCollection(), 2033 this, SLOT( createAboutData() ), actionCollection(),
2033 "kaddressbook_about_data" ); 2034 "kaddressbook_about_data" );
2034#endif //KAB_EMBEDDED 2035#endif //KAB_EMBEDDED
2035 2036
2036 clipboardDataChanged(); 2037 clipboardDataChanged();
2037 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2038 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2038 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2039 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2039} 2040}
2040 2041
2041//US we need this function, to plug all actions into the correct menues. 2042//US we need this function, to plug all actions into the correct menues.
2042// KDE uses a XML format to plug the actions, but we work her without this overhead. 2043// KDE uses a XML format to plug the actions, but we work her without this overhead.
2043void KABCore::addActionsManually() 2044void KABCore::addActionsManually()
2044{ 2045{
2045//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2046//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2046 2047
2047#ifdef KAB_EMBEDDED 2048#ifdef KAB_EMBEDDED
2048 QPopupMenu *fileMenu = new QPopupMenu( this ); 2049 QPopupMenu *fileMenu = new QPopupMenu( this );
2049 QPopupMenu *editMenu = new QPopupMenu( this ); 2050 QPopupMenu *editMenu = new QPopupMenu( this );
2050 QPopupMenu *helpMenu = new QPopupMenu( this ); 2051 QPopupMenu *helpMenu = new QPopupMenu( this );
2051 2052
2052 KToolBar* tb = mMainWindow->toolBar(); 2053 KToolBar* tb = mMainWindow->toolBar();
2053 2054
2054#ifndef DESKTOP_VERSION 2055#ifndef DESKTOP_VERSION
2055 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2056 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2056#endif 2057#endif
2057 QMenuBar* mb = mMainWindow->menuBar(); 2058 QMenuBar* mb = mMainWindow->menuBar();
2058 2059
2059 //US setup menubar. 2060 //US setup menubar.
2060 //Disable the following block if you do not want to have a menubar. 2061 //Disable the following block if you do not want to have a menubar.
2061 mb->insertItem( i18n("&File"), fileMenu ); 2062 mb->insertItem( i18n("&File"), fileMenu );
2062 mb->insertItem( i18n("&Edit"), editMenu ); 2063 mb->insertItem( i18n("&Edit"), editMenu );
2063 mb->insertItem( i18n("&View"), viewMenu ); 2064 mb->insertItem( i18n("&View"), viewMenu );
2064 mb->insertItem( i18n("&Settings"), settingsMenu ); 2065 mb->insertItem( i18n("&Settings"), settingsMenu );
2065 mb->insertItem( i18n("Synchronize"), syncMenu ); 2066 mb->insertItem( i18n("Synchronize"), syncMenu );
2066 //mb->insertItem( i18n("&Change"), changeMenu ); 2067 //mb->insertItem( i18n("&Change"), changeMenu );
2067 mb->insertItem( i18n("&Help"), helpMenu ); 2068 mb->insertItem( i18n("&Help"), helpMenu );
2068 mIncSearchWidget = new IncSearchWidget( tb ); 2069 mIncSearchWidget = new IncSearchWidget( tb );
2069 // tb->insertWidget(-1, 0, mIncSearchWidget); 2070 // tb->insertWidget(-1, 0, mIncSearchWidget);
2070#ifndef DESKTOP_VERSION 2071#ifndef DESKTOP_VERSION
2071 } else { 2072 } else {
2072 //US setup toolbar 2073 //US setup toolbar
2073 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2074 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2074 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2075 QPopupMenu *popupBarTB = new QPopupMenu( this );
2075 menuBarTB->insertItem( "ME", popupBarTB); 2076 menuBarTB->insertItem( "ME", popupBarTB);
2076 tb->insertWidget(-1, 0, menuBarTB); 2077 tb->insertWidget(-1, 0, menuBarTB);
2077 mIncSearchWidget = new IncSearchWidget( tb ); 2078 mIncSearchWidget = new IncSearchWidget( tb );
2078 2079
2079 tb->enableMoving(false); 2080 tb->enableMoving(false);
2080 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2081 popupBarTB->insertItem( i18n("&File"), fileMenu );
2081 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2082 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2082 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2083 popupBarTB->insertItem( i18n("&View"), viewMenu );
2083 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2084 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2084 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2085 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2085 mViewManager->getFilterAction()->plug ( popupBarTB); 2086 mViewManager->getFilterAction()->plug ( popupBarTB);
2086 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2087 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2087 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2088 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2088 if (QApplication::desktop()->width() > 320 ) { 2089 if (QApplication::desktop()->width() > 320 ) {
2089 // mViewManager->getFilterAction()->plug ( tb); 2090 // mViewManager->getFilterAction()->plug ( tb);
2090 } 2091 }
2091 } 2092 }
2092#endif 2093#endif
2093 // mActionQuit->plug ( mMainWindow->toolBar()); 2094 // mActionQuit->plug ( mMainWindow->toolBar());
2094 2095
2095 2096
2096 2097
2097 //US Now connect the actions with the menue entries. 2098 //US Now connect the actions with the menue entries.
2098 mActionPrint->plug( fileMenu ); 2099 mActionPrint->plug( fileMenu );
2099 mActionMail->plug( fileMenu ); 2100 mActionMail->plug( fileMenu );
2100 fileMenu->insertSeparator(); 2101 fileMenu->insertSeparator();
2101 2102
2102 mActionNewContact->plug( fileMenu ); 2103 mActionNewContact->plug( fileMenu );
2103 mActionNewContact->plug( tb ); 2104 mActionNewContact->plug( tb );
2104 2105
2105 mActionEditAddressee->plug( fileMenu ); 2106 mActionEditAddressee->plug( fileMenu );
2106 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2107 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2107 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2108 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2108 mActionEditAddressee->plug( tb ); 2109 mActionEditAddressee->plug( tb );
2109 2110
2110 fileMenu->insertSeparator(); 2111 fileMenu->insertSeparator();
2111 mActionSave->plug( fileMenu ); 2112 mActionSave->plug( fileMenu );
2112 fileMenu->insertItem( "&Import", ImportMenu ); 2113 fileMenu->insertItem( "&Import", ImportMenu );
2113 fileMenu->insertItem( "&Export", ExportMenu ); 2114 fileMenu->insertItem( "&Export", ExportMenu );
2114 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2115 fileMenu->insertItem( i18n("&Change"), changeMenu );
2115#ifndef DESKTOP_VERSION 2116#ifndef DESKTOP_VERSION
2116 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2117 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2117#endif 2118#endif
2118 2119
2119 fileMenu->insertSeparator(); 2120 fileMenu->insertSeparator();
2120 mActionMailVCard->plug( fileMenu ); 2121 mActionMailVCard->plug( fileMenu );
2121#ifndef DESKTOP_VERSION 2122#ifndef DESKTOP_VERSION
2122 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2123 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2123 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2124 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2124 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2125 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2125#endif 2126#endif
2126 fileMenu->insertSeparator(); 2127 fileMenu->insertSeparator();
2127 mActionQuit->plug( fileMenu ); 2128 mActionQuit->plug( fileMenu );
2128#ifdef _WIN32_ 2129#ifdef _WIN32_
2129 mActionImportOL->plug( ImportMenu ); 2130 mActionImportOL->plug( ImportMenu );
2130#endif 2131#endif
2131 // edit menu 2132 // edit menu
2132 mActionUndo->plug( editMenu ); 2133 mActionUndo->plug( editMenu );
2133 mActionRedo->plug( editMenu ); 2134 mActionRedo->plug( editMenu );
2134 editMenu->insertSeparator(); 2135 editMenu->insertSeparator();
2135 mActionCut->plug( editMenu ); 2136 mActionCut->plug( editMenu );
2136 mActionCopy->plug( editMenu ); 2137 mActionCopy->plug( editMenu );
2137 mActionPaste->plug( editMenu ); 2138 mActionPaste->plug( editMenu );
2138 mActionDelete->plug( editMenu ); 2139 mActionDelete->plug( editMenu );
2139 editMenu->insertSeparator(); 2140 editMenu->insertSeparator();
2140 mActionSelectAll->plug( editMenu ); 2141 mActionSelectAll->plug( editMenu );
2141 2142
2142 mActionRemoveVoice->plug( changeMenu ); 2143 mActionRemoveVoice->plug( changeMenu );
2143 // settings menu 2144 // settings menu
2144//US special menuentry to configure the addressbook resources. On KDE 2145//US special menuentry to configure the addressbook resources. On KDE
2145// you do that through the control center !!! 2146// you do that through the control center !!!
2146 mActionConfigResources->plug( settingsMenu ); 2147 mActionConfigResources->plug( settingsMenu );
2147 settingsMenu->insertSeparator(); 2148 settingsMenu->insertSeparator();
2148 2149
2149 mActionConfigKAddressbook->plug( settingsMenu ); 2150 mActionConfigKAddressbook->plug( settingsMenu );
2150 2151
2151 if ( mIsPart ) { 2152 if ( mIsPart ) {
2152 //US not implemented yet 2153 //US not implemented yet
2153 //mActionConfigShortcuts->plug( settingsMenu ); 2154 //mActionConfigShortcuts->plug( settingsMenu );
2154 //mActionConfigureToolbars->plug( settingsMenu ); 2155 //mActionConfigureToolbars->plug( settingsMenu );
2155 2156
2156 } else { 2157 } else {
2157 //US not implemented yet 2158 //US not implemented yet
2158 //mActionKeyBindings->plug( settingsMenu ); 2159 //mActionKeyBindings->plug( settingsMenu );
2159 } 2160 }
2160 2161
2161 settingsMenu->insertSeparator(); 2162 settingsMenu->insertSeparator();
2162 2163
2163 mActionJumpBar->plug( settingsMenu ); 2164 mActionJumpBar->plug( settingsMenu );
2164 mActionDetails->plug( settingsMenu ); 2165 mActionDetails->plug( settingsMenu );
2165 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2166 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2166 mActionDetails->plug( tb ); 2167 mActionDetails->plug( tb );
2167 settingsMenu->insertSeparator(); 2168 settingsMenu->insertSeparator();
2168#ifndef DESKTOP_VERSION 2169#ifndef DESKTOP_VERSION
2169 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2170 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2170#endif 2171#endif
2171 settingsMenu->insertSeparator(); 2172 settingsMenu->insertSeparator();
2172 2173
2173 mActionWhoAmI->plug( settingsMenu ); 2174 mActionWhoAmI->plug( settingsMenu );
2174 mActionEditCategories->plug( settingsMenu ); 2175 mActionEditCategories->plug( settingsMenu );
2175 mActionEditCategories->plug( changeMenu ); 2176 mActionEditCategories->plug( changeMenu );
2176 mActionCategories->plug( changeMenu ); 2177 mActionCategories->plug( changeMenu );
2177 mActionManageCategories->plug( changeMenu ); 2178 mActionManageCategories->plug( changeMenu );
2178 2179
2179 mActionCategories->plug( settingsMenu ); 2180 mActionCategories->plug( settingsMenu );
2180 mActionManageCategories->plug( settingsMenu ); 2181 mActionManageCategories->plug( settingsMenu );
2181 2182
2182 2183
2183 mActionWN->plug( helpMenu ); 2184 mActionWN->plug( helpMenu );
2184 mActionSyncHowto->plug( helpMenu ); 2185 mActionSyncHowto->plug( helpMenu );
2185 mActionKdeSyncHowto->plug( helpMenu ); 2186 mActionKdeSyncHowto->plug( helpMenu );
2186 mActionMultiSyncHowto->plug( helpMenu ); 2187 mActionMultiSyncHowto->plug( helpMenu );
2187 mActionFaq->plug( helpMenu ); 2188 mActionFaq->plug( helpMenu );
2188 mActionLicence->plug( helpMenu ); 2189 mActionLicence->plug( helpMenu );
2189 mActionAboutKAddressbook->plug( helpMenu ); 2190 mActionAboutKAddressbook->plug( helpMenu );
2190 2191
2191 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2192 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2192 2193
2193 mActionSave->plug( tb ); 2194 mActionSave->plug( tb );
2194 mViewManager->getFilterAction()->plug ( tb); 2195 mViewManager->getFilterAction()->plug ( tb);
2195 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2196 //LR hide filteraction on started in 480x640
2196 mActionUndo->plug( tb ); 2197 if (QApplication::desktop()->width() == 480 ) {
2197 mActionDelete->plug( tb ); 2198 mViewManager->getFilterAction()->setComboWidth( 0 );
2198 mActionRedo->plug( tb );
2199 } 2199 }
2200 mActionUndo->plug( tb );
2201 mActionDelete->plug( tb );
2202 mActionRedo->plug( tb );
2200 } else { 2203 } else {
2201 mActionSave->plug( tb ); 2204 mActionSave->plug( tb );
2202 tb->enableMoving(false); 2205 tb->enableMoving(false);
2203 } 2206 }
2204 //mActionQuit->plug ( tb ); 2207 //mActionQuit->plug ( tb );
2205 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2208 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2206 2209
2207 //US link the searchwidget first to this. 2210 //US link the searchwidget first to this.
2208 // The real linkage to the toolbar happens later. 2211 // The real linkage to the toolbar happens later.
2209//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2212//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2210//US tb->insertItem( mIncSearchWidget ); 2213//US tb->insertItem( mIncSearchWidget );
2211/*US 2214/*US
2212 mIncSearchWidget = new IncSearchWidget( tb ); 2215 mIncSearchWidget = new IncSearchWidget( tb );
2213 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2216 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2214 SLOT( incrementalSearch( const QString& ) ) ); 2217 SLOT( incrementalSearch( const QString& ) ) );
2215 2218
2216 mJumpButtonBar = new JumpButtonBar( this, this ); 2219 mJumpButtonBar = new JumpButtonBar( this, this );
2217 2220
2218//US topLayout->addWidget( mJumpButtonBar ); 2221//US topLayout->addWidget( mJumpButtonBar );
2219 this->layout()->add( mJumpButtonBar ); 2222 this->layout()->add( mJumpButtonBar );
2220*/ 2223*/
2221 2224
2222#endif //KAB_EMBEDDED 2225#endif //KAB_EMBEDDED
2223 2226
2224 mActionExport2phone->plug( ExportMenu ); 2227 mActionExport2phone->plug( ExportMenu );
2225 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2228 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2226 syncManager->fillSyncMenu(); 2229 syncManager->fillSyncMenu();
2227 2230
2228} 2231}
2229void KABCore::showLicence() 2232void KABCore::showLicence()
2230{ 2233{
2231 KApplication::showLicence(); 2234 KApplication::showLicence();
2232} 2235}
2233 2236
2234void KABCore::manageCategories( ) 2237void KABCore::manageCategories( )
2235{ 2238{
2236 KABCatPrefs* cp = new KABCatPrefs(); 2239 KABCatPrefs* cp = new KABCatPrefs();
2237 cp->show(); 2240 cp->show();
2238 int w =cp->sizeHint().width() ; 2241 int w =cp->sizeHint().width() ;
2239 int h = cp->sizeHint().height() ; 2242 int h = cp->sizeHint().height() ;
2240 int dw = QApplication::desktop()->width(); 2243 int dw = QApplication::desktop()->width();
2241 int dh = QApplication::desktop()->height(); 2244 int dh = QApplication::desktop()->height();
2242 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2245 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2243 if ( !cp->exec() ) { 2246 if ( !cp->exec() ) {
2244 delete cp; 2247 delete cp;
2245 return; 2248 return;
2246 } 2249 }
2247 int count = 0; 2250 int count = 0;
2248 message( i18n("Please wait, processing categories...")); 2251 message( i18n("Please wait, processing categories..."));
2249 if ( cp->addCat() ) { 2252 if ( cp->addCat() ) {
2250 KABC::AddressBook::Iterator it; 2253 KABC::AddressBook::Iterator it;
2251 QStringList catList = KABPrefs::instance()->mCustomCategories; 2254 QStringList catList = KABPrefs::instance()->mCustomCategories;
2252 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2255 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2253 QStringList catIncList = (*it).categories(); 2256 QStringList catIncList = (*it).categories();
2254 int i; 2257 int i;
2255 for( i = 0; i< catIncList.count(); ++i ) { 2258 for( i = 0; i< catIncList.count(); ++i ) {
2256 if ( !catList.contains (catIncList[i])) { 2259 if ( !catList.contains (catIncList[i])) {
2257 catList.append( catIncList[i] ); 2260 catList.append( catIncList[i] );
2258 //qDebug("add cat %s ", catIncList[i].latin1()); 2261 //qDebug("add cat %s ", catIncList[i].latin1());
2259 ++count; 2262 ++count;
2260 } 2263 }
2261 } 2264 }
2262 } 2265 }
2263 catList.sort(); 2266 catList.sort();
2264 KABPrefs::instance()->mCustomCategories = catList; 2267 KABPrefs::instance()->mCustomCategories = catList;
2265 KABPrefs::instance()->writeConfig(); 2268 KABPrefs::instance()->writeConfig();
2266 message(QString::number( count )+ i18n(" categories added to list! ")); 2269 message(QString::number( count )+ i18n(" categories added to list! "));
2267 } else { 2270 } else {
2268 QStringList catList = KABPrefs::instance()->mCustomCategories; 2271 QStringList catList = KABPrefs::instance()->mCustomCategories;
2269 QStringList catIncList; 2272 QStringList catIncList;
2270 QStringList newCatList; 2273 QStringList newCatList;
2271 KABC::AddressBook::Iterator it; 2274 KABC::AddressBook::Iterator it;
2272 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2275 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2273 QStringList catIncList = (*it).categories(); 2276 QStringList catIncList = (*it).categories();
2274 int i; 2277 int i;
2275 if ( catIncList.count() ) { 2278 if ( catIncList.count() ) {
2276 newCatList.clear(); 2279 newCatList.clear();
2277 for( i = 0; i< catIncList.count(); ++i ) { 2280 for( i = 0; i< catIncList.count(); ++i ) {
2278 if ( catList.contains (catIncList[i])) { 2281 if ( catList.contains (catIncList[i])) {
2279 newCatList.append( catIncList[i] ); 2282 newCatList.append( catIncList[i] );
2280 } 2283 }
2281 } 2284 }
2282 newCatList.sort(); 2285 newCatList.sort();
2283 (*it).setCategories( newCatList ); 2286 (*it).setCategories( newCatList );
2284 mAddressBook->insertAddressee( (*it) ); 2287 mAddressBook->insertAddressee( (*it) );
2285 } 2288 }
2286 } 2289 }
2287 setModified( true ); 2290 setModified( true );
2288 mViewManager->refreshView(); 2291 mViewManager->refreshView();
2289 mDetails->refreshView(); 2292 mDetails->refreshView();
2290 message( i18n("Removing categories done!")); 2293 message( i18n("Removing categories done!"));
2291 } 2294 }
2292 delete cp; 2295 delete cp;
2293} 2296}
2294void KABCore::removeVoice() 2297void KABCore::removeVoice()
2295{ 2298{
2296 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 ) 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 )
2297 return; 2300 return;
2298 KABC::Addressee::List list; 2301 KABC::Addressee::List list;
2299 XXPortSelectDialog dlg( this, false, this ); 2302 XXPortSelectDialog dlg( this, false, this );
2300 if ( dlg.exec() ) 2303 if ( dlg.exec() )
2301 list = dlg.contacts(); 2304 list = dlg.contacts();
2302 else 2305 else
2303 return; 2306 return;
2304 KABC::Addressee::List::Iterator it; 2307 KABC::Addressee::List::Iterator it;
2305 for ( it = list.begin(); it != list.end(); ++it ) { 2308 for ( it = list.begin(); it != list.end(); ++it ) {
2306 if ( (*it).removeVoice() ) 2309 if ( (*it).removeVoice() )
2307 contactModified((*it) ); 2310 contactModified((*it) );
2308 } 2311 }
2309} 2312}
2310 2313
2311 2314
2312 2315
2313void KABCore::clipboardDataChanged() 2316void KABCore::clipboardDataChanged()
2314{ 2317{
2315 2318
2316 if ( mReadWrite ) 2319 if ( mReadWrite )
2317 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2320 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2318 2321
2319} 2322}
2320 2323
2321void KABCore::updateActionMenu() 2324void KABCore::updateActionMenu()
2322{ 2325{
2323 UndoStack *undo = UndoStack::instance(); 2326 UndoStack *undo = UndoStack::instance();
2324 RedoStack *redo = RedoStack::instance(); 2327 RedoStack *redo = RedoStack::instance();
2325 2328
2326 if ( undo->isEmpty() ) 2329 if ( undo->isEmpty() )
2327 mActionUndo->setText( i18n( "Undo" ) ); 2330 mActionUndo->setText( i18n( "Undo" ) );
2328 else 2331 else
2329 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2332 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2330 2333
2331 mActionUndo->setEnabled( !undo->isEmpty() ); 2334 mActionUndo->setEnabled( !undo->isEmpty() );
2332 2335
2333 if ( !redo->top() ) 2336 if ( !redo->top() )
2334 mActionRedo->setText( i18n( "Redo" ) ); 2337 mActionRedo->setText( i18n( "Redo" ) );
2335 else 2338 else
2336 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2339 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2337 2340
2338 mActionRedo->setEnabled( !redo->isEmpty() ); 2341 mActionRedo->setEnabled( !redo->isEmpty() );
2339} 2342}
2340 2343
2341void KABCore::configureKeyBindings() 2344void KABCore::configureKeyBindings()
2342{ 2345{
2343#ifndef KAB_EMBEDDED 2346#ifndef KAB_EMBEDDED
2344 KKeyDialog::configure( actionCollection(), true ); 2347 KKeyDialog::configure( actionCollection(), true );
2345#else //KAB_EMBEDDED 2348#else //KAB_EMBEDDED
2346 qDebug("KABCore::configureKeyBindings() not implemented"); 2349 qDebug("KABCore::configureKeyBindings() not implemented");
2347#endif //KAB_EMBEDDED 2350#endif //KAB_EMBEDDED
2348} 2351}
2349 2352
2350#ifdef KAB_EMBEDDED 2353#ifdef KAB_EMBEDDED
2351void KABCore::configureResources() 2354void KABCore::configureResources()
2352{ 2355{
2353 KRES::KCMKResources dlg( this, "" , 0 ); 2356 KRES::KCMKResources dlg( this, "" , 0 );
2354 2357
2355 if ( !dlg.exec() ) 2358 if ( !dlg.exec() )
2356 return; 2359 return;
2357 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2360 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2358} 2361}
2359#endif //KAB_EMBEDDED 2362#endif //KAB_EMBEDDED
2360 2363
2361 2364
2362/* this method will be called through the QCop interface from Ko/Pi to select addresses 2365/* this method will be called through the QCop interface from Ko/Pi to select addresses
2363 * for the attendees list of an event. 2366 * for the attendees list of an event.
2364 */ 2367 */
2365void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2368void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2366{ 2369{
2367 QStringList nameList; 2370 QStringList nameList;
2368 QStringList emailList; 2371 QStringList emailList;
2369 QStringList uidList; 2372 QStringList uidList;
2370 2373
2371 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2374 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2372 uint i=0; 2375 uint i=0;
2373 for (i=0; i < list.count(); i++) 2376 for (i=0; i < list.count(); i++)
2374 { 2377 {
2375 nameList.append(list[i].realName()); 2378 nameList.append(list[i].realName());
2376 emailList.append(list[i].preferredEmail()); 2379 emailList.append(list[i].preferredEmail());
2377 uidList.append(list[i].uid()); 2380 uidList.append(list[i].uid());
2378 } 2381 }
2379 2382
2380 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2383 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2381 2384
2382} 2385}
2383 2386
2384/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2387/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2385 * to put them into the calendar. 2388 * to put them into the calendar.
2386 */ 2389 */
2387void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2390void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2388{ 2391{
2389 // qDebug("KABCore::requestForBirthdayList"); 2392 // qDebug("KABCore::requestForBirthdayList");
2390 QStringList birthdayList; 2393 QStringList birthdayList;
2391 QStringList anniversaryList; 2394 QStringList anniversaryList;
2392 QStringList realNameList; 2395 QStringList realNameList;
2393 QStringList preferredEmailList; 2396 QStringList preferredEmailList;
2394 QStringList assembledNameList; 2397 QStringList assembledNameList;
2395 QStringList uidList; 2398 QStringList uidList;
2396 2399
2397 KABC::AddressBook::Iterator it; 2400 KABC::AddressBook::Iterator it;
2398 2401
2399 int count = 0; 2402 int count = 0;
2400 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2403 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2401 ++count; 2404 ++count;
2402 } 2405 }
2403 QProgressBar bar(count,0 ); 2406 QProgressBar bar(count,0 );
2404 int w = 300; 2407 int w = 300;
2405 if ( QApplication::desktop()->width() < 320 ) 2408 if ( QApplication::desktop()->width() < 320 )
2406 w = 220; 2409 w = 220;
2407 int h = bar.sizeHint().height() ; 2410 int h = bar.sizeHint().height() ;
2408 int dw = QApplication::desktop()->width(); 2411 int dw = QApplication::desktop()->width();
2409 int dh = QApplication::desktop()->height(); 2412 int dh = QApplication::desktop()->height();
2410 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2413 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2411 bar.show(); 2414 bar.show();
2412 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2415 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2413 qApp->processEvents(); 2416 qApp->processEvents();
2414 2417
2415 QDate bday; 2418 QDate bday;
2416 QString anni; 2419 QString anni;
2417 QString formattedbday; 2420 QString formattedbday;
2418 2421
2419 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2422 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2420 { 2423 {
2421 if ( ! bar.isVisible() ) 2424 if ( ! bar.isVisible() )
2422 return; 2425 return;
2423 bar.setProgress( count++ ); 2426 bar.setProgress( count++ );
2424 qApp->processEvents(); 2427 qApp->processEvents();
2425 bday = (*it).birthday().date(); 2428 bday = (*it).birthday().date();
2426 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2429 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2427 2430
2428 if ( bday.isValid() || !anni.isEmpty()) 2431 if ( bday.isValid() || !anni.isEmpty())
2429 { 2432 {
2430 if (bday.isValid()) 2433 if (bday.isValid())
2431 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2434 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2432 else 2435 else
2433 formattedbday = "NOTVALID"; 2436 formattedbday = "NOTVALID";
2434 if (anni.isEmpty()) 2437 if (anni.isEmpty())
2435 anni = "INVALID"; 2438 anni = "INVALID";
2436 2439
2437 birthdayList.append(formattedbday); 2440 birthdayList.append(formattedbday);
2438 anniversaryList.append(anni); //should be ISODate 2441 anniversaryList.append(anni); //should be ISODate
2439 realNameList.append((*it).realName()); 2442 realNameList.append((*it).realName());
2440 preferredEmailList.append((*it).preferredEmail()); 2443 preferredEmailList.append((*it).preferredEmail());
2441 assembledNameList.append((*it).assembledName()); 2444 assembledNameList.append((*it).assembledName());
2442 uidList.append((*it).uid()); 2445 uidList.append((*it).uid());
2443 2446
2444 //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() ); 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() );
2445 } 2448 }
2446 } 2449 }
2447 2450
2448 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2451 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2449 2452
2450} 2453}
2451 2454
2452/* this method will be called through the QCop interface from other apps to show details of a contact. 2455/* this method will be called through the QCop interface from other apps to show details of a contact.
2453 */ 2456 */
2454void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2457void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2455{ 2458{
2456 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2459 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2457 2460
2458 QString foundUid = QString::null; 2461 QString foundUid = QString::null;
2459 if ( ! uid.isEmpty() ) { 2462 if ( ! uid.isEmpty() ) {
2460 Addressee adrr = mAddressBook->findByUid( uid ); 2463 Addressee adrr = mAddressBook->findByUid( uid );
2461 if ( !adrr.isEmpty() ) { 2464 if ( !adrr.isEmpty() ) {
2462 foundUid = uid; 2465 foundUid = uid;
2463 } 2466 }
2464 if ( email == "sendbacklist" ) { 2467 if ( email == "sendbacklist" ) {
2465 //qDebug("ssssssssssssssssssssssend "); 2468 //qDebug("ssssssssssssssssssssssend ");
2466 QStringList nameList; 2469 QStringList nameList;
2467 QStringList emailList; 2470 QStringList emailList;
2468 QStringList uidList; 2471 QStringList uidList;
2469 nameList.append(adrr.realName()); 2472 nameList.append(adrr.realName());
2470 emailList = adrr.emails(); 2473 emailList = adrr.emails();
2471 uidList.append( adrr.preferredEmail()); 2474 uidList.append( adrr.preferredEmail());
2472 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2475 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2473 return; 2476 return;
2474 } 2477 }
2475 2478
2476 } 2479 }
2477 2480
2478 if ( email == "sendbacklist" ) 2481 if ( email == "sendbacklist" )
2479 return; 2482 return;
2480 if (foundUid.isEmpty()) 2483 if (foundUid.isEmpty())
2481 { 2484 {
2482 //find the uid of the person first 2485 //find the uid of the person first
2483 Addressee::List namelist; 2486 Addressee::List namelist;
2484 Addressee::List emaillist; 2487 Addressee::List emaillist;
2485 2488
2486 if (!name.isEmpty()) 2489 if (!name.isEmpty())
2487 namelist = mAddressBook->findByName( name ); 2490 namelist = mAddressBook->findByName( name );
2488 2491
2489 if (!email.isEmpty()) 2492 if (!email.isEmpty())
2490 emaillist = mAddressBook->findByEmail( email ); 2493 emaillist = mAddressBook->findByEmail( email );
2491 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2494 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2492 //check if we have a match in Namelist and Emaillist 2495 //check if we have a match in Namelist and Emaillist
2493 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2496 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2494 foundUid = emaillist[0].uid(); 2497 foundUid = emaillist[0].uid();
2495 } 2498 }
2496 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2499 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2497 foundUid = namelist[0].uid(); 2500 foundUid = namelist[0].uid();
2498 else 2501 else
2499 { 2502 {
2500 for (int i = 0; i < namelist.count(); i++) 2503 for (int i = 0; i < namelist.count(); i++)
2501 { 2504 {
2502 for (int j = 0; j < emaillist.count(); j++) 2505 for (int j = 0; j < emaillist.count(); j++)
2503 { 2506 {
2504 if (namelist[i] == emaillist[j]) 2507 if (namelist[i] == emaillist[j])
2505 { 2508 {
2506 foundUid = namelist[i].uid(); 2509 foundUid = namelist[i].uid();
2507 } 2510 }
2508 } 2511 }
2509 } 2512 }
2510 } 2513 }
2511 } 2514 }
2512 else 2515 else
2513 { 2516 {
2514 foundUid = uid; 2517 foundUid = uid;
2515 } 2518 }
2516 2519
2517 if (!foundUid.isEmpty()) 2520 if (!foundUid.isEmpty())
2518 { 2521 {
2519 2522
2520 // raise Ka/Pi if it is in the background 2523 // raise Ka/Pi if it is in the background
2521#ifndef DESKTOP_VERSION 2524#ifndef DESKTOP_VERSION
2522#ifndef KORG_NODCOP 2525#ifndef KORG_NODCOP
2523 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2526 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2524#endif 2527#endif
2525#endif 2528#endif
2526 2529
2527 mMainWindow->showMaximized(); 2530 mMainWindow->showMaximized();
2528 mMainWindow-> raise(); 2531 mMainWindow-> raise();
2529 2532
2530 mViewManager->setSelected( "", false); 2533 mViewManager->setSelected( "", false);
2531 mViewManager->refreshView( "" ); 2534 mViewManager->refreshView( "" );
2532 mViewManager->setSelected( foundUid, true ); 2535 mViewManager->setSelected( foundUid, true );
2533 mViewManager->refreshView( foundUid ); 2536 mViewManager->refreshView( foundUid );
2534 2537
2535 if ( !mMultipleViewsAtOnce ) 2538 if ( !mMultipleViewsAtOnce )
2536 { 2539 {
2537 setDetailsVisible( true ); 2540 setDetailsVisible( true );
2538 mActionDetails->setChecked(true); 2541 mActionDetails->setChecked(true);
2539 } 2542 }
2540 } 2543 }
2541} 2544}
2542 2545
2543void KABCore::whatsnew() 2546void KABCore::whatsnew()
2544{ 2547{
2545 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2548 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2546} 2549}
2547void KABCore::synchowto() 2550void KABCore::synchowto()
2548{ 2551{
2549 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2552 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2550} 2553}
2551void KABCore::kdesynchowto() 2554void KABCore::kdesynchowto()
2552{ 2555{
2553 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2556 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2554} 2557}
2555void KABCore::multisynchowto() 2558void KABCore::multisynchowto()
2556{ 2559{
2557 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2560 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2558} 2561}
2559void KABCore::faq() 2562void KABCore::faq()
2560{ 2563{
2561 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2564 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2562} 2565}
2563 2566
2564#include <libkcal/syncdefines.h> 2567#include <libkcal/syncdefines.h>
2565 2568
2566KABC::Addressee KABCore::getLastSyncAddressee() 2569KABC::Addressee KABCore::getLastSyncAddressee()
2567{ 2570{
2568 Addressee lse; 2571 Addressee lse;
2569 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2572 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2570 2573
2571 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2574 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2572 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2575 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2573 if (lse.isEmpty()) { 2576 if (lse.isEmpty()) {
2574 qDebug("Creating new last-syncAddressee "); 2577 qDebug("Creating new last-syncAddressee ");
2575 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2578 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2576 QString sum = ""; 2579 QString sum = "";
2577 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2580 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2578 sum = "E: "; 2581 sum = "E: ";
2579 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2582 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2580 lse.setRevision( mLastAddressbookSync ); 2583 lse.setRevision( mLastAddressbookSync );
2581 lse.setCategories( i18n("SyncEvent") ); 2584 lse.setCategories( i18n("SyncEvent") );
2582 mAddressBook->insertAddressee( lse ); 2585 mAddressBook->insertAddressee( lse );
2583 } 2586 }
2584 return lse; 2587 return lse;
2585} 2588}
2586int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2589int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2587{ 2590{
2588 2591
2589 //void setZaurusId(int id); 2592 //void setZaurusId(int id);
2590 // int zaurusId() const; 2593 // int zaurusId() const;
2591 // void setZaurusUid(int id); 2594 // void setZaurusUid(int id);
2592 // int zaurusUid() const; 2595 // int zaurusUid() const;
2593 // void setZaurusStat(int id); 2596 // void setZaurusStat(int id);
2594 // int zaurusStat() const; 2597 // int zaurusStat() const;
2595 // 0 equal 2598 // 0 equal
2596 // 1 take local 2599 // 1 take local
2597 // 2 take remote 2600 // 2 take remote
2598 // 3 cancel 2601 // 3 cancel
2599 QDateTime lastSync = mLastAddressbookSync; 2602 QDateTime lastSync = mLastAddressbookSync;
2600 QDateTime localMod = local->revision(); 2603 QDateTime localMod = local->revision();
2601 QDateTime remoteMod = remote->revision(); 2604 QDateTime remoteMod = remote->revision();
2602 2605
2603 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2606 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2604 2607
2605 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2608 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2606 bool remCh, locCh; 2609 bool remCh, locCh;
2607 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2610 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2608 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2611 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2609 locCh = ( localMod > mLastAddressbookSync ); 2612 locCh = ( localMod > mLastAddressbookSync );
2610 if ( !remCh && ! locCh ) { 2613 if ( !remCh && ! locCh ) {
2611 //qDebug("both not changed "); 2614 //qDebug("both not changed ");
2612 lastSync = localMod.addDays(1); 2615 lastSync = localMod.addDays(1);
2613 if ( mode <= SYNC_PREF_ASK ) 2616 if ( mode <= SYNC_PREF_ASK )
2614 return 0; 2617 return 0;
2615 } else { 2618 } else {
2616 if ( locCh ) { 2619 if ( locCh ) {
2617 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2620 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2618 lastSync = localMod.addDays( -1 ); 2621 lastSync = localMod.addDays( -1 );
2619 if ( !remCh ) 2622 if ( !remCh )
2620 remoteMod =( lastSync.addDays( -1 ) ); 2623 remoteMod =( lastSync.addDays( -1 ) );
2621 } else { 2624 } else {
2622 //qDebug(" not loc changed "); 2625 //qDebug(" not loc changed ");
2623 lastSync = localMod.addDays( 1 ); 2626 lastSync = localMod.addDays( 1 );
2624 if ( remCh ) { 2627 if ( remCh ) {
2625 //qDebug("rem changed "); 2628 //qDebug("rem changed ");
2626 remoteMod =( lastSync.addDays( 1 ) ); 2629 remoteMod =( lastSync.addDays( 1 ) );
2627 } 2630 }
2628 2631
2629 } 2632 }
2630 } 2633 }
2631 full = true; 2634 full = true;
2632 if ( mode < SYNC_PREF_ASK ) 2635 if ( mode < SYNC_PREF_ASK )
2633 mode = SYNC_PREF_ASK; 2636 mode = SYNC_PREF_ASK;
2634 } else { 2637 } else {
2635 if ( localMod == remoteMod ) 2638 if ( localMod == remoteMod )
2636 return 0; 2639 return 0;
2637 2640
2638 } 2641 }
2639 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2642 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2640 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2643 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2641 //full = true; //debug only 2644 //full = true; //debug only
2642 if ( full ) { 2645 if ( full ) {
2643 bool equ = ( (*local) == (*remote) ); 2646 bool equ = ( (*local) == (*remote) );
2644 if ( equ ) { 2647 if ( equ ) {
2645 //qDebug("equal "); 2648 //qDebug("equal ");
2646 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2649 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2647 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2650 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2648 } 2651 }
2649 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2652 if ( mode < SYNC_PREF_FORCE_LOCAL )
2650 return 0; 2653 return 0;
2651 2654
2652 }//else //debug only 2655 }//else //debug only
2653 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2656 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2654 } 2657 }
2655 int result; 2658 int result;
2656 bool localIsNew; 2659 bool localIsNew;
2657 //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() ); 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() );
2658 2661
2659 if ( full && mode < SYNC_PREF_NEWEST ) 2662 if ( full && mode < SYNC_PREF_NEWEST )
2660 mode = SYNC_PREF_ASK; 2663 mode = SYNC_PREF_ASK;
2661 2664
2662 switch( mode ) { 2665 switch( mode ) {
2663 case SYNC_PREF_LOCAL: 2666 case SYNC_PREF_LOCAL:
2664 if ( lastSync > remoteMod ) 2667 if ( lastSync > remoteMod )
2665 return 1; 2668 return 1;
2666 if ( lastSync > localMod ) 2669 if ( lastSync > localMod )
2667 return 2; 2670 return 2;
2668 return 1; 2671 return 1;
2669 break; 2672 break;
2670 case SYNC_PREF_REMOTE: 2673 case SYNC_PREF_REMOTE:
2671 if ( lastSync > remoteMod ) 2674 if ( lastSync > remoteMod )
2672 return 1; 2675 return 1;
2673 if ( lastSync > localMod ) 2676 if ( lastSync > localMod )
2674 return 2; 2677 return 2;
2675 return 2; 2678 return 2;
2676 break; 2679 break;
2677 case SYNC_PREF_NEWEST: 2680 case SYNC_PREF_NEWEST:
2678 if ( localMod > remoteMod ) 2681 if ( localMod > remoteMod )
2679 return 1; 2682 return 1;
2680 else 2683 else
2681 return 2; 2684 return 2;
2682 break; 2685 break;
2683 case SYNC_PREF_ASK: 2686 case SYNC_PREF_ASK:
2684 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2687 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2685 if ( lastSync > remoteMod ) 2688 if ( lastSync > remoteMod )
2686 return 1; 2689 return 1;
2687 if ( lastSync > localMod ) 2690 if ( lastSync > localMod )
2688 return 2; 2691 return 2;
2689 localIsNew = localMod >= remoteMod; 2692 localIsNew = localMod >= remoteMod;
2690 //qDebug("conflict! ************************************** "); 2693 //qDebug("conflict! ************************************** ");
2691 { 2694 {
2692 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2695 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2693 result = acd.executeD(localIsNew); 2696 result = acd.executeD(localIsNew);
2694 return result; 2697 return result;
2695 } 2698 }
2696 break; 2699 break;
2697 case SYNC_PREF_FORCE_LOCAL: 2700 case SYNC_PREF_FORCE_LOCAL:
2698 return 1; 2701 return 1;
2699 break; 2702 break;
2700 case SYNC_PREF_FORCE_REMOTE: 2703 case SYNC_PREF_FORCE_REMOTE:
2701 return 2; 2704 return 2;
2702 break; 2705 break;
2703 2706
2704 default: 2707 default:
2705 // SYNC_PREF_TAKE_BOTH not implemented 2708 // SYNC_PREF_TAKE_BOTH not implemented
2706 break; 2709 break;
2707 } 2710 }
2708 return 0; 2711 return 0;
2709} 2712}
2710 2713
2711 2714
2712bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2715bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2713{ 2716{
2714 bool syncOK = true; 2717 bool syncOK = true;
2715 int addedAddressee = 0; 2718 int addedAddressee = 0;
2716 int addedAddresseeR = 0; 2719 int addedAddresseeR = 0;
2717 int deletedAddresseeR = 0; 2720 int deletedAddresseeR = 0;
2718 int deletedAddresseeL = 0; 2721 int deletedAddresseeL = 0;
2719 int changedLocal = 0; 2722 int changedLocal = 0;
2720 int changedRemote = 0; 2723 int changedRemote = 0;
2721 2724
2722 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2725 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2723 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2726 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2724 2727
2725 //QPtrList<Addressee> el = local->rawAddressees(); 2728 //QPtrList<Addressee> el = local->rawAddressees();
2726 Addressee addresseeR; 2729 Addressee addresseeR;
2727 QString uid; 2730 QString uid;
2728 int take; 2731 int take;
2729 Addressee addresseeL; 2732 Addressee addresseeL;
2730 Addressee addresseeRSync; 2733 Addressee addresseeRSync;
2731 Addressee addresseeLSync; 2734 Addressee addresseeLSync;
2732 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2735 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2733 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2736 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2734 bool fullDateRange = false; 2737 bool fullDateRange = false;
2735 local->resetTempSyncStat(); 2738 local->resetTempSyncStat();
2736 mLastAddressbookSync = QDateTime::currentDateTime(); 2739 mLastAddressbookSync = QDateTime::currentDateTime();
2737 if ( syncManager->syncWithDesktop() ) { 2740 if ( syncManager->syncWithDesktop() ) {
2738 // remote->removeSyncInfo( QString());//remove all info 2741 // remote->removeSyncInfo( QString());//remove all info
2739 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2742 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2740 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2743 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2741 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2744 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2742 } else { 2745 } else {
2743 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2746 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2744 } 2747 }
2745 } 2748 }
2746 QDateTime modifiedCalendar = mLastAddressbookSync; 2749 QDateTime modifiedCalendar = mLastAddressbookSync;
2747 addresseeLSync = getLastSyncAddressee(); 2750 addresseeLSync = getLastSyncAddressee();
2748 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2751 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2749 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2752 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2750 if ( !addresseeR.isEmpty() ) { 2753 if ( !addresseeR.isEmpty() ) {
2751 addresseeRSync = addresseeR; 2754 addresseeRSync = addresseeR;
2752 remote->removeAddressee(addresseeR ); 2755 remote->removeAddressee(addresseeR );
2753 2756
2754 } else { 2757 } else {
2755 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2758 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2756 addresseeRSync = addresseeLSync ; 2759 addresseeRSync = addresseeLSync ;
2757 } else { 2760 } else {
2758 //qDebug("FULLDATE 1"); 2761 //qDebug("FULLDATE 1");
2759 fullDateRange = true; 2762 fullDateRange = true;
2760 Addressee newAdd; 2763 Addressee newAdd;
2761 addresseeRSync = newAdd; 2764 addresseeRSync = newAdd;
2762 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2765 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2763 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2766 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2764 addresseeRSync.setRevision( mLastAddressbookSync ); 2767 addresseeRSync.setRevision( mLastAddressbookSync );
2765 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2768 addresseeRSync.setCategories( i18n("SyncAddressee") );
2766 } 2769 }
2767 } 2770 }
2768 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2771 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2769 // qDebug("FULLDATE 2"); 2772 // qDebug("FULLDATE 2");
2770 fullDateRange = true; 2773 fullDateRange = true;
2771 } 2774 }
2772 if ( ! fullDateRange ) { 2775 if ( ! fullDateRange ) {
2773 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2776 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2774 2777
2775 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2778 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2776 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2779 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2777 fullDateRange = true; 2780 fullDateRange = true;
2778 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2781 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2779 } 2782 }
2780 } 2783 }
2781 // fullDateRange = true; // debug only! 2784 // fullDateRange = true; // debug only!
2782 if ( fullDateRange ) 2785 if ( fullDateRange )
2783 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2786 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2784 else 2787 else
2785 mLastAddressbookSync = addresseeLSync.revision(); 2788 mLastAddressbookSync = addresseeLSync.revision();
2786 // for resyncing if own file has changed 2789 // for resyncing if own file has changed
2787 // PENDING fixme later when implemented 2790 // PENDING fixme later when implemented
2788#if 0 2791#if 0
2789 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2792 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2790 mLastAddressbookSync = loadedFileVersion; 2793 mLastAddressbookSync = loadedFileVersion;
2791 qDebug("setting mLastAddressbookSync "); 2794 qDebug("setting mLastAddressbookSync ");
2792 } 2795 }
2793#endif 2796#endif
2794 2797
2795 //qDebug("*************************** "); 2798 //qDebug("*************************** ");
2796 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2799 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2797 QStringList er = remote->uidList(); 2800 QStringList er = remote->uidList();
2798 Addressee inR ;//= er.first(); 2801 Addressee inR ;//= er.first();
2799 Addressee inL; 2802 Addressee inL;
2800 2803
2801 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2804 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2802 2805
2803 int modulo = (er.count()/10)+1; 2806 int modulo = (er.count()/10)+1;
2804 int incCounter = 0; 2807 int incCounter = 0;
2805 while ( incCounter < er.count()) { 2808 while ( incCounter < er.count()) {
2806 if (syncManager->isProgressBarCanceled()) 2809 if (syncManager->isProgressBarCanceled())
2807 return false; 2810 return false;
2808 if ( incCounter % modulo == 0 ) 2811 if ( incCounter % modulo == 0 )
2809 syncManager->showProgressBar(incCounter); 2812 syncManager->showProgressBar(incCounter);
2810 2813
2811 uid = er[ incCounter ]; 2814 uid = er[ incCounter ];
2812 bool skipIncidence = false; 2815 bool skipIncidence = false;
2813 if ( uid.left(19) == QString("last-syncAddressee-") ) 2816 if ( uid.left(19) == QString("last-syncAddressee-") )
2814 skipIncidence = true; 2817 skipIncidence = true;
2815 QString idS,OidS; 2818 QString idS,OidS;
2816 qApp->processEvents(); 2819 qApp->processEvents();
2817 if ( !skipIncidence ) { 2820 if ( !skipIncidence ) {
2818 inL = local->findByUid( uid ); 2821 inL = local->findByUid( uid );
2819 inR = remote->findByUid( uid ); 2822 inR = remote->findByUid( uid );
2820 //inL.setResource( 0 ); 2823 //inL.setResource( 0 );
2821 //inR.setResource( 0 ); 2824 //inR.setResource( 0 );
2822 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2825 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2823 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2826 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2824 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2827 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2825 //qDebug("take %d %s ", take, inL.summary().latin1()); 2828 //qDebug("take %d %s ", take, inL.summary().latin1());
2826 if ( take == 3 ) 2829 if ( take == 3 )
2827 return false; 2830 return false;
2828 if ( take == 1 ) {// take local ********************** 2831 if ( take == 1 ) {// take local **********************
2829 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2832 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2830 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2833 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2831 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2834 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2832 local->insertAddressee( inL, false ); 2835 local->insertAddressee( inL, false );
2833 idS = inR.externalUID(); 2836 idS = inR.externalUID();
2834 OidS = inR.originalExternalUID(); 2837 OidS = inR.originalExternalUID();
2835 } 2838 }
2836 else 2839 else
2837 idS = inR.IDStr(); 2840 idS = inR.IDStr();
2838 remote->removeAddressee( inR ); 2841 remote->removeAddressee( inR );
2839 inR = inL; 2842 inR = inL;
2840 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2843 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2841 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2844 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2842 inR.setOriginalExternalUID( OidS ); 2845 inR.setOriginalExternalUID( OidS );
2843 inR.setExternalUID( idS ); 2846 inR.setExternalUID( idS );
2844 if ( syncManager->syncWithDesktop() ) { 2847 if ( syncManager->syncWithDesktop() ) {
2845 inR.setIDStr("changed" ); 2848 inR.setIDStr("changed" );
2846 } 2849 }
2847 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2850 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2848 } else { 2851 } else {
2849 inR.setIDStr( idS ); 2852 inR.setIDStr( idS );
2850 } 2853 }
2851 inR.setResource( 0 ); 2854 inR.setResource( 0 );
2852 remote->insertAddressee( inR , false); 2855 remote->insertAddressee( inR , false);
2853 ++changedRemote; 2856 ++changedRemote;
2854 } else { // take == 2 take remote ********************** 2857 } else { // take == 2 take remote **********************
2855 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2856 if ( inR.revision().date().year() < 2004 ) 2859 if ( inR.revision().date().year() < 2004 )
2857 inR.setRevision( modifiedCalendar ); 2860 inR.setRevision( modifiedCalendar );
2858 } 2861 }
2859 idS = inL.IDStr(); 2862 idS = inL.IDStr();
2860 local->removeAddressee( inL ); 2863 local->removeAddressee( inL );
2861 inL = inR; 2864 inL = inR;
2862 inL.setIDStr( idS ); 2865 inL.setIDStr( idS );
2863 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2866 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2864 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2867 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2865 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2868 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2866 } 2869 }
2867 inL.setResource( 0 ); 2870 inL.setResource( 0 );
2868 local->insertAddressee( inL , false ); 2871 local->insertAddressee( inL , false );
2869 ++changedLocal; 2872 ++changedLocal;
2870 } 2873 }
2871 } 2874 }
2872 } 2875 }
2873 } else { // no conflict ********** add or delete remote 2876 } else { // no conflict ********** add or delete remote
2874 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2877 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2875 QString des = addresseeLSync.note(); 2878 QString des = addresseeLSync.note();
2876 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2879 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2877 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2880 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2878 remote->insertAddressee( inR, false ); 2881 remote->insertAddressee( inR, false );
2879 ++deletedAddresseeR; 2882 ++deletedAddresseeR;
2880 } else { 2883 } else {
2881 inR.setRevision( modifiedCalendar ); 2884 inR.setRevision( modifiedCalendar );
2882 remote->insertAddressee( inR, false ); 2885 remote->insertAddressee( inR, false );
2883 inL = inR; 2886 inL = inR;
2884 inL.setIDStr( ":" ); 2887 inL.setIDStr( ":" );
2885 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2888 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2886 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2889 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2887 inL.setResource( 0 ); 2890 inL.setResource( 0 );
2888 local->insertAddressee( inL , false); 2891 local->insertAddressee( inL , false);
2889 ++addedAddressee; 2892 ++addedAddressee;
2890 } 2893 }
2891 } else { 2894 } else {
2892 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2895 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2893 inR.setRevision( modifiedCalendar ); 2896 inR.setRevision( modifiedCalendar );
2894 remote->insertAddressee( inR, false ); 2897 remote->insertAddressee( inR, false );
2895 inR.setResource( 0 ); 2898 inR.setResource( 0 );
2896 local->insertAddressee( inR, false ); 2899 local->insertAddressee( inR, false );
2897 ++addedAddressee; 2900 ++addedAddressee;
2898 } else { 2901 } else {
2899 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2902 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2900 remote->removeAddressee( inR ); 2903 remote->removeAddressee( inR );
2901 ++deletedAddresseeR; 2904 ++deletedAddresseeR;
2902 } 2905 }
2903 } 2906 }
2904 } 2907 }
2905 } 2908 }
2906 ++incCounter; 2909 ++incCounter;
2907 } 2910 }
2908 er.clear(); 2911 er.clear();
2909 QStringList el = local->uidList(); 2912 QStringList el = local->uidList();
2910 modulo = (el.count()/10)+1; 2913 modulo = (el.count()/10)+1;
2911 2914
2912 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2915 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2913 incCounter = 0; 2916 incCounter = 0;
2914 while ( incCounter < el.count()) { 2917 while ( incCounter < el.count()) {
2915 qApp->processEvents(); 2918 qApp->processEvents();
2916 if (syncManager->isProgressBarCanceled()) 2919 if (syncManager->isProgressBarCanceled())
2917 return false; 2920 return false;
2918 if ( incCounter % modulo == 0 ) 2921 if ( incCounter % modulo == 0 )
2919 syncManager->showProgressBar(incCounter); 2922 syncManager->showProgressBar(incCounter);
2920 uid = el[ incCounter ]; 2923 uid = el[ incCounter ];
2921 bool skipIncidence = false; 2924 bool skipIncidence = false;
2922 if ( uid.left(19) == QString("last-syncAddressee-") ) 2925 if ( uid.left(19) == QString("last-syncAddressee-") )
2923 skipIncidence = true; 2926 skipIncidence = true;
2924 if ( !skipIncidence ) { 2927 if ( !skipIncidence ) {
2925 inL = local->findByUid( uid ); 2928 inL = local->findByUid( uid );
2926 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2929 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2927 inR = remote->findByUid( uid ); 2930 inR = remote->findByUid( uid );
2928 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2931 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2932 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2930 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2933 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2931 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2934 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2932 local->removeAddressee( inL ); 2935 local->removeAddressee( inL );
2933 ++deletedAddresseeL; 2936 ++deletedAddresseeL;
2934 } else { 2937 } else {
2935 if ( ! syncManager->mWriteBackExistingOnly ) { 2938 if ( ! syncManager->mWriteBackExistingOnly ) {
2936 inL.removeID(mCurrentSyncDevice ); 2939 inL.removeID(mCurrentSyncDevice );
2937 ++addedAddresseeR; 2940 ++addedAddresseeR;
2938 inL.setRevision( modifiedCalendar ); 2941 inL.setRevision( modifiedCalendar );
2939 local->insertAddressee( inL, false ); 2942 local->insertAddressee( inL, false );
2940 inR = inL; 2943 inR = inL;
2941 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2944 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2942 inR.setResource( 0 ); 2945 inR.setResource( 0 );
2943 remote->insertAddressee( inR, false ); 2946 remote->insertAddressee( inR, false );
2944 } 2947 }
2945 } 2948 }
2946 } else { 2949 } else {
2947 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2950 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2948 //qDebug("data %s ", inL.revision().toString().latin1()); 2951 //qDebug("data %s ", inL.revision().toString().latin1());
2949 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2952 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2950 local->removeAddressee( inL ); 2953 local->removeAddressee( inL );
2951 ++deletedAddresseeL; 2954 ++deletedAddresseeL;
2952 } else { 2955 } else {
2953 if ( ! syncManager->mWriteBackExistingOnly ) { 2956 if ( ! syncManager->mWriteBackExistingOnly ) {
2954 ++addedAddresseeR; 2957 ++addedAddresseeR;
2955 inL.setRevision( modifiedCalendar ); 2958 inL.setRevision( modifiedCalendar );
2956 local->insertAddressee( inL, false ); 2959 local->insertAddressee( inL, false );
2957 inR = inL; 2960 inR = inL;
2958 inR.setIDStr( ":" ); 2961 inR.setIDStr( ":" );
2959 inR.setResource( 0 ); 2962 inR.setResource( 0 );
2960 remote->insertAddressee( inR, false ); 2963 remote->insertAddressee( inR, false );
2961 } 2964 }
2962 } 2965 }
2963 } 2966 }
2964 } 2967 }
2965 } 2968 }
2966 } 2969 }
2967 ++incCounter; 2970 ++incCounter;
2968 } 2971 }
2969 el.clear(); 2972 el.clear();
2970 syncManager->hideProgressBar(); 2973 syncManager->hideProgressBar();
2971 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2974 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2972 // get rid of micro seconds 2975 // get rid of micro seconds
2973 QTime t = mLastAddressbookSync.time(); 2976 QTime t = mLastAddressbookSync.time();
2974 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2977 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2975 addresseeLSync.setRevision( mLastAddressbookSync ); 2978 addresseeLSync.setRevision( mLastAddressbookSync );
2976 addresseeRSync.setRevision( mLastAddressbookSync ); 2979 addresseeRSync.setRevision( mLastAddressbookSync );
2977 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2980 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2978 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2981 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2979 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2982 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2980 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2983 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2981 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2984 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2982 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2985 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2983 addresseeRSync.setNote( "" ) ; 2986 addresseeRSync.setNote( "" ) ;
2984 addresseeLSync.setNote( "" ); 2987 addresseeLSync.setNote( "" );
2985 2988
2986 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2989 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2987 remote->insertAddressee( addresseeRSync, false ); 2990 remote->insertAddressee( addresseeRSync, false );
2988 local->insertAddressee( addresseeLSync, false ); 2991 local->insertAddressee( addresseeLSync, false );
2989 QString mes; 2992 QString mes;
2990 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2993 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2991 qDebug( mes ); 2994 qDebug( mes );
2992 mes = i18n("Local addressbook changed!\n") +mes; 2995 mes = i18n("Local addressbook changed!\n") +mes;
2993 if ( syncManager->mShowSyncSummary ) { 2996 if ( syncManager->mShowSyncSummary ) {
2994 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2997 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2995 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2998 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2996 qDebug("cancelled "); 2999 qDebug("cancelled ");
2997 return false; 3000 return false;
2998 } 3001 }
2999 } 3002 }
3000 return syncOK; 3003 return syncOK;
3001} 3004}
3002 3005
3003 3006
3004//this is a overwritten callbackmethods from the syncinterface 3007//this is a overwritten callbackmethods from the syncinterface
3005bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3008bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3006{ 3009{
3007 3010
3008 //pending prepare addresseeview for output 3011 //pending prepare addresseeview for output
3009 //pending detect, if remote file has REV field. if not switch to external sync 3012 //pending detect, if remote file has REV field. if not switch to external sync
3010 mGlobalSyncMode = SYNC_MODE_NORMAL; 3013 mGlobalSyncMode = SYNC_MODE_NORMAL;
3011 if ( manager != syncManager ) 3014 if ( manager != syncManager )
3012 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3015 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3013 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3016 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3014 3017
3015 AddressBook abLocal(filename,"syncContact"); 3018 AddressBook abLocal(filename,"syncContact");
3016 bool syncOK = false; 3019 bool syncOK = false;
3017 if ( abLocal.load() ) { 3020 if ( abLocal.load() ) {
3018 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3021 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3019 bool external = false; 3022 bool external = false;
3020 bool isXML = false; 3023 bool isXML = false;
3021 if ( filename.right(4) == ".xml") { 3024 if ( filename.right(4) == ".xml") {
3022 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3025 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3023 isXML = true; 3026 isXML = true;
3024 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3027 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3025 } else { 3028 } else {
3026 external = !manager->mIsKapiFile; 3029 external = !manager->mIsKapiFile;
3027 if ( external ) { 3030 if ( external ) {
3028 qDebug("Setting vcf mode to external "); 3031 qDebug("Setting vcf mode to external ");
3029 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3032 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3030 AddressBook::Iterator it; 3033 AddressBook::Iterator it;
3031 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3034 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3032 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3035 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3033 (*it).computeCsum( mCurrentSyncDevice ); 3036 (*it).computeCsum( mCurrentSyncDevice );
3034 } 3037 }
3035 } 3038 }
3036 } 3039 }
3037 //AddressBook::Iterator it; 3040 //AddressBook::Iterator it;
3038 //QStringList vcards; 3041 //QStringList vcards;
3039 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3042 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3040 // qDebug("Name %s ", (*it).familyName().latin1()); 3043 // qDebug("Name %s ", (*it).familyName().latin1());
3041 //} 3044 //}
3042 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3043 if ( syncOK ) { 3046 if ( syncOK ) {
3044 if ( syncManager->mWriteBackFile ) 3047 if ( syncManager->mWriteBackFile )
3045 { 3048 {
3046 if ( external ) 3049 if ( external )
3047 abLocal.removeSyncAddressees( !isXML); 3050 abLocal.removeSyncAddressees( !isXML);
3048 qDebug("Saving remote AB "); 3051 qDebug("Saving remote AB ");
3049 if ( ! abLocal.saveAB()) 3052 if ( ! abLocal.saveAB())
3050 qDebug("Error writing back AB to file "); 3053 qDebug("Error writing back AB to file ");
3051 if ( external ) { 3054 if ( external ) {
3052 // afterwrite processing 3055 // afterwrite processing
3053 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3056 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3054 } 3057 }
3055 } 3058 }
3056 } 3059 }
3057 setModified(); 3060 setModified();
3058 3061
3059 } 3062 }
3060 abLocal.removeResources(); 3063 abLocal.removeResources();
3061 if ( syncOK ) 3064 if ( syncOK )
3062 mViewManager->refreshView(); 3065 mViewManager->refreshView();
3063 return syncOK; 3066 return syncOK;
3064 3067
3065} 3068}
3066void KABCore::removeSyncInfo( QString syncProfile) 3069void KABCore::removeSyncInfo( QString syncProfile)
3067{ 3070{
3068 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3071 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3069 mAddressBook->removeSyncInfo( syncProfile ); 3072 mAddressBook->removeSyncInfo( syncProfile );
3070 setModified(); 3073 setModified();
3071} 3074}
3072 3075
3073 3076
3074//this is a overwritten callbackmethods from the syncinterface 3077//this is a overwritten callbackmethods from the syncinterface
3075bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3078bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3076{ 3079{
3077 if ( resource == "phone" ) 3080 if ( resource == "phone" )
3078 return syncPhone(); 3081 return syncPhone();
3079 disableBR( true ); 3082 disableBR( true );
3080 if ( manager != syncManager ) 3083 if ( manager != syncManager )
3081 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3084 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3082 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3085 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3083 3086
3084 AddressBook abLocal( resource,"syncContact"); 3087 AddressBook abLocal( resource,"syncContact");
3085 bool syncOK = false; 3088 bool syncOK = false;
3086 if ( abLocal.load() ) { 3089 if ( abLocal.load() ) {
3087 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3090 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3088 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3091 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3089 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3092 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3090 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3093 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3091 if ( syncOK ) { 3094 if ( syncOK ) {
3092 if ( syncManager->mWriteBackFile ) { 3095 if ( syncManager->mWriteBackFile ) {
3093 abLocal.removeSyncAddressees( false ); 3096 abLocal.removeSyncAddressees( false );
3094 abLocal.saveAB(); 3097 abLocal.saveAB();
3095 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3098 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3096 } 3099 }
3097 } else 3100 } else
3098 message( i18n("Sync cancelled or failed.") ); 3101 message( i18n("Sync cancelled or failed.") );
3099 setModified(); 3102 setModified();
3100 } 3103 }
3101 abLocal.removeResources(); 3104 abLocal.removeResources();
3102 if ( syncOK ) 3105 if ( syncOK )
3103 mViewManager->refreshView(); 3106 mViewManager->refreshView();
3104 disableBR( false ); 3107 disableBR( false );
3105 return syncOK; 3108 return syncOK;
3106 3109
3107} 3110}
3108void KABCore::message( QString m ) 3111void KABCore::message( QString m )
3109{ 3112{
3110 topLevelWidget()->setCaption( m ); 3113 topLevelWidget()->setCaption( m );
3111 mMessageTimer->start( 15000, true ); 3114 mMessageTimer->start( 15000, true );
3112} 3115}
3113bool KABCore::syncPhone() 3116bool KABCore::syncPhone()
3114{ 3117{
3115 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3118 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3116 QString fileName = getPhoneFile(); 3119 QString fileName = getPhoneFile();
3117 if ( !PhoneAccess::readFromPhone( fileName) ) { 3120 if ( !PhoneAccess::readFromPhone( fileName) ) {
3118 message(i18n("Phone access failed!")); 3121 message(i18n("Phone access failed!"));
3119 return false; 3122 return false;
3120 } 3123 }
3121 AddressBook abLocal( fileName,"syncContact"); 3124 AddressBook abLocal( fileName,"syncContact");
3122 bool syncOK = false; 3125 bool syncOK = false;
3123 { 3126 {
3124 abLocal.importFromFile( fileName ); 3127 abLocal.importFromFile( fileName );
3125 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3128 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3126 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3129 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3127 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3130 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3128 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3131 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3129 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3132 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3130 if ( syncOK ) { 3133 if ( syncOK ) {
3131 if ( syncManager->mWriteBackFile ) { 3134 if ( syncManager->mWriteBackFile ) {
3132 abLocal.removeSyncAddressees( true ); 3135 abLocal.removeSyncAddressees( true );
3133 abLocal.saveABphone( fileName ); 3136 abLocal.saveABphone( fileName );
3134 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3137 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3135 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3138 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3136 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3139 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3137 } 3140 }
3138 } 3141 }
3139 setModified(); 3142 setModified();
3140 } 3143 }
3141 abLocal.removeResources(); 3144 abLocal.removeResources();
3142 if ( syncOK ) 3145 if ( syncOK )
3143 mViewManager->refreshView(); 3146 mViewManager->refreshView();
3144 return syncOK; 3147 return syncOK;
3145} 3148}
3146void KABCore::getFile( bool success ) 3149void KABCore::getFile( bool success )
3147{ 3150{
3148 if ( ! success ) { 3151 if ( ! success ) {
3149 message( i18n("Error receiving file. Nothing changed!") ); 3152 message( i18n("Error receiving file. Nothing changed!") );
3150 return; 3153 return;
3151 } 3154 }
3152 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3155 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3153 if ( count ) 3156 if ( count )
3154 setModified( true ); 3157 setModified( true );
3155 message( i18n("Pi-Sync successful!") ); 3158 message( i18n("Pi-Sync successful!") );
3156 mViewManager->refreshView(); 3159 mViewManager->refreshView();
3157} 3160}
3158void KABCore::syncFileRequest() 3161void KABCore::syncFileRequest()
3159{ 3162{
3160 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3163 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3161 syncManager->slotSyncMenu( 999 ); 3164 syncManager->slotSyncMenu( 999 );
3162 } 3165 }
3163 mAddressBook->export2File( sentSyncFile() ); 3166 mAddressBook->export2File( sentSyncFile() );
3164} 3167}
3165QString KABCore::sentSyncFile() 3168QString KABCore::sentSyncFile()
3166{ 3169{
3167#ifdef DESKTOP_VERSION 3170#ifdef DESKTOP_VERSION
3168 return locateLocal( "tmp", "copysyncab.vcf" ); 3171 return locateLocal( "tmp", "copysyncab.vcf" );
3169#else 3172#else
3170 return QString( "/tmp/copysyncab.vcf" ); 3173 return QString( "/tmp/copysyncab.vcf" );
3171#endif 3174#endif
3172} 3175}
3173 3176
3174void KABCore::setCaptionBack() 3177void KABCore::setCaptionBack()
3175{ 3178{
3176 mMessageTimer->stop(); 3179 mMessageTimer->stop();
3177 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3180 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3178} 3181}
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 0d91c12..33bef5a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,718 +1,725 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h>
63#include <qwidgetstack.h> 64#include <qwidgetstack.h>
64 65
65#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
66#include "filtereditdialog.h" 67#include "filtereditdialog.h"
67#include "addviewdialog.h" 68#include "addviewdialog.h"
68#include "kabcore.h" 69#include "kabcore.h"
69#include "kabprefs.h" 70#include "kabprefs.h"
70#include "viewmanager.h" 71#include "viewmanager.h"
71 72
72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
74{ 75{
75 initGUI(); 76 initGUI();
76 initActions(); 77 initActions();
77 78
78 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
79 80
80 createViewFactories(); 81 createViewFactories();
81} 82}
82 83
83ViewManager::~ViewManager() 84ViewManager::~ViewManager()
84{ 85{
85 unloadViews(); 86 unloadViews();
86 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
87} 88}
88void ViewManager::scrollUP() 89void ViewManager::scrollUP()
89{ 90{
90 if ( mActiveView ) 91 if ( mActiveView )
91 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
92} 93}
93void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
94{ 95{
95 if ( mActiveView ) 96 if ( mActiveView )
96 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
97} 98}
98void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
99{ 100{
100 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
101 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
102 103
103 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
104 105
105 // Filter 106 // Filter
106 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
107 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
108 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
109 mActionSelectFilter->setComboWidth( 150 ); 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 )
112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw );
110 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
111 // been modified by global settings 115 // been modified by global settings
112 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
113 117
114 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
115 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
116 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
117 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
118 } 122 }
119 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
120 124
121 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
122} 126}
123 127
124void ViewManager::saveSettings() 128void ViewManager::saveSettings()
125{ 129{
126 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
127 131
128 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
129 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
130 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
131#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
132 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
133#else 137#else
134 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
135#endif 139#endif
136 } 140 }
137 141
138 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
139 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
140 144
141 // write the view name list 145 // write the view name list
142 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
143 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
144 148
145} 149}
146 150
147QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
148{ 152{
149 if ( mActiveView ) 153 if ( mActiveView )
150 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
151 else 155 else
152 return QStringList(); 156 return QStringList();
153} 157}
154 158
155QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
156{ 160{
157 if ( mActiveView ) 161 if ( mActiveView )
158 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
159 else 163 else
160 return QStringList(); 164 return QStringList();
161} 165}
162 166
163KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
164{ 168{
165 KABC::Addressee::List list; 169 KABC::Addressee::List list;
166 if ( mActiveView ) { 170 if ( mActiveView ) {
167 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
168 QStringList::Iterator it; 172 QStringList::Iterator it;
169 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
170 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
171 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
172 list.append( addr ); 176 list.append( addr );
173 } 177 }
174 } 178 }
175 179
176 return list; 180 return list;
177} 181}
178//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
179void ViewManager::setSelected() 183void ViewManager::setSelected()
180{ 184{
181 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
182} 186}
183 187
184void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
185{ 189{
186 if ( mActiveView ) 190 if ( mActiveView )
187 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
188} 192}
189 193
190void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
191{ 195{
192 int i, count = list.count(); 196 int i, count = list.count();
193 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
194 setSelected( list[i], true ); 198 setSelected( list[i], true );
195 199
196} 200}
197void ViewManager::unloadViews() 201void ViewManager::unloadViews()
198{ 202{
199 mViewDict.clear(); 203 mViewDict.clear();
200 mActiveView = 0; 204 mActiveView = 0;
201} 205}
202 206
203void ViewManager::setActiveView( const QString &name ) 207void ViewManager::setActiveView( const QString &name )
204{ 208{
205 KAddressBookView *view = 0; 209 KAddressBookView *view = 0;
206 210
207 // Check that this isn't the same as the current active view 211 // Check that this isn't the same as the current active view
208 if ( mActiveView && ( mActiveView->caption() == name ) ) 212 if ( mActiveView && ( mActiveView->caption() == name ) )
209 return; 213 return;
210 214
211 // At this point we know the view that should be active is not 215 // At this point we know the view that should be active is not
212 // currently active. We will try to find the new on in the list. If 216 // currently active. We will try to find the new on in the list. If
213 // we can't find it, it means it hasn't been instantiated, so we will 217 // we can't find it, it means it hasn't been instantiated, so we will
214 // create it on demand. 218 // create it on demand.
215 219
216 view = mViewDict.find( name ); 220 view = mViewDict.find( name );
217 221
218 // Check if we found the view. If we didn't, then we need to create it 222 // Check if we found the view. If we didn't, then we need to create it
219 if ( view == 0 ) { 223 if ( view == 0 ) {
220 KConfig *config = mCore->config(); 224 KConfig *config = mCore->config();
221 225
222 KConfigGroupSaver saver( config, name ); 226 KConfigGroupSaver saver( config, name );
223 227
224 QString type = config->readEntry( "Type", "Table" ); 228 QString type = config->readEntry( "Type", "Table" );
225 229
226 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
227 231
228 ViewFactory *factory = mViewFactoryDict.find( type ); 232 ViewFactory *factory = mViewFactoryDict.find( type );
229 if ( factory ) 233 if ( factory )
230 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 234 view = factory->view( mCore->addressBook(), mViewWidgetStack );
231 235
232 if ( view ) { 236 if ( view ) {
233 view->setCaption( name ); 237 view->setCaption( name );
234 mViewDict.insert( name, view ); 238 mViewDict.insert( name, view );
235//US my version needs an int as second parameter to addWidget 239//US my version needs an int as second parameter to addWidget
236 mViewWidgetStack->addWidget( view, -1 ); 240 mViewWidgetStack->addWidget( view, -1 );
237 view->readConfig( config ); 241 view->readConfig( config );
238 242
239 // The manager just relays the signals 243 // The manager just relays the signals
240 connect( view, SIGNAL( selected( const QString& ) ), 244 connect( view, SIGNAL( selected( const QString& ) ),
241 SIGNAL( selected( const QString & ) ) ); 245 SIGNAL( selected( const QString & ) ) );
242 connect( view, SIGNAL( executed( const QString& ) ), 246 connect( view, SIGNAL( executed( const QString& ) ),
243 SIGNAL( executed( const QString& ) ) ); 247 SIGNAL( executed( const QString& ) ) );
244 248
245 connect( view, SIGNAL( deleteRequest( ) ), 249 connect( view, SIGNAL( deleteRequest( ) ),
246 SIGNAL( deleteRequest( ) ) ); 250 SIGNAL( deleteRequest( ) ) );
247 251
248 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
249 connect( view, SIGNAL( dropped( QDropEvent* ) ), 253 connect( view, SIGNAL( dropped( QDropEvent* ) ),
250 SLOT( dropped( QDropEvent* ) ) ); 254 SLOT( dropped( QDropEvent* ) ) );
251 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
252 } 256 }
253 } 257 }
254 258
255 // 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
256 if ( view ) { 260 if ( view ) {
257 mActiveView = view; 261 mActiveView = view;
258 mViewWidgetStack->raiseWidget( view ); 262 mViewWidgetStack->raiseWidget( view );
259 // Set the proper filter in the view. By setting the combo 263 // Set the proper filter in the view. By setting the combo
260 // box, the activated slot will be called, which will push 264 // box, the activated slot will be called, which will push
261 // the filter to the view and refresh it. 265 // the filter to the view and refresh it.
262 266
263 if ( view->defaultFilterType() == KAddressBookView::None ) { 267 if ( view->defaultFilterType() == KAddressBookView::None ) {
264 268
265 mActionSelectFilter->setCurrentItem( 0 ); 269 mActionSelectFilter->setCurrentItem( 0 );
266 setActiveFilter( 0 ); 270 setActiveFilter( 0 );
267 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
268 setActiveFilter( mActionSelectFilter->currentItem() ); 272 setActiveFilter( mActionSelectFilter->currentItem() );
269 } else { 273 } else {
270 uint pos = filterPosition( view->defaultFilterName() ); 274 uint pos = filterPosition( view->defaultFilterName() );
271 mActionSelectFilter->setCurrentItem( pos ); 275 mActionSelectFilter->setCurrentItem( pos );
272 setActiveFilter( pos ); 276 setActiveFilter( pos );
273 } 277 }
274//US qDebug("ViewManager::setActiveView 6" ); 278//US qDebug("ViewManager::setActiveView 6" );
275 279
276 // 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
277 // view. 281 // view.
278 mCore->setSearchFields( mActiveView->fields() ); 282 mCore->setSearchFields( mActiveView->fields() );
279 283
280//US performance optimization. setActiveFilter calls also mActiveView->refresh() 284//US performance optimization. setActiveFilter calls also mActiveView->refresh()
281//US mActiveView->refresh(); 285//US mActiveView->refresh();
282 286
283 } 287 }
284 else 288 else
285 { 289 {
286 qDebug("ViewManager::setActiveView: unable to find view" ); 290 qDebug("ViewManager::setActiveView: unable to find view" );
287 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; 291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
288 } 292 }
289} 293}
290 294
291//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.
292void ViewManager::refreshView() 296void ViewManager::refreshView()
293{ 297{
294 refreshView( QString::null ); 298 refreshView( QString::null );
295} 299}
296 300
297void ViewManager::refreshView( const QString &uid ) 301void ViewManager::refreshView( const QString &uid )
298{ 302{
299 if ( mActiveView ) 303 if ( mActiveView )
300 mActiveView->refresh( uid ); 304 mActiveView->refresh( uid );
301} 305}
302 306
303void ViewManager::setFocusAV() 307void ViewManager::setFocusAV()
304{ 308{
305 if ( mActiveView ) 309 if ( mActiveView )
306 mActiveView->setFocusAV(); 310 mActiveView->setFocusAV();
307} 311}
308void ViewManager::editView() 312void ViewManager::editView()
309{ 313{
310 if ( !mActiveView ) 314 if ( !mActiveView )
311 return; 315 return;
312 316
313 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
314 ViewConfigureWidget *wdg = 0; 318 ViewConfigureWidget *wdg = 0;
315 ViewConfigureDialog* dlg = 0; 319 ViewConfigureDialog* dlg = 0;
316 if ( factory ) { 320 if ( factory ) {
317 // Save the filters so the dialog has the latest set 321 // Save the filters so the dialog has the latest set
318 Filter::save( mCore->config(), "Filter", mFilterList ); 322 Filter::save( mCore->config(), "Filter", mFilterList );
319 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
320 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
321 } else { 325 } else {
322 qDebug("ViewManager::editView()::cannot find viewfactory "); 326 qDebug("ViewManager::editView()::cannot find viewfactory ");
323 return; 327 return;
324 } 328 }
325 if ( wdg ) { 329 if ( wdg ) {
326 dlg->setWidget( wdg ); 330 dlg->setWidget( wdg );
327 331
328#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
329 //dlg.setMaximumSize( 640, 480 ); 333 //dlg.setMaximumSize( 640, 480 );
330 //dlg->setGeometry( 40,40, 400, 300); 334 //dlg->setGeometry( 40,40, 400, 300);
331 dlg->showMaximized(); 335 dlg->showMaximized();
332#endif 336#endif
333 337
334 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
335 339
336 dlg->restoreSettings( mCore->config() ); 340 dlg->restoreSettings( mCore->config() );
337 341
338 if ( dlg->exec() ) { 342 if ( dlg->exec() ) {
339 dlg->saveSettings( mCore->config() ); 343 dlg->saveSettings( mCore->config() );
340 mActiveView->readConfig( mCore->config() ); 344 mActiveView->readConfig( mCore->config() );
341 345
342 // Set the proper filter in the view. By setting the combo 346 // Set the proper filter in the view. By setting the combo
343 // box, the activated slot will be called, which will push 347 // box, the activated slot will be called, which will push
344 // the filter to the view and refresh it. 348 // the filter to the view and refresh it.
345 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
346 mActionSelectFilter->setCurrentItem( 0 ); 350 mActionSelectFilter->setCurrentItem( 0 );
347 setActiveFilter( 0 ); 351 setActiveFilter( 0 );
348 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
349 setActiveFilter( mActionSelectFilter->currentItem() ); 353 setActiveFilter( mActionSelectFilter->currentItem() );
350 } else { 354 } else {
351 uint pos = filterPosition( mActiveView->defaultFilterName() ); 355 uint pos = filterPosition( mActiveView->defaultFilterName() );
352 mActionSelectFilter->setCurrentItem( pos ); 356 mActionSelectFilter->setCurrentItem( pos );
353 setActiveFilter( pos ); 357 setActiveFilter( pos );
354 } 358 }
355 mCore->setSearchFields( mActiveView->fields() ); 359 mCore->setSearchFields( mActiveView->fields() );
356//US performance optimization. setActiveFilter calls also mActiveView->refresh() 360//US performance optimization. setActiveFilter calls also mActiveView->refresh()
357//US mActiveView->refresh(); 361//US mActiveView->refresh();
358 362
359 363
360 //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
361 emit modified(); 365 emit modified();
362 366
363 } 367 }
364 368
365 } 369 }
366 delete dlg; 370 delete dlg;
367} 371}
368 372
369void ViewManager::deleteView() 373void ViewManager::deleteView()
370{ 374{
371 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>" )
372 .arg( mActiveView->caption() ); 376 .arg( mActiveView->caption() );
373 QString caption = i18n( "Confirm Delete" ); 377 QString caption = i18n( "Confirm Delete" );
374 378
375 379
376 if (QMessageBox::information( this, caption, 380 if (QMessageBox::information( this, caption,
377 text, 381 text,
378 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 382 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
379 { 383 {
380 mViewNameList.remove( mActiveView->caption() ); 384 mViewNameList.remove( mActiveView->caption() );
381 385
382 // remove the view from the config file 386 // remove the view from the config file
383 KConfig *config = mCore->config(); 387 KConfig *config = mCore->config();
384 config->deleteGroup( mActiveView->caption() ); 388 config->deleteGroup( mActiveView->caption() );
385 389
386 mViewDict.remove( mActiveView->caption() ); 390 mViewDict.remove( mActiveView->caption() );
387 mActiveView = 0; 391 mActiveView = 0;
388 392
389 // 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
390 // we emit the signal 394 // we emit the signal
391 mActionSelectView->setItems( mViewNameList ); 395 mActionSelectView->setItems( mViewNameList );
392 if ( mViewNameList.count() > 0 ) { 396 if ( mViewNameList.count() > 0 ) {
393 mActionSelectView->setCurrentItem( 0 ); 397 mActionSelectView->setCurrentItem( 0 );
394 setActiveView( mViewNameList[ 0 ] ); 398 setActiveView( mViewNameList[ 0 ] );
395 } 399 }
396 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 400 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
397 } 401 }
398} 402}
399 403
400void ViewManager::addView() 404void ViewManager::addView()
401{ 405{
402 AddViewDialog dialog( &mViewFactoryDict, this ); 406 AddViewDialog dialog( &mViewFactoryDict, this );
403 407
404 if ( dialog.exec() ) { 408 if ( dialog.exec() ) {
405 QString newName = dialog.viewName(); 409 QString newName = dialog.viewName();
406 QString type = dialog.viewType(); 410 QString type = dialog.viewType();
407 411
408 // Check for name conflicts 412 // Check for name conflicts
409 bool firstConflict = true; 413 bool firstConflict = true;
410 int numTries = 1; 414 int numTries = 1;
411 while ( mViewNameList.contains( newName ) > 0 ) { 415 while ( mViewNameList.contains( newName ) > 0 ) {
412 if ( !firstConflict ) { 416 if ( !firstConflict ) {
413 newName = newName.left( newName.length() - 4 ); 417 newName = newName.left( newName.length() - 4 );
414 firstConflict = false; 418 firstConflict = false;
415 } 419 }
416 420
417 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 421 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
418 numTries++; 422 numTries++;
419 } 423 }
420 424
421 // Add the new one to the list 425 // Add the new one to the list
422 mViewNameList.append( newName ); 426 mViewNameList.append( newName );
423 427
424 // write the view to the config file, 428 // write the view to the config file,
425 KConfig *config = mCore->config(); 429 KConfig *config = mCore->config();
426 430
427 config->deleteGroup( newName ); 431 config->deleteGroup( newName );
428 432
429 KConfigGroupSaver saver( config, newName ); 433 KConfigGroupSaver saver( config, newName );
430 434
431 config->writeEntry( "Type", type ); 435 config->writeEntry( "Type", type );
432 436
433 // try to set the active view 437 // try to set the active view
434 mActionSelectView->setItems( mViewNameList ); 438 mActionSelectView->setItems( mViewNameList );
435 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 439 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
436 setActiveView( newName ); 440 setActiveView( newName );
437 441
438 editView(); 442 editView();
439 443
440 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 444 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
441 } 445 }
442} 446}
443 447
444void ViewManager::createViewFactories() 448void ViewManager::createViewFactories()
445{ 449{
446#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
447 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 451 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
448 KTrader::OfferList::ConstIterator it; 452 KTrader::OfferList::ConstIterator it;
449 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 453 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
450 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 454 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
451 continue; 455 continue;
452 456
453 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 457 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
454 458
455 if ( !factory ) { 459 if ( !factory ) {
456 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 460 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
457 continue; 461 continue;
458 } 462 }
459 463
460 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 464 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
461 465
462 if ( !viewFactory ) { 466 if ( !viewFactory ) {
463 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 467 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
464 continue; 468 continue;
465 } 469 }
466 470
467 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 471 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
468 } 472 }
469 473
470#else //KAB_EMBEDDED 474#else //KAB_EMBEDDED
471 ViewFactory* viewFactory = new IconViewFactory(); 475 ViewFactory* viewFactory = new IconViewFactory();
472 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 476 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
473// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
474 478
475 viewFactory = new TableViewFactory(); 479 viewFactory = new TableViewFactory();
476 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 480 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
478 482
479 viewFactory = new CardViewFactory(); 483 viewFactory = new CardViewFactory();
480 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 484 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 485// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
482 486
483#endif //KAB_EMBEDDED 487#endif //KAB_EMBEDDED
484 488
485} 489}
486 490
487void ViewManager::dropped( QDropEvent *e ) 491void ViewManager::dropped( QDropEvent *e )
488{ 492{
489 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 493 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
490 494
491#ifndef KAB_EMBEDDED 495#ifndef KAB_EMBEDDED
492 496
493 QString clipText, vcards; 497 QString clipText, vcards;
494 KURL::List urls; 498 KURL::List urls;
495 499
496 if ( KURLDrag::decode( e, urls) ) { 500 if ( KURLDrag::decode( e, urls) ) {
497 KURL::List::Iterator it = urls.begin(); 501 KURL::List::Iterator it = urls.begin();
498 int c = urls.count(); 502 int c = urls.count();
499 if ( c > 1 ) { 503 if ( c > 1 ) {
500 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 );
501 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 505 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
502 for ( ; it != urls.end(); ++it ) 506 for ( ; it != urls.end(); ++it )
503 emit urlDropped( *it ); 507 emit urlDropped( *it );
504 } 508 }
505 } else if ( c == 1 ) 509 } else if ( c == 1 )
506 emit urlDropped( *it ); 510 emit urlDropped( *it );
507 } else if ( KVCardDrag::decode( e, vcards ) ) { 511 } else if ( KVCardDrag::decode( e, vcards ) ) {
508 KABC::Addressee addr; 512 KABC::Addressee addr;
509 KABC::VCardConverter converter; 513 KABC::VCardConverter converter;
510 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 514 QStringList list = QStringList::split( "\r\n\r\n", vcards );
511 QStringList::Iterator it; 515 QStringList::Iterator it;
512 for ( it = list.begin(); it != list.end(); ++it ) { 516 for ( it = list.begin(); it != list.end(); ++it ) {
513 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 517 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
514 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 518 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
515 if ( a.isEmpty() ) { 519 if ( a.isEmpty() ) {
516 mCore->addressBook()->insertAddressee( addr ); 520 mCore->addressBook()->insertAddressee( addr );
517 emit modified(); 521 emit modified();
518 } 522 }
519 } 523 }
520 } 524 }
521 525
522 mActiveView->refresh(); 526 mActiveView->refresh();
523 } 527 }
524#else //KAB_EMBEDDED 528#else //KAB_EMBEDDED
525qDebug("ViewManager::dropped() has to be changed!!" ); 529qDebug("ViewManager::dropped() has to be changed!!" );
526#endif //KAB_EMBEDDED 530#endif //KAB_EMBEDDED
527 531
528} 532}
529 533
530void ViewManager::startDrag() 534void ViewManager::startDrag()
531{ 535{
532 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 536 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
533 537
534#ifndef KAB_EMBEDDED 538#ifndef KAB_EMBEDDED
535 539
536 // Get the list of all the selected addressees 540 // Get the list of all the selected addressees
537 KABC::Addressee::List addrList; 541 KABC::Addressee::List addrList;
538 QStringList uidList = selectedUids(); 542 QStringList uidList = selectedUids();
539 QStringList::Iterator iter; 543 QStringList::Iterator iter;
540 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 544 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
541 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 545 addrList.append( mCore->addressBook()->findByUid( *iter ) );
542 546
543 KMultipleDrag *drag = new KMultipleDrag( this ); 547 KMultipleDrag *drag = new KMultipleDrag( this );
544 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 548 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
545 KABC::Addressee::List::Iterator it; 549 KABC::Addressee::List::Iterator it;
546 QStringList vcards; 550 QStringList vcards;
547 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 551 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
548 QString vcard = QString::null; 552 QString vcard = QString::null;
549 KABC::VCardConverter converter; 553 KABC::VCardConverter converter;
550 if ( converter.addresseeToVCard( *it, vcard ) ) 554 if ( converter.addresseeToVCard( *it, vcard ) )
551 vcards.append( vcard ); 555 vcards.append( vcard );
552 } 556 }
553 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 557 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
554 558
555 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 559 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
556 drag->dragCopy(); 560 drag->dragCopy();
557 561
558#else //KAB_EMBEDDED 562#else //KAB_EMBEDDED
559qDebug("ViewManager::startDrag() has to be changed!!" ); 563qDebug("ViewManager::startDrag() has to be changed!!" );
560#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
561 565
562} 566}
563void ViewManager::doSearch( const QString& s,KABC::Field *field ) 567void ViewManager::doSearch( const QString& s,KABC::Field *field )
564{ 568{
565 if ( mActiveView ) 569 if ( mActiveView )
566 mActiveView->doSearch( s, field ); 570 mActiveView->doSearch( s, field );
567 571
568} 572}
569void ViewManager::setActiveFilter( int index ) 573void ViewManager::setActiveFilter( int index )
570{ 574{
571 Filter currentFilter; 575 Filter currentFilter;
572 576
573 if ( ( index - 1 ) < 0 ) 577 if ( ( index - 1 ) < 0 )
574 currentFilter = Filter(); 578 currentFilter = Filter();
575 else 579 else
576 currentFilter = mFilterList[ index - 1 ]; 580 currentFilter = mFilterList[ index - 1 ];
577 581
578 // 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
579 // 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.
580 if ( mActiveView ) { 584 if ( mActiveView ) {
581 mActiveView->setFilter( currentFilter ); 585 mActiveView->setFilter( currentFilter );
582 mActiveView->refresh(); 586 mActiveView->refresh();
583 emit selected( QString::null ); 587 emit selected( QString::null );
584 } 588 }
585} 589}
586 590
587void ViewManager::configureFilters() 591void ViewManager::configureFilters()
588{ 592{
589 FilterDialog dlg( this ); 593 FilterDialog dlg( this );
590 594
591 dlg.setFilters( mFilterList ); 595 dlg.setFilters( mFilterList );
592 596
593 if ( dlg.exec() ) 597 if ( dlg.exec() )
594 mFilterList = dlg.filters(); 598 mFilterList = dlg.filters();
595 599
596 uint pos = mActionSelectFilter->currentItem(); 600 uint pos = mActionSelectFilter->currentItem();
597 mActionSelectFilter->setItems( filterNames() ); 601 mActionSelectFilter->setItems( filterNames() );
598 mActionSelectFilter->setCurrentItem( pos ); 602 mActionSelectFilter->setCurrentItem( pos );
599 setActiveFilter( pos ); 603 setActiveFilter( pos );
600 mActionSelectFilter->setComboWidth( 150 ); 604 int cw = 150;
605 if (QApplication::desktop()->width() == 480 )
606 cw = 0;
607 mActionSelectFilter->setComboWidth( cw );
601} 608}
602 609
603QStringList ViewManager::filterNames() const 610QStringList ViewManager::filterNames() const
604{ 611{
605 QStringList names( i18n( "No Filter" ) ); 612 QStringList names( i18n( "No Filter" ) );
606 613
607 Filter::List::ConstIterator it; 614 Filter::List::ConstIterator it;
608 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 615 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
609 names.append( (*it).name() ); 616 names.append( (*it).name() );
610 617
611 return names; 618 return names;
612} 619}
613 620
614int ViewManager::filterPosition( const QString &name ) const 621int ViewManager::filterPosition( const QString &name ) const
615{ 622{
616 int pos = 0; 623 int pos = 0;
617 624
618 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
619 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
620 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
621 return pos + 1; 628 return pos + 1;
622 629
623 return 0; 630 return 0;
624} 631}
625 632
626void ViewManager::initActions() 633void ViewManager::initActions()
627{ 634{
628//US <ActionList name="view_loadedviews"/> 635//US <ActionList name="view_loadedviews"/>
629//US <Separator/> 636//US <Separator/>
630 637
631#ifdef KAB_EMBEDDED 638#ifdef KAB_EMBEDDED
632 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 639 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
633 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 640 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
634 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 641 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
635#endif //KAB_EMBEDDED 642#endif //KAB_EMBEDDED
636 643
637 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 644 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
638#if KDE_VERSION >= 309 645#if KDE_VERSION >= 309
639 mActionSelectView->setMenuAccelsEnabled( false ); 646 mActionSelectView->setMenuAccelsEnabled( false );
640#endif 647#endif
641 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 648 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
642 SLOT( setActiveView( const QString& ) ) ); 649 SLOT( setActiveView( const QString& ) ) );
643 650
644 651
645#ifdef KAB_EMBEDDED 652#ifdef KAB_EMBEDDED
646 mActionSelectView->plug(viewmenu); 653 mActionSelectView->plug(viewmenu);
647 viewmenu->insertSeparator(); 654 viewmenu->insertSeparator();
648#endif //KAB_EMBEDDED 655#endif //KAB_EMBEDDED
649 656
650 KAction *action; 657 KAction *action;
651 658
652 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 659 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
653 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 660 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
654#ifndef KAB_EMBEDDED 661#ifndef KAB_EMBEDDED
655 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." ) ); 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." ) );
656#else //KAB_EMBEDDED 663#else //KAB_EMBEDDED
657 action->plug(viewmenu); 664 action->plug(viewmenu);
658#endif //KAB_EMBEDDED 665#endif //KAB_EMBEDDED
659 666
660 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 667 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
661 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 668 SLOT( addView() ), mCore->actionCollection(), "view_add" );
662#ifndef KAB_EMBEDDED 669#ifndef KAB_EMBEDDED
663 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." ) ); 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." ) );
664#else //KAB_EMBEDDED 671#else //KAB_EMBEDDED
665 action->plug(viewmenu); 672 action->plug(viewmenu);
666#endif //KAB_EMBEDDED 673#endif //KAB_EMBEDDED
667 674
668 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 675 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
669 this, SLOT( deleteView() ), 676 this, SLOT( deleteView() ),
670 mCore->actionCollection(), "view_delete" ); 677 mCore->actionCollection(), "view_delete" );
671#ifndef KAB_EMBEDDED 678#ifndef KAB_EMBEDDED
672 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 679 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
673#else //KAB_EMBEDDED 680#else //KAB_EMBEDDED
674 mActionDeleteView->plug(viewmenu); 681 mActionDeleteView->plug(viewmenu);
675 viewmenu->insertSeparator(); 682 viewmenu->insertSeparator();
676#endif //KAB_EMBEDDED 683#endif //KAB_EMBEDDED
677 684
678#ifndef KAB_EMBEDDED 685#ifndef KAB_EMBEDDED
679 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 686 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
680 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 687 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
681 "view_refresh" ); 688 "view_refresh" );
682 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 689 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
683#else //KAB_EMBEDDED 690#else //KAB_EMBEDDED
684 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 691 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
685 SLOT( refreshView()), mCore->actionCollection(), 692 SLOT( refreshView()), mCore->actionCollection(),
686 "view_refresh" ); 693 "view_refresh" );
687 action->plug(viewmenu); 694 action->plug(viewmenu);
688 viewmenu->insertSeparator(); 695 viewmenu->insertSeparator();
689#endif //KAB_EMBEDDED 696#endif //KAB_EMBEDDED
690 697
691 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 698 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
692 SLOT( configureFilters() ), mCore->actionCollection(), 699 SLOT( configureFilters() ), mCore->actionCollection(),
693 "options_edit_filters" ); 700 "options_edit_filters" );
694 701
695 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 702 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
696#if KDE_VERSION >= 309 703#if KDE_VERSION >= 309
697 mActionSelectFilter->setMenuAccelsEnabled( false ); 704 mActionSelectFilter->setMenuAccelsEnabled( false );
698#endif 705#endif
699 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 706 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
700 SLOT( setActiveFilter( int ) ) ); 707 SLOT( setActiveFilter( int ) ) );
701 708
702#ifdef KAB_EMBEDDED 709#ifdef KAB_EMBEDDED
703 action->plug(settingsmenu); 710 action->plug(settingsmenu);
704 mActionSelectFilter->plug(viewmenu); 711 mActionSelectFilter->plug(viewmenu);
705#endif //KAB_EMBEDDED 712#endif //KAB_EMBEDDED
706 713
707} 714}
708 715
709void ViewManager::initGUI() 716void ViewManager::initGUI()
710{ 717{
711 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 718 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
712 mViewWidgetStack = new QWidgetStack( this ); 719 mViewWidgetStack = new QWidgetStack( this );
713 layout->addWidget( mViewWidgetStack ); 720 layout->addWidget( mViewWidgetStack );
714} 721}
715 722
716#ifndef KAB_EMBEDDED 723#ifndef KAB_EMBEDDED
717#include "viewmanager.moc" 724#include "viewmanager.moc"
718#endif //KAB_EMBEDDED 725#endif //KAB_EMBEDDED
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp
index 04afe7c..19093b1 100644
--- a/kmicromail/libmailwrapper/settings.cpp
+++ b/kmicromail/libmailwrapper/settings.cpp
@@ -1,501 +1,501 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <qdir.h> 2#include <qdir.h>
3 3
4//#include <opie2/odebug.h> 4//#include <opie2/odebug.h>
5#include <kconfig.h> 5#include <kconfig.h>
6 6
7#include <kstandarddirs.h> 7#include <kstandarddirs.h>
8#include "settings.h" 8#include "settings.h"
9//#include "defines.h" 9//#include "defines.h"
10 10
11#define IMAP_PORT "143" 11#define IMAP_PORT "143"
12#define IMAP_SSL_PORT "993" 12#define IMAP_SSL_PORT "993"
13#define SMTP_PORT "25" 13#define SMTP_PORT "25"
14#define SMTP_SSL_PORT "465" 14#define SMTP_SSL_PORT "465"
15#define POP3_PORT "110" 15#define POP3_PORT "110"
16#define POP3_SSL_PORT "995" 16#define POP3_SSL_PORT "995"
17#define NNTP_PORT "119" 17#define NNTP_PORT "119"
18#define NNTP_SSL_PORT "563" 18#define NNTP_SSL_PORT "563"
19 19
20 20
21Settings::Settings() 21Settings::Settings()
22 : QObject() 22 : QObject()
23{ 23{
24 accounts.setAutoDelete( true ); ; 24 accounts.setAutoDelete( true ); ;
25 updateAccounts(); 25 updateAccounts();
26 //qDebug("++++++++++++++++++new settings "); 26 //qDebug("++++++++++++++++++new settings ");
27} 27}
28 28
29void Settings::checkDirectory() 29void Settings::checkDirectory()
30{ 30{
31 return; 31 return;
32 locateLocal("data", "kopiemail" ); 32 locateLocal("data", "kopiemail" );
33 /* 33 /*
34 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 34 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
35 system( "mkdir -p $HOME/Applications/opiemail" ); 35 system( "mkdir -p $HOME/Applications/opiemail" );
36 qDebug("$HOME/Applications/opiemail created "); 36 qDebug("$HOME/Applications/opiemail created ");
37 } 37 }
38 */ 38 */
39} 39}
40 40
41QList<Account> Settings::getAccounts() 41QList<Account> Settings::getAccounts()
42{ 42{
43 return accounts; 43 return accounts;
44} 44}
45 45
46void Settings::addAccount( Account *account ) 46void Settings::addAccount( Account *account )
47{ 47{
48 accounts.append( account ); 48 accounts.append( account );
49} 49}
50 50
51void Settings::delAccount( Account *account ) 51void Settings::delAccount( Account *account )
52{ 52{
53 accounts.remove( account );
54 account->remove(); 53 account->remove();
54 accounts.remove( account );
55} 55}
56 56
57void Settings::updateAccounts() 57void Settings::updateAccounts()
58{ 58{
59 accounts.clear(); 59 accounts.clear();
60 QDir dir( locateLocal("data", "kopiemail" ) ); 60 QDir dir( locateLocal("data", "kopiemail" ) );
61 QStringList::Iterator it; 61 QStringList::Iterator it;
62 62
63 QStringList imap = dir.entryList( "imap-*" ); 63 QStringList imap = dir.entryList( "imap-*" );
64 for ( it = imap.begin(); it != imap.end(); it++ ) { 64 for ( it = imap.begin(); it != imap.end(); it++ ) {
65 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 65 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
66 accounts.append( account ); 66 accounts.append( account );
67 } 67 }
68 68
69 QStringList pop3 = dir.entryList( "pop3-*" ); 69 QStringList pop3 = dir.entryList( "pop3-*" );
70 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 70 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
71 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 71 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
72 accounts.append( account ); 72 accounts.append( account );
73 } 73 }
74 74
75 QStringList smtp = dir.entryList( "smtp-*" ); 75 QStringList smtp = dir.entryList( "smtp-*" );
76 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 76 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
77 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 77 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
78 accounts.append( account ); 78 accounts.append( account );
79 } 79 }
80 80
81 QStringList nntp = dir.entryList( "nntp-*" ); 81 QStringList nntp = dir.entryList( "nntp-*" );
82 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 82 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
83 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 83 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
84 accounts.append( account ); 84 accounts.append( account );
85 } 85 }
86 86
87 readAccounts(); 87 readAccounts();
88} 88}
89 89
90void Settings::saveAccounts() 90void Settings::saveAccounts()
91{ 91{
92 checkDirectory(); 92 checkDirectory();
93 Account *it; 93 Account *it;
94 94
95 for ( it = accounts.first(); it; it = accounts.next() ) { 95 for ( it = accounts.first(); it; it = accounts.next() ) {
96 it->save(); 96 it->save();
97 } 97 }
98} 98}
99 99
100void Settings::readAccounts() 100void Settings::readAccounts()
101{ 101{
102 checkDirectory(); 102 checkDirectory();
103 Account *it; 103 Account *it;
104 104
105 for ( it = accounts.first(); it; it = accounts.next() ) { 105 for ( it = accounts.first(); it; it = accounts.next() ) {
106 it->read(); 106 it->read();
107 } 107 }
108} 108}
109 109
110Account::Account() 110Account::Account()
111{ 111{
112 accountName = "changeMe"; 112 accountName = "changeMe";
113 type = MAILLIB::A_UNDEFINED; 113 type = MAILLIB::A_UNDEFINED;
114 ssl = false; 114 ssl = false;
115 connectionType = 1; 115 connectionType = 1;
116 offline = false; 116 offline = false;
117 maxMailSize = 0; 117 maxMailSize = 0;
118 lastFetch; 118 lastFetch;
119 leaveOnServer = false; 119 leaveOnServer = false;
120} 120}
121 121
122void Account::remove() 122void Account::remove()
123{ 123{
124 QFile file( getFileName() ); 124 QFile file( getFileName() );
125 file.remove(); 125 file.remove();
126} 126}
127 127
128void Account::setPasswordList(const QStringList &str) 128void Account::setPasswordList(const QStringList &str)
129{ 129{
130 password = ""; 130 password = "";
131 int i; 131 int i;
132 for ( i = 0; i < str.count() ; ++i ) { 132 for ( i = 0; i < str.count() ; ++i ) {
133 QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); 133 QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3)));
134 password.append( c ); 134 password.append( c );
135 } 135 }
136 //qDebug("password %s ", password.latin1()); 136 //qDebug("password %s ", password.latin1());
137} 137}
138QStringList Account::getPasswordList() 138QStringList Account::getPasswordList()
139{ 139{
140 int i; 140 int i;
141 int len = password.length(); 141 int len = password.length();
142 QStringList str; 142 QStringList str;
143 143
144 for ( i = 0; i < len ; ++i ) { 144 for ( i = 0; i < len ; ++i ) {
145 int val = password.at(i).unicode()*(len-(i%3))+131; 145 int val = password.at(i).unicode()*(len-(i%3))+131;
146 str.append( QString::number( val ) ); 146 str.append( QString::number( val ) );
147 // qDebug("append %s ", str[i].latin1()); 147 // qDebug("append %s ", str[i].latin1());
148 } 148 }
149 return str; 149 return str;
150} 150}
151 151
152IMAPaccount::IMAPaccount() 152IMAPaccount::IMAPaccount()
153 : Account() 153 : Account()
154{ 154{
155 file = IMAPaccount::getUniqueFileName(); 155 file = IMAPaccount::getUniqueFileName();
156 accountName = "New IMAP Account"; 156 accountName = "New IMAP Account";
157 ssl = false; 157 ssl = false;
158 connectionType = 1; 158 connectionType = 1;
159 type = MAILLIB::A_IMAP; 159 type = MAILLIB::A_IMAP;
160 port = IMAP_PORT; 160 port = IMAP_PORT;
161} 161}
162 162
163IMAPaccount::IMAPaccount( QString filename ) 163IMAPaccount::IMAPaccount( QString filename )
164 : Account() 164 : Account()
165{ 165{
166 file = filename; 166 file = filename;
167 accountName = "New IMAP Account"; 167 accountName = "New IMAP Account";
168 ssl = false; 168 ssl = false;
169 connectionType = 1; 169 connectionType = 1;
170 type = MAILLIB::A_IMAP; 170 type = MAILLIB::A_IMAP;
171 port = IMAP_PORT; 171 port = IMAP_PORT;
172} 172}
173 173
174QString IMAPaccount::getUniqueFileName() 174QString IMAPaccount::getUniqueFileName()
175{ 175{
176 int num = 0; 176 int num = 0;
177 QString unique; 177 QString unique;
178 178
179 QDir dir( locateLocal("data", "kopiemail" ) ); 179 QDir dir( locateLocal("data", "kopiemail" ) );
180 180
181 QStringList imap = dir.entryList( "imap-*" ); 181 QStringList imap = dir.entryList( "imap-*" );
182 do { 182 do {
183 unique.setNum( num++ ); 183 unique.setNum( num++ );
184 } while ( imap.contains( "imap-" + unique ) > 0 ); 184 } while ( imap.contains( "imap-" + unique ) > 0 );
185 185
186 return unique; 186 return unique;
187} 187}
188 188
189void IMAPaccount::read() 189void IMAPaccount::read()
190{ 190{
191 KConfig *conf = new KConfig( getFileName() ); 191 KConfig *conf = new KConfig( getFileName() );
192 conf->setGroup( "IMAP Account" ); 192 conf->setGroup( "IMAP Account" );
193 accountName = conf->readEntry( "Account","" ); 193 accountName = conf->readEntry( "Account","" );
194 if (accountName.isNull()) accountName = ""; 194 if (accountName.isNull()) accountName = "";
195 server = conf->readEntry( "Server","" ); 195 server = conf->readEntry( "Server","" );
196 if (server.isNull()) server=""; 196 if (server.isNull()) server="";
197 port = conf->readEntry( "Port","" ); 197 port = conf->readEntry( "Port","" );
198 if (port.isNull()) port="143"; 198 if (port.isNull()) port="143";
199 connectionType = conf->readNumEntry( "ConnectionType" ); 199 connectionType = conf->readNumEntry( "ConnectionType" );
200 ssl = conf->readBoolEntry( "SSL",false ); 200 ssl = conf->readBoolEntry( "SSL",false );
201 user = conf->readEntry( "User","" ); 201 user = conf->readEntry( "User","" );
202 if (user.isNull()) user = ""; 202 if (user.isNull()) user = "";
203 //password = conf->readEntryCrypt( "Password","" ); 203 //password = conf->readEntryCrypt( "Password","" );
204 setPasswordList( conf->readListEntry( "FolderHistory")); 204 setPasswordList( conf->readListEntry( "FolderHistory"));
205 if (password.isNull()) password = ""; 205 if (password.isNull()) password = "";
206 prefix = conf->readEntry("MailPrefix",""); 206 prefix = conf->readEntry("MailPrefix","");
207 if (prefix.isNull()) prefix = ""; 207 if (prefix.isNull()) prefix = "";
208 offline = conf->readBoolEntry("Offline",false); 208 offline = conf->readBoolEntry("Offline",false);
209 localFolder = conf->readEntry( "LocalFolder" ); 209 localFolder = conf->readEntry( "LocalFolder" );
210 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 210 maxMailSize = conf->readNumEntry( "MaxSize",0 );
211 int lf = conf->readNumEntry( "LastFetch",0 ); 211 int lf = conf->readNumEntry( "LastFetch",0 );
212 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 212 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
213 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 213 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
214 if ( lf < 0 ) lf = 0; 214 if ( lf < 0 ) lf = 0;
215 lastFetch = dt.addSecs( lf ); 215 lastFetch = dt.addSecs( lf );
216 delete conf; 216 delete conf;
217} 217}
218 218
219void IMAPaccount::save() 219void IMAPaccount::save()
220{ 220{
221 221
222 Settings::checkDirectory(); 222 Settings::checkDirectory();
223 223
224 KConfig *conf = new KConfig( getFileName() ); 224 KConfig *conf = new KConfig( getFileName() );
225 conf->setGroup( "IMAP Account" ); 225 conf->setGroup( "IMAP Account" );
226 conf->writeEntry( "Account", accountName ); 226 conf->writeEntry( "Account", accountName );
227 conf->writeEntry( "Server", server ); 227 conf->writeEntry( "Server", server );
228 conf->writeEntry( "Port", port ); 228 conf->writeEntry( "Port", port );
229 conf->writeEntry( "SSL", ssl ); 229 conf->writeEntry( "SSL", ssl );
230 conf->writeEntry( "ConnectionType", connectionType ); 230 conf->writeEntry( "ConnectionType", connectionType );
231 conf->writeEntry( "User", user ); 231 conf->writeEntry( "User", user );
232 //conf->writeEntryCrypt( "Password", password ); 232 //conf->writeEntryCrypt( "Password", password );
233 conf->writeEntry( "FolderHistory",getPasswordList() ); 233 conf->writeEntry( "FolderHistory",getPasswordList() );
234 conf->writeEntry( "MailPrefix",prefix); 234 conf->writeEntry( "MailPrefix",prefix);
235 conf->writeEntry( "Offline",offline); 235 conf->writeEntry( "Offline",offline);
236 conf->writeEntry( "LocalFolder", localFolder ); 236 conf->writeEntry( "LocalFolder", localFolder );
237 conf->writeEntry( "MaxSize", maxMailSize ); 237 conf->writeEntry( "MaxSize", maxMailSize );
238 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 238 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
239 int lf = dt.secsTo ( lastFetch ); 239 int lf = dt.secsTo ( lastFetch );
240 conf->writeEntry( "LastFetch", lf ); 240 conf->writeEntry( "LastFetch", lf );
241 conf->writeEntry( "LeaveOnServer", leaveOnServer); 241 conf->writeEntry( "LeaveOnServer", leaveOnServer);
242 conf->sync(); 242 conf->sync();
243 delete conf; 243 delete conf;
244} 244}
245 245
246 246
247QString IMAPaccount::getFileName() 247QString IMAPaccount::getFileName()
248{ 248{
249 return locateLocal("data", "kopiemail" ) +"/imap-" + file; 249 return locateLocal("data", "kopiemail" ) +"/imap-" + file;
250} 250}
251 251
252POP3account::POP3account() 252POP3account::POP3account()
253 : Account() 253 : Account()
254{ 254{
255 file = POP3account::getUniqueFileName(); 255 file = POP3account::getUniqueFileName();
256 accountName = "New POP3 Account"; 256 accountName = "New POP3 Account";
257 ssl = false; 257 ssl = false;
258 connectionType = 1; 258 connectionType = 1;
259 type = MAILLIB::A_POP3; 259 type = MAILLIB::A_POP3;
260 port = POP3_PORT; 260 port = POP3_PORT;
261} 261}
262 262
263POP3account::POP3account( QString filename ) 263POP3account::POP3account( QString filename )
264 : Account() 264 : Account()
265{ 265{
266 file = filename; 266 file = filename;
267 accountName = "New POP3 Account"; 267 accountName = "New POP3 Account";
268 ssl = false; 268 ssl = false;
269 connectionType = 1; 269 connectionType = 1;
270 type = MAILLIB::A_POP3; 270 type = MAILLIB::A_POP3;
271 port = POP3_PORT; 271 port = POP3_PORT;
272} 272}
273 273
274QString POP3account::getUniqueFileName() 274QString POP3account::getUniqueFileName()
275{ 275{
276 int num = 0; 276 int num = 0;
277 QString unique; 277 QString unique;
278 278
279 QDir dir( locateLocal("data", "kopiemail" ) ); 279 QDir dir( locateLocal("data", "kopiemail" ) );
280 280
281 QStringList imap = dir.entryList( "pop3-*" ); 281 QStringList imap = dir.entryList( "pop3-*" );
282 do { 282 do {
283 unique.setNum( num++ ); 283 unique.setNum( num++ );
284 } while ( imap.contains( "pop3-" + unique ) > 0 ); 284 } while ( imap.contains( "pop3-" + unique ) > 0 );
285 285
286 return unique; 286 return unique;
287} 287}
288 288
289void POP3account::read() 289void POP3account::read()
290{ 290{
291 KConfig *conf = new KConfig( getFileName()); 291 KConfig *conf = new KConfig( getFileName());
292 conf->setGroup( "POP3 Account" ); 292 conf->setGroup( "POP3 Account" );
293 accountName = conf->readEntry( "Account" ); 293 accountName = conf->readEntry( "Account" );
294 server = conf->readEntry( "Server" ); 294 server = conf->readEntry( "Server" );
295 port = conf->readEntry( "Port" ); 295 port = conf->readEntry( "Port" );
296 ssl = conf->readBoolEntry( "SSL" ); 296 ssl = conf->readBoolEntry( "SSL" );
297 connectionType = conf->readNumEntry( "ConnectionType" ); 297 connectionType = conf->readNumEntry( "ConnectionType" );
298 user = conf->readEntry( "User" ); 298 user = conf->readEntry( "User" );
299 //password = conf->readEntryCrypt( "Password" ); 299 //password = conf->readEntryCrypt( "Password" );
300 setPasswordList( conf->readListEntry( "FolderHistory")); 300 setPasswordList( conf->readListEntry( "FolderHistory"));
301 offline = conf->readBoolEntry("Offline",false); 301 offline = conf->readBoolEntry("Offline",false);
302 localFolder = conf->readEntry( "LocalFolder" ); 302 localFolder = conf->readEntry( "LocalFolder" );
303 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 303 maxMailSize = conf->readNumEntry( "MaxSize",0 );
304 int lf = conf->readNumEntry( "LastFetch",0 ); 304 int lf = conf->readNumEntry( "LastFetch",0 );
305 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 305 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
306 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 306 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
307 lastFetch = dt.addSecs( lf ); 307 lastFetch = dt.addSecs( lf );
308 delete conf; 308 delete conf;
309} 309}
310 310
311void POP3account::save() 311void POP3account::save()
312{ 312{
313 Settings::checkDirectory(); 313 Settings::checkDirectory();
314 314
315 KConfig *conf = new KConfig( getFileName() ); 315 KConfig *conf = new KConfig( getFileName() );
316 conf->setGroup( "POP3 Account" ); 316 conf->setGroup( "POP3 Account" );
317 conf->writeEntry( "Account", accountName ); 317 conf->writeEntry( "Account", accountName );
318 conf->writeEntry( "Server", server ); 318 conf->writeEntry( "Server", server );
319 conf->writeEntry( "Port", port ); 319 conf->writeEntry( "Port", port );
320 conf->writeEntry( "SSL", ssl ); 320 conf->writeEntry( "SSL", ssl );
321 conf->writeEntry( "ConnectionType", connectionType ); 321 conf->writeEntry( "ConnectionType", connectionType );
322 conf->writeEntry( "User", user ); 322 conf->writeEntry( "User", user );
323 //conf->writeEntryCrypt( "Password", password ); 323 //conf->writeEntryCrypt( "Password", password );
324 conf->writeEntry( "FolderHistory",getPasswordList() ); 324 conf->writeEntry( "FolderHistory",getPasswordList() );
325 conf->writeEntry( "Offline",offline); 325 conf->writeEntry( "Offline",offline);
326 conf->writeEntry( "LocalFolder", localFolder ); 326 conf->writeEntry( "LocalFolder", localFolder );
327 conf->writeEntry( "MaxSize", maxMailSize ); 327 conf->writeEntry( "MaxSize", maxMailSize );
328 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 328 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
329 int lf = dt.secsTo ( lastFetch ); 329 int lf = dt.secsTo ( lastFetch );
330 conf->writeEntry( "LastFetch", lf ); 330 conf->writeEntry( "LastFetch", lf );
331 conf->writeEntry( "LeaveOnServer", leaveOnServer); 331 conf->writeEntry( "LeaveOnServer", leaveOnServer);
332 conf->sync(); 332 conf->sync();
333 delete conf; 333 delete conf;
334} 334}
335 335
336 336
337QString POP3account::getFileName() 337QString POP3account::getFileName()
338{ 338{
339 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 339 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
340} 340}
341 341
342SMTPaccount::SMTPaccount() 342SMTPaccount::SMTPaccount()
343 : Account() 343 : Account()
344{ 344{
345 file = SMTPaccount::getUniqueFileName(); 345 file = SMTPaccount::getUniqueFileName();
346 accountName = "New SMTP Account"; 346 accountName = "New SMTP Account";
347 ssl = false; 347 ssl = false;
348 connectionType = 1; 348 connectionType = 1;
349 login = false; 349 login = false;
350 useCC = false; 350 useCC = false;
351 useBCC = false; 351 useBCC = false;
352 useReply = false; 352 useReply = false;
353 type = MAILLIB::A_SMTP; 353 type = MAILLIB::A_SMTP;
354 port = SMTP_PORT; 354 port = SMTP_PORT;
355} 355}
356 356
357SMTPaccount::SMTPaccount( QString filename ) 357SMTPaccount::SMTPaccount( QString filename )
358 : Account() 358 : Account()
359{ 359{
360 file = filename; 360 file = filename;
361 accountName = "New SMTP Account"; 361 accountName = "New SMTP Account";
362 ssl = false; 362 ssl = false;
363 connectionType = 1; 363 connectionType = 1;
364 login = false; 364 login = false;
365 type = MAILLIB::A_SMTP; 365 type = MAILLIB::A_SMTP;
366 port = SMTP_PORT; 366 port = SMTP_PORT;
367} 367}
368 368
369QString SMTPaccount::getUniqueFileName() 369QString SMTPaccount::getUniqueFileName()
370{ 370{
371 int num = 0; 371 int num = 0;
372 QString unique; 372 QString unique;
373 373
374 QDir dir( locateLocal("data", "kopiemail" ) ); 374 QDir dir( locateLocal("data", "kopiemail" ) );
375 375
376 QStringList imap = dir.entryList( "smtp-*" ); 376 QStringList imap = dir.entryList( "smtp-*" );
377 do { 377 do {
378 unique.setNum( num++ ); 378 unique.setNum( num++ );
379 } while ( imap.contains( "smtp-" + unique ) > 0 ); 379 } while ( imap.contains( "smtp-" + unique ) > 0 );
380 380
381 return unique; 381 return unique;
382} 382}
383 383
384void SMTPaccount::read() 384void SMTPaccount::read()
385{ 385{
386 KConfig *conf = new KConfig( getFileName() ); 386 KConfig *conf = new KConfig( getFileName() );
387 conf->setGroup( "SMTP Account" ); 387 conf->setGroup( "SMTP Account" );
388 accountName = conf->readEntry( "Account" ); 388 accountName = conf->readEntry( "Account" );
389 server = conf->readEntry( "Server" ); 389 server = conf->readEntry( "Server" );
390 port = conf->readEntry( "Port" ); 390 port = conf->readEntry( "Port" );
391 ssl = conf->readBoolEntry( "SSL" ); 391 ssl = conf->readBoolEntry( "SSL" );
392 connectionType = conf->readNumEntry( "ConnectionType" ); 392 connectionType = conf->readNumEntry( "ConnectionType" );
393 login = conf->readBoolEntry( "Login" ); 393 login = conf->readBoolEntry( "Login" );
394 user = conf->readEntry( "User" ); 394 user = conf->readEntry( "User" );
395 //password = conf->readEntryCrypt( "Password" ); 395 //password = conf->readEntryCrypt( "Password" );
396 setPasswordList( conf->readListEntry( "FolderHistory")); 396 setPasswordList( conf->readListEntry( "FolderHistory"));
397 delete conf; 397 delete conf;
398} 398}
399 399
400void SMTPaccount::save() 400void SMTPaccount::save()
401{ 401{
402 Settings::checkDirectory(); 402 Settings::checkDirectory();
403 403
404 KConfig *conf = new KConfig( getFileName() ); 404 KConfig *conf = new KConfig( getFileName() );
405 conf->setGroup( "SMTP Account" ); 405 conf->setGroup( "SMTP Account" );
406 conf->writeEntry( "Account", accountName ); 406 conf->writeEntry( "Account", accountName );
407 conf->writeEntry( "Server", server ); 407 conf->writeEntry( "Server", server );
408 conf->writeEntry( "Port", port ); 408 conf->writeEntry( "Port", port );
409 conf->writeEntry( "SSL", ssl ); 409 conf->writeEntry( "SSL", ssl );
410 conf->writeEntry( "ConnectionType", connectionType ); 410 conf->writeEntry( "ConnectionType", connectionType );
411 conf->writeEntry( "Login", login ); 411 conf->writeEntry( "Login", login );
412 conf->writeEntry( "User", user ); 412 conf->writeEntry( "User", user );
413 //conf->writeEntryCrypt( "Password", password ); 413 //conf->writeEntryCrypt( "Password", password );
414 conf->writeEntry( "FolderHistory",getPasswordList() ); 414 conf->writeEntry( "FolderHistory",getPasswordList() );
415 conf->sync(); 415 conf->sync();
416 delete conf; 416 delete conf;
417} 417}
418 418
419 419
420QString SMTPaccount::getFileName() 420QString SMTPaccount::getFileName()
421{ 421{
422 return locateLocal("data", "kopiemail" ) +"/smtp-" + file; 422 return locateLocal("data", "kopiemail" ) +"/smtp-" + file;
423} 423}
424 424
425NNTPaccount::NNTPaccount() 425NNTPaccount::NNTPaccount()
426 : Account() 426 : Account()
427{ 427{
428 file = NNTPaccount::getUniqueFileName(); 428 file = NNTPaccount::getUniqueFileName();
429 accountName = "New NNTP Account"; 429 accountName = "New NNTP Account";
430 ssl = false; 430 ssl = false;
431 login = false; 431 login = false;
432 type = MAILLIB::A_NNTP; 432 type = MAILLIB::A_NNTP;
433 port = NNTP_PORT; 433 port = NNTP_PORT;
434} 434}
435 435
436NNTPaccount::NNTPaccount( QString filename ) 436NNTPaccount::NNTPaccount( QString filename )
437 : Account() 437 : Account()
438{ 438{
439 file = filename; 439 file = filename;
440 accountName = "New NNTP Account"; 440 accountName = "New NNTP Account";
441 ssl = false; 441 ssl = false;
442 login = false; 442 login = false;
443 type = MAILLIB::A_NNTP; 443 type = MAILLIB::A_NNTP;
444 port = NNTP_PORT; 444 port = NNTP_PORT;
445} 445}
446 446
447QString NNTPaccount::getUniqueFileName() 447QString NNTPaccount::getUniqueFileName()
448{ 448{
449 int num = 0; 449 int num = 0;
450 QString unique; 450 QString unique;
451 451
452 QDir dir( locateLocal("data", "kopiemail" ) ); 452 QDir dir( locateLocal("data", "kopiemail" ) );
453 453
454 QStringList imap = dir.entryList( "nntp-*" ); 454 QStringList imap = dir.entryList( "nntp-*" );
455 do { 455 do {
456 unique.setNum( num++ ); 456 unique.setNum( num++ );
457 } while ( imap.contains( "nntp-" + unique ) > 0 ); 457 } while ( imap.contains( "nntp-" + unique ) > 0 );
458 458
459 return unique; 459 return unique;
460} 460}
461 461
462void NNTPaccount::read() 462void NNTPaccount::read()
463{ 463{
464 KConfig *conf = new KConfig( getFileName() ); 464 KConfig *conf = new KConfig( getFileName() );
465 conf->setGroup( "NNTP Account" ); 465 conf->setGroup( "NNTP Account" );
466 accountName = conf->readEntry( "Account" ); 466 accountName = conf->readEntry( "Account" );
467 server = conf->readEntry( "Server" ); 467 server = conf->readEntry( "Server" );
468 port = conf->readEntry( "Port" ); 468 port = conf->readEntry( "Port" );
469 ssl = conf->readBoolEntry( "SSL" ); 469 ssl = conf->readBoolEntry( "SSL" );
470 login = conf->readBoolEntry( "Login" ); 470 login = conf->readBoolEntry( "Login" );
471 user = conf->readEntry( "User" ); 471 user = conf->readEntry( "User" );
472 //password = conf->readEntryCrypt( "Password" ); 472 //password = conf->readEntryCrypt( "Password" );
473 setPasswordList( conf->readListEntry( "FolderHistory")); 473 setPasswordList( conf->readListEntry( "FolderHistory"));
474 subscribedGroups = conf->readListEntry( "Subscribed"); 474 subscribedGroups = conf->readListEntry( "Subscribed");
475 delete conf; 475 delete conf;
476} 476}
477 477
478void NNTPaccount::save() 478void NNTPaccount::save()
479{ 479{
480 Settings::checkDirectory(); 480 Settings::checkDirectory();
481 481
482 KConfig *conf = new KConfig( getFileName() ); 482 KConfig *conf = new KConfig( getFileName() );
483 conf->setGroup( "NNTP Account" ); 483 conf->setGroup( "NNTP Account" );
484 conf->writeEntry( "Account", accountName ); 484 conf->writeEntry( "Account", accountName );
485 conf->writeEntry( "Server", server ); 485 conf->writeEntry( "Server", server );
486 conf->writeEntry( "Port", port ); 486 conf->writeEntry( "Port", port );
487 conf->writeEntry( "SSL", ssl ); 487 conf->writeEntry( "SSL", ssl );
488 conf->writeEntry( "Login", login ); 488 conf->writeEntry( "Login", login );
489 conf->writeEntry( "User", user ); 489 conf->writeEntry( "User", user );
490 //conf->writeEntryCrypt( "Password", password ); 490 //conf->writeEntryCrypt( "Password", password );
491 conf->writeEntry( "FolderHistory",getPasswordList() ); 491 conf->writeEntry( "FolderHistory",getPasswordList() );
492 conf->writeEntry( "Subscribed" , subscribedGroups ); 492 conf->writeEntry( "Subscribed" , subscribedGroups );
493 conf->sync(); 493 conf->sync();
494 delete conf; 494 delete conf;
495} 495}
496 496
497 497
498QString NNTPaccount::getFileName() 498QString NNTPaccount::getFileName()
499{ 499{
500 return locateLocal("data", "kopiemail" ) +"/nntp-" + file; 500 return locateLocal("data", "kopiemail" ) +"/nntp-" + file;
501} 501}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index ec192ea..915b3e8 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,560 +1,587 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27 27
28#ifdef DESKTOP_VERSION 28#ifdef DESKTOP_VERSION
29#include <qapplication.h> 29#include <qapplication.h>
30#else 30#else
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#endif 32#endif
33#include <libmailwrapper/smtpwrapper.h> 33#include <libmailwrapper/smtpwrapper.h>
34#include <libmailwrapper/mailtypes.h> 34#include <libmailwrapper/mailtypes.h>
35#include <libmailwrapper/abstractmail.h> 35#include <libmailwrapper/abstractmail.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38//using namespace Opie::Core; 38//using namespace Opie::Core;
39 39
40OpieMail::OpieMail( QWidget *parent, const char *name ) 40OpieMail::OpieMail( QWidget *parent, const char *name )
41 : MainWindow( parent, name) //, WStyle_ContextHelp ) 41 : MainWindow( parent, name) //, WStyle_ContextHelp )
42{ 42{
43 settings = new Settings(); 43 settings = new Settings();
44 44
45 setIcon(SmallIcon( "kmicromail" ) ); 45 setIcon(SmallIcon( "kmicromail" ) );
46 folderView->populate( settings->getAccounts() ); 46 folderView->populate( settings->getAccounts() );
47 47
48} 48}
49 49
50OpieMail::~OpieMail() 50OpieMail::~OpieMail()
51{ 51{
52 if (settings) delete settings; 52 if (settings) delete settings;
53} 53}
54 54
55void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 55void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
56{ 56{
57 57
58} 58}
59#include <stdlib.h> 59#include <stdlib.h>
60void OpieMail::message(const QCString &msg, const QByteArray &data) 60void OpieMail::message(const QCString &msg, const QByteArray &data)
61{ 61{
62 // copied from old mail2 62 // copied from old mail2
63 static int ii = 0; 63 static int ii = 0;
64 //qDebug("QCOP CALL ############################# %d ", ii); 64 //qDebug("QCOP CALL ############################# %d ", ii);
65 //QString mess ( msg ); 65 //QString mess ( msg );
66 //qDebug("Message = %s ",mess.latin1()); 66 //qDebug("Message = %s ",mess.latin1());
67 ++ii; 67 ++ii;
68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
69 69
70 mPendingEmail = QString::null; 70 mPendingEmail = QString::null;
71 mPendingName = QString::null; 71 mPendingName = QString::null;
72 if (msg == "writeMail(QString,QString)") 72 if (msg == "writeMail(QString,QString)")
73 { 73 {
74 //qDebug("writeMail(QString,QString) "); 74 //qDebug("writeMail(QString,QString) ");
75 QDataStream stream(data,IO_ReadOnly); 75 QDataStream stream(data,IO_ReadOnly);
76 stream >> mPendingName >> mPendingEmail; 76 stream >> mPendingName >> mPendingEmail;
77 // removing the whitespaces at beginning and end is needed! 77 // removing the whitespaces at beginning and end is needed!
78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
79 } 79 }
80 else if (msg == "newMail()") 80 else if (msg == "newMail()")
81 { 81 {
82 //qDebug("slotComposeMail() "); 82 //qDebug("slotComposeMail() ");
83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
84 // and a QCOP call does not like a processevents in his execution 84 // and a QCOP call does not like a processevents in his execution
85 // with the Qtimer we call slotComposeMail() after we reached the main event loop 85 // with the Qtimer we call slotComposeMail() after we reached the main event loop
86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
87 // slotComposeMail(); 87 // slotComposeMail();
88 } 88 }
89 else if (msg == "newMail(QString)") 89 else if (msg == "newMail(QString)")
90 { 90 {
91 //qDebug(" newMail(QString)"); 91 //qDebug(" newMail(QString)");
92 QDataStream stream(data,IO_ReadOnly); 92 QDataStream stream(data,IO_ReadOnly);
93 stream >> mPendingName; 93 stream >> mPendingName;
94 // the format is 94 // the format is
95 // NAME <EMAIL>:SUBJECT 95 // NAME <EMAIL>:SUBJECT
96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
97 } else { 97 } else {
98 mPendingData = data; 98 mPendingData = data;
99 mPendingMessage = msg; 99 mPendingMessage = msg;
100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
101 } 101 }
102 102
103 //qDebug("END OpieMail::message "); 103 //qDebug("END OpieMail::message ");
104} 104}
105void OpieMail::slotExtAppHandler() 105void OpieMail::slotExtAppHandler()
106{ 106{
107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
108} 108}
109void OpieMail::slotwriteMail2(const QString& namemail ) 109void OpieMail::slotwriteMail2(const QString& namemail )
110{ 110{
111 //qDebug("OpieMail::slotwriteMail2 "); 111 //qDebug("OpieMail::slotwriteMail2 ");
112 //qApp->processEvents(); 112 //qApp->processEvents();
113 ComposeMail compose( settings, this, 0, true ); 113 ComposeMail compose( settings, this, 0, true );
114 if ( !namemail.isEmpty() ) { 114 if ( !namemail.isEmpty() ) {
115 QString to = namemail; 115 QString to = namemail;
116 if ( namemail.find( " <") > 1 ) { 116 if ( namemail.find( " <") > 1 ) {
117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
118 } else 118 } else
119 if ( namemail.find( "<") > 1 ) { 119 if ( namemail.find( "<") > 1 ) {
120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
121 } 121 }
122 int sub = to.find( ">:"); 122 int sub = to.find( ">:");
123 if ( sub > 0 ) { 123 if ( sub > 0 ) {
124 compose.setTo( to.left(sub+1) ); 124 compose.setTo( to.left(sub+1) );
125 compose.setSubject( to.mid(sub+2) ); 125 compose.setSubject( to.mid(sub+2) );
126 } else 126 } else
127 compose.setTo( to ); 127 compose.setTo( to );
128 } 128 }
129 compose.slotAdjustColumns(); 129 compose.slotAdjustColumns();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 compose.showMaximized(); 131 compose.showMaximized();
132#endif 132#endif
133 compose.exec(); 133 compose.exec();
134 raise(); 134 raise();
135 //qDebug("retttich "); 135 //qDebug("retttich ");
136} 136}
137void OpieMail::slotwriteMail(const QString&name,const QString&email) 137void OpieMail::slotwriteMail(const QString&name,const QString&email)
138{ 138{
139 // qDebug("OpieMail::slotwriteMail "); 139 // qDebug("OpieMail::slotwriteMail ");
140 ComposeMail compose( settings, this, 0, true ); 140 ComposeMail compose( settings, this, 0, true );
141 if (!email.isEmpty()) 141 if (!email.isEmpty())
142 { 142 {
143 if (!name.isEmpty()) 143 if (!name.isEmpty())
144 { 144 {
145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
146 } 146 }
147 else 147 else
148 { 148 {
149 compose.setTo(email); 149 compose.setTo(email);
150 } 150 }
151 } 151 }
152 compose.slotAdjustColumns(); 152 compose.slotAdjustColumns();
153#ifndef DESKTOP_VERSION 153#ifndef DESKTOP_VERSION
154 compose.showMaximized(); 154 compose.showMaximized();
155#endif 155#endif
156 compose.exec(); 156 compose.exec();
157 raise(); 157 raise();
158} 158}
159 159
160void OpieMail::slotComposeMail() 160void OpieMail::slotComposeMail()
161{ 161{
162 if ( mPendingEmail == QString::null && mPendingName == QString::null) 162 if ( mPendingEmail == QString::null && mPendingName == QString::null)
163 slotwriteMail2( QString () ); 163 slotwriteMail2( QString () );
164 else { 164 else {
165 if ( mPendingEmail == QString::null ) 165 if ( mPendingEmail == QString::null )
166 slotwriteMail2( mPendingName ); 166 slotwriteMail2( mPendingName );
167 else 167 else
168 slotwriteMail( mPendingName, mPendingEmail ); 168 slotwriteMail( mPendingName, mPendingEmail );
169 } 169 }
170 //slotwriteMail(0l,0l); 170 //slotwriteMail(0l,0l);
171} 171}
172 172
173void OpieMail::slotSendQueued() 173void OpieMail::slotSendQueued()
174{ 174{
175 SMTPaccount *smtp = 0; 175 SMTPaccount *smtp = 0;
176 176
177 QList<Account> list = settings->getAccounts(); 177 QList<Account> list = settings->getAccounts();
178 QList<SMTPaccount> smtpList; 178 QList<SMTPaccount> smtpList;
179 smtpList.setAutoDelete(false); 179 smtpList.setAutoDelete(false);
180 Account *it; 180 Account *it;
181 for ( it = list.first(); it; it = list.next() ) 181 for ( it = list.first(); it; it = list.next() )
182 { 182 {
183 if ( it->getType() == MAILLIB::A_SMTP ) 183 if ( it->getType() == MAILLIB::A_SMTP )
184 { 184 {
185 smtp = static_cast<SMTPaccount *>(it); 185 smtp = static_cast<SMTPaccount *>(it);
186 smtpList.append(smtp); 186 smtpList.append(smtp);
187 } 187 }
188 } 188 }
189 if (smtpList.count()==0) 189 if (smtpList.count()==0)
190 { 190 {
191 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 191 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
192 return; 192 return;
193 } 193 }
194 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 194 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
195 return; 195 return;
196 if (smtpList.count()==1) 196 if (smtpList.count()==1)
197 { 197 {
198 smtp = smtpList.at(0); 198 smtp = smtpList.at(0);
199 } 199 }
200 else 200 else
201 { 201 {
202 smtp = 0; 202 smtp = 0;
203 selectsmtp selsmtp; 203 selectsmtp selsmtp;
204 selsmtp.setSelectionlist(&smtpList); 204 selsmtp.setSelectionlist(&smtpList);
205#ifndef DESKTOP_VERSION 205#ifndef DESKTOP_VERSION
206 selsmtp.showMaximized(); 206 selsmtp.showMaximized();
207#endif 207#endif
208 if ( selsmtp.exec() == QDialog::Accepted ) 208 if ( selsmtp.exec() == QDialog::Accepted )
209 { 209 {
210 smtp = selsmtp.selected_smtp(); 210 smtp = selsmtp.selected_smtp();
211 } 211 }
212 } 212 }
213 if (smtp) 213 if (smtp)
214 { 214 {
215 215
216 Global::statusMessage("Sending mails...!"); 216 Global::statusMessage("Sending mails...!");
217 SMTPwrapper * wrap = new SMTPwrapper(smtp); 217 SMTPwrapper * wrap = new SMTPwrapper(smtp);
218 if ( wrap->flushOutbox() ) 218 if ( wrap->flushOutbox() )
219 { 219 {
220 Global::statusMessage("Mails sent!"); 220 Global::statusMessage("Mails sent!");
221 } 221 }
222 delete wrap; 222 delete wrap;
223 } 223 }
224 // pending refresh list view, if outgoing is displayed 224 // pending refresh list view, if outgoing is displayed
225} 225}
226 226
227void OpieMail::slotSearchMails() 227void OpieMail::slotSearchMails()
228{ 228{
229 qDebug("OpieMail::slotSearchMails():not implemented "); 229 qDebug("OpieMail::slotSearchMails():not implemented ");
230} 230}
231 231
232void OpieMail::slotEditSettings() 232void OpieMail::slotEditSettings()
233{ 233{
234 234
235 KOPrefsDialog settingsDialog( this, "koprefs", true ); 235 KOPrefsDialog settingsDialog( this, "koprefs", true );
236#ifndef DESKTOP_VERSION 236#ifndef DESKTOP_VERSION
237 settingsDialog.showMaximized(); 237 settingsDialog.showMaximized();
238#endif 238#endif
239 settingsDialog.exec(); 239 settingsDialog.exec();
240 240
241 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 241 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
242 // KApplication::execDialog(settingsDialog); 242 // KApplication::execDialog(settingsDialog);
243} 243}
244 244
245void OpieMail::slotEditAccounts() 245void OpieMail::slotEditAccounts()
246{ 246{
247 EditAccounts eaDialog( settings, this, 0, true ); 247 EditAccounts eaDialog( settings, this, 0, true );
248 eaDialog.slotAdjustColumns(); 248 eaDialog.slotAdjustColumns();
249#ifndef DESKTOP_VERSION 249#ifndef DESKTOP_VERSION
250 eaDialog.showMaximized(); 250 eaDialog.showMaximized();
251#endif 251#endif
252 eaDialog.exec(); 252 eaDialog.exec();
253 if ( settings ) delete settings; 253 if ( settings ) delete settings;
254 settings = new Settings(); 254 settings = new Settings();
255 255
256 folderView->populate( settings->getAccounts() ); 256 folderView->populate( settings->getAccounts() );
257} 257}
258void OpieMail::replyMail() 258void OpieMail::replyMail()
259{ 259{
260 260
261 QListViewItem*item = mailView->currentItem(); 261 QListViewItem*item = mailView->currentItem();
262 if (!item) return; 262 if (!item) return;
263 RecMailP mail = ((MailListViewItem*)item)->data(); 263 RecMailP mail = ((MailListViewItem*)item)->data();
264 RecBodyP body = folderView->fetchBody(mail); 264 RecBodyP body = folderView->fetchBody(mail);
265 265
266 QString rtext; 266 QString rtext;
267 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 267 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
268 .arg( mail->getFrom()) 268 .arg( mail->getFrom())
269 .arg( mail->getDate()); 269 .arg( mail->getDate());
270 270
271 QString text = body->Bodytext(); 271 QString text = body->Bodytext();
272 QStringList lines = QStringList::split(QRegExp("\\n"), text); 272 QStringList lines = QStringList::split(QRegExp("\\n"), text);
273 QStringList::Iterator it; 273 QStringList::Iterator it;
274 for (it = lines.begin(); it != lines.end(); it++) 274 for (it = lines.begin(); it != lines.end(); it++)
275 { 275 {
276 rtext += "> " + *it + "\n"; 276 rtext += "> " + *it + "\n";
277 } 277 }
278 rtext += "\n"; 278 rtext += "\n";
279 279
280 QString prefix; 280 QString prefix;
281 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 281 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
282 else prefix = "Re: "; // no i18n on purpose 282 else prefix = "Re: "; // no i18n on purpose
283 283
284 Settings *settings = new Settings(); 284 Settings *settings = new Settings();
285 ComposeMail composer( settings ,this, 0, true); 285 ComposeMail composer( settings ,this, 0, true);
286 if (mail->Replyto().isEmpty()) { 286 if (mail->Replyto().isEmpty()) {
287 composer.setTo( mail->getFrom()); 287 composer.setTo( mail->getFrom());
288 } else { 288 } else {
289 composer.setTo( mail->Replyto()); 289 composer.setTo( mail->Replyto());
290 } 290 }
291 composer.setSubject( prefix + mail->getSubject()); 291 composer.setSubject( prefix + mail->getSubject());
292 composer.setMessage( rtext ); 292 composer.setMessage( rtext );
293 composer.setInReplyTo( mail->Msgid()); 293 composer.setInReplyTo( mail->Msgid());
294 composer.setCharset( body->getCharset() ); 294 composer.setCharset( body->getCharset() );
295 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 295 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
296 { 296 {
297 mail->Wrapper()->answeredMail(mail); 297 mail->Wrapper()->answeredMail(mail);
298 } 298 }
299 delete settings; 299 delete settings;
300 300
301} 301}
302void OpieMail::closeViewMail(ViewMail * vm)
303{
304 vm->hide();
305}
306void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
307{
308 QListViewItem*item = mailView->currentItem();
309 if (!item ) {
310 closeViewMail(vm);
311 return;
312 }
313 RecMailP mail = ((MailListViewItem*)item)->data();
314 mail->Wrapper()->deleteMail( mail );
315 item = item->itemBelow();
316 if (!item ) {
317 closeViewMail(vm);
318 return;
319 }
320 mailView->setCurrentItem(item);
321 mail = ((MailListViewItem*)item)->data();
322 RecBodyP body = folderView->fetchBody(mail);
323 vm->setBody( body );
324 vm->setMail( mail );
325}
302void OpieMail::displayNextMail(ViewMail * vm) 326void OpieMail::displayNextMail(ViewMail * vm)
303{ 327{
304 QListViewItem*item = mailView->currentItem(); 328 QListViewItem*item = mailView->currentItem();
305 if (!item) return; 329 if (!item) return;
330 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
306 item = item->itemBelow(); 331 item = item->itemBelow();
307 if (!item) { 332 if (!item) {
308 vm->setCaption(i18n("End of List" )); 333 vm->setCaption(i18n("End of List" ));
309 return; 334 return;
310 } 335 }
311 mailView->setCurrentItem(item); 336 mailView->setCurrentItem(item);
312 RecMailP mail = ((MailListViewItem*)item)->data(); 337 RecMailP mail = ((MailListViewItem*)item)->data();
313 RecBodyP body = folderView->fetchBody(mail); 338 RecBodyP body = folderView->fetchBody(mail);
314 vm->setBody( body ); 339 vm->setBody( body );
315 vm->setMail( mail ); 340 vm->setMail( mail );
316} 341}
317void OpieMail::displayMail() 342void OpieMail::displayMail()
318{ 343{
319 QListViewItem*item = mailView->currentItem(); 344 QListViewItem*item = mailView->currentItem();
320 if (!item) return; 345 if (!item) return;
321 RecMailP mail = ((MailListViewItem*)item)->data(); 346 RecMailP mail = ((MailListViewItem*)item)->data();
322 RecBodyP body = folderView->fetchBody(mail); 347 RecBodyP body = folderView->fetchBody(mail);
323 ViewMail readMail( this,"", Qt::WType_Modal ); 348 ViewMail readMail( this,"", Qt::WType_Modal );
324 readMail.setBody( body ); 349 readMail.setBody( body );
325 readMail.setMail( mail ); 350 readMail.setMail( mail );
326#ifndef DESKTOP_VERSION 351#ifndef DESKTOP_VERSION
327 readMail.showMaximized(); 352 readMail.showMaximized();
328#else 353#else
329 readMail.resize( 640, 480); 354 readMail.resize( 640, 480);
330#endif 355#endif
331 connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); 356 connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) );
357 connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) );
358
332 readMail.exec(); 359 readMail.exec();
333 360
334 if ( readMail.deleted ) 361 if ( readMail.deleted )
335 { 362 {
336 folderView->refreshCurrent(); 363 folderView->refreshCurrent();
337 } 364 }
338 else 365 else
339 { 366 {
340 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 367 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
341 } 368 }
342} 369}
343void OpieMail::slotGetAllMail() 370void OpieMail::slotGetAllMail()
344{ 371{
345 QListViewItem * item = folderView->firstChild(); 372 QListViewItem * item = folderView->firstChild();
346 while ( item ){ 373 while ( item ){
347 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 374 ((AccountViewItem *)item)->contextMenuSelected( 101 );
348 item = item->nextSibling (); 375 item = item->nextSibling ();
349 } 376 }
350} 377}
351void OpieMail::slotGetMail() 378void OpieMail::slotGetMail()
352{ 379{
353 QListViewItem * item = folderView->currentItem(); 380 QListViewItem * item = folderView->currentItem();
354 if ( ! item ) return; 381 if ( ! item ) return;
355 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 382 ((AccountViewItem *)item)->contextMenuSelected( 101 );
356} 383}
357void OpieMail::slotDeleteMail() 384void OpieMail::slotDeleteMail()
358{ 385{
359 if (!mailView->currentItem()) return; 386 if (!mailView->currentItem()) return;
360 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 387 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
361 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 388 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
362 { 389 {
363 mail->Wrapper()->deleteMail( mail ); 390 mail->Wrapper()->deleteMail( mail );
364 folderView->refreshCurrent(); 391 folderView->refreshCurrent();
365 } 392 }
366} 393}
367void OpieMail::slotDeleteAllMail() 394void OpieMail::slotDeleteAllMail()
368{ 395{
369 396
370 QValueList<RecMailP> t; 397 QValueList<RecMailP> t;
371 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 398 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
372 { 399 {
373 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 400 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
374 while ( item ) { 401 while ( item ) {
375 if ( item->isSelected() ) { 402 if ( item->isSelected() ) {
376 t.append( item->data() ); 403 t.append( item->data() );
377 } 404 }
378 item = (MailListViewItem*)item->nextSibling(); 405 item = (MailListViewItem*)item->nextSibling();
379 } 406 }
380 } 407 }
381 else 408 else
382 return; 409 return;
383 if ( t.count() == 0 ) 410 if ( t.count() == 0 )
384 return; 411 return;
385 RecMailP mail = t.first(); 412 RecMailP mail = t.first();
386 mail->Wrapper()->deleteMailList(t); 413 mail->Wrapper()->deleteMailList(t);
387 folderView->refreshCurrent(); 414 folderView->refreshCurrent();
388 415
389 416
390} 417}
391void OpieMail::clearSelection() 418void OpieMail::clearSelection()
392{ 419{
393 mailView->clearSelection(); 420 mailView->clearSelection();
394 421
395} 422}
396 423
397void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 424void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
398{ 425{
399 if (!mailView->currentItem()) return; 426 if (!mailView->currentItem()) return;
400 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 427 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
401 /* just the RIGHT button - or hold on pda */ 428 /* just the RIGHT button - or hold on pda */
402 if (button!=2) {return;} 429 if (button!=2) {return;}
403 if (!item) return; 430 if (!item) return;
404 QPopupMenu *m = new QPopupMenu(0); 431 QPopupMenu *m = new QPopupMenu(0);
405 if (m) 432 if (m)
406 { 433 {
407 if (mailtype==MAILLIB::A_NNTP) { 434 if (mailtype==MAILLIB::A_NNTP) {
408 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 435 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
409 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 436 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
410 m->insertSeparator(); 437 m->insertSeparator();
411 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 438 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
412 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 439 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
413 } else { 440 } else {
414 if (folderView->currentisDraft()) { 441 if (folderView->currentisDraft()) {
415 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 442 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
416 } 443 }
417 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); 444 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
418 m->insertSeparator(); 445 m->insertSeparator();
419 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 446 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
420 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 447 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
421 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 448 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
422 m->insertSeparator(); 449 m->insertSeparator();
423 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 450 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
424 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 451 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
425 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 452 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
426 } 453 }
427 m->setFocus(); 454 m->setFocus();
428 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 455 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
429 delete m; 456 delete m;
430 } 457 }
431} 458}
432 459
433void OpieMail::slotShowFolders( bool show ) 460void OpieMail::slotShowFolders( bool show )
434{ 461{
435 if ( show && folderView->isHidden() ) 462 if ( show && folderView->isHidden() )
436 { 463 {
437 folderView->show(); 464 folderView->show();
438 } 465 }
439 else if ( !show && !folderView->isHidden() ) 466 else if ( !show && !folderView->isHidden() )
440 { 467 {
441 folderView->hide(); 468 folderView->hide();
442 } 469 }
443} 470}
444 471
445void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 472void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
446{ 473{
447 MailListViewItem*item = 0; 474 MailListViewItem*item = 0;
448 mailView->clear(); 475 mailView->clear();
449 476
450 QValueList<RecMailP>::ConstIterator it; 477 QValueList<RecMailP>::ConstIterator it;
451 for (it = list.begin(); it != list.end();++it) 478 for (it = list.begin(); it != list.end();++it)
452 { 479 {
453 item = new MailListViewItem(mailView,item); 480 item = new MailListViewItem(mailView,item);
454 item->storeData((*it)); 481 item->storeData((*it));
455 item->showEntry(); 482 item->showEntry();
456 } 483 }
457 mailView->setSorting ( 4, false ); 484 mailView->setSorting ( 4, false );
458} 485}
459 486
460void OpieMail::mailLeftClicked( QListViewItem *item ) 487void OpieMail::mailLeftClicked( QListViewItem *item )
461{ 488{
462 mailView->clearSelection(); 489 mailView->clearSelection();
463 /* just LEFT button - or tap with stylus on pda */ 490 /* just LEFT button - or tap with stylus on pda */
464 //if (button!=1) return; 491 //if (button!=1) return;
465 if (!item) return; 492 if (!item) return;
466 if (folderView->currentisDraft()) { 493 if (folderView->currentisDraft()) {
467 reEditMail(); 494 reEditMail();
468 } else { 495 } else {
469 displayMail(); 496 displayMail();
470 } 497 }
471} 498}
472 499
473void OpieMail::slotMoveCopyMail() 500void OpieMail::slotMoveCopyMail()
474{ 501{
475 if (!mailView->currentItem()) return; 502 if (!mailView->currentItem()) return;
476 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 503 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
477 AbstractMail*targetMail = 0; 504 AbstractMail*targetMail = 0;
478 QString targetFolder = ""; 505 QString targetFolder = "";
479 Selectstore sels; 506 Selectstore sels;
480 folderView->setupFolderselect(&sels); 507 folderView->setupFolderselect(&sels);
481 if (!sels.exec()) return; 508 if (!sels.exec()) return;
482 targetMail = sels.currentMail(); 509 targetMail = sels.currentMail();
483 targetFolder = sels.currentFolder(); 510 targetFolder = sels.currentFolder();
484 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 511 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
485 targetFolder.isEmpty()) 512 targetFolder.isEmpty())
486 { 513 {
487 return; 514 return;
488 } 515 }
489 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 516 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
490 { 517 {
491 QMessageBox::critical(0,i18n("Error creating new Folder"), 518 QMessageBox::critical(0,i18n("Error creating new Folder"),
492 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 519 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
493 return; 520 return;
494 } 521 }
495 sels.hide(); 522 sels.hide();
496 qApp->processEvents(); 523 qApp->processEvents();
497 // qDebug("hiding sels "); 524 // qDebug("hiding sels ");
498 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 525 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
499 folderView->refreshCurrent(); 526 folderView->refreshCurrent();
500} 527}
501 528
502void OpieMail::slotMoveCopyAllMail() 529void OpieMail::slotMoveCopyAllMail()
503{ 530{
504 531
505 if (!mailView->currentItem()) return; 532 if (!mailView->currentItem()) return;
506 QValueList<RecMailP> t; 533 QValueList<RecMailP> t;
507 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 534 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
508 { 535 {
509 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 536 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
510 while ( item ) { 537 while ( item ) {
511 if ( item->isSelected() ) { 538 if ( item->isSelected() ) {
512 t.append( item->data() ); 539 t.append( item->data() );
513 } 540 }
514 item = (MailListViewItem*)item->nextSibling(); 541 item = (MailListViewItem*)item->nextSibling();
515 } 542 }
516 } 543 }
517 // else 544 // else
518 // return; 545 // return;
519 if ( t.count() == 0 ) 546 if ( t.count() == 0 )
520 return; 547 return;
521 RecMailP mail = t.first(); 548 RecMailP mail = t.first();
522 AbstractMail*targetMail = 0; 549 AbstractMail*targetMail = 0;
523 QString targetFolder = ""; 550 QString targetFolder = "";
524 Selectstore sels; 551 Selectstore sels;
525 folderView->setupFolderselect(&sels); 552 folderView->setupFolderselect(&sels);
526 if (!sels.exec()) return; 553 if (!sels.exec()) return;
527 targetMail = sels.currentMail(); 554 targetMail = sels.currentMail();
528 targetFolder = sels.currentFolder(); 555 targetFolder = sels.currentFolder();
529 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 556 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
530 targetFolder.isEmpty()) 557 targetFolder.isEmpty())
531 { 558 {
532 return; 559 return;
533 } 560 }
534 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 561 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
535 { 562 {
536 QMessageBox::critical(0,i18n("Error creating new Folder"), 563 QMessageBox::critical(0,i18n("Error creating new Folder"),
537 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 564 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
538 return; 565 return;
539 } 566 }
540 sels.hide(); 567 sels.hide();
541 qApp->processEvents(); 568 qApp->processEvents();
542 //qDebug("hiding sels "); 569 //qDebug("hiding sels ");
543 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 570 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
544 folderView->refreshCurrent(); 571 folderView->refreshCurrent();
545} 572}
546 573
547void OpieMail::reEditMail() 574void OpieMail::reEditMail()
548{ 575{
549 if (!mailView->currentItem()) return; 576 if (!mailView->currentItem()) return;
550 577
551 ComposeMail compose( settings, this, 0, true ); 578 ComposeMail compose( settings, this, 0, true );
552 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 579 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
553 compose.slotAdjustColumns(); 580 compose.slotAdjustColumns();
554#ifndef DESKTOP_VERSION 581#ifndef DESKTOP_VERSION
555 compose.showMaximized(); 582 compose.showMaximized();
556#else 583#else
557 compose.resize(640,480); 584 compose.resize(640,480);
558#endif 585#endif
559 compose.exec(); 586 compose.exec();
560} 587}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 30968a7..a81a34c 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -1,58 +1,60 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef OPIEMAIL_H 2#ifndef OPIEMAIL_H
3#define OPIEMAIL_H 3#define OPIEMAIL_H
4 4
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7 7
8#include <opie2/osmartpointer.h> 8#include <opie2/osmartpointer.h>
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10#include <viewmail.h> 10#include <viewmail.h>
11 11
12class OpieMail : public MainWindow 12class OpieMail : public MainWindow
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15 15
16public: 16public:
17 OpieMail( QWidget *parent = 0, const char *name = 0 ); 17 OpieMail( QWidget *parent = 0, const char *name = 0 );
18 virtual ~OpieMail(); 18 virtual ~OpieMail();
19 static QString appName() { return QString::fromLatin1("kopiemail"); } 19 static QString appName() { return QString::fromLatin1("kopiemail"); }
20 20
21public slots: 21public slots:
22 virtual void slotwriteMail(const QString&name,const QString&email); 22 virtual void slotwriteMail(const QString&name,const QString&email);
23 virtual void slotwriteMail2(const QString&nameemail); 23 virtual void slotwriteMail2(const QString&nameemail);
24 virtual void slotComposeMail(); 24 virtual void slotComposeMail();
25 virtual void slotExtAppHandler(); 25 virtual void slotExtAppHandler();
26 virtual void appMessage(const QCString &msg, const QByteArray &data); 26 virtual void appMessage(const QCString &msg, const QByteArray &data);
27 virtual void message(const QCString &msg, const QByteArray &data); 27 virtual void message(const QCString &msg, const QByteArray &data);
28protected slots: 28protected slots:
29 virtual void deleteAndDisplayNextMail(ViewMail * vm);
29 virtual void displayNextMail(ViewMail * vm); 30 virtual void displayNextMail(ViewMail * vm);
30 virtual void slotSendQueued(); 31 virtual void slotSendQueued();
31 virtual void slotSearchMails(); 32 virtual void slotSearchMails();
32 virtual void slotEditSettings(); 33 virtual void slotEditSettings();
33 virtual void slotEditAccounts(); 34 virtual void slotEditAccounts();
34 virtual void displayMail(); 35 virtual void displayMail();
35 virtual void replyMail(); 36 virtual void replyMail();
36 virtual void slotDeleteMail(); 37 virtual void slotDeleteMail();
37 virtual void slotGetMail(); 38 virtual void slotGetMail();
38 virtual void slotGetAllMail(); 39 virtual void slotGetAllMail();
39 virtual void slotDeleteAllMail(); 40 virtual void slotDeleteAllMail();
40 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 41 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
41 virtual void slotShowFolders( bool show ); 42 virtual void slotShowFolders( bool show );
42 virtual void refreshMailView(const QValueList<RecMailP>&); 43 virtual void refreshMailView(const QValueList<RecMailP>&);
43 virtual void mailLeftClicked( QListViewItem * ); 44 virtual void mailLeftClicked( QListViewItem * );
44 virtual void slotMoveCopyMail(); 45 virtual void slotMoveCopyMail();
45 virtual void slotMoveCopyAllMail(); 46 virtual void slotMoveCopyAllMail();
46 virtual void reEditMail(); 47 virtual void reEditMail();
47 void clearSelection(); 48 void clearSelection();
48 49
49private: 50private:
51 void closeViewMail(ViewMail * vm);
50 QString mPendingEmail; 52 QString mPendingEmail;
51 QString mPendingName; 53 QString mPendingName;
52 QByteArray mPendingData; 54 QByteArray mPendingData;
53 QCString mPendingMessage; 55 QCString mPendingMessage;
54 Settings *settings; 56 Settings *settings;
55 57
56}; 58};
57 59
58#endif 60#endif
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 60c764c..6d88cad 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,533 +1,534 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3 3
4 4
5#include <kfiledialog.h> 5#include <kfiledialog.h>
6#include "koprefs.h" 6#include "koprefs.h"
7#include <klocale.h> 7#include <klocale.h>
8#include <kglobal.h> 8#include <kglobal.h>
9#include <kapplication.h> 9#include <kapplication.h>
10 10
11#ifdef MINIKDE_KDIALOG_H 11#ifdef MINIKDE_KDIALOG_H
12#undef MINIKDE_KDIALOG_H 12#undef MINIKDE_KDIALOG_H
13#endif 13#endif
14 14
15#include "composemail.h" 15#include "composemail.h"
16#include "viewmail.h" 16#include "viewmail.h"
17 17
18#include <libmailwrapper/settings.h> 18#include <libmailwrapper/settings.h>
19#include <libmailwrapper/abstractmail.h> 19#include <libmailwrapper/abstractmail.h>
20#include <libmailwrapper/mailtypes.h> 20#include <libmailwrapper/mailtypes.h>
21 21
22#include <qdialog.h> 22#include <qdialog.h>
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26/* QT */ 26/* QT */
27#include <qtextbrowser.h> 27#include <qtextbrowser.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qaction.h> 30#include <qaction.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qlayout.h> 33#include <qlayout.h>
34 34
35//using namespace Opie::Ui; 35//using namespace Opie::Ui;
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
39 const QString&fsize,int num,const QValueList<int>&path) 39 const QString&fsize,int num,const QValueList<int>&path)
40 : QListViewItem(parent,after),_partNum(num) 40 : QListViewItem(parent,after),_partNum(num)
41{ 41{
42 _path=path; 42 _path=path;
43 setText(0, mime); 43 setText(0, mime);
44 setText(1, desc); 44 setText(1, desc);
45 setText(2, file); 45 setText(2, file);
46 setText(3, fsize); 46 setText(3, fsize);
47} 47}
48 48
49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
50 const QString&fsize,int num,const QValueList<int>&path) 50 const QString&fsize,int num,const QValueList<int>&path)
51 : QListViewItem(parent,after),_partNum(num) 51 : QListViewItem(parent,after),_partNum(num)
52{ 52{
53 _path=path; 53 _path=path;
54 setText(0, mime); 54 setText(0, mime);
55 setText(1, desc); 55 setText(1, desc);
56 setText(2, file); 56 setText(2, file);
57 setText(3, fsize); 57 setText(3, fsize);
58} 58}
59 59
60bool AttachItem::isParentof(const QValueList<int>&path) 60bool AttachItem::isParentof(const QValueList<int>&path)
61{ 61{
62 /* if not set, then no parent */ 62 /* if not set, then no parent */
63 if (path.count()==0||_path.count()==0) return false; 63 if (path.count()==0||_path.count()==0) return false;
64 /* the parent must have one digit less then a child */ 64 /* the parent must have one digit less then a child */
65 if (path.count()!=_path.count()+1) return false; 65 if (path.count()!=_path.count()+1) return false;
66 for (unsigned int i=0; i < _path.count();++i) 66 for (unsigned int i=0; i < _path.count();++i)
67 { 67 {
68 if (_path[i]!=path[i]) return false; 68 if (_path[i]!=path[i]) return false;
69 } 69 }
70 return true; 70 return true;
71} 71}
72 72
73AttachItem* ViewMail::searchParent(const QValueList<int>&path) 73AttachItem* ViewMail::searchParent(const QValueList<int>&path)
74{ 74{
75 QListViewItemIterator it( attachments ); 75 QListViewItemIterator it( attachments );
76 for ( ; it.current(); ++it ) 76 for ( ; it.current(); ++it )
77 { 77 {
78 AttachItem*ati = (AttachItem*)it.current(); 78 AttachItem*ati = (AttachItem*)it.current();
79 if (ati->isParentof(path)) return ati; 79 if (ati->isParentof(path)) return ati;
80 } 80 }
81 return 0; 81 return 0;
82} 82}
83 83
84AttachItem* ViewMail::lastChild(AttachItem*parent) 84AttachItem* ViewMail::lastChild(AttachItem*parent)
85{ 85{
86 if (!parent) return 0; 86 if (!parent) return 0;
87 AttachItem* item = (AttachItem*)parent->firstChild(); 87 AttachItem* item = (AttachItem*)parent->firstChild();
88 if (!item) return item; 88 if (!item) return item;
89 AttachItem*temp=0; 89 AttachItem*temp=0;
90 while( (temp=(AttachItem*)item->nextSibling())) 90 while( (temp=(AttachItem*)item->nextSibling()))
91 { 91 {
92 item = temp; 92 item = temp;
93 } 93 }
94 return item; 94 return item;
95} 95}
96 96
97void ViewMail::setBody(const RecBodyP&body ) 97void ViewMail::setBody(const RecBodyP&body )
98{ 98{
99 99
100 m_body = body; 100 m_body = body;
101 m_mail[2] = body->Bodytext(); 101 m_mail[2] = body->Bodytext();
102 // qDebug("********text %s ",m_mail[2].latin1() ); 102 // qDebug("********text %s ",m_mail[2].latin1() );
103 attachbutton->setEnabled(body->Parts().count()>0); 103 attachbutton->setEnabled(body->Parts().count()>0);
104 attachments->setEnabled(body->Parts().count()>0); 104 attachments->setEnabled(body->Parts().count()>0);
105 if (body->Parts().count()==0) 105 if (body->Parts().count()==0)
106 { 106 {
107 return; 107 return;
108 } 108 }
109 AttachItem * curItem=0; 109 AttachItem * curItem=0;
110 AttachItem * parentItem = 0; 110 AttachItem * parentItem = 0;
111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
112 QString desc,fsize; 112 QString desc,fsize;
113 double s = body->Description()->Size(); 113 double s = body->Description()->Size();
114 int w; 114 int w;
115 w=0; 115 w=0;
116 116
117 while (s>1024) 117 while (s>1024)
118 { 118 {
119 s/=1024; 119 s/=1024;
120 ++w; 120 ++w;
121 if (w>=2) break; 121 if (w>=2) break;
122 } 122 }
123 123
124 QString q=""; 124 QString q="";
125 switch(w) 125 switch(w)
126 { 126 {
127 case 1: 127 case 1:
128 q="k"; 128 q="k";
129 break; 129 break;
130 case 2: 130 case 2:
131 q="M"; 131 q="M";
132 break; 132 break;
133 default: 133 default:
134 break; 134 break;
135 } 135 }
136 136
137 { 137 {
138 /* I did not found a method to make a CONTENT reset on a QTextStream 138 /* I did not found a method to make a CONTENT reset on a QTextStream
139 so I use this construct that the stream will re-constructed in each 139 so I use this construct that the stream will re-constructed in each
140 loop. To let it work, the textstream is packed into a own area of 140 loop. To let it work, the textstream is packed into a own area of
141 code is it will be destructed after finishing its small job. 141 code is it will be destructed after finishing its small job.
142 */ 142 */
143 QTextOStream o(&fsize); 143 QTextOStream o(&fsize);
144 if (w>0) o.precision(2); else o.precision(0); 144 if (w>0) o.precision(2); else o.precision(0);
145 o.setf(QTextStream::fixed); 145 o.setf(QTextStream::fixed);
146 o << s << " " << q << "Byte"; 146 o << s << " " << q << "Byte";
147 } 147 }
148 148
149 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 149 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
150 QString filename = ""; 150 QString filename = "";
151 151
152 for (unsigned int i = 0; i < body->Parts().count();++i) 152 for (unsigned int i = 0; i < body->Parts().count();++i)
153 { 153 {
154 filename = ""; 154 filename = "";
155 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 155 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
156 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 156 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
157 for (;it!=body->Parts()[i]->Parameters().end();++it) 157 for (;it!=body->Parts()[i]->Parameters().end();++it)
158 { 158 {
159 if (it.key().lower()=="name") 159 if (it.key().lower()=="name")
160 { 160 {
161 filename=it.data(); 161 filename=it.data();
162 } 162 }
163 } 163 }
164 s = body->Parts()[i]->Size(); 164 s = body->Parts()[i]->Size();
165 w = 0; 165 w = 0;
166 while (s>1024) 166 while (s>1024)
167 { 167 {
168 s/=1024; 168 s/=1024;
169 ++w; 169 ++w;
170 if (w>=2) break; 170 if (w>=2) break;
171 } 171 }
172 switch(w) 172 switch(w)
173 { 173 {
174 case 1: 174 case 1:
175 q="k"; 175 q="k";
176 break; 176 break;
177 case 2: 177 case 2:
178 q="M"; 178 q="M";
179 break; 179 break;
180 default: 180 default:
181 q=""; 181 q="";
182 break; 182 break;
183 } 183 }
184 QTextOStream o(&fsize); 184 QTextOStream o(&fsize);
185 if (w>0) o.precision(2); else o.precision(0); 185 if (w>0) o.precision(2); else o.precision(0);
186 o.setf(QTextStream::fixed); 186 o.setf(QTextStream::fixed);
187 o << s << " " << q << "Byte"; 187 o << s << " " << q << "Byte";
188 desc = body->Parts()[i]->Description(); 188 desc = body->Parts()[i]->Description();
189 parentItem = searchParent(body->Parts()[i]->Positionlist()); 189 parentItem = searchParent(body->Parts()[i]->Positionlist());
190 if (parentItem) 190 if (parentItem)
191 { 191 {
192 AttachItem*temp = lastChild(parentItem); 192 AttachItem*temp = lastChild(parentItem);
193 if (temp) curItem = temp; 193 if (temp) curItem = temp;
194 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 194 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
195 attachments->setRootIsDecorated(true); 195 attachments->setRootIsDecorated(true);
196 curItem = parentItem; 196 curItem = parentItem;
197 } 197 }
198 else 198 else
199 { 199 {
200 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 200 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
201 } 201 }
202 } 202 }
203} 203}
204 204
205 205
206void ViewMail::slotShowHtml( bool state ) 206void ViewMail::slotShowHtml( bool state )
207{ 207{
208 m_showHtml = state; 208 m_showHtml = state;
209 setText(); 209 setText();
210} 210}
211 211
212void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 212void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
213{ 213{
214 if (!item ) 214 if (!item )
215 return; 215 return;
216 216
217 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 217 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
218 { 218 {
219 setText(); 219 setText();
220 return; 220 return;
221 } 221 }
222 QPopupMenu *menu = new QPopupMenu(); 222 QPopupMenu *menu = new QPopupMenu();
223 int ret=0; 223 int ret=0;
224 224
225 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 225 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
226 { 226 {
227 menu->insertItem( i18n( "Show Text" ), 1 ); 227 menu->insertItem( i18n( "Show Text" ), 1 );
228 } 228 }
229 if (item->text(0).left(6)=="image/") { 229 if (item->text(0).left(6)=="image/") {
230 menu->insertItem(i18n("Display image preview"),2); 230 menu->insertItem(i18n("Display image preview"),2);
231 } 231 }
232 menu->insertItem( i18n( "Save Attachment" ), 0 ); 232 menu->insertItem( i18n( "Save Attachment" ), 0 );
233 menu->insertSeparator(1); 233 menu->insertSeparator(1);
234 234
235 ret = menu->exec( point, 0 ); 235 ret = menu->exec( point, 0 );
236 236
237 switch(ret) 237 switch(ret)
238 { 238 {
239 case 0: 239 case 0:
240 { 240 {
241 //MimeTypes types; 241 //MimeTypes types;
242 //types.insert( "all", "*" ); 242 //types.insert( "all", "*" );
243 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 243 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
244 244
245 if( !str.isEmpty() ) 245 if( !str.isEmpty() )
246 { 246 {
247 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 247 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
248 if (content) 248 if (content)
249 { 249 {
250 QFile output(str); 250 QFile output(str);
251 output.open(IO_WriteOnly); 251 output.open(IO_WriteOnly);
252 output.writeBlock(content->Content(),content->Length()); 252 output.writeBlock(content->Content(),content->Length());
253 output.close(); 253 output.close();
254 delete content; 254 delete content;
255 } 255 }
256 } 256 }
257 } 257 }
258 break ; 258 break ;
259 259
260 case 2: 260 case 2:
261 { 261 {
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 QString tmpfile = locateLocal( "tmp", "opiemail-image"); 263 QString tmpfile = locateLocal( "tmp", "opiemail-image");
264#else 264#else
265 QString tmpfile = "/tmp/opiemail-image"; 265 QString tmpfile = "/tmp/opiemail-image";
266#endif 266#endif
267 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 267 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
268 if (content) { 268 if (content) {
269 QFile output(tmpfile); 269 QFile output(tmpfile);
270 output.open(IO_WriteOnly); 270 output.open(IO_WriteOnly);
271 output.writeBlock(content->Content(),content->Length()); 271 output.writeBlock(content->Content(),content->Length());
272 output.close(); 272 output.close();
273 delete content; 273 delete content;
274 MailImageDlg iview(""); 274 MailImageDlg iview("");
275 iview.setName(tmpfile); 275 iview.setName(tmpfile);
276 KApplication::execDialog(&iview); 276 KApplication::execDialog(&iview);
277 output.remove(); 277 output.remove();
278 } 278 }
279 } 279 }
280 break; 280 break;
281 case 1: 281 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 283 {
284 setText(); 284 setText();
285 } 285 }
286 else 286 else
287 { 287 {
288 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 289 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
291 } 291 }
292 } 292 }
293 break; 293 break;
294 } 294 }
295 delete menu; 295 delete menu;
296} 296}
297 297
298 298
299void ViewMail::setMail(const RecMailP&mail ) 299void ViewMail::setMail(const RecMailP&mail )
300{ 300{
301 301
302 m_recMail = mail; 302 m_recMail = mail;
303 303
304 m_mail[0] = mail->getFrom(); 304 m_mail[0] = mail->getFrom();
305 m_mail[1] = mail->getSubject(); 305 m_mail[1] = mail->getSubject();
306 m_mail[3] = mail->getDate(); 306 m_mail[3] = mail->getDate();
307 m_mail[4] = mail->Msgid(); 307 m_mail[4] = mail->Msgid();
308 308
309 m_mail2[0] = mail->To(); 309 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 310 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 311 m_mail2[2] = mail->Bcc();
312 312
313 setText(); 313 setText();
314} 314}
315 315
316 316
317 317
318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
319 : ViewMailBase(parent, name, fl), _inLoop(false) 319 : ViewMailBase(parent, name, fl), _inLoop(false)
320{ 320{
321 m_gotBody = false; 321 m_gotBody = false;
322 deleted = false; 322 deleted = false;
323 323
324 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 324 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
325 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 325 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
329 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); 329 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) );
330 330
331 attachments->setEnabled(m_gotBody); 331 attachments->setEnabled(m_gotBody);
332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 333
334 readConfig(); 334 readConfig();
335 attachments->setSorting(-1); 335 attachments->setSorting(-1);
336} 336}
337 337
338void ViewMail::readConfig() 338void ViewMail::readConfig()
339{ 339{
340 340
341 setFont ( KOPrefs::instance()->mReadFont ); 341 setFont ( KOPrefs::instance()->mReadFont );
342 m_showHtml = KOPrefs::instance()->mViewAsHtml; 342 m_showHtml = KOPrefs::instance()->mViewAsHtml;
343 showHtml->setOn( m_showHtml ); 343 showHtml->setOn( m_showHtml );
344} 344}
345 345
346void ViewMail::setText() 346void ViewMail::setText()
347{ 347{
348 348
349 QString toString; 349 QString toString;
350 QString ccString; 350 QString ccString;
351 QString bccString; 351 QString bccString;
352 352
353 353
354 toString = m_mail2[0].join(","); 354 toString = m_mail2[0].join(",");
355 ccString = m_mail2[1].join(","); 355 ccString = m_mail2[1].join(",");
356 bccString = m_mail2[2].join(","); 356 bccString = m_mail2[2].join(",");
357 357
358 358
359 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 359 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
360 360
361 m_mailHtml = "<html><body>" 361 m_mailHtml = "<html><body>"
362 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 362 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
363 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 363 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
364 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 364 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
365 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 365 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
366 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 366 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
367 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 367 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
368 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 368 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
369 "</td></tr></table><font>"; 369 "</td></tr></table><font>";
370 370
371 if ( !m_showHtml ) 371 if ( !m_showHtml )
372 { 372 {
373 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 373 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
374 } 374 }
375 else 375 else
376 { 376 {
377 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 377 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
378 } 378 }
379 // remove later in favor of a real handling 379 // remove later in favor of a real handling
380 m_gotBody = true; 380 m_gotBody = true;
381} 381}
382 382
383 383
384ViewMail::~ViewMail() 384ViewMail::~ViewMail()
385{ 385{
386 m_recMail->Wrapper()->cleanMimeCache(); 386 m_recMail->Wrapper()->cleanMimeCache();
387 hide(); 387 hide();
388} 388}
389 389
390void ViewMail::hide() 390void ViewMail::hide()
391{ 391{
392 QWidget::hide(); 392 QWidget::hide();
393 393
394 if (_inLoop) 394 if (_inLoop)
395 { 395 {
396 _inLoop = false; 396 _inLoop = false;
397 qApp->exit_loop(); 397 qApp->exit_loop();
398 398
399 } 399 }
400 400
401} 401}
402 402
403void ViewMail::exec() 403void ViewMail::exec()
404{ 404{
405 show(); 405 show();
406 406
407 if (!_inLoop) 407 if (!_inLoop)
408 { 408 {
409 _inLoop = true; 409 _inLoop = true;
410 qApp->enter_loop(); 410 qApp->enter_loop();
411 } 411 }
412 412
413} 413}
414 414
415QString ViewMail::deHtml(const QString &string) 415QString ViewMail::deHtml(const QString &string)
416{ 416{
417 QString string_ = string; 417 QString string_ = string;
418 string_.replace(QRegExp("&"), "&amp;"); 418 string_.replace(QRegExp("&"), "&amp;");
419 string_.replace(QRegExp("<"), "&lt;"); 419 string_.replace(QRegExp("<"), "&lt;");
420 string_.replace(QRegExp(">"), "&gt;"); 420 string_.replace(QRegExp(">"), "&gt;");
421 string_.replace(QRegExp("\\n"), "<br>"); 421 string_.replace(QRegExp("\\n"), "<br>");
422 return string_; 422 return string_;
423} 423}
424 424
425void ViewMail::slotReply() 425void ViewMail::slotReply()
426{ 426{
427 if (!m_gotBody) 427 if (!m_gotBody)
428 { 428 {
429 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); 429 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok"));
430 return; 430 return;
431 } 431 }
432 432
433 QString rtext; 433 QString rtext;
434 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 434 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
435 .arg( m_mail[0] ) 435 .arg( m_mail[0] )
436 .arg( m_mail[3] ); 436 .arg( m_mail[3] );
437 437
438 QString text = m_mail[2]; 438 QString text = m_mail[2];
439 QStringList lines = QStringList::split(QRegExp("\\n"), text); 439 QStringList lines = QStringList::split(QRegExp("\\n"), text);
440 QStringList::Iterator it; 440 QStringList::Iterator it;
441 for (it = lines.begin(); it != lines.end(); it++) 441 for (it = lines.begin(); it != lines.end(); it++)
442 { 442 {
443 rtext += "> " + *it + "\n"; 443 rtext += "> " + *it + "\n";
444 } 444 }
445 rtext += "\n"; 445 rtext += "\n";
446 446
447 QString prefix; 447 QString prefix;
448 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 448 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
449 else prefix = "Re: "; // no i18n on purpose 449 else prefix = "Re: "; // no i18n on purpose
450 450
451 Settings *settings = new Settings(); 451 Settings *settings = new Settings();
452 ComposeMail composer( settings ,this, 0, true); 452 ComposeMail composer( settings ,this, 0, true);
453 if (m_recMail->Replyto().isEmpty()) { 453 if (m_recMail->Replyto().isEmpty()) {
454 composer.setTo(m_recMail->getFrom()); 454 composer.setTo(m_recMail->getFrom());
455 } else { 455 } else {
456 composer.setTo(m_recMail->Replyto()); 456 composer.setTo(m_recMail->Replyto());
457 } 457 }
458 composer.setSubject( prefix + m_mail[1] ); 458 composer.setSubject( prefix + m_mail[1] );
459 composer.setMessage( rtext ); 459 composer.setMessage( rtext );
460 composer.setInReplyTo(m_recMail->Msgid()); 460 composer.setInReplyTo(m_recMail->Msgid());
461 composer.setCharset( m_body->getCharset() ); 461 composer.setCharset( m_body->getCharset() );
462 462
463 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 463 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
464 { 464 {
465 m_recMail->Wrapper()->answeredMail(m_recMail); 465 m_recMail->Wrapper()->answeredMail(m_recMail);
466 } 466 }
467 delete settings; 467 delete settings;
468} 468}
469 469
470void ViewMail::slotForward() 470void ViewMail::slotForward()
471{ 471{
472 if (!m_gotBody) 472 if (!m_gotBody)
473 { 473 {
474 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); 474 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok"));
475 return; 475 return;
476 } 476 }
477 477
478 QString ftext; 478 QString ftext;
479 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 479 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
480 .arg( m_mail[0] ); 480 .arg( m_mail[0] );
481 if (!m_mail[3].isNull()) 481 if (!m_mail[3].isNull())
482 ftext += QString("Date: %1\n") 482 ftext += QString("Date: %1\n")
483 .arg( m_mail[3] ); 483 .arg( m_mail[3] );
484 if (!m_mail[0].isNull()) 484 if (!m_mail[0].isNull())
485 ftext += QString("From: %1\n") 485 ftext += QString("From: %1\n")
486 .arg( m_mail[0] ); 486 .arg( m_mail[0] );
487 if (!m_mail[1].isNull()) 487 if (!m_mail[1].isNull())
488 ftext += QString("Subject: %1\n") 488 ftext += QString("Subject: %1\n")
489 .arg( m_mail[1] ); 489 .arg( m_mail[1] );
490 490
491 ftext += QString("\n%1\n") 491 ftext += QString("\n%1\n")
492 .arg( m_mail[2]); 492 .arg( m_mail[2]);
493 493
494 ftext += QString("----- End forwarded message -----\n"); 494 ftext += QString("----- End forwarded message -----\n");
495 495
496 Settings *settings = new Settings(); 496 Settings *settings = new Settings();
497 ComposeMail composer( settings ,this, 0, true); 497 ComposeMail composer( settings ,this, 0, true);
498 composer.setSubject( "Fwd: " + m_mail[1] ); 498 composer.setSubject( "Fwd: " + m_mail[1] );
499 composer.setMessage( ftext ); 499 composer.setMessage( ftext );
500 if ( QDialog::Accepted == KApplication::execDialog( &composer )) 500 if ( QDialog::Accepted == KApplication::execDialog( &composer ))
501 { 501 {
502 } 502 }
503} 503}
504 504
505void ViewMail::slotDeleteMail( ) 505void ViewMail::slotDeleteMail( )
506{ 506{
507 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 507 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
508 { 508 {
509 m_recMail->Wrapper()->deleteMail( m_recMail ); 509 emit deleteAndDisplayNextMail( this);
510 hide(); 510 //m_recMail->Wrapper()->deleteMail( m_recMail );
511 //hide();
511 deleted = true; 512 deleted = true;
512 } 513 }
513} 514}
514 515
515MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 516MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f)
516 : QDialog(parent,name,modal) 517 : QDialog(parent,name,modal)
517{ 518{
518 QVBoxLayout*dlglayout = new QVBoxLayout(this); 519 QVBoxLayout*dlglayout = new QVBoxLayout(this);
519 dlglayout->setSpacing(2); 520 dlglayout->setSpacing(2);
520 dlglayout->setMargin(1); 521 dlglayout->setMargin(1);
521 //m_imageview = new Opie::MM::OImageScrollView(this); 522 //m_imageview = new Opie::MM::OImageScrollView(this);
522 //dlglayout->addWidget(m_imageview); 523 //dlglayout->addWidget(m_imageview);
523} 524}
524 525
525MailImageDlg::~MailImageDlg() 526MailImageDlg::~MailImageDlg()
526{ 527{
527} 528}
528 529
529void MailImageDlg::setName(const QString&fname) 530void MailImageDlg::setName(const QString&fname)
530{ 531{
531 qDebug("viewmail.cpp: MailImageDlg::setName Pending"); 532 qDebug("viewmail.cpp: MailImageDlg::setName Pending");
532 // m_imageview->setImage(fname); 533 // m_imageview->setImage(fname);
533} 534}
diff --git a/kmicromail/viewmail.h b/kmicromail/viewmail.h
index c2c2ce3..d85b8b2 100644
--- a/kmicromail/viewmail.h
+++ b/kmicromail/viewmail.h
@@ -1,88 +1,89 @@
1#ifndef VIEWMAIL_H 1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H 2#define VIEWMAIL_H
3 3
4#include "viewmailbase.h" 4#include "viewmailbase.h"
5#include <libmailwrapper/mailtypes.h> 5#include <libmailwrapper/mailtypes.h>
6 6
7#include <qdialog.h> 7#include <qdialog.h>
8 8
9#include <qlistview.h> 9#include <qlistview.h>
10#include <qmap.h> 10#include <qmap.h>
11#include <qstringlist.h> 11#include <qstringlist.h>
12#include <qvaluelist.h> 12#include <qvaluelist.h>
13 13
14//namespace Opie { namespace MM { class OImageScrollView; } } 14//namespace Opie { namespace MM { class OImageScrollView; } }
15 15
16class AttachItem : public QListViewItem 16class AttachItem : public QListViewItem
17{ 17{
18public: 18public:
19 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 19 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
20 const QString&fsize,int num,const QValueList<int>&path); 20 const QString&fsize,int num,const QValueList<int>&path);
21 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 21 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path); 22 const QString&fsize,int num,const QValueList<int>&path);
23 int Partnumber() { return _partNum; } 23 int Partnumber() { return _partNum; }
24 bool isParentof(const QValueList<int>&path); 24 bool isParentof(const QValueList<int>&path);
25 25
26private: 26private:
27 int _partNum; 27 int _partNum;
28 /* needed for a better display of attachments */ 28 /* needed for a better display of attachments */
29 QValueList<int> _path; 29 QValueList<int> _path;
30}; 30};
31 31
32class ViewMail : public ViewMailBase 32class ViewMail : public ViewMailBase
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); 37 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
38 ~ViewMail(); 38 ~ViewMail();
39 39
40 void hide(); 40 void hide();
41 void exec(); 41 void exec();
42 void setMail(const RecMailP&mail ); 42 void setMail(const RecMailP&mail );
43 void setBody(const RecBodyP&body); 43 void setBody(const RecBodyP&body);
44 bool deleted; 44 bool deleted;
45 signals: 45 signals:
46 void showNextMail(ViewMail*); 46 void showNextMail(ViewMail*);
47 void deleteAndDisplayNextMail(ViewMail *);
47protected: 48protected:
48 QString deHtml(const QString &string); 49 QString deHtml(const QString &string);
49 AttachItem* searchParent(const QValueList<int>&path); 50 AttachItem* searchParent(const QValueList<int>&path);
50 AttachItem* lastChild(AttachItem*parent); 51 AttachItem* lastChild(AttachItem*parent);
51 52
52protected slots: 53protected slots:
53 void slotNextMail() { emit showNextMail(this); }; 54 void slotNextMail() { emit showNextMail(this); };
54 void slotReply(); 55 void slotReply();
55 void slotForward(); 56 void slotForward();
56 void setText(); 57 void setText();
57 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 58 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
58 void slotDeleteMail( ); 59 void slotDeleteMail( );
59 void slotShowHtml( bool ); 60 void slotShowHtml( bool );
60 61
61private: 62private:
62 void readConfig(); 63 void readConfig();
63 64
64 bool _inLoop; 65 bool _inLoop;
65 QString m_mailHtml; 66 QString m_mailHtml;
66 bool m_gotBody; 67 bool m_gotBody;
67 RecBodyP m_body; 68 RecBodyP m_body;
68 RecMailP m_recMail; 69 RecMailP m_recMail;
69 bool m_showHtml; 70 bool m_showHtml;
70 71
71 // 0 from 1 subject 2 bodytext 3 date 72 // 0 from 1 subject 2 bodytext 3 date
72 QMap <int,QString> m_mail; 73 QMap <int,QString> m_mail;
73 // 0 to 1 cc 2 bcc 74 // 0 to 1 cc 2 bcc
74 QMap <int,QStringList> m_mail2; 75 QMap <int,QStringList> m_mail2;
75}; 76};
76 77
77class MailImageDlg:public QDialog 78class MailImageDlg:public QDialog
78{ 79{
79 Q_OBJECT 80 Q_OBJECT
80public: 81public:
81 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); 82 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0);
82 ~MailImageDlg(); 83 ~MailImageDlg();
83 void setName(const QString&); 84 void setName(const QString&);
84protected: 85protected:
85 //Opie::MM::OImageScrollView*m_imageview; 86 //Opie::MM::OImageScrollView*m_imageview;
86}; 87};
87 88
88#endif 89#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 15c5dd9..a46cd87 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1452,2282 +1452,2284 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1452 if (!ok) { 1452 if (!ok) {
1453 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1453 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1454 } 1454 }
1455 realName = realNameList[i]; 1455 realName = realNameList[i];
1456 email = emailList[i]; 1456 email = emailList[i];
1457 assembledName = assembledNameList[i]; 1457 assembledName = assembledNameList[i];
1458 uid = uidList[i]; 1458 uid = uidList[i];
1459 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1459 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1460 1460
1461 if ( birthday.isValid() ){ 1461 if ( birthday.isValid() ){
1462 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1462 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1463 KCal::Attendee::ReqParticipant,uid) ; 1463 KCal::Attendee::ReqParticipant,uid) ;
1464 if ( addAnniversary( birthday, assembledName, a, true ) ) 1464 if ( addAnniversary( birthday, assembledName, a, true ) )
1465 ++addCount; 1465 ++addCount;
1466 } 1466 }
1467 1467
1468 if ( anniversary.isValid() ){ 1468 if ( anniversary.isValid() ){
1469 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1469 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1470 KCal::Attendee::ReqParticipant,uid) ; 1470 KCal::Attendee::ReqParticipant,uid) ;
1471 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1471 if ( addAnniversary( anniversary, assembledName, a, false ) )
1472 ++addCount; 1472 ++addCount;
1473 } 1473 }
1474 } 1474 }
1475 1475
1476 updateView(); 1476 updateView();
1477 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1477 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1478 1478
1479 } 1479 }
1480 1480
1481} 1481}
1482 1482
1483 1483
1484 1484
1485bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1485bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1486{ 1486{
1487 //qDebug("addAnni "); 1487 //qDebug("addAnni ");
1488 Event * ev = new Event(); 1488 Event * ev = new Event();
1489 if ( a ) { 1489 if ( a ) {
1490 ev->addAttendee( a ); 1490 ev->addAttendee( a );
1491 } 1491 }
1492 QString kind; 1492 QString kind;
1493 if ( birthday ) 1493 if ( birthday )
1494 kind = i18n( "Birthday" ); 1494 kind = i18n( "Birthday" );
1495 else 1495 else
1496 kind = i18n( "Anniversary" ); 1496 kind = i18n( "Anniversary" );
1497 ev->setSummary( name + " - " + kind ); 1497 ev->setSummary( name + " - " + kind );
1498 ev->setOrganizer(a->email()); 1498 ev->setOrganizer(a->email());
1499 ev->setCategories( kind ); 1499 ev->setCategories( kind );
1500 ev->setDtStart( QDateTime(date) ); 1500 ev->setDtStart( QDateTime(date) );
1501 ev->setDtEnd( QDateTime(date) ); 1501 ev->setDtEnd( QDateTime(date) );
1502 ev->setFloats( true ); 1502 ev->setFloats( true );
1503 Recurrence * rec = ev->recurrence(); 1503 Recurrence * rec = ev->recurrence();
1504 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1504 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1505 rec->addYearlyNum( date.month() ); 1505 rec->addYearlyNum( date.month() );
1506 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1506 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1507 delete ev; 1507 delete ev;
1508 return false; 1508 return false;
1509 } 1509 }
1510 return true; 1510 return true;
1511 1511
1512} 1512}
1513bool CalendarView::importQtopia( const QString &categories, 1513bool CalendarView::importQtopia( const QString &categories,
1514 const QString &datebook, 1514 const QString &datebook,
1515 const QString &todolist ) 1515 const QString &todolist )
1516{ 1516{
1517 1517
1518 QtopiaFormat qtopiaFormat; 1518 QtopiaFormat qtopiaFormat;
1519 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1519 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1520 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1520 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1521 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1521 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1522 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1522 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1523 1523
1524 updateView(); 1524 updateView();
1525 return true; 1525 return true;
1526 1526
1527#if 0 1527#if 0
1528 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1528 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1529 mCurrentSyncDevice = "qtopia-XML"; 1529 mCurrentSyncDevice = "qtopia-XML";
1530 if ( mSyncManager->mAskForPreferences ) 1530 if ( mSyncManager->mAskForPreferences )
1531 edit_sync_options(); 1531 edit_sync_options();
1532 qApp->processEvents(); 1532 qApp->processEvents();
1533 CalendarLocal* calendar = new CalendarLocal(); 1533 CalendarLocal* calendar = new CalendarLocal();
1534 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1534 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1535 bool syncOK = false; 1535 bool syncOK = false;
1536 QtopiaFormat qtopiaFormat; 1536 QtopiaFormat qtopiaFormat;
1537 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1537 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1538 bool loadOk = true; 1538 bool loadOk = true;
1539 if ( !categories.isEmpty() ) 1539 if ( !categories.isEmpty() )
1540 loadOk = qtopiaFormat.load( calendar, categories ); 1540 loadOk = qtopiaFormat.load( calendar, categories );
1541 if ( loadOk && !datebook.isEmpty() ) 1541 if ( loadOk && !datebook.isEmpty() )
1542 loadOk = qtopiaFormat.load( calendar, datebook ); 1542 loadOk = qtopiaFormat.load( calendar, datebook );
1543 if ( loadOk && !todolist.isEmpty() ) 1543 if ( loadOk && !todolist.isEmpty() )
1544 loadOk = qtopiaFormat.load( calendar, todolist ); 1544 loadOk = qtopiaFormat.load( calendar, todolist );
1545 1545
1546 if ( loadOk ) { 1546 if ( loadOk ) {
1547 getEventViewerDialog()->setSyncMode( true ); 1547 getEventViewerDialog()->setSyncMode( true );
1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1549 getEventViewerDialog()->setSyncMode( false ); 1549 getEventViewerDialog()->setSyncMode( false );
1550 qApp->processEvents(); 1550 qApp->processEvents();
1551 if ( syncOK ) { 1551 if ( syncOK ) {
1552 if ( mSyncManager->mWriteBackFile ) 1552 if ( mSyncManager->mWriteBackFile )
1553 { 1553 {
1554 // write back XML file 1554 // write back XML file
1555 1555
1556 } 1556 }
1557 setModified( true ); 1557 setModified( true );
1558 } 1558 }
1559 } else { 1559 } else {
1560 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1560 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1561 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1561 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1562 question, i18n("Ok")) ; 1562 question, i18n("Ok")) ;
1563 } 1563 }
1564 delete calendar; 1564 delete calendar;
1565 updateView(); 1565 updateView();
1566 return syncOK; 1566 return syncOK;
1567 1567
1568 1568
1569#endif 1569#endif
1570 1570
1571} 1571}
1572 1572
1573void CalendarView::setSyncEventsReadOnly() 1573void CalendarView::setSyncEventsReadOnly()
1574{ 1574{
1575 Event * ev; 1575 Event * ev;
1576 QPtrList<Event> eL = mCalendar->rawEvents(); 1576 QPtrList<Event> eL = mCalendar->rawEvents();
1577 ev = eL.first(); 1577 ev = eL.first();
1578 while ( ev ) { 1578 while ( ev ) {
1579 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1579 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1580 ev->setReadOnly( true ); 1580 ev->setReadOnly( true );
1581 ev = eL.next(); 1581 ev = eL.next();
1582 } 1582 }
1583} 1583}
1584bool CalendarView::openCalendar(QString filename, bool merge) 1584bool CalendarView::openCalendar(QString filename, bool merge)
1585{ 1585{
1586 1586
1587 if (filename.isEmpty()) { 1587 if (filename.isEmpty()) {
1588 return false; 1588 return false;
1589 } 1589 }
1590 1590
1591 if (!QFile::exists(filename)) { 1591 if (!QFile::exists(filename)) {
1592 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1592 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1593 return false; 1593 return false;
1594 } 1594 }
1595 1595
1596 globalFlagBlockAgenda = 1; 1596 globalFlagBlockAgenda = 1;
1597 if (!merge) mCalendar->close(); 1597 if (!merge) mCalendar->close();
1598 1598
1599 mStorage->setFileName( filename ); 1599 mStorage->setFileName( filename );
1600 1600
1601 if ( mStorage->load() ) { 1601 if ( mStorage->load() ) {
1602 if ( merge ) ;//setModified( true ); 1602 if ( merge ) ;//setModified( true );
1603 else { 1603 else {
1604 //setModified( true ); 1604 //setModified( true );
1605 mViewManager->setDocumentId( filename ); 1605 mViewManager->setDocumentId( filename );
1606 mDialogManager->setDocumentId( filename ); 1606 mDialogManager->setDocumentId( filename );
1607 mTodoList->setDocumentId( filename ); 1607 mTodoList->setDocumentId( filename );
1608 } 1608 }
1609 globalFlagBlockAgenda = 2; 1609 globalFlagBlockAgenda = 2;
1610 // if ( getLastSyncEvent() ) 1610 // if ( getLastSyncEvent() )
1611 // getLastSyncEvent()->setReadOnly( true ); 1611 // getLastSyncEvent()->setReadOnly( true );
1612 mCalendar->reInitAlarmSettings(); 1612 mCalendar->reInitAlarmSettings();
1613 setSyncEventsReadOnly(); 1613 setSyncEventsReadOnly();
1614 updateUnmanagedViews(); 1614 updateUnmanagedViews();
1615 updateView(); 1615 updateView();
1616 if ( filename != MainWindow::defaultFileName() ) { 1616 if ( filename != MainWindow::defaultFileName() ) {
1617 saveCalendar( MainWindow::defaultFileName() ); 1617 saveCalendar( MainWindow::defaultFileName() );
1618 } else { 1618 } else {
1619 QFileInfo finf ( MainWindow::defaultFileName()); 1619 QFileInfo finf ( MainWindow::defaultFileName());
1620 if ( finf.exists() ) { 1620 if ( finf.exists() ) {
1621 setLoadedFileVersion( finf.lastModified () ); 1621 setLoadedFileVersion( finf.lastModified () );
1622 } 1622 }
1623 } 1623 }
1624 return true; 1624 return true;
1625 } else { 1625 } else {
1626 // while failing to load, the calendar object could 1626 // while failing to load, the calendar object could
1627 // have become partially populated. Clear it out. 1627 // have become partially populated. Clear it out.
1628 if ( !merge ) { 1628 if ( !merge ) {
1629 mCalendar->close(); 1629 mCalendar->close();
1630 mViewManager->setDocumentId( filename ); 1630 mViewManager->setDocumentId( filename );
1631 mDialogManager->setDocumentId( filename ); 1631 mDialogManager->setDocumentId( filename );
1632 mTodoList->setDocumentId( filename ); 1632 mTodoList->setDocumentId( filename );
1633 } 1633 }
1634 1634
1635 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1635 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1636 1636
1637 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1637 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1638 globalFlagBlockAgenda = 2; 1638 globalFlagBlockAgenda = 2;
1639 mCalendar->reInitAlarmSettings(); 1639 mCalendar->reInitAlarmSettings();
1640 setSyncEventsReadOnly(); 1640 setSyncEventsReadOnly();
1641 updateUnmanagedViews(); 1641 updateUnmanagedViews();
1642 updateView(); 1642 updateView();
1643 } 1643 }
1644 return false; 1644 return false;
1645} 1645}
1646void CalendarView::showOpenError() 1646void CalendarView::showOpenError()
1647{ 1647{
1648 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1648 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1649} 1649}
1650void CalendarView::setLoadedFileVersion(QDateTime dt) 1650void CalendarView::setLoadedFileVersion(QDateTime dt)
1651{ 1651{
1652 loadedFileVersion = dt; 1652 loadedFileVersion = dt;
1653} 1653}
1654bool CalendarView::checkFileChanged(QString fn) 1654bool CalendarView::checkFileChanged(QString fn)
1655{ 1655{
1656 QFileInfo finf ( fn ); 1656 QFileInfo finf ( fn );
1657 if ( !finf.exists() ) 1657 if ( !finf.exists() )
1658 return true; 1658 return true;
1659 QDateTime dt = finf.lastModified (); 1659 QDateTime dt = finf.lastModified ();
1660 if ( dt <= loadedFileVersion ) 1660 if ( dt <= loadedFileVersion )
1661 return false; 1661 return false;
1662 return true; 1662 return true;
1663 1663
1664} 1664}
1665void CalendarView::watchSavedFile() 1665void CalendarView::watchSavedFile()
1666{ 1666{
1667 QFileInfo finf ( MainWindow::defaultFileName()); 1667 QFileInfo finf ( MainWindow::defaultFileName());
1668 if ( !finf.exists() ) 1668 if ( !finf.exists() )
1669 return; 1669 return;
1670 QDateTime dt = finf.lastModified (); 1670 QDateTime dt = finf.lastModified ();
1671 if ( dt < loadedFileVersion ) { 1671 if ( dt < loadedFileVersion ) {
1672 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1672 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1673 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1673 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1674 return; 1674 return;
1675 } 1675 }
1676 loadedFileVersion = dt; 1676 loadedFileVersion = dt;
1677} 1677}
1678 1678
1679bool CalendarView::checkFileVersion(QString fn) 1679bool CalendarView::checkFileVersion(QString fn)
1680{ 1680{
1681 QFileInfo finf ( fn ); 1681 QFileInfo finf ( fn );
1682 if ( !finf.exists() ) 1682 if ( !finf.exists() )
1683 return true; 1683 return true;
1684 QDateTime dt = finf.lastModified (); 1684 QDateTime dt = finf.lastModified ();
1685 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1685 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1686 //qDebug("file on disk version %s",dt.toString().latin1()); 1686 //qDebug("file on disk version %s",dt.toString().latin1());
1687 if ( dt <= loadedFileVersion ) 1687 if ( dt <= loadedFileVersion )
1688 return true; 1688 return true;
1689 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1689 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1690 i18n("KO/Pi Warning"),i18n("Overwrite"), 1690 i18n("KO/Pi Warning"),i18n("Overwrite"),
1691 i18n("Sync+save")); 1691 i18n("Sync+save"));
1692 1692
1693 if ( km == KMessageBox::Cancel ) 1693 if ( km == KMessageBox::Cancel )
1694 return false; 1694 return false;
1695 if ( km == KMessageBox::Yes ) 1695 if ( km == KMessageBox::Yes )
1696 return true; 1696 return true;
1697 1697
1698 setSyncDevice("deleteaftersync" ); 1698 setSyncDevice("deleteaftersync" );
1699 mSyncManager->mAskForPreferences = true; 1699 mSyncManager->mAskForPreferences = true;
1700 mSyncManager->mSyncAlgoPrefs = 3; 1700 mSyncManager->mSyncAlgoPrefs = 3;
1701 mSyncManager->mWriteBackFile = false; 1701 mSyncManager->mWriteBackFile = false;
1702 mSyncManager->mWriteBackExistingOnly = false; 1702 mSyncManager->mWriteBackExistingOnly = false;
1703 mSyncManager->mShowSyncSummary = false; 1703 mSyncManager->mShowSyncSummary = false;
1704 syncCalendar( fn, 3 ); 1704 syncCalendar( fn, 3 );
1705 Event * e = getLastSyncEvent(); 1705 Event * e = getLastSyncEvent();
1706 mCalendar->deleteEvent ( e ); 1706 mCalendar->deleteEvent ( e );
1707 updateView(); 1707 updateView();
1708 return true; 1708 return true;
1709} 1709}
1710 1710
1711bool CalendarView::saveCalendar( QString filename ) 1711bool CalendarView::saveCalendar( QString filename )
1712{ 1712{
1713 1713
1714 // Store back all unsaved data into calendar object 1714 // Store back all unsaved data into calendar object
1715 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1715 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1716 if ( mViewManager->currentView() ) 1716 if ( mViewManager->currentView() )
1717 mViewManager->currentView()->flushView(); 1717 mViewManager->currentView()->flushView();
1718 1718
1719 1719
1720 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1720 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1721 mStorage->setSaveFormat( new ICalFormat() ); 1721 mStorage->setSaveFormat( new ICalFormat() );
1722 mStorage->setFileName( filename ); 1722 mStorage->setFileName( filename );
1723 bool success; 1723 bool success;
1724 success = mStorage->save(); 1724 success = mStorage->save();
1725 if ( !success ) { 1725 if ( !success ) {
1726 return false; 1726 return false;
1727 } 1727 }
1728 if ( filename == MainWindow::defaultFileName() ) { 1728 if ( filename == MainWindow::defaultFileName() ) {
1729 setLoadedFileVersion( lfv ); 1729 setLoadedFileVersion( lfv );
1730 watchSavedFile(); 1730 watchSavedFile();
1731 } 1731 }
1732 return true; 1732 return true;
1733} 1733}
1734 1734
1735void CalendarView::closeCalendar() 1735void CalendarView::closeCalendar()
1736{ 1736{
1737 1737
1738 // child windows no longer valid 1738 // child windows no longer valid
1739 emit closingDown(); 1739 emit closingDown();
1740 1740
1741 mCalendar->close(); 1741 mCalendar->close();
1742 setModified(false); 1742 setModified(false);
1743 updateView(); 1743 updateView();
1744} 1744}
1745 1745
1746void CalendarView::archiveCalendar() 1746void CalendarView::archiveCalendar()
1747{ 1747{
1748 mDialogManager->showArchiveDialog(); 1748 mDialogManager->showArchiveDialog();
1749} 1749}
1750 1750
1751 1751
1752void CalendarView::readSettings() 1752void CalendarView::readSettings()
1753{ 1753{
1754 1754
1755 1755
1756 // mViewManager->showAgendaView(); 1756 // mViewManager->showAgendaView();
1757 QString str; 1757 QString str;
1758 //qDebug("CalendarView::readSettings() "); 1758 //qDebug("CalendarView::readSettings() ");
1759 // read settings from the KConfig, supplying reasonable 1759 // read settings from the KConfig, supplying reasonable
1760 // defaults where none are to be found 1760 // defaults where none are to be found
1761 KConfig *config = KOGlobals::config(); 1761 KConfig *config = KOGlobals::config();
1762#ifndef KORG_NOSPLITTER 1762#ifndef KORG_NOSPLITTER
1763 config->setGroup("KOrganizer Geometry"); 1763 config->setGroup("KOrganizer Geometry");
1764 1764
1765 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1765 QValueList<int> sizes = config->readIntListEntry("Separator1");
1766 if (sizes.count() != 2) { 1766 if (sizes.count() != 2) {
1767 sizes << mDateNavigator->minimumSizeHint().width(); 1767 sizes << mDateNavigator->minimumSizeHint().width();
1768 sizes << 300; 1768 sizes << 300;
1769 } 1769 }
1770 mPanner->setSizes(sizes); 1770 mPanner->setSizes(sizes);
1771 1771
1772 sizes = config->readIntListEntry("Separator2"); 1772 sizes = config->readIntListEntry("Separator2");
1773 if ( ( mResourceView && sizes.count() == 4 ) || 1773 if ( ( mResourceView && sizes.count() == 4 ) ||
1774 ( !mResourceView && sizes.count() == 3 ) ) { 1774 ( !mResourceView && sizes.count() == 3 ) ) {
1775 mLeftSplitter->setSizes(sizes); 1775 mLeftSplitter->setSizes(sizes);
1776 } 1776 }
1777#endif 1777#endif
1778 globalFlagBlockAgenda = 1; 1778 globalFlagBlockAgenda = 1;
1779 mViewManager->showAgendaView(); 1779 mViewManager->showAgendaView();
1780 //mViewManager->readSettings( config ); 1780 //mViewManager->readSettings( config );
1781 mTodoList->restoreLayout(config,QString("Todo Layout")); 1781 mTodoList->restoreLayout(config,QString("Todo Layout"));
1782 readFilterSettings(config); 1782 readFilterSettings(config);
1783 config->setGroup( "Views" ); 1783 config->setGroup( "Views" );
1784 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1784 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1785 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1785 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1786 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1786 else if ( dateCount == 7 ) mNavigator->selectWeek();
1787 else mNavigator->selectDates( dateCount ); 1787 else mNavigator->selectDates( dateCount );
1788 // mViewManager->readSettings( config ); 1788 // mViewManager->readSettings( config );
1789 updateConfig(); 1789 updateConfig();
1790 globalFlagBlockAgenda = 2; 1790 globalFlagBlockAgenda = 2;
1791 mViewManager->readSettings( config ); 1791 mViewManager->readSettings( config );
1792#ifdef DESKTOP_VERSION 1792#ifdef DESKTOP_VERSION
1793 config->setGroup("WidgetLayout"); 1793 config->setGroup("WidgetLayout");
1794 QStringList list; 1794 QStringList list;
1795 list = config->readListEntry("MainLayout"); 1795 list = config->readListEntry("MainLayout");
1796 int x,y,w,h; 1796 int x,y,w,h;
1797 if ( ! list.isEmpty() ) { 1797 if ( ! list.isEmpty() ) {
1798 x = list[0].toInt(); 1798 x = list[0].toInt();
1799 y = list[1].toInt(); 1799 y = list[1].toInt();
1800 w = list[2].toInt(); 1800 w = list[2].toInt();
1801 h = list[3].toInt(); 1801 h = list[3].toInt();
1802 topLevelWidget()->setGeometry(x,y,w,h); 1802 topLevelWidget()->setGeometry(x,y,w,h);
1803 1803
1804 } else { 1804 } else {
1805 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1805 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1806 } 1806 }
1807 list = config->readListEntry("EditEventLayout"); 1807 list = config->readListEntry("EditEventLayout");
1808 if ( ! list.isEmpty() ) { 1808 if ( ! list.isEmpty() ) {
1809 x = list[0].toInt(); 1809 x = list[0].toInt();
1810 y = list[1].toInt(); 1810 y = list[1].toInt();
1811 w = list[2].toInt(); 1811 w = list[2].toInt();
1812 h = list[3].toInt(); 1812 h = list[3].toInt();
1813 mEventEditor->setGeometry(x,y,w,h); 1813 mEventEditor->setGeometry(x,y,w,h);
1814 1814
1815 } 1815 }
1816 list = config->readListEntry("EditTodoLayout"); 1816 list = config->readListEntry("EditTodoLayout");
1817 if ( ! list.isEmpty() ) { 1817 if ( ! list.isEmpty() ) {
1818 x = list[0].toInt(); 1818 x = list[0].toInt();
1819 y = list[1].toInt(); 1819 y = list[1].toInt();
1820 w = list[2].toInt(); 1820 w = list[2].toInt();
1821 h = list[3].toInt(); 1821 h = list[3].toInt();
1822 mTodoEditor->setGeometry(x,y,w,h); 1822 mTodoEditor->setGeometry(x,y,w,h);
1823 1823
1824 } 1824 }
1825 list = config->readListEntry("ViewerLayout"); 1825 list = config->readListEntry("ViewerLayout");
1826 if ( ! list.isEmpty() ) { 1826 if ( ! list.isEmpty() ) {
1827 x = list[0].toInt(); 1827 x = list[0].toInt();
1828 y = list[1].toInt(); 1828 y = list[1].toInt();
1829 w = list[2].toInt(); 1829 w = list[2].toInt();
1830 h = list[3].toInt(); 1830 h = list[3].toInt();
1831 getEventViewerDialog()->setGeometry(x,y,w,h); 1831 getEventViewerDialog()->setGeometry(x,y,w,h);
1832 } 1832 }
1833#endif 1833#endif
1834 1834
1835} 1835}
1836 1836
1837 1837
1838void CalendarView::writeSettings() 1838void CalendarView::writeSettings()
1839{ 1839{
1840 // kdDebug() << "CalendarView::writeSettings" << endl; 1840 // kdDebug() << "CalendarView::writeSettings" << endl;
1841 1841
1842 KConfig *config = KOGlobals::config(); 1842 KConfig *config = KOGlobals::config();
1843 1843
1844#ifndef KORG_NOSPLITTER 1844#ifndef KORG_NOSPLITTER
1845 config->setGroup("KOrganizer Geometry"); 1845 config->setGroup("KOrganizer Geometry");
1846 1846
1847 QValueList<int> list = mPanner->sizes(); 1847 QValueList<int> list = mPanner->sizes();
1848 config->writeEntry("Separator1",list); 1848 config->writeEntry("Separator1",list);
1849 1849
1850 list = mLeftSplitter->sizes(); 1850 list = mLeftSplitter->sizes();
1851 config->writeEntry("Separator2",list); 1851 config->writeEntry("Separator2",list);
1852#endif 1852#endif
1853 1853
1854 mViewManager->writeSettings( config ); 1854 mViewManager->writeSettings( config );
1855 mTodoList->saveLayout(config,QString("Todo Layout")); 1855 mTodoList->saveLayout(config,QString("Todo Layout"));
1856 mDialogManager->writeSettings( config ); 1856 mDialogManager->writeSettings( config );
1857 //KOPrefs::instance()->usrWriteConfig(); 1857 //KOPrefs::instance()->usrWriteConfig();
1858 KOPrefs::instance()->writeConfig(); 1858 KOPrefs::instance()->writeConfig();
1859 1859
1860 writeFilterSettings(config); 1860 writeFilterSettings(config);
1861 1861
1862 config->setGroup( "Views" ); 1862 config->setGroup( "Views" );
1863 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1863 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1864 1864
1865#ifdef DESKTOP_VERSION 1865#ifdef DESKTOP_VERSION
1866 config->setGroup("WidgetLayout"); 1866 config->setGroup("WidgetLayout");
1867 QStringList list ;//= config->readListEntry("MainLayout"); 1867 QStringList list ;//= config->readListEntry("MainLayout");
1868 int x,y,w,h; 1868 int x,y,w,h;
1869 QWidget* wid; 1869 QWidget* wid;
1870 wid = topLevelWidget(); 1870 wid = topLevelWidget();
1871 x = wid->geometry().x(); 1871 x = wid->geometry().x();
1872 y = wid->geometry().y(); 1872 y = wid->geometry().y();
1873 w = wid->width(); 1873 w = wid->width();
1874 h = wid->height(); 1874 h = wid->height();
1875 list.clear(); 1875 list.clear();
1876 list << QString::number( x ); 1876 list << QString::number( x );
1877 list << QString::number( y ); 1877 list << QString::number( y );
1878 list << QString::number( w ); 1878 list << QString::number( w );
1879 list << QString::number( h ); 1879 list << QString::number( h );
1880 config->writeEntry("MainLayout",list ); 1880 config->writeEntry("MainLayout",list );
1881 1881
1882 wid = mEventEditor; 1882 wid = mEventEditor;
1883 x = wid->geometry().x(); 1883 x = wid->geometry().x();
1884 y = wid->geometry().y(); 1884 y = wid->geometry().y();
1885 w = wid->width(); 1885 w = wid->width();
1886 h = wid->height(); 1886 h = wid->height();
1887 list.clear(); 1887 list.clear();
1888 list << QString::number( x ); 1888 list << QString::number( x );
1889 list << QString::number( y ); 1889 list << QString::number( y );
1890 list << QString::number( w ); 1890 list << QString::number( w );
1891 list << QString::number( h ); 1891 list << QString::number( h );
1892 config->writeEntry("EditEventLayout",list ); 1892 config->writeEntry("EditEventLayout",list );
1893 1893
1894 wid = mTodoEditor; 1894 wid = mTodoEditor;
1895 x = wid->geometry().x(); 1895 x = wid->geometry().x();
1896 y = wid->geometry().y(); 1896 y = wid->geometry().y();
1897 w = wid->width(); 1897 w = wid->width();
1898 h = wid->height(); 1898 h = wid->height();
1899 list.clear(); 1899 list.clear();
1900 list << QString::number( x ); 1900 list << QString::number( x );
1901 list << QString::number( y ); 1901 list << QString::number( y );
1902 list << QString::number( w ); 1902 list << QString::number( w );
1903 list << QString::number( h ); 1903 list << QString::number( h );
1904 config->writeEntry("EditTodoLayout",list ); 1904 config->writeEntry("EditTodoLayout",list );
1905 wid = getEventViewerDialog(); 1905 wid = getEventViewerDialog();
1906 x = wid->geometry().x(); 1906 x = wid->geometry().x();
1907 y = wid->geometry().y(); 1907 y = wid->geometry().y();
1908 w = wid->width(); 1908 w = wid->width();
1909 h = wid->height(); 1909 h = wid->height();
1910 list.clear(); 1910 list.clear();
1911 list << QString::number( x ); 1911 list << QString::number( x );
1912 list << QString::number( y ); 1912 list << QString::number( y );
1913 list << QString::number( w ); 1913 list << QString::number( w );
1914 list << QString::number( h ); 1914 list << QString::number( h );
1915 config->writeEntry("ViewerLayout",list ); 1915 config->writeEntry("ViewerLayout",list );
1916 wid = mDialogManager->getSearchDialog(); 1916 wid = mDialogManager->getSearchDialog();
1917 if ( wid ) { 1917 if ( wid ) {
1918 x = wid->geometry().x(); 1918 x = wid->geometry().x();
1919 y = wid->geometry().y(); 1919 y = wid->geometry().y();
1920 w = wid->width(); 1920 w = wid->width();
1921 h = wid->height(); 1921 h = wid->height();
1922 list.clear(); 1922 list.clear();
1923 list << QString::number( x ); 1923 list << QString::number( x );
1924 list << QString::number( y ); 1924 list << QString::number( y );
1925 list << QString::number( w ); 1925 list << QString::number( w );
1926 list << QString::number( h ); 1926 list << QString::number( h );
1927 config->writeEntry("SearchLayout",list ); 1927 config->writeEntry("SearchLayout",list );
1928 } 1928 }
1929#endif 1929#endif
1930 1930
1931 1931
1932 config->sync(); 1932 config->sync();
1933} 1933}
1934 1934
1935void CalendarView::readFilterSettings(KConfig *config) 1935void CalendarView::readFilterSettings(KConfig *config)
1936{ 1936{
1937 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1937 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1938 1938
1939 mFilters.clear(); 1939 mFilters.clear();
1940 1940
1941 config->setGroup("General"); 1941 config->setGroup("General");
1942 QStringList filterList = config->readListEntry("CalendarFilters"); 1942 QStringList filterList = config->readListEntry("CalendarFilters");
1943 1943
1944 QStringList::ConstIterator it = filterList.begin(); 1944 QStringList::ConstIterator it = filterList.begin();
1945 QStringList::ConstIterator end = filterList.end(); 1945 QStringList::ConstIterator end = filterList.end();
1946 while(it != end) { 1946 while(it != end) {
1947 // kdDebug() << " filter: " << (*it) << endl; 1947 // kdDebug() << " filter: " << (*it) << endl;
1948 1948
1949 CalFilter *filter; 1949 CalFilter *filter;
1950 filter = new CalFilter(*it); 1950 filter = new CalFilter(*it);
1951 config->setGroup("Filter_" + (*it)); 1951 config->setGroup("Filter_" + (*it));
1952 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1952 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1953 filter->setCriteria(config->readNumEntry("Criteria",0)); 1953 filter->setCriteria(config->readNumEntry("Criteria",0));
1954 filter->setCategoryList(config->readListEntry("CategoryList")); 1954 filter->setCategoryList(config->readListEntry("CategoryList"));
1955 mFilters.append(filter); 1955 mFilters.append(filter);
1956 1956
1957 ++it; 1957 ++it;
1958 } 1958 }
1959 1959
1960 if (mFilters.count() == 0) { 1960 if (mFilters.count() == 0) {
1961 CalFilter *filter = new CalFilter(i18n("Default")); 1961 CalFilter *filter = new CalFilter(i18n("Default"));
1962 mFilters.append(filter); 1962 mFilters.append(filter);
1963 } 1963 }
1964 mFilterView->updateFilters(); 1964 mFilterView->updateFilters();
1965 config->setGroup("FilterView"); 1965 config->setGroup("FilterView");
1966 1966
1967 mFilterView->blockSignals(true); 1967 mFilterView->blockSignals(true);
1968 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1968 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1969 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1969 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1970 mFilterView->blockSignals(false); 1970 mFilterView->blockSignals(false);
1971 // We do it manually to avoid it being done twice by the above calls 1971 // We do it manually to avoid it being done twice by the above calls
1972 updateFilter(); 1972 updateFilter();
1973} 1973}
1974 1974
1975void CalendarView::writeFilterSettings(KConfig *config) 1975void CalendarView::writeFilterSettings(KConfig *config)
1976{ 1976{
1977 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1977 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1978 1978
1979 QStringList filterList; 1979 QStringList filterList;
1980 1980
1981 CalFilter *filter = mFilters.first(); 1981 CalFilter *filter = mFilters.first();
1982 while(filter) { 1982 while(filter) {
1983 // kdDebug() << " fn: " << filter->name() << endl; 1983 // kdDebug() << " fn: " << filter->name() << endl;
1984 filterList << filter->name(); 1984 filterList << filter->name();
1985 config->setGroup("Filter_" + filter->name()); 1985 config->setGroup("Filter_" + filter->name());
1986 config->writeEntry("Criteria",filter->criteria()); 1986 config->writeEntry("Criteria",filter->criteria());
1987 config->writeEntry("CategoryList",filter->categoryList()); 1987 config->writeEntry("CategoryList",filter->categoryList());
1988 filter = mFilters.next(); 1988 filter = mFilters.next();
1989 } 1989 }
1990 config->setGroup("General"); 1990 config->setGroup("General");
1991 config->writeEntry("CalendarFilters",filterList); 1991 config->writeEntry("CalendarFilters",filterList);
1992 1992
1993 config->setGroup("FilterView"); 1993 config->setGroup("FilterView");
1994 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1994 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1995 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1995 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1996} 1996}
1997 1997
1998 1998
1999void CalendarView::goToday() 1999void CalendarView::goToday()
2000{ 2000{
2001 if ( mViewManager->currentView()->isMonthView() ) 2001 if ( mViewManager->currentView()->isMonthView() )
2002 mNavigator->selectTodayMonth(); 2002 mNavigator->selectTodayMonth();
2003 else 2003 else
2004 mNavigator->selectToday(); 2004 mNavigator->selectToday();
2005} 2005}
2006 2006
2007void CalendarView::goNext() 2007void CalendarView::goNext()
2008{ 2008{
2009 mNavigator->selectNext(); 2009 mNavigator->selectNext();
2010} 2010}
2011 2011
2012void CalendarView::goPrevious() 2012void CalendarView::goPrevious()
2013{ 2013{
2014 mNavigator->selectPrevious(); 2014 mNavigator->selectPrevious();
2015} 2015}
2016void CalendarView::goNextMonth() 2016void CalendarView::goNextMonth()
2017{ 2017{
2018 mNavigator->selectNextMonth(); 2018 mNavigator->selectNextMonth();
2019} 2019}
2020 2020
2021void CalendarView::goPreviousMonth() 2021void CalendarView::goPreviousMonth()
2022{ 2022{
2023 mNavigator->selectPreviousMonth(); 2023 mNavigator->selectPreviousMonth();
2024} 2024}
2025void CalendarView::writeLocale() 2025void CalendarView::writeLocale()
2026{ 2026{
2027 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2027 //KPimGlobalPrefs::instance()->setGlobalConfig();
2028#if 0 2028#if 0
2029 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2029 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2030 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2030 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2031 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2031 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2032 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2032 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2033 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2033 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2034 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2034 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2035 dummy = KOPrefs::instance()->mUserDateFormatShort; 2035 dummy = KOPrefs::instance()->mUserDateFormatShort;
2036 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2036 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2037 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2037 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2038 KOPrefs::instance()->mDaylightsavingStart, 2038 KOPrefs::instance()->mDaylightsavingStart,
2039 KOPrefs::instance()->mDaylightsavingEnd ); 2039 KOPrefs::instance()->mDaylightsavingEnd );
2040 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2040 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2041#endif 2041#endif
2042} 2042}
2043void CalendarView::updateConfig() 2043void CalendarView::updateConfig()
2044{ 2044{
2045 writeLocale(); 2045 writeLocale();
2046 if ( KOPrefs::instance()->mUseAppColors ) 2046 if ( KOPrefs::instance()->mUseAppColors )
2047 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2047 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2048 emit configChanged(); 2048 emit configChanged();
2049 mTodoList->updateConfig(); 2049 mTodoList->updateConfig();
2050 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2050 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2051 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2051 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2052 // To make the "fill window" configurations work 2052 // To make the "fill window" configurations work
2053 //mViewManager->raiseCurrentView(); 2053 //mViewManager->raiseCurrentView();
2054} 2054}
2055 2055
2056 2056
2057void CalendarView::eventChanged(Event *event) 2057void CalendarView::eventChanged(Event *event)
2058{ 2058{
2059 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2059 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2060 //updateUnmanagedViews(); 2060 //updateUnmanagedViews();
2061} 2061}
2062 2062
2063void CalendarView::eventAdded(Event *event) 2063void CalendarView::eventAdded(Event *event)
2064{ 2064{
2065 changeEventDisplay(event,KOGlobals::EVENTADDED); 2065 changeEventDisplay(event,KOGlobals::EVENTADDED);
2066} 2066}
2067 2067
2068void CalendarView::eventToBeDeleted(Event *) 2068void CalendarView::eventToBeDeleted(Event *)
2069{ 2069{
2070 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2070 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2071} 2071}
2072 2072
2073void CalendarView::eventDeleted() 2073void CalendarView::eventDeleted()
2074{ 2074{
2075 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2075 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2076} 2076}
2077void CalendarView::changeTodoDisplay(Todo *which, int action) 2077void CalendarView::changeTodoDisplay(Todo *which, int action)
2078{ 2078{
2079 changeIncidenceDisplay((Incidence *)which, action); 2079 changeIncidenceDisplay((Incidence *)which, action);
2080 mDateNavigator->updateView(); //LR 2080 mDateNavigator->updateView(); //LR
2081 //mDialogManager->updateSearchDialog(); 2081 //mDialogManager->updateSearchDialog();
2082 2082
2083 if (which) { 2083 if (which) {
2084 mViewManager->updateWNview(); 2084 mViewManager->updateWNview();
2085 //mTodoList->updateView(); 2085 //mTodoList->updateView();
2086 } 2086 }
2087 2087
2088} 2088}
2089 2089
2090void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2090void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2091{ 2091{
2092 updateUnmanagedViews(); 2092 updateUnmanagedViews();
2093 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2093 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2094 if ( action == KOGlobals::EVENTDELETED ) { //delete 2094 if ( action == KOGlobals::EVENTDELETED ) { //delete
2095 mCalendar->checkAlarmForIncidence( 0, true ); 2095 mCalendar->checkAlarmForIncidence( 0, true );
2096 if ( mEventViewerDialog ) 2096 if ( mEventViewerDialog )
2097 mEventViewerDialog->hide(); 2097 mEventViewerDialog->hide();
2098 } 2098 }
2099 else 2099 else
2100 mCalendar->checkAlarmForIncidence( which , false ); 2100 mCalendar->checkAlarmForIncidence( which , false );
2101} 2101}
2102 2102
2103// most of the changeEventDisplays() right now just call the view's 2103// most of the changeEventDisplays() right now just call the view's
2104// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2104// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2105void CalendarView::changeEventDisplay(Event *which, int action) 2105void CalendarView::changeEventDisplay(Event *which, int action)
2106{ 2106{
2107 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2107 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2108 changeIncidenceDisplay((Incidence *)which, action); 2108 changeIncidenceDisplay((Incidence *)which, action);
2109 mDateNavigator->updateView(); 2109 mDateNavigator->updateView();
2110 //mDialogManager->updateSearchDialog(); 2110 //mDialogManager->updateSearchDialog();
2111 2111
2112 if (which) { 2112 if (which) {
2113 // If there is an event view visible update the display 2113 // If there is an event view visible update the display
2114 mViewManager->currentView()->changeEventDisplay(which,action); 2114 mViewManager->currentView()->changeEventDisplay(which,action);
2115 // TODO: check, if update needed 2115 // TODO: check, if update needed
2116 // if (which->getTodoStatus()) { 2116 // if (which->getTodoStatus()) {
2117 mTodoList->updateView(); 2117 mTodoList->updateView();
2118 // } 2118 // }
2119 } else { 2119 } else {
2120 mViewManager->currentView()->updateView(); 2120 mViewManager->currentView()->updateView();
2121 } 2121 }
2122} 2122}
2123 2123
2124 2124
2125void CalendarView::updateTodoViews() 2125void CalendarView::updateTodoViews()
2126{ 2126{
2127 2127
2128 mTodoList->updateView(); 2128 mTodoList->updateView();
2129 mViewManager->currentView()->updateView(); 2129 mViewManager->currentView()->updateView();
2130 2130
2131} 2131}
2132 2132
2133 2133
2134void CalendarView::updateView(const QDate &start, const QDate &end) 2134void CalendarView::updateView(const QDate &start, const QDate &end)
2135{ 2135{
2136 mTodoList->updateView(); 2136 mTodoList->updateView();
2137 mViewManager->updateView(start, end); 2137 mViewManager->updateView(start, end);
2138 //mDateNavigator->updateView(); 2138 //mDateNavigator->updateView();
2139} 2139}
2140 2140
2141void CalendarView::updateView() 2141void CalendarView::updateView()
2142{ 2142{
2143 DateList tmpList = mNavigator->selectedDates(); 2143 DateList tmpList = mNavigator->selectedDates();
2144 2144
2145 // We assume that the navigator only selects consecutive days. 2145 // We assume that the navigator only selects consecutive days.
2146 updateView( tmpList.first(), tmpList.last() ); 2146 updateView( tmpList.first(), tmpList.last() );
2147} 2147}
2148 2148
2149void CalendarView::updateUnmanagedViews() 2149void CalendarView::updateUnmanagedViews()
2150{ 2150{
2151 mDateNavigator->updateDayMatrix(); 2151 mDateNavigator->updateDayMatrix();
2152} 2152}
2153 2153
2154int CalendarView::msgItemDelete() 2154int CalendarView::msgItemDelete()
2155{ 2155{
2156 return KMessageBox::warningContinueCancel(this, 2156 return KMessageBox::warningContinueCancel(this,
2157 i18n("This item will be\npermanently deleted."), 2157 i18n("This item will be\npermanently deleted."),
2158 i18n("KO/Pi Confirmation"),i18n("Delete")); 2158 i18n("KO/Pi Confirmation"),i18n("Delete"));
2159} 2159}
2160 2160
2161 2161
2162void CalendarView::edit_cut() 2162void CalendarView::edit_cut()
2163{ 2163{
2164 Event *anEvent=0; 2164 Event *anEvent=0;
2165 2165
2166 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2166 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2167 2167
2168 if (mViewManager->currentView()->isEventView()) { 2168 if (mViewManager->currentView()->isEventView()) {
2169 if ( incidence && incidence->type() == "Event" ) { 2169 if ( incidence && incidence->type() == "Event" ) {
2170 anEvent = static_cast<Event *>(incidence); 2170 anEvent = static_cast<Event *>(incidence);
2171 } 2171 }
2172 } 2172 }
2173 2173
2174 if (!anEvent) { 2174 if (!anEvent) {
2175 KNotifyClient::beep(); 2175 KNotifyClient::beep();
2176 return; 2176 return;
2177 } 2177 }
2178 DndFactory factory( mCalendar ); 2178 DndFactory factory( mCalendar );
2179 factory.cutEvent(anEvent); 2179 factory.cutEvent(anEvent);
2180 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2180 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2181} 2181}
2182 2182
2183void CalendarView::edit_copy() 2183void CalendarView::edit_copy()
2184{ 2184{
2185 Event *anEvent=0; 2185 Event *anEvent=0;
2186 2186
2187 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2187 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2188 2188
2189 if (mViewManager->currentView()->isEventView()) { 2189 if (mViewManager->currentView()->isEventView()) {
2190 if ( incidence && incidence->type() == "Event" ) { 2190 if ( incidence && incidence->type() == "Event" ) {
2191 anEvent = static_cast<Event *>(incidence); 2191 anEvent = static_cast<Event *>(incidence);
2192 } 2192 }
2193 } 2193 }
2194 2194
2195 if (!anEvent) { 2195 if (!anEvent) {
2196 KNotifyClient::beep(); 2196 KNotifyClient::beep();
2197 return; 2197 return;
2198 } 2198 }
2199 DndFactory factory( mCalendar ); 2199 DndFactory factory( mCalendar );
2200 factory.copyEvent(anEvent); 2200 factory.copyEvent(anEvent);
2201} 2201}
2202 2202
2203void CalendarView::edit_paste() 2203void CalendarView::edit_paste()
2204{ 2204{
2205 QDate date = mNavigator->selectedDates().first(); 2205 QDate date = mNavigator->selectedDates().first();
2206 2206
2207 DndFactory factory( mCalendar ); 2207 DndFactory factory( mCalendar );
2208 Event *pastedEvent = factory.pasteEvent( date ); 2208 Event *pastedEvent = factory.pasteEvent( date );
2209 2209
2210 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2210 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2211} 2211}
2212 2212
2213void CalendarView::edit_options() 2213void CalendarView::edit_options()
2214{ 2214{
2215 mDialogManager->showOptionsDialog(); 2215 mDialogManager->showOptionsDialog();
2216 //writeSettings(); 2216 //writeSettings();
2217} 2217}
2218 2218
2219 2219
2220void CalendarView::slotSelectPickerDate( QDate d) 2220void CalendarView::slotSelectPickerDate( QDate d)
2221{ 2221{
2222 mDateFrame->hide(); 2222 mDateFrame->hide();
2223 if ( mDatePickerMode == 1 ) { 2223 if ( mDatePickerMode == 1 ) {
2224 mNavigator->slotDaySelect( d ); 2224 mNavigator->slotDaySelect( d );
2225 } else if ( mDatePickerMode == 2 ) { 2225 } else if ( mDatePickerMode == 2 ) {
2226 if ( mMoveIncidence->type() == "Todo" ) { 2226 if ( mMoveIncidence->type() == "Todo" ) {
2227 Todo * to = (Todo *) mMoveIncidence; 2227 Todo * to = (Todo *) mMoveIncidence;
2228 QTime tim; 2228 QTime tim;
2229 if ( to->hasDueDate() ) 2229 if ( to->hasDueDate() )
2230 tim = to->dtDue().time(); 2230 tim = to->dtDue().time();
2231 else { 2231 else {
2232 tim = QTime ( 0,0,0 ); 2232 tim = QTime ( 0,0,0 );
2233 to->setFloats( true ); 2233 to->setFloats( true );
2234 to->setHasDueDate( true ); 2234 to->setHasDueDate( true );
2235 } 2235 }
2236 QDateTime dt ( d,tim ); 2236 QDateTime dt ( d,tim );
2237 to->setDtDue( dt ); 2237 to->setDtDue( dt );
2238 todoChanged( to ); 2238 todoChanged( to );
2239 } else { 2239 } else {
2240 if ( mMoveIncidence->doesRecur() ) { 2240 if ( mMoveIncidence->doesRecur() ) {
2241#if 0 2241#if 0
2242 // PENDING implement this 2242 // PENDING implement this
2243 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2243 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2244 mCalendar()->addIncidence( newInc ); 2244 mCalendar()->addIncidence( newInc );
2245 if ( mMoveIncidence->type() == "Todo" ) 2245 if ( mMoveIncidence->type() == "Todo" )
2246 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2246 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2247 else 2247 else
2248 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2248 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2249 mMoveIncidence = newInc; 2249 mMoveIncidence = newInc;
2250 2250
2251#endif 2251#endif
2252 } 2252 }
2253 QTime tim = mMoveIncidence->dtStart().time(); 2253 QTime tim = mMoveIncidence->dtStart().time();
2254 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2254 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2255 QDateTime dt ( d,tim ); 2255 QDateTime dt ( d,tim );
2256 mMoveIncidence->setDtStart( dt ); 2256 mMoveIncidence->setDtStart( dt );
2257 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2257 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2258 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2258 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2259 } 2259 }
2260 2260
2261 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2261 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2262 } 2262 }
2263} 2263}
2264 2264
2265void CalendarView::removeCategories() 2265void CalendarView::removeCategories()
2266{ 2266{
2267 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2267 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2268 QStringList catList = KOPrefs::instance()->mCustomCategories; 2268 QStringList catList = KOPrefs::instance()->mCustomCategories;
2269 QStringList catIncList; 2269 QStringList catIncList;
2270 QStringList newCatList; 2270 QStringList newCatList;
2271 Incidence* inc = incList.first(); 2271 Incidence* inc = incList.first();
2272 int i; 2272 int i;
2273 int count = 0; 2273 int count = 0;
2274 while ( inc ) { 2274 while ( inc ) {
2275 newCatList.clear(); 2275 newCatList.clear();
2276 catIncList = inc->categories() ; 2276 catIncList = inc->categories() ;
2277 for( i = 0; i< catIncList.count(); ++i ) { 2277 for( i = 0; i< catIncList.count(); ++i ) {
2278 if ( catList.contains (catIncList[i])) 2278 if ( catList.contains (catIncList[i]))
2279 newCatList.append( catIncList[i] ); 2279 newCatList.append( catIncList[i] );
2280 } 2280 }
2281 newCatList.sort(); 2281 newCatList.sort();
2282 inc->setCategories( newCatList.join(",") ); 2282 inc->setCategories( newCatList.join(",") );
2283 inc = incList.next(); 2283 inc = incList.next();
2284 } 2284 }
2285} 2285}
2286 2286
2287int CalendarView::addCategories() 2287int CalendarView::addCategories()
2288{ 2288{
2289 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2289 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2290 QStringList catList = KOPrefs::instance()->mCustomCategories; 2290 QStringList catList = KOPrefs::instance()->mCustomCategories;
2291 QStringList catIncList; 2291 QStringList catIncList;
2292 Incidence* inc = incList.first(); 2292 Incidence* inc = incList.first();
2293 int i; 2293 int i;
2294 int count = 0; 2294 int count = 0;
2295 while ( inc ) { 2295 while ( inc ) {
2296 catIncList = inc->categories() ; 2296 catIncList = inc->categories() ;
2297 for( i = 0; i< catIncList.count(); ++i ) { 2297 for( i = 0; i< catIncList.count(); ++i ) {
2298 if ( !catList.contains (catIncList[i])) { 2298 if ( !catList.contains (catIncList[i])) {
2299 catList.append( catIncList[i] ); 2299 catList.append( catIncList[i] );
2300 //qDebug("add cat %s ", catIncList[i].latin1()); 2300 //qDebug("add cat %s ", catIncList[i].latin1());
2301 ++count; 2301 ++count;
2302 } 2302 }
2303 } 2303 }
2304 inc = incList.next(); 2304 inc = incList.next();
2305 } 2305 }
2306 catList.sort(); 2306 catList.sort();
2307 KOPrefs::instance()->mCustomCategories = catList; 2307 KOPrefs::instance()->mCustomCategories = catList;
2308 return count; 2308 return count;
2309} 2309}
2310 2310
2311void CalendarView::manageCategories() 2311void CalendarView::manageCategories()
2312{ 2312{
2313 KOCatPrefs* cp = new KOCatPrefs(); 2313 KOCatPrefs* cp = new KOCatPrefs();
2314 cp->show(); 2314 cp->show();
2315 int w =cp->sizeHint().width() ; 2315 int w =cp->sizeHint().width() ;
2316 int h = cp->sizeHint().height() ; 2316 int h = cp->sizeHint().height() ;
2317 int dw = QApplication::desktop()->width(); 2317 int dw = QApplication::desktop()->width();
2318 int dh = QApplication::desktop()->height(); 2318 int dh = QApplication::desktop()->height();
2319 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2319 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2320 if ( !cp->exec() ) { 2320 if ( !cp->exec() ) {
2321 delete cp; 2321 delete cp;
2322 return; 2322 return;
2323 } 2323 }
2324 int count = 0; 2324 int count = 0;
2325 if ( cp->addCat() ) { 2325 if ( cp->addCat() ) {
2326 count = addCategories(); 2326 count = addCategories();
2327 if ( count ) { 2327 if ( count ) {
2328 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2328 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2329 writeSettings(); 2329 writeSettings();
2330 } else 2330 } else
2331 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2331 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2332 } else { 2332 } else {
2333 removeCategories(); 2333 removeCategories();
2334 updateView(); 2334 updateView();
2335 } 2335 }
2336 delete cp; 2336 delete cp;
2337} 2337}
2338 2338
2339void CalendarView::beamIncidence(Incidence * Inc) 2339void CalendarView::beamIncidence(Incidence * Inc)
2340{ 2340{
2341 QPtrList<Incidence> delSel ; 2341 QPtrList<Incidence> delSel ;
2342 delSel.append(Inc); 2342 delSel.append(Inc);
2343 beamIncidenceList( delSel ); 2343 beamIncidenceList( delSel );
2344} 2344}
2345void CalendarView::beamCalendar() 2345void CalendarView::beamCalendar()
2346{ 2346{
2347 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2347 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2348 //qDebug("beamCalendar() "); 2348 //qDebug("beamCalendar() ");
2349 beamIncidenceList( delSel ); 2349 beamIncidenceList( delSel );
2350} 2350}
2351void CalendarView::beamFilteredCalendar() 2351void CalendarView::beamFilteredCalendar()
2352{ 2352{
2353 QPtrList<Incidence> delSel = mCalendar->incidences(); 2353 QPtrList<Incidence> delSel = mCalendar->incidences();
2354 //qDebug("beamFilteredCalendar() "); 2354 //qDebug("beamFilteredCalendar() ");
2355 beamIncidenceList( delSel ); 2355 beamIncidenceList( delSel );
2356} 2356}
2357void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2357void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2358{ 2358{
2359 if ( beamDialog->exec () == QDialog::Rejected ) 2359 if ( beamDialog->exec () == QDialog::Rejected )
2360 return; 2360 return;
2361#ifdef DESKTOP_VERSION 2361#ifdef DESKTOP_VERSION
2362 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2362 QString fn = locateLocal( "tmp", "kopibeamfile" );
2363#else 2363#else
2364 QString fn = "/tmp/kopibeamfile"; 2364 QString fn = "/tmp/kopibeamfile";
2365#endif 2365#endif
2366 QString mes; 2366 QString mes;
2367 bool createbup = true; 2367 bool createbup = true;
2368 if ( createbup ) { 2368 if ( createbup ) {
2369 QString description = "\n"; 2369 QString description = "\n";
2370 CalendarLocal* cal = new CalendarLocal(); 2370 CalendarLocal* cal = new CalendarLocal();
2371 if ( beamDialog->beamLocal() ) 2371 if ( beamDialog->beamLocal() )
2372 cal->setLocalTime(); 2372 cal->setLocalTime();
2373 else 2373 else
2374 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2374 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2375 Incidence *incidence = delSel.first(); 2375 Incidence *incidence = delSel.first();
2376 bool addText = false; 2376 bool addText = false;
2377 if ( delSel.count() < 10 ) 2377 if ( delSel.count() < 10 )
2378 addText = true; 2378 addText = true;
2379 else { 2379 else {
2380 description.sprintf(i18n(" %d items?"),delSel.count() ); 2380 description.sprintf(i18n(" %d items?"),delSel.count() );
2381 } 2381 }
2382 while ( incidence ) { 2382 while ( incidence ) {
2383 Incidence *in = incidence->clone(); 2383 Incidence *in = incidence->clone();
2384 if ( ! in->summary().isEmpty() ) { 2384 if ( ! in->summary().isEmpty() ) {
2385 in->setDescription(""); 2385 in->setDescription("");
2386 } else { 2386 } else {
2387 in->setSummary( in->description().left(20)); 2387 in->setSummary( in->description().left(20));
2388 in->setDescription(""); 2388 in->setDescription("");
2389 } 2389 }
2390 if ( addText ) 2390 if ( addText )
2391 description += in->summary() + "\n"; 2391 description += in->summary() + "\n";
2392 cal->addIncidence( in ); 2392 cal->addIncidence( in );
2393 incidence = delSel.next(); 2393 incidence = delSel.next();
2394 } 2394 }
2395 if ( beamDialog->beamVcal() ) { 2395 if ( beamDialog->beamVcal() ) {
2396 fn += ".vcs"; 2396 fn += ".vcs";
2397 FileStorage storage( cal, fn, new VCalFormat ); 2397 FileStorage storage( cal, fn, new VCalFormat );
2398 storage.save(); 2398 storage.save();
2399 } else { 2399 } else {
2400 fn += ".ics"; 2400 fn += ".ics";
2401 FileStorage storage( cal, fn, new ICalFormat( ) ); 2401 FileStorage storage( cal, fn, new ICalFormat( ) );
2402 storage.save(); 2402 storage.save();
2403 } 2403 }
2404 delete cal; 2404 delete cal;
2405 mes = i18n("KO/Pi: Ready for beaming"); 2405 mes = i18n("KO/Pi: Ready for beaming");
2406 topLevelWidget()->setCaption(mes); 2406 topLevelWidget()->setCaption(mes);
2407 KApplication::convert2latin1( fn ); 2407 KApplication::convert2latin1( fn );
2408#ifndef DESKTOP_VERSION 2408#ifndef DESKTOP_VERSION
2409 Ir *ir = new Ir( this ); 2409 Ir *ir = new Ir( this );
2410 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2410 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2411 ir->send( fn, description, "text/x-vCalendar" ); 2411 ir->send( fn, description, "text/x-vCalendar" );
2412#endif 2412#endif
2413 } 2413 }
2414} 2414}
2415void CalendarView::beamDone( Ir *ir ) 2415void CalendarView::beamDone( Ir *ir )
2416{ 2416{
2417#ifndef DESKTOP_VERSION 2417#ifndef DESKTOP_VERSION
2418 delete ir; 2418 delete ir;
2419#endif 2419#endif
2420 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2420 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2421 topLevelWidget()->raise(); 2421 topLevelWidget()->raise();
2422} 2422}
2423 2423
2424void CalendarView::moveIncidence(Incidence * inc ) 2424void CalendarView::moveIncidence(Incidence * inc )
2425{ 2425{
2426 if ( !inc ) return; 2426 if ( !inc ) return;
2427 // qDebug("showDatePickerForIncidence( ) "); 2427 // qDebug("showDatePickerForIncidence( ) ");
2428 if ( mDateFrame->isVisible() ) 2428 if ( mDateFrame->isVisible() )
2429 mDateFrame->hide(); 2429 mDateFrame->hide();
2430 else { 2430 else {
2431 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2431 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2432 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2432 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2433 int dw = QApplication::desktop()->width(); 2433 int dw = QApplication::desktop()->width();
2434 int dh = QApplication::desktop()->height(); 2434 int dh = QApplication::desktop()->height();
2435 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2435 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2436 mDateFrame->show(); 2436 mDateFrame->show();
2437 } 2437 }
2438 mDatePickerMode = 2; 2438 mDatePickerMode = 2;
2439 mMoveIncidence = inc ; 2439 mMoveIncidence = inc ;
2440 QDate da; 2440 QDate da;
2441 if ( mMoveIncidence->type() == "Todo" ) { 2441 if ( mMoveIncidence->type() == "Todo" ) {
2442 Todo * to = (Todo *) mMoveIncidence; 2442 Todo * to = (Todo *) mMoveIncidence;
2443 if ( to->hasDueDate() ) 2443 if ( to->hasDueDate() )
2444 da = to->dtDue().date(); 2444 da = to->dtDue().date();
2445 else 2445 else
2446 da = QDate::currentDate(); 2446 da = QDate::currentDate();
2447 } else { 2447 } else {
2448 da = mMoveIncidence->dtStart().date(); 2448 da = mMoveIncidence->dtStart().date();
2449 } 2449 }
2450 //PENDING set date for recurring incidence to date of recurrence 2450 //PENDING set date for recurring incidence to date of recurrence
2451 //mMoveIncidenceOldDate; 2451 //mMoveIncidenceOldDate;
2452 mDatePicker->setDate( da ); 2452 mDatePicker->setDate( da );
2453} 2453}
2454void CalendarView::showDatePicker( ) 2454void CalendarView::showDatePicker( )
2455{ 2455{
2456 //qDebug("CalendarView::showDatePicker( ) "); 2456 //qDebug("CalendarView::showDatePicker( ) ");
2457 if ( mDateFrame->isVisible() ) 2457 if ( mDateFrame->isVisible() )
2458 mDateFrame->hide(); 2458 mDateFrame->hide();
2459 else { 2459 else {
2460 int w =mDatePicker->sizeHint().width() ; 2460 int w =mDatePicker->sizeHint().width() ;
2461 int h = mDatePicker->sizeHint().height() ; 2461 int h = mDatePicker->sizeHint().height() ;
2462 int dw = QApplication::desktop()->width(); 2462 int dw = QApplication::desktop()->width();
2463 int dh = QApplication::desktop()->height(); 2463 int dh = QApplication::desktop()->height();
2464 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2464 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2465 mDateFrame->show(); 2465 mDateFrame->show();
2466 } 2466 }
2467 mDatePickerMode = 1; 2467 mDatePickerMode = 1;
2468 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2468 mDatePicker->setDate( mNavigator->selectedDates().first() );
2469} 2469}
2470 2470
2471void CalendarView::showEventEditor() 2471void CalendarView::showEventEditor()
2472{ 2472{
2473#ifdef DESKTOP_VERSION 2473#ifdef DESKTOP_VERSION
2474 mEventEditor->show(); 2474 mEventEditor->show();
2475#else 2475#else
2476 if ( mEventEditor->width() != QApplication::desktop()->width() ) { 2476 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2477 qDebug("CalendarView: recreate mEventEditor "); 2477 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2478 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2478 delete mEventEditor; 2479 delete mEventEditor;
2479 mEventEditor = mDialogManager->getEventEditor(); 2480 mEventEditor = mDialogManager->getEventEditor();
2480 } 2481 }
2481 mEventEditor->showMaximized(); 2482 mEventEditor->showMaximized();
2482#endif 2483#endif
2483} 2484}
2484void CalendarView::showTodoEditor() 2485void CalendarView::showTodoEditor()
2485{ 2486{
2486#ifdef DESKTOP_VERSION 2487#ifdef DESKTOP_VERSION
2487 mTodoEditor->show(); 2488 mTodoEditor->show();
2488#else 2489#else
2489 if ( mTodoEditor->width() != QApplication::desktop()->width() ) { 2490 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2490 qDebug("CalendarView: recreate mTodoEditor "); 2491 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2492 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2491 delete mTodoEditor; 2493 delete mTodoEditor;
2492 mTodoEditor = mDialogManager->getTodoEditor(); 2494 mTodoEditor = mDialogManager->getTodoEditor();
2493 } 2495 }
2494 mTodoEditor->showMaximized(); 2496 mTodoEditor->showMaximized();
2495#endif 2497#endif
2496} 2498}
2497 2499
2498void CalendarView::cloneIncidence() 2500void CalendarView::cloneIncidence()
2499{ 2501{
2500 Incidence *incidence = currentSelection(); 2502 Incidence *incidence = currentSelection();
2501 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2503 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2502 if ( incidence ) { 2504 if ( incidence ) {
2503 cloneIncidence(incidence); 2505 cloneIncidence(incidence);
2504 } 2506 }
2505} 2507}
2506void CalendarView::moveIncidence() 2508void CalendarView::moveIncidence()
2507{ 2509{
2508 Incidence *incidence = currentSelection(); 2510 Incidence *incidence = currentSelection();
2509 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2511 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2510 if ( incidence ) { 2512 if ( incidence ) {
2511 moveIncidence(incidence); 2513 moveIncidence(incidence);
2512 } 2514 }
2513} 2515}
2514void CalendarView::beamIncidence() 2516void CalendarView::beamIncidence()
2515{ 2517{
2516 Incidence *incidence = currentSelection(); 2518 Incidence *incidence = currentSelection();
2517 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2519 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2518 if ( incidence ) { 2520 if ( incidence ) {
2519 beamIncidence(incidence); 2521 beamIncidence(incidence);
2520 } 2522 }
2521} 2523}
2522void CalendarView::toggleCancelIncidence() 2524void CalendarView::toggleCancelIncidence()
2523{ 2525{
2524 Incidence *incidence = currentSelection(); 2526 Incidence *incidence = currentSelection();
2525 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2527 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2526 if ( incidence ) { 2528 if ( incidence ) {
2527 cancelIncidence(incidence); 2529 cancelIncidence(incidence);
2528 } 2530 }
2529} 2531}
2530 2532
2531 2533
2532void CalendarView::cancelIncidence(Incidence * inc ) 2534void CalendarView::cancelIncidence(Incidence * inc )
2533{ 2535{
2534 inc->setCancelled( ! inc->cancelled() ); 2536 inc->setCancelled( ! inc->cancelled() );
2535 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2537 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2536 updateView(); 2538 updateView();
2537} 2539}
2538void CalendarView::cloneIncidence(Incidence * orgInc ) 2540void CalendarView::cloneIncidence(Incidence * orgInc )
2539{ 2541{
2540 Incidence * newInc = orgInc->clone(); 2542 Incidence * newInc = orgInc->clone();
2541 newInc->recreate(); 2543 newInc->recreate();
2542 2544
2543 if ( newInc->type() == "Todo" ) { 2545 if ( newInc->type() == "Todo" ) {
2544 Todo* t = (Todo*) newInc; 2546 Todo* t = (Todo*) newInc;
2545 mTodoEditor->editTodo( t );
2546 showTodoEditor(); 2547 showTodoEditor();
2548 mTodoEditor->editTodo( t );
2547 if ( mTodoEditor->exec() ) { 2549 if ( mTodoEditor->exec() ) {
2548 mCalendar->addTodo( t ); 2550 mCalendar->addTodo( t );
2549 updateView(); 2551 updateView();
2550 } else { 2552 } else {
2551 delete t; 2553 delete t;
2552 } 2554 }
2553 } 2555 }
2554 else { 2556 else {
2555 Event* e = (Event*) newInc; 2557 Event* e = (Event*) newInc;
2556 mEventEditor->editEvent( e );
2557 showEventEditor(); 2558 showEventEditor();
2559 mEventEditor->editEvent( e );
2558 if ( mEventEditor->exec() ) { 2560 if ( mEventEditor->exec() ) {
2559 mCalendar->addEvent( e ); 2561 mCalendar->addEvent( e );
2560 updateView(); 2562 updateView();
2561 } else { 2563 } else {
2562 delete e; 2564 delete e;
2563 } 2565 }
2564 } 2566 }
2565} 2567}
2566 2568
2567void CalendarView::newEvent() 2569void CalendarView::newEvent()
2568{ 2570{
2569 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2571 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2570 KOAgendaView *aView = mViewManager->agendaView(); 2572 KOAgendaView *aView = mViewManager->agendaView();
2571 if (aView) { 2573 if (aView) {
2572 if (aView->selectionStart().isValid()) { 2574 if (aView->selectionStart().isValid()) {
2573 if (aView->selectedIsAllDay()) { 2575 if (aView->selectedIsAllDay()) {
2574 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2576 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2575 } else { 2577 } else {
2576 newEvent(aView->selectionStart(),aView->selectionEnd()); 2578 newEvent(aView->selectionStart(),aView->selectionEnd());
2577 } 2579 }
2578 return; 2580 return;
2579 } 2581 }
2580 } 2582 }
2581 2583
2582 QDate date = mNavigator->selectedDates().first(); 2584 QDate date = mNavigator->selectedDates().first();
2583 QDateTime current = QDateTime::currentDateTime(); 2585 QDateTime current = QDateTime::currentDateTime();
2584 if ( date <= current.date() ) { 2586 if ( date <= current.date() ) {
2585 int hour = current.time().hour() +1; 2587 int hour = current.time().hour() +1;
2586 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2588 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2587 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2589 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2588 } else 2590 } else
2589 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2591 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2590 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2592 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2591 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2593 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2592} 2594}
2593 2595
2594void CalendarView::newEvent(QDateTime fh) 2596void CalendarView::newEvent(QDateTime fh)
2595{ 2597{
2596 newEvent(fh, 2598 newEvent(fh,
2597 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2599 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2598} 2600}
2599 2601
2600void CalendarView::newEvent(QDate dt) 2602void CalendarView::newEvent(QDate dt)
2601{ 2603{
2602 newEvent(QDateTime(dt, QTime(0,0,0)), 2604 newEvent(QDateTime(dt, QTime(0,0,0)),
2603 QDateTime(dt, QTime(0,0,0)), true); 2605 QDateTime(dt, QTime(0,0,0)), true);
2604} 2606}
2605 2607
2606void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2608void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2607{ 2609{
2608 2610
2611 showEventEditor();
2609 mEventEditor->newEvent(fromHint,toHint,allDay); 2612 mEventEditor->newEvent(fromHint,toHint,allDay);
2610 if ( mFilterView->filtersEnabled() ) { 2613 if ( mFilterView->filtersEnabled() ) {
2611 CalFilter *filter = mFilterView->selectedFilter(); 2614 CalFilter *filter = mFilterView->selectedFilter();
2612 if (filter && filter->showCategories()) { 2615 if (filter && filter->showCategories()) {
2613 mEventEditor->setCategories(filter->categoryList().join(",") ); 2616 mEventEditor->setCategories(filter->categoryList().join(",") );
2614 } 2617 }
2615 if ( filter ) 2618 if ( filter )
2616 mEventEditor->setSecrecy( filter->getSecrecy() ); 2619 mEventEditor->setSecrecy( filter->getSecrecy() );
2617 } 2620 }
2618 showEventEditor();
2619} 2621}
2620void CalendarView::todoAdded(Todo * t) 2622void CalendarView::todoAdded(Todo * t)
2621{ 2623{
2622 2624
2623 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2625 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2624 updateTodoViews(); 2626 updateTodoViews();
2625} 2627}
2626void CalendarView::todoChanged(Todo * t) 2628void CalendarView::todoChanged(Todo * t)
2627{ 2629{
2628 emit todoModified( t, 4 ); 2630 emit todoModified( t, 4 );
2629 // updateTodoViews(); 2631 // updateTodoViews();
2630} 2632}
2631void CalendarView::todoToBeDeleted(Todo *) 2633void CalendarView::todoToBeDeleted(Todo *)
2632{ 2634{
2633 //qDebug("todoToBeDeleted(Todo *) "); 2635 //qDebug("todoToBeDeleted(Todo *) ");
2634 updateTodoViews(); 2636 updateTodoViews();
2635} 2637}
2636void CalendarView::todoDeleted() 2638void CalendarView::todoDeleted()
2637{ 2639{
2638 //qDebug(" todoDeleted()"); 2640 //qDebug(" todoDeleted()");
2639 updateTodoViews(); 2641 updateTodoViews();
2640} 2642}
2641 2643
2642 2644
2643 2645
2644void CalendarView::newTodo() 2646void CalendarView::newTodo()
2645{ 2647{
2646 2648
2649 showTodoEditor();
2647 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2650 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2648 if ( mFilterView->filtersEnabled() ) { 2651 if ( mFilterView->filtersEnabled() ) {
2649 CalFilter *filter = mFilterView->selectedFilter(); 2652 CalFilter *filter = mFilterView->selectedFilter();
2650 if (filter && filter->showCategories()) { 2653 if (filter && filter->showCategories()) {
2651 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2654 mTodoEditor->setCategories(filter->categoryList().join(",") );
2652 } 2655 }
2653 if ( filter ) 2656 if ( filter )
2654 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2657 mTodoEditor->setSecrecy( filter->getSecrecy() );
2655 } 2658 }
2656 showTodoEditor();
2657} 2659}
2658 2660
2659void CalendarView::newSubTodo() 2661void CalendarView::newSubTodo()
2660{ 2662{
2661 Todo *todo = selectedTodo(); 2663 Todo *todo = selectedTodo();
2662 if ( todo ) newSubTodo( todo ); 2664 if ( todo ) newSubTodo( todo );
2663} 2665}
2664 2666
2665void CalendarView::newSubTodo(Todo *parentEvent) 2667void CalendarView::newSubTodo(Todo *parentEvent)
2666{ 2668{
2667 2669
2668 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2669 showTodoEditor(); 2670 showTodoEditor();
2671 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2670} 2672}
2671 2673
2672void CalendarView::newFloatingEvent() 2674void CalendarView::newFloatingEvent()
2673{ 2675{
2674 DateList tmpList = mNavigator->selectedDates(); 2676 DateList tmpList = mNavigator->selectedDates();
2675 QDate date = tmpList.first(); 2677 QDate date = tmpList.first();
2676 2678
2677 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2679 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2678 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2680 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2679} 2681}
2680 2682
2681 2683
2682void CalendarView::editEvent( Event *event ) 2684void CalendarView::editEvent( Event *event )
2683{ 2685{
2684 2686
2685 if ( !event ) return; 2687 if ( !event ) return;
2686 if ( event->isReadOnly() ) { 2688 if ( event->isReadOnly() ) {
2687 showEvent( event ); 2689 showEvent( event );
2688 return; 2690 return;
2689 } 2691 }
2690 mEventEditor->editEvent( event , mFlagEditDescription);
2691 showEventEditor(); 2692 showEventEditor();
2693 mEventEditor->editEvent( event , mFlagEditDescription);
2692} 2694}
2693void CalendarView::editJournal( Journal *jour ) 2695void CalendarView::editJournal( Journal *jour )
2694{ 2696{
2695 if ( !jour ) return; 2697 if ( !jour ) return;
2696 mDialogManager->hideSearchDialog(); 2698 mDialogManager->hideSearchDialog();
2697 mViewManager->showJournalView(); 2699 mViewManager->showJournalView();
2698 mNavigator->slotDaySelect( jour->dtStart().date() ); 2700 mNavigator->slotDaySelect( jour->dtStart().date() );
2699} 2701}
2700void CalendarView::editTodo( Todo *todo ) 2702void CalendarView::editTodo( Todo *todo )
2701{ 2703{
2702 if ( !todo ) return; 2704 if ( !todo ) return;
2703 2705
2704 if ( todo->isReadOnly() ) { 2706 if ( todo->isReadOnly() ) {
2705 showTodo( todo ); 2707 showTodo( todo );
2706 return; 2708 return;
2707 } 2709 }
2708 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2709 showTodoEditor(); 2710 showTodoEditor();
2711 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2710 2712
2711} 2713}
2712 2714
2713KOEventViewerDialog* CalendarView::getEventViewerDialog() 2715KOEventViewerDialog* CalendarView::getEventViewerDialog()
2714{ 2716{
2715 if ( !mEventViewerDialog ) { 2717 if ( !mEventViewerDialog ) {
2716 mEventViewerDialog = new KOEventViewerDialog(this); 2718 mEventViewerDialog = new KOEventViewerDialog(this);
2717 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2719 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2718 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2720 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2719 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2721 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2720 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2722 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2721 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2723 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2722 viewManager(), SLOT( showAgendaView( bool ) ) ); 2724 viewManager(), SLOT( showAgendaView( bool ) ) );
2723 mEventViewerDialog->resize( 640, 480 ); 2725 mEventViewerDialog->resize( 640, 480 );
2724 2726
2725 } 2727 }
2726 return mEventViewerDialog; 2728 return mEventViewerDialog;
2727} 2729}
2728void CalendarView::showEvent(Event *event) 2730void CalendarView::showEvent(Event *event)
2729{ 2731{
2730 getEventViewerDialog()->setEvent(event); 2732 getEventViewerDialog()->setEvent(event);
2731 getEventViewerDialog()->showMe(); 2733 getEventViewerDialog()->showMe();
2732} 2734}
2733 2735
2734void CalendarView::showTodo(Todo *event) 2736void CalendarView::showTodo(Todo *event)
2735{ 2737{
2736 getEventViewerDialog()->setTodo(event); 2738 getEventViewerDialog()->setTodo(event);
2737 getEventViewerDialog()->showMe(); 2739 getEventViewerDialog()->showMe();
2738} 2740}
2739void CalendarView::showJournal( Journal *jour ) 2741void CalendarView::showJournal( Journal *jour )
2740{ 2742{
2741 getEventViewerDialog()->setJournal(jour); 2743 getEventViewerDialog()->setJournal(jour);
2742 getEventViewerDialog()->showMe(); 2744 getEventViewerDialog()->showMe();
2743 2745
2744} 2746}
2745// void CalendarView::todoModified (Todo *event, int changed) 2747// void CalendarView::todoModified (Todo *event, int changed)
2746// { 2748// {
2747// // if (mDialogList.find (event) != mDialogList.end ()) { 2749// // if (mDialogList.find (event) != mDialogList.end ()) {
2748// // kdDebug() << "Todo modified and open" << endl; 2750// // kdDebug() << "Todo modified and open" << endl;
2749// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2751// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2750// // temp->modified (changed); 2752// // temp->modified (changed);
2751 2753
2752// // } 2754// // }
2753 2755
2754// mViewManager->updateView(); 2756// mViewManager->updateView();
2755// } 2757// }
2756 2758
2757void CalendarView::appointment_show() 2759void CalendarView::appointment_show()
2758{ 2760{
2759 Event *anEvent = 0; 2761 Event *anEvent = 0;
2760 2762
2761 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2763 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2762 2764
2763 if (mViewManager->currentView()->isEventView()) { 2765 if (mViewManager->currentView()->isEventView()) {
2764 if ( incidence && incidence->type() == "Event" ) { 2766 if ( incidence && incidence->type() == "Event" ) {
2765 anEvent = static_cast<Event *>(incidence); 2767 anEvent = static_cast<Event *>(incidence);
2766 } 2768 }
2767 } 2769 }
2768 2770
2769 if (!anEvent) { 2771 if (!anEvent) {
2770 KNotifyClient::beep(); 2772 KNotifyClient::beep();
2771 return; 2773 return;
2772 } 2774 }
2773 2775
2774 showEvent(anEvent); 2776 showEvent(anEvent);
2775} 2777}
2776 2778
2777void CalendarView::appointment_edit() 2779void CalendarView::appointment_edit()
2778{ 2780{
2779 Event *anEvent = 0; 2781 Event *anEvent = 0;
2780 2782
2781 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2783 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2782 2784
2783 if (mViewManager->currentView()->isEventView()) { 2785 if (mViewManager->currentView()->isEventView()) {
2784 if ( incidence && incidence->type() == "Event" ) { 2786 if ( incidence && incidence->type() == "Event" ) {
2785 anEvent = static_cast<Event *>(incidence); 2787 anEvent = static_cast<Event *>(incidence);
2786 } 2788 }
2787 } 2789 }
2788 2790
2789 if (!anEvent) { 2791 if (!anEvent) {
2790 KNotifyClient::beep(); 2792 KNotifyClient::beep();
2791 return; 2793 return;
2792 } 2794 }
2793 2795
2794 editEvent(anEvent); 2796 editEvent(anEvent);
2795} 2797}
2796 2798
2797void CalendarView::appointment_delete() 2799void CalendarView::appointment_delete()
2798{ 2800{
2799 Event *anEvent = 0; 2801 Event *anEvent = 0;
2800 2802
2801 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2803 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2802 2804
2803 if (mViewManager->currentView()->isEventView()) { 2805 if (mViewManager->currentView()->isEventView()) {
2804 if ( incidence && incidence->type() == "Event" ) { 2806 if ( incidence && incidence->type() == "Event" ) {
2805 anEvent = static_cast<Event *>(incidence); 2807 anEvent = static_cast<Event *>(incidence);
2806 } 2808 }
2807 } 2809 }
2808 2810
2809 if (!anEvent) { 2811 if (!anEvent) {
2810 KNotifyClient::beep(); 2812 KNotifyClient::beep();
2811 return; 2813 return;
2812 } 2814 }
2813 2815
2814 deleteEvent(anEvent); 2816 deleteEvent(anEvent);
2815} 2817}
2816 2818
2817void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2819void CalendarView::todo_resub( Todo * parent, Todo * sub )
2818{ 2820{
2819 if (!sub) return; 2821 if (!sub) return;
2820 if (!parent) return; 2822 if (!parent) return;
2821 if ( sub->relatedTo() ) 2823 if ( sub->relatedTo() )
2822 sub->relatedTo()->removeRelation(sub); 2824 sub->relatedTo()->removeRelation(sub);
2823 sub->setRelatedTo(parent); 2825 sub->setRelatedTo(parent);
2824 sub->setRelatedToUid(parent->uid()); 2826 sub->setRelatedToUid(parent->uid());
2825 parent->addRelation(sub); 2827 parent->addRelation(sub);
2826 sub->updated(); 2828 sub->updated();
2827 parent->updated(); 2829 parent->updated();
2828 setModified(true); 2830 setModified(true);
2829 updateView(); 2831 updateView();
2830} 2832}
2831void CalendarView::todo_unsub(Todo *anTodo ) 2833void CalendarView::todo_unsub(Todo *anTodo )
2832{ 2834{
2833 // Todo *anTodo = selectedTodo(); 2835 // Todo *anTodo = selectedTodo();
2834 if (!anTodo) return; 2836 if (!anTodo) return;
2835 if (!anTodo->relatedTo()) return; 2837 if (!anTodo->relatedTo()) return;
2836 anTodo->relatedTo()->removeRelation(anTodo); 2838 anTodo->relatedTo()->removeRelation(anTodo);
2837 anTodo->setRelatedTo(0); 2839 anTodo->setRelatedTo(0);
2838 anTodo->updated(); 2840 anTodo->updated();
2839 anTodo->setRelatedToUid(""); 2841 anTodo->setRelatedToUid("");
2840 setModified(true); 2842 setModified(true);
2841 updateView(); 2843 updateView();
2842} 2844}
2843 2845
2844void CalendarView::deleteTodo(Todo *todo) 2846void CalendarView::deleteTodo(Todo *todo)
2845{ 2847{
2846 if (!todo) { 2848 if (!todo) {
2847 KNotifyClient::beep(); 2849 KNotifyClient::beep();
2848 return; 2850 return;
2849 } 2851 }
2850 if (KOPrefs::instance()->mConfirm) { 2852 if (KOPrefs::instance()->mConfirm) {
2851 switch (msgItemDelete()) { 2853 switch (msgItemDelete()) {
2852 case KMessageBox::Continue: // OK 2854 case KMessageBox::Continue: // OK
2853 if (!todo->relations().isEmpty()) { 2855 if (!todo->relations().isEmpty()) {
2854 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2856 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2855 i18n("Delete To-Do")); 2857 i18n("Delete To-Do"));
2856 } else { 2858 } else {
2857 checkExternalId( todo ); 2859 checkExternalId( todo );
2858 calendar()->deleteTodo(todo); 2860 calendar()->deleteTodo(todo);
2859 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2861 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2860 updateView(); 2862 updateView();
2861 } 2863 }
2862 break; 2864 break;
2863 } // switch 2865 } // switch
2864 } else { 2866 } else {
2865 if (!todo->relations().isEmpty()) { 2867 if (!todo->relations().isEmpty()) {
2866 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2868 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2867 i18n("Delete To-Do")); 2869 i18n("Delete To-Do"));
2868 } else { 2870 } else {
2869 checkExternalId( todo ); 2871 checkExternalId( todo );
2870 mCalendar->deleteTodo(todo); 2872 mCalendar->deleteTodo(todo);
2871 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2873 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2872 updateView(); 2874 updateView();
2873 } 2875 }
2874 } 2876 }
2875 emit updateSearchDialog(); 2877 emit updateSearchDialog();
2876} 2878}
2877void CalendarView::deleteJournal(Journal *jour) 2879void CalendarView::deleteJournal(Journal *jour)
2878{ 2880{
2879 if (!jour) { 2881 if (!jour) {
2880 KNotifyClient::beep(); 2882 KNotifyClient::beep();
2881 return; 2883 return;
2882 } 2884 }
2883 if (KOPrefs::instance()->mConfirm) { 2885 if (KOPrefs::instance()->mConfirm) {
2884 switch (msgItemDelete()) { 2886 switch (msgItemDelete()) {
2885 case KMessageBox::Continue: // OK 2887 case KMessageBox::Continue: // OK
2886 calendar()->deleteJournal(jour); 2888 calendar()->deleteJournal(jour);
2887 updateView(); 2889 updateView();
2888 break; 2890 break;
2889 } // switch 2891 } // switch
2890 } else { 2892 } else {
2891 calendar()->deleteJournal(jour);; 2893 calendar()->deleteJournal(jour);;
2892 updateView(); 2894 updateView();
2893 } 2895 }
2894 emit updateSearchDialog(); 2896 emit updateSearchDialog();
2895} 2897}
2896 2898
2897void CalendarView::deleteEvent(Event *anEvent) 2899void CalendarView::deleteEvent(Event *anEvent)
2898{ 2900{
2899 if (!anEvent) { 2901 if (!anEvent) {
2900 KNotifyClient::beep(); 2902 KNotifyClient::beep();
2901 return; 2903 return;
2902 } 2904 }
2903 2905
2904 if (anEvent->recurrence()->doesRecur()) { 2906 if (anEvent->recurrence()->doesRecur()) {
2905 QDate itemDate = mViewManager->currentSelectionDate(); 2907 QDate itemDate = mViewManager->currentSelectionDate();
2906 int km; 2908 int km;
2907 if (!itemDate.isValid()) { 2909 if (!itemDate.isValid()) {
2908 //kdDebug() << "Date Not Valid" << endl; 2910 //kdDebug() << "Date Not Valid" << endl;
2909 if (KOPrefs::instance()->mConfirm) { 2911 if (KOPrefs::instance()->mConfirm) {
2910 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2912 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2911 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2913 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2912 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2914 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2913 if ( km == KMessageBox::Continue ) 2915 if ( km == KMessageBox::Continue )
2914 km = KMessageBox::No; // No = all below 2916 km = KMessageBox::No; // No = all below
2915 } else 2917 } else
2916 km = KMessageBox::No; 2918 km = KMessageBox::No;
2917 } else { 2919 } else {
2918 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2920 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2919 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2921 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2920 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2922 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2921 i18n("KO/Pi Confirmation"),i18n("Current"), 2923 i18n("KO/Pi Confirmation"),i18n("Current"),
2922 i18n("All")); 2924 i18n("All"));
2923 } 2925 }
2924 switch(km) { 2926 switch(km) {
2925 2927
2926 case KMessageBox::No: // Continue // all 2928 case KMessageBox::No: // Continue // all
2927 //qDebug("KMessageBox::No "); 2929 //qDebug("KMessageBox::No ");
2928 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2930 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2929 schedule(Scheduler::Cancel,anEvent); 2931 schedule(Scheduler::Cancel,anEvent);
2930 2932
2931 checkExternalId( anEvent); 2933 checkExternalId( anEvent);
2932 mCalendar->deleteEvent(anEvent); 2934 mCalendar->deleteEvent(anEvent);
2933 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2935 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2934 break; 2936 break;
2935 2937
2936 // Disabled because it does not work 2938 // Disabled because it does not work
2937 //#if 0 2939 //#if 0
2938 case KMessageBox::Yes: // just this one 2940 case KMessageBox::Yes: // just this one
2939 //QDate qd = mNavigator->selectedDates().first(); 2941 //QDate qd = mNavigator->selectedDates().first();
2940 //if (!qd.isValid()) { 2942 //if (!qd.isValid()) {
2941 // kdDebug() << "no date selected, or invalid date" << endl; 2943 // kdDebug() << "no date selected, or invalid date" << endl;
2942 // KNotifyClient::beep(); 2944 // KNotifyClient::beep();
2943 // return; 2945 // return;
2944 //} 2946 //}
2945 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2947 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2946 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2948 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2947 anEvent->addExDate(itemDate); 2949 anEvent->addExDate(itemDate);
2948 int duration = anEvent->recurrence()->duration(); 2950 int duration = anEvent->recurrence()->duration();
2949 if ( duration > 0 ) { 2951 if ( duration > 0 ) {
2950 anEvent->recurrence()->setDuration( duration - 1 ); 2952 anEvent->recurrence()->setDuration( duration - 1 );
2951 } 2953 }
2952 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2954 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2953 } 2955 }
2954 break; 2956 break;
2955 //#endif 2957 //#endif
2956 } // switch 2958 } // switch
2957 } else { 2959 } else {
2958 if (KOPrefs::instance()->mConfirm) { 2960 if (KOPrefs::instance()->mConfirm) {
2959 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2961 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2960 i18n("\nAre you sure you want\nto delete this event?"), 2962 i18n("\nAre you sure you want\nto delete this event?"),
2961 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2963 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2962 case KMessageBox::Continue: // OK 2964 case KMessageBox::Continue: // OK
2963 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2965 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2964 schedule(Scheduler::Cancel,anEvent); 2966 schedule(Scheduler::Cancel,anEvent);
2965 checkExternalId( anEvent); 2967 checkExternalId( anEvent);
2966 mCalendar->deleteEvent(anEvent); 2968 mCalendar->deleteEvent(anEvent);
2967 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2969 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2968 break; 2970 break;
2969 } // switch 2971 } // switch
2970 } else { 2972 } else {
2971 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2973 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2972 schedule(Scheduler::Cancel,anEvent); 2974 schedule(Scheduler::Cancel,anEvent);
2973 checkExternalId( anEvent); 2975 checkExternalId( anEvent);
2974 mCalendar->deleteEvent(anEvent); 2976 mCalendar->deleteEvent(anEvent);
2975 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2977 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2976 } 2978 }
2977 } // if-else 2979 } // if-else
2978 emit updateSearchDialog(); 2980 emit updateSearchDialog();
2979} 2981}
2980 2982
2981bool CalendarView::deleteEvent(const QString &uid) 2983bool CalendarView::deleteEvent(const QString &uid)
2982{ 2984{
2983 Event *ev = mCalendar->event(uid); 2985 Event *ev = mCalendar->event(uid);
2984 if (ev) { 2986 if (ev) {
2985 deleteEvent(ev); 2987 deleteEvent(ev);
2986 return true; 2988 return true;
2987 } else { 2989 } else {
2988 return false; 2990 return false;
2989 } 2991 }
2990} 2992}
2991 2993
2992/*****************************************************************************/ 2994/*****************************************************************************/
2993 2995
2994void CalendarView::action_mail() 2996void CalendarView::action_mail()
2995{ 2997{
2996#ifndef KORG_NOMAIL 2998#ifndef KORG_NOMAIL
2997 KOMailClient mailClient; 2999 KOMailClient mailClient;
2998 3000
2999 Incidence *incidence = currentSelection(); 3001 Incidence *incidence = currentSelection();
3000 3002
3001 if (!incidence) { 3003 if (!incidence) {
3002 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3004 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3003 return; 3005 return;
3004 } 3006 }
3005 if(incidence->attendeeCount() == 0 ) { 3007 if(incidence->attendeeCount() == 0 ) {
3006 KMessageBox::sorry(this, 3008 KMessageBox::sorry(this,
3007 i18n("Can't generate mail:\nNo attendees defined.\n")); 3009 i18n("Can't generate mail:\nNo attendees defined.\n"));
3008 return; 3010 return;
3009 } 3011 }
3010 3012
3011 CalendarLocal cal_tmp; 3013 CalendarLocal cal_tmp;
3012 Event *event = 0; 3014 Event *event = 0;
3013 Event *ev = 0; 3015 Event *ev = 0;
3014 if ( incidence && incidence->type() == "Event" ) { 3016 if ( incidence && incidence->type() == "Event" ) {
3015 event = static_cast<Event *>(incidence); 3017 event = static_cast<Event *>(incidence);
3016 ev = new Event(*event); 3018 ev = new Event(*event);
3017 cal_tmp.addEvent(ev); 3019 cal_tmp.addEvent(ev);
3018 } 3020 }
3019 ICalFormat mForm(); 3021 ICalFormat mForm();
3020 QString attachment = mForm.toString( &cal_tmp ); 3022 QString attachment = mForm.toString( &cal_tmp );
3021 if (ev) delete(ev); 3023 if (ev) delete(ev);
3022 3024
3023 mailClient.mailAttendees(currentSelection(), attachment); 3025 mailClient.mailAttendees(currentSelection(), attachment);
3024 3026
3025#endif 3027#endif
3026 3028
3027#if 0 3029#if 0
3028 Event *anEvent = 0; 3030 Event *anEvent = 0;
3029 if (mViewManager->currentView()->isEventView()) { 3031 if (mViewManager->currentView()->isEventView()) {
3030 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3032 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3031 } 3033 }
3032 3034
3033 if (!anEvent) { 3035 if (!anEvent) {
3034 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3036 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3035 return; 3037 return;
3036 } 3038 }
3037 if(anEvent->attendeeCount() == 0 ) { 3039 if(anEvent->attendeeCount() == 0 ) {
3038 KMessageBox::sorry(this, 3040 KMessageBox::sorry(this,
3039 i18n("Can't generate mail:\nNo attendees defined.\n")); 3041 i18n("Can't generate mail:\nNo attendees defined.\n"));
3040 return; 3042 return;
3041 } 3043 }
3042 3044
3043 mailobject.emailEvent(anEvent); 3045 mailobject.emailEvent(anEvent);
3044#endif 3046#endif
3045} 3047}
3046 3048
3047 3049
3048void CalendarView::schedule_publish(Incidence *incidence) 3050void CalendarView::schedule_publish(Incidence *incidence)
3049{ 3051{
3050 Event *event = 0; 3052 Event *event = 0;
3051 Todo *todo = 0; 3053 Todo *todo = 0;
3052 3054
3053 if (incidence == 0) { 3055 if (incidence == 0) {
3054 incidence = mViewManager->currentView()->selectedIncidences().first(); 3056 incidence = mViewManager->currentView()->selectedIncidences().first();
3055 if (incidence == 0) { 3057 if (incidence == 0) {
3056 incidence = mTodoList->selectedIncidences().first(); 3058 incidence = mTodoList->selectedIncidences().first();
3057 } 3059 }
3058 } 3060 }
3059 if ( incidence && incidence->type() == "Event" ) { 3061 if ( incidence && incidence->type() == "Event" ) {
3060 event = static_cast<Event *>(incidence); 3062 event = static_cast<Event *>(incidence);
3061 } else { 3063 } else {
3062 if ( incidence && incidence->type() == "Todo" ) { 3064 if ( incidence && incidence->type() == "Todo" ) {
3063 todo = static_cast<Todo *>(incidence); 3065 todo = static_cast<Todo *>(incidence);
3064 } 3066 }
3065 } 3067 }
3066 3068
3067 if (!event && !todo) { 3069 if (!event && !todo) {
3068 KMessageBox::sorry(this,i18n("No event selected.")); 3070 KMessageBox::sorry(this,i18n("No event selected."));
3069 return; 3071 return;
3070 } 3072 }
3071 3073
3072 PublishDialog *publishdlg = new PublishDialog(); 3074 PublishDialog *publishdlg = new PublishDialog();
3073 if (incidence->attendeeCount()>0) { 3075 if (incidence->attendeeCount()>0) {
3074 QPtrList<Attendee> attendees = incidence->attendees(); 3076 QPtrList<Attendee> attendees = incidence->attendees();
3075 attendees.first(); 3077 attendees.first();
3076 while ( attendees.current()!=0 ) { 3078 while ( attendees.current()!=0 ) {
3077 publishdlg->addAttendee(attendees.current()); 3079 publishdlg->addAttendee(attendees.current());
3078 attendees.next(); 3080 attendees.next();
3079 } 3081 }
3080 } 3082 }
3081 bool send = true; 3083 bool send = true;
3082 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3084 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3083 if ( publishdlg->exec() != QDialog::Accepted ) 3085 if ( publishdlg->exec() != QDialog::Accepted )
3084 send = false; 3086 send = false;
3085 } 3087 }
3086 if ( send ) { 3088 if ( send ) {
3087 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3089 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3088 if ( event ) { 3090 if ( event ) {
3089 Event *ev = new Event(*event); 3091 Event *ev = new Event(*event);
3090 ev->registerObserver(0); 3092 ev->registerObserver(0);
3091 ev->clearAttendees(); 3093 ev->clearAttendees();
3092 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3094 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3093 delete(ev); 3095 delete(ev);
3094 } 3096 }
3095 } else { 3097 } else {
3096 if ( todo ) { 3098 if ( todo ) {
3097 Todo *ev = new Todo(*todo); 3099 Todo *ev = new Todo(*todo);
3098 ev->registerObserver(0); 3100 ev->registerObserver(0);
3099 ev->clearAttendees(); 3101 ev->clearAttendees();
3100 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3102 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3101 delete(ev); 3103 delete(ev);
3102 } 3104 }
3103 } 3105 }
3104 } 3106 }
3105 } 3107 }
3106 delete publishdlg; 3108 delete publishdlg;
3107} 3109}
3108 3110
3109void CalendarView::schedule_request(Incidence *incidence) 3111void CalendarView::schedule_request(Incidence *incidence)
3110{ 3112{
3111 schedule(Scheduler::Request,incidence); 3113 schedule(Scheduler::Request,incidence);
3112} 3114}
3113 3115
3114void CalendarView::schedule_refresh(Incidence *incidence) 3116void CalendarView::schedule_refresh(Incidence *incidence)
3115{ 3117{
3116 schedule(Scheduler::Refresh,incidence); 3118 schedule(Scheduler::Refresh,incidence);
3117} 3119}
3118 3120
3119void CalendarView::schedule_cancel(Incidence *incidence) 3121void CalendarView::schedule_cancel(Incidence *incidence)
3120{ 3122{
3121 schedule(Scheduler::Cancel,incidence); 3123 schedule(Scheduler::Cancel,incidence);
3122} 3124}
3123 3125
3124void CalendarView::schedule_add(Incidence *incidence) 3126void CalendarView::schedule_add(Incidence *incidence)
3125{ 3127{
3126 schedule(Scheduler::Add,incidence); 3128 schedule(Scheduler::Add,incidence);
3127} 3129}
3128 3130
3129void CalendarView::schedule_reply(Incidence *incidence) 3131void CalendarView::schedule_reply(Incidence *incidence)
3130{ 3132{
3131 schedule(Scheduler::Reply,incidence); 3133 schedule(Scheduler::Reply,incidence);
3132} 3134}
3133 3135
3134void CalendarView::schedule_counter(Incidence *incidence) 3136void CalendarView::schedule_counter(Incidence *incidence)
3135{ 3137{
3136 schedule(Scheduler::Counter,incidence); 3138 schedule(Scheduler::Counter,incidence);
3137} 3139}
3138 3140
3139void CalendarView::schedule_declinecounter(Incidence *incidence) 3141void CalendarView::schedule_declinecounter(Incidence *incidence)
3140{ 3142{
3141 schedule(Scheduler::Declinecounter,incidence); 3143 schedule(Scheduler::Declinecounter,incidence);
3142} 3144}
3143 3145
3144void CalendarView::schedule_publish_freebusy(int daysToPublish) 3146void CalendarView::schedule_publish_freebusy(int daysToPublish)
3145{ 3147{
3146 QDateTime start = QDateTime::currentDateTime(); 3148 QDateTime start = QDateTime::currentDateTime();
3147 QDateTime end = start.addDays(daysToPublish); 3149 QDateTime end = start.addDays(daysToPublish);
3148 3150
3149 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3151 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3150 freebusy->setOrganizer(KOPrefs::instance()->email()); 3152 freebusy->setOrganizer(KOPrefs::instance()->email());
3151 3153
3152 3154
3153 PublishDialog *publishdlg = new PublishDialog(); 3155 PublishDialog *publishdlg = new PublishDialog();
3154 if ( publishdlg->exec() == QDialog::Accepted ) { 3156 if ( publishdlg->exec() == QDialog::Accepted ) {
3155 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3157 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3156 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3158 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3157 delete(freebusy); 3159 delete(freebusy);
3158 } 3160 }
3159 } 3161 }
3160 delete publishdlg; 3162 delete publishdlg;
3161} 3163}
3162 3164
3163void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3165void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3164{ 3166{
3165 Event *event = 0; 3167 Event *event = 0;
3166 Todo *todo = 0; 3168 Todo *todo = 0;
3167 3169
3168 if (incidence == 0) { 3170 if (incidence == 0) {
3169 incidence = mViewManager->currentView()->selectedIncidences().first(); 3171 incidence = mViewManager->currentView()->selectedIncidences().first();
3170 if (incidence == 0) { 3172 if (incidence == 0) {
3171 incidence = mTodoList->selectedIncidences().first(); 3173 incidence = mTodoList->selectedIncidences().first();
3172 } 3174 }
3173 } 3175 }
3174 if ( incidence && incidence->type() == "Event" ) { 3176 if ( incidence && incidence->type() == "Event" ) {
3175 event = static_cast<Event *>(incidence); 3177 event = static_cast<Event *>(incidence);
3176 } 3178 }
3177 if ( incidence && incidence->type() == "Todo" ) { 3179 if ( incidence && incidence->type() == "Todo" ) {
3178 todo = static_cast<Todo *>(incidence); 3180 todo = static_cast<Todo *>(incidence);
3179 } 3181 }
3180 3182
3181 if (!event && !todo) { 3183 if (!event && !todo) {
3182 KMessageBox::sorry(this,i18n("No event selected.")); 3184 KMessageBox::sorry(this,i18n("No event selected."));
3183 return; 3185 return;
3184 } 3186 }
3185 3187
3186 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3188 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3187 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3189 KMessageBox::sorry(this,i18n("The event has no attendees."));
3188 return; 3190 return;
3189 } 3191 }
3190 3192
3191 Event *ev = 0; 3193 Event *ev = 0;
3192 if (event) ev = new Event(*event); 3194 if (event) ev = new Event(*event);
3193 Todo *to = 0; 3195 Todo *to = 0;
3194 if (todo) to = new Todo(*todo); 3196 if (todo) to = new Todo(*todo);
3195 3197
3196 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3198 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3197 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3199 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3198 if (!me) { 3200 if (!me) {
3199 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3201 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3200 return; 3202 return;
3201 } 3203 }
3202 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3204 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3203 StatusDialog *statdlg = new StatusDialog(this); 3205 StatusDialog *statdlg = new StatusDialog(this);
3204 if (!statdlg->exec()==QDialog::Accepted) return; 3206 if (!statdlg->exec()==QDialog::Accepted) return;
3205 me->setStatus( statdlg->status() ); 3207 me->setStatus( statdlg->status() );
3206 delete(statdlg); 3208 delete(statdlg);
3207 } 3209 }
3208 Attendee *menew = new Attendee(*me); 3210 Attendee *menew = new Attendee(*me);
3209 if (ev) { 3211 if (ev) {
3210 ev->clearAttendees(); 3212 ev->clearAttendees();
3211 ev->addAttendee(menew,false); 3213 ev->addAttendee(menew,false);
3212 } else { 3214 } else {
3213 if (to) { 3215 if (to) {
3214 todo->clearAttendees(); 3216 todo->clearAttendees();
3215 todo->addAttendee(menew,false); 3217 todo->addAttendee(menew,false);
3216 } 3218 }
3217 } 3219 }
3218 } 3220 }
3219 3221
3220 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3222 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3221 if (ev) { 3223 if (ev) {
3222 if ( !dlg->addMessage(ev,method) ) delete(ev); 3224 if ( !dlg->addMessage(ev,method) ) delete(ev);
3223 } else { 3225 } else {
3224 if (to) { 3226 if (to) {
3225 if ( !dlg->addMessage(to,method) ) delete(to); 3227 if ( !dlg->addMessage(to,method) ) delete(to);
3226 } 3228 }
3227 } 3229 }
3228} 3230}
3229 3231
3230void CalendarView::openAddressbook() 3232void CalendarView::openAddressbook()
3231{ 3233{
3232 KRun::runCommand("kaddressbook"); 3234 KRun::runCommand("kaddressbook");
3233} 3235}
3234 3236
3235void CalendarView::setModified(bool modified) 3237void CalendarView::setModified(bool modified)
3236{ 3238{
3237 if ( modified ) 3239 if ( modified )
3238 emit signalmodified(); 3240 emit signalmodified();
3239 if (mModified != modified) { 3241 if (mModified != modified) {
3240 mModified = modified; 3242 mModified = modified;
3241 emit modifiedChanged(mModified); 3243 emit modifiedChanged(mModified);
3242 } 3244 }
3243} 3245}
3244 3246
3245bool CalendarView::isReadOnly() 3247bool CalendarView::isReadOnly()
3246{ 3248{
3247 return mReadOnly; 3249 return mReadOnly;
3248} 3250}
3249 3251
3250void CalendarView::setReadOnly(bool readOnly) 3252void CalendarView::setReadOnly(bool readOnly)
3251{ 3253{
3252 if (mReadOnly != readOnly) { 3254 if (mReadOnly != readOnly) {
3253 mReadOnly = readOnly; 3255 mReadOnly = readOnly;
3254 emit readOnlyChanged(mReadOnly); 3256 emit readOnlyChanged(mReadOnly);
3255 } 3257 }
3256} 3258}
3257 3259
3258bool CalendarView::isModified() 3260bool CalendarView::isModified()
3259{ 3261{
3260 return mModified; 3262 return mModified;
3261} 3263}
3262 3264
3263void CalendarView::printSetup() 3265void CalendarView::printSetup()
3264{ 3266{
3265#ifndef KORG_NOPRINTER 3267#ifndef KORG_NOPRINTER
3266 createPrinter(); 3268 createPrinter();
3267 3269
3268 mCalPrinter->setupPrinter(); 3270 mCalPrinter->setupPrinter();
3269#endif 3271#endif
3270} 3272}
3271 3273
3272void CalendarView::print() 3274void CalendarView::print()
3273{ 3275{
3274#ifndef KORG_NOPRINTER 3276#ifndef KORG_NOPRINTER
3275 createPrinter(); 3277 createPrinter();
3276 3278
3277 DateList tmpDateList = mNavigator->selectedDates(); 3279 DateList tmpDateList = mNavigator->selectedDates();
3278 mCalPrinter->print(CalPrinter::Month, 3280 mCalPrinter->print(CalPrinter::Month,
3279 tmpDateList.first(), tmpDateList.last()); 3281 tmpDateList.first(), tmpDateList.last());
3280#endif 3282#endif
3281} 3283}
3282 3284
3283void CalendarView::printPreview() 3285void CalendarView::printPreview()
3284{ 3286{
3285#ifndef KORG_NOPRINTER 3287#ifndef KORG_NOPRINTER
3286 kdDebug() << "CalendarView::printPreview()" << endl; 3288 kdDebug() << "CalendarView::printPreview()" << endl;
3287 3289
3288 createPrinter(); 3290 createPrinter();
3289 3291
3290 DateList tmpDateList = mNavigator->selectedDates(); 3292 DateList tmpDateList = mNavigator->selectedDates();
3291 3293
3292 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3294 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3293 tmpDateList.last()); 3295 tmpDateList.last());
3294#endif 3296#endif
3295} 3297}
3296 3298
3297void CalendarView::exportICalendar() 3299void CalendarView::exportICalendar()
3298{ 3300{
3299 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3301 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3300 3302
3301 // Force correct extension 3303 // Force correct extension
3302 if (filename.right(4) != ".ics") filename += ".ics"; 3304 if (filename.right(4) != ".ics") filename += ".ics";
3303 3305
3304 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3306 FileStorage storage( mCalendar, filename, new ICalFormat() );
3305 storage.save(); 3307 storage.save();
3306} 3308}
3307 3309
3308bool CalendarView::exportVCalendar( QString filename ) 3310bool CalendarView::exportVCalendar( QString filename )
3309{ 3311{
3310 if (mCalendar->journals().count() > 0) { 3312 if (mCalendar->journals().count() > 0) {
3311 int result = KMessageBox::warningContinueCancel(this, 3313 int result = KMessageBox::warningContinueCancel(this,
3312 i18n("The journal entries can not be\nexported to a vCalendar file."), 3314 i18n("The journal entries can not be\nexported to a vCalendar file."),
3313 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3315 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3314 true); 3316 true);
3315 if (result != KMessageBox::Continue) return false; 3317 if (result != KMessageBox::Continue) return false;
3316 } 3318 }
3317 3319
3318 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3320 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3319 3321
3320 // Force correct extension 3322 // Force correct extension
3321 if (filename.right(4) != ".vcs") filename += ".vcs"; 3323 if (filename.right(4) != ".vcs") filename += ".vcs";
3322 3324
3323 FileStorage storage( mCalendar, filename, new VCalFormat ); 3325 FileStorage storage( mCalendar, filename, new VCalFormat );
3324 return storage.save(); 3326 return storage.save();
3325 3327
3326} 3328}
3327 3329
3328void CalendarView::eventUpdated(Incidence *) 3330void CalendarView::eventUpdated(Incidence *)
3329{ 3331{
3330 setModified(); 3332 setModified();
3331 // Don't call updateView here. The code, which has caused the update of the 3333 // Don't call updateView here. The code, which has caused the update of the
3332 // event is responsible for updating the view. 3334 // event is responsible for updating the view.
3333 // updateView(); 3335 // updateView();
3334} 3336}
3335 3337
3336void CalendarView::adaptNavigationUnits() 3338void CalendarView::adaptNavigationUnits()
3337{ 3339{
3338 if (mViewManager->currentView()->isEventView()) { 3340 if (mViewManager->currentView()->isEventView()) {
3339 int days = mViewManager->currentView()->currentDateCount(); 3341 int days = mViewManager->currentView()->currentDateCount();
3340 if (days == 1) { 3342 if (days == 1) {
3341 emit changeNavStringPrev(i18n("&Previous Day")); 3343 emit changeNavStringPrev(i18n("&Previous Day"));
3342 emit changeNavStringNext(i18n("&Next Day")); 3344 emit changeNavStringNext(i18n("&Next Day"));
3343 } else { 3345 } else {
3344 emit changeNavStringPrev(i18n("&Previous Week")); 3346 emit changeNavStringPrev(i18n("&Previous Week"));
3345 emit changeNavStringNext(i18n("&Next Week")); 3347 emit changeNavStringNext(i18n("&Next Week"));
3346 } 3348 }
3347 } 3349 }
3348} 3350}
3349 3351
3350void CalendarView::processMainViewSelection( Incidence *incidence ) 3352void CalendarView::processMainViewSelection( Incidence *incidence )
3351{ 3353{
3352 if ( incidence ) mTodoList->clearSelection(); 3354 if ( incidence ) mTodoList->clearSelection();
3353 processIncidenceSelection( incidence ); 3355 processIncidenceSelection( incidence );
3354} 3356}
3355 3357
3356void CalendarView::processTodoListSelection( Incidence *incidence ) 3358void CalendarView::processTodoListSelection( Incidence *incidence )
3357{ 3359{
3358 if ( incidence && mViewManager->currentView() ) { 3360 if ( incidence && mViewManager->currentView() ) {
3359 mViewManager->currentView()->clearSelection(); 3361 mViewManager->currentView()->clearSelection();
3360 } 3362 }
3361 processIncidenceSelection( incidence ); 3363 processIncidenceSelection( incidence );
3362} 3364}
3363 3365
3364void CalendarView::processIncidenceSelection( Incidence *incidence ) 3366void CalendarView::processIncidenceSelection( Incidence *incidence )
3365{ 3367{
3366 if ( incidence == mSelectedIncidence ) return; 3368 if ( incidence == mSelectedIncidence ) return;
3367 3369
3368 mSelectedIncidence = incidence; 3370 mSelectedIncidence = incidence;
3369 3371
3370 emit incidenceSelected( mSelectedIncidence ); 3372 emit incidenceSelected( mSelectedIncidence );
3371 3373
3372 if ( incidence && incidence->type() == "Event" ) { 3374 if ( incidence && incidence->type() == "Event" ) {
3373 Event *event = static_cast<Event *>( incidence ); 3375 Event *event = static_cast<Event *>( incidence );
3374 if ( event->organizer() == KOPrefs::instance()->email() ) { 3376 if ( event->organizer() == KOPrefs::instance()->email() ) {
3375 emit organizerEventsSelected( true ); 3377 emit organizerEventsSelected( true );
3376 } else { 3378 } else {
3377 emit organizerEventsSelected(false); 3379 emit organizerEventsSelected(false);
3378 } 3380 }
3379 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3381 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3380 KOPrefs::instance()->email() ) ) { 3382 KOPrefs::instance()->email() ) ) {
3381 emit groupEventsSelected( true ); 3383 emit groupEventsSelected( true );
3382 } else { 3384 } else {
3383 emit groupEventsSelected(false); 3385 emit groupEventsSelected(false);
3384 } 3386 }
3385 return; 3387 return;
3386 } else { 3388 } else {
3387 if ( incidence && incidence->type() == "Todo" ) { 3389 if ( incidence && incidence->type() == "Todo" ) {
3388 emit todoSelected( true ); 3390 emit todoSelected( true );
3389 Todo *event = static_cast<Todo *>( incidence ); 3391 Todo *event = static_cast<Todo *>( incidence );
3390 if ( event->organizer() == KOPrefs::instance()->email() ) { 3392 if ( event->organizer() == KOPrefs::instance()->email() ) {
3391 emit organizerEventsSelected( true ); 3393 emit organizerEventsSelected( true );
3392 } else { 3394 } else {
3393 emit organizerEventsSelected(false); 3395 emit organizerEventsSelected(false);
3394 } 3396 }
3395 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3397 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3396 KOPrefs::instance()->email() ) ) { 3398 KOPrefs::instance()->email() ) ) {
3397 emit groupEventsSelected( true ); 3399 emit groupEventsSelected( true );
3398 } else { 3400 } else {
3399 emit groupEventsSelected(false); 3401 emit groupEventsSelected(false);
3400 } 3402 }
3401 return; 3403 return;
3402 } else { 3404 } else {
3403 emit todoSelected( false ); 3405 emit todoSelected( false );
3404 emit organizerEventsSelected(false); 3406 emit organizerEventsSelected(false);
3405 emit groupEventsSelected(false); 3407 emit groupEventsSelected(false);
3406 } 3408 }
3407 return; 3409 return;
3408 } 3410 }
3409 3411
3410 /* if ( incidence && incidence->type() == "Todo" ) { 3412 /* if ( incidence && incidence->type() == "Todo" ) {
3411 emit todoSelected( true ); 3413 emit todoSelected( true );
3412 } else { 3414 } else {
3413 emit todoSelected( false ); 3415 emit todoSelected( false );
3414 }*/ 3416 }*/
3415} 3417}
3416 3418
3417 3419
3418void CalendarView::checkClipboard() 3420void CalendarView::checkClipboard()
3419{ 3421{
3420#ifndef KORG_NODND 3422#ifndef KORG_NODND
3421 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3423 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3422 emit pasteEnabled(true); 3424 emit pasteEnabled(true);
3423 } else { 3425 } else {
3424 emit pasteEnabled(false); 3426 emit pasteEnabled(false);
3425 } 3427 }
3426#endif 3428#endif
3427} 3429}
3428 3430
3429void CalendarView::showDates(const DateList &selectedDates) 3431void CalendarView::showDates(const DateList &selectedDates)
3430{ 3432{
3431 // kdDebug() << "CalendarView::selectDates()" << endl; 3433 // kdDebug() << "CalendarView::selectDates()" << endl;
3432 3434
3433 if ( mViewManager->currentView() ) { 3435 if ( mViewManager->currentView() ) {
3434 updateView( selectedDates.first(), selectedDates.last() ); 3436 updateView( selectedDates.first(), selectedDates.last() );
3435 } else { 3437 } else {
3436 mViewManager->showAgendaView(); 3438 mViewManager->showAgendaView();
3437 } 3439 }
3438 3440
3439 QString selDates; 3441 QString selDates;
3440 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3442 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3441 if (selectedDates.first() < selectedDates.last() ) 3443 if (selectedDates.first() < selectedDates.last() )
3442 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3444 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3443 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3445 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3444 3446
3445} 3447}
3446 3448
3447QPtrList<CalFilter> CalendarView::filters() 3449QPtrList<CalFilter> CalendarView::filters()
3448{ 3450{
3449 return mFilters; 3451 return mFilters;
3450 3452
3451} 3453}
3452void CalendarView::editFilters() 3454void CalendarView::editFilters()
3453{ 3455{
3454 // kdDebug() << "CalendarView::editFilters()" << endl; 3456 // kdDebug() << "CalendarView::editFilters()" << endl;
3455 3457
3456 CalFilter *filter = mFilters.first(); 3458 CalFilter *filter = mFilters.first();
3457 while(filter) { 3459 while(filter) {
3458 kdDebug() << " Filter: " << filter->name() << endl; 3460 kdDebug() << " Filter: " << filter->name() << endl;
3459 filter = mFilters.next(); 3461 filter = mFilters.next();
3460 } 3462 }
3461 3463
3462 mDialogManager->showFilterEditDialog(&mFilters); 3464 mDialogManager->showFilterEditDialog(&mFilters);
3463} 3465}
3464void CalendarView::toggleFilter() 3466void CalendarView::toggleFilter()
3465{ 3467{
3466 showFilter(! mFilterView->isVisible()); 3468 showFilter(! mFilterView->isVisible());
3467} 3469}
3468 3470
3469KOFilterView *CalendarView::filterView() 3471KOFilterView *CalendarView::filterView()
3470{ 3472{
3471 return mFilterView; 3473 return mFilterView;
3472} 3474}
3473void CalendarView::selectFilter( int fil ) 3475void CalendarView::selectFilter( int fil )
3474{ 3476{
3475 mFilterView->setSelectedFilter( fil ); 3477 mFilterView->setSelectedFilter( fil );
3476} 3478}
3477void CalendarView::showFilter(bool visible) 3479void CalendarView::showFilter(bool visible)
3478{ 3480{
3479 if (visible) mFilterView->show(); 3481 if (visible) mFilterView->show();
3480 else mFilterView->hide(); 3482 else mFilterView->hide();
3481} 3483}
3482void CalendarView::toggleFilerEnabled( ) 3484void CalendarView::toggleFilerEnabled( )
3483{ 3485{
3484 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3486 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3485 if ( !mFilterView->filtersEnabled() ) 3487 if ( !mFilterView->filtersEnabled() )
3486 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3488 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3487 3489
3488} 3490}
3489void CalendarView::updateFilter() 3491void CalendarView::updateFilter()
3490{ 3492{
3491 CalFilter *filter = mFilterView->selectedFilter(); 3493 CalFilter *filter = mFilterView->selectedFilter();
3492 if (filter) { 3494 if (filter) {
3493 if (mFilterView->filtersEnabled()) { 3495 if (mFilterView->filtersEnabled()) {
3494 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3496 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3495 filter->setEnabled(true); 3497 filter->setEnabled(true);
3496 } 3498 }
3497 else filter->setEnabled(false); 3499 else filter->setEnabled(false);
3498 mCalendar->setFilter(filter); 3500 mCalendar->setFilter(filter);
3499 updateView(); 3501 updateView();
3500 } 3502 }
3501} 3503}
3502 3504
3503void CalendarView::filterEdited() 3505void CalendarView::filterEdited()
3504{ 3506{
3505 mFilterView->updateFilters(); 3507 mFilterView->updateFilters();
3506 updateFilter(); 3508 updateFilter();
3507 writeSettings(); 3509 writeSettings();
3508} 3510}
3509 3511
3510 3512
3511void CalendarView::takeOverEvent() 3513void CalendarView::takeOverEvent()
3512{ 3514{
3513 Incidence *incidence = currentSelection(); 3515 Incidence *incidence = currentSelection();
3514 3516
3515 if (!incidence) return; 3517 if (!incidence) return;
3516 3518
3517 incidence->setOrganizer(KOPrefs::instance()->email()); 3519 incidence->setOrganizer(KOPrefs::instance()->email());
3518 incidence->recreate(); 3520 incidence->recreate();
3519 incidence->setReadOnly(false); 3521 incidence->setReadOnly(false);
3520 3522
3521 updateView(); 3523 updateView();
3522} 3524}
3523 3525
3524void CalendarView::takeOverCalendar() 3526void CalendarView::takeOverCalendar()
3525{ 3527{
3526 // TODO: Create Calendar::allIncidences() function and use it here 3528 // TODO: Create Calendar::allIncidences() function and use it here
3527 3529
3528 QPtrList<Event> events = mCalendar->events(); 3530 QPtrList<Event> events = mCalendar->events();
3529 for(uint i=0; i<events.count(); ++i) { 3531 for(uint i=0; i<events.count(); ++i) {
3530 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3532 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3531 events.at(i)->recreate(); 3533 events.at(i)->recreate();
3532 events.at(i)->setReadOnly(false); 3534 events.at(i)->setReadOnly(false);
3533 } 3535 }
3534 3536
3535 QPtrList<Todo> todos = mCalendar->todos(); 3537 QPtrList<Todo> todos = mCalendar->todos();
3536 for(uint i=0; i<todos.count(); ++i) { 3538 for(uint i=0; i<todos.count(); ++i) {
3537 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3539 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3538 todos.at(i)->recreate(); 3540 todos.at(i)->recreate();
3539 todos.at(i)->setReadOnly(false); 3541 todos.at(i)->setReadOnly(false);
3540 } 3542 }
3541 3543
3542 QPtrList<Journal> journals = mCalendar->journals(); 3544 QPtrList<Journal> journals = mCalendar->journals();
3543 for(uint i=0; i<journals.count(); ++i) { 3545 for(uint i=0; i<journals.count(); ++i) {
3544 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3546 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3545 journals.at(i)->recreate(); 3547 journals.at(i)->recreate();
3546 journals.at(i)->setReadOnly(false); 3548 journals.at(i)->setReadOnly(false);
3547 } 3549 }
3548 3550
3549 updateView(); 3551 updateView();
3550} 3552}
3551 3553
3552void CalendarView::showIntro() 3554void CalendarView::showIntro()
3553{ 3555{
3554 kdDebug() << "To be implemented." << endl; 3556 kdDebug() << "To be implemented." << endl;
3555} 3557}
3556 3558
3557QWidgetStack *CalendarView::viewStack() 3559QWidgetStack *CalendarView::viewStack()
3558{ 3560{
3559 return mRightFrame; 3561 return mRightFrame;
3560} 3562}
3561 3563
3562QWidget *CalendarView::leftFrame() 3564QWidget *CalendarView::leftFrame()
3563{ 3565{
3564 return mLeftFrame; 3566 return mLeftFrame;
3565} 3567}
3566 3568
3567DateNavigator *CalendarView::dateNavigator() 3569DateNavigator *CalendarView::dateNavigator()
3568{ 3570{
3569 return mNavigator; 3571 return mNavigator;
3570} 3572}
3571 3573
3572KDateNavigator* CalendarView::dateNavigatorWidget() 3574KDateNavigator* CalendarView::dateNavigatorWidget()
3573{ 3575{
3574 return mDateNavigator; 3576 return mDateNavigator;
3575} 3577}
3576void CalendarView::toggleDateNavigatorWidget() 3578void CalendarView::toggleDateNavigatorWidget()
3577{ 3579{
3578 if (mDateNavigator->isVisible()) 3580 if (mDateNavigator->isVisible())
3579 mDateNavigator->hide(); 3581 mDateNavigator->hide();
3580 else 3582 else
3581 mDateNavigator->show(); 3583 mDateNavigator->show();
3582} 3584}
3583void CalendarView::addView(KOrg::BaseView *view) 3585void CalendarView::addView(KOrg::BaseView *view)
3584{ 3586{
3585 mViewManager->addView(view); 3587 mViewManager->addView(view);
3586} 3588}
3587 3589
3588void CalendarView::showView(KOrg::BaseView *view) 3590void CalendarView::showView(KOrg::BaseView *view)
3589{ 3591{
3590 mViewManager->showView(view, mLeftFrame->isVisible()); 3592 mViewManager->showView(view, mLeftFrame->isVisible());
3591} 3593}
3592 3594
3593Incidence *CalendarView::currentSelection() 3595Incidence *CalendarView::currentSelection()
3594{ 3596{
3595 return mViewManager->currentSelection(); 3597 return mViewManager->currentSelection();
3596} 3598}
3597void CalendarView::toggleAllDaySize() 3599void CalendarView::toggleAllDaySize()
3598{ 3600{
3599 /* 3601 /*
3600 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3602 if ( KOPrefs::instance()->mAllDaySize > 47 )
3601 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3603 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3602 else 3604 else
3603 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3605 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3604 */ 3606 */
3605 viewManager()->agendaView()->toggleAllDay(); 3607 viewManager()->agendaView()->toggleAllDay();
3606} 3608}
3607void CalendarView::toggleExpand() 3609void CalendarView::toggleExpand()
3608{ 3610{
3609 // if ( mLeftFrame->isHidden() ) { 3611 // if ( mLeftFrame->isHidden() ) {
3610 // mLeftFrame->show(); 3612 // mLeftFrame->show();
3611 // emit calendarViewExpanded( false ); 3613 // emit calendarViewExpanded( false );
3612 // } else { 3614 // } else {
3613 // mLeftFrame->hide(); 3615 // mLeftFrame->hide();
3614 // emit calendarViewExpanded( true ); 3616 // emit calendarViewExpanded( true );
3615 // } 3617 // }
3616 3618
3617 globalFlagBlockAgenda = 1; 3619 globalFlagBlockAgenda = 1;
3618 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3620 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3619 globalFlagBlockAgenda = 5; 3621 globalFlagBlockAgenda = 5;
3620 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3622 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3621 //mViewManager->showView( 0, true ); 3623 //mViewManager->showView( 0, true );
3622} 3624}
3623 3625
3624void CalendarView::calendarModified( bool modified, Calendar * ) 3626void CalendarView::calendarModified( bool modified, Calendar * )
3625{ 3627{
3626 setModified( modified ); 3628 setModified( modified );
3627} 3629}
3628 3630
3629Todo *CalendarView::selectedTodo() 3631Todo *CalendarView::selectedTodo()
3630{ 3632{
3631 Incidence *incidence = currentSelection(); 3633 Incidence *incidence = currentSelection();
3632 if ( incidence && incidence->type() == "Todo" ) { 3634 if ( incidence && incidence->type() == "Todo" ) {
3633 return static_cast<Todo *>( incidence ); 3635 return static_cast<Todo *>( incidence );
3634 } 3636 }
3635 3637
3636 incidence = mTodoList->selectedIncidences().first(); 3638 incidence = mTodoList->selectedIncidences().first();
3637 if ( incidence && incidence->type() == "Todo" ) { 3639 if ( incidence && incidence->type() == "Todo" ) {
3638 return static_cast<Todo *>( incidence ); 3640 return static_cast<Todo *>( incidence );
3639 } 3641 }
3640 3642
3641 return 0; 3643 return 0;
3642} 3644}
3643 3645
3644void CalendarView::dialogClosing(Incidence *in) 3646void CalendarView::dialogClosing(Incidence *in)
3645{ 3647{
3646 // mDialogList.remove(in); 3648 // mDialogList.remove(in);
3647} 3649}
3648 3650
3649void CalendarView::showIncidence() 3651void CalendarView::showIncidence()
3650{ 3652{
3651 Incidence *incidence = currentSelection(); 3653 Incidence *incidence = currentSelection();
3652 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3654 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3653 if ( incidence ) { 3655 if ( incidence ) {
3654 ShowIncidenceVisitor v; 3656 ShowIncidenceVisitor v;
3655 v.act( incidence, this ); 3657 v.act( incidence, this );
3656 } 3658 }
3657} 3659}
3658void CalendarView::editIncidenceDescription() 3660void CalendarView::editIncidenceDescription()
3659{ 3661{
3660 mFlagEditDescription = true; 3662 mFlagEditDescription = true;
3661 editIncidence(); 3663 editIncidence();
3662 mFlagEditDescription = false; 3664 mFlagEditDescription = false;
3663} 3665}
3664void CalendarView::editIncidence() 3666void CalendarView::editIncidence()
3665{ 3667{
3666 // qDebug("editIncidence() "); 3668 // qDebug("editIncidence() ");
3667 Incidence *incidence = currentSelection(); 3669 Incidence *incidence = currentSelection();
3668 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3670 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3669 if ( incidence ) { 3671 if ( incidence ) {
3670 EditIncidenceVisitor v; 3672 EditIncidenceVisitor v;
3671 v.act( incidence, this ); 3673 v.act( incidence, this );
3672 } 3674 }
3673} 3675}
3674 3676
3675void CalendarView::deleteIncidence() 3677void CalendarView::deleteIncidence()
3676{ 3678{
3677 Incidence *incidence = currentSelection(); 3679 Incidence *incidence = currentSelection();
3678 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3680 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3679 if ( incidence ) { 3681 if ( incidence ) {
3680 deleteIncidence(incidence); 3682 deleteIncidence(incidence);
3681 } 3683 }
3682} 3684}
3683 3685
3684void CalendarView::showIncidence(Incidence *incidence) 3686void CalendarView::showIncidence(Incidence *incidence)
3685{ 3687{
3686 if ( incidence ) { 3688 if ( incidence ) {
3687 ShowIncidenceVisitor v; 3689 ShowIncidenceVisitor v;
3688 v.act( incidence, this ); 3690 v.act( incidence, this );
3689 } 3691 }
3690} 3692}
3691 3693
3692void CalendarView::editIncidence(Incidence *incidence) 3694void CalendarView::editIncidence(Incidence *incidence)
3693{ 3695{
3694 if ( incidence ) { 3696 if ( incidence ) {
3695 3697
3696 EditIncidenceVisitor v; 3698 EditIncidenceVisitor v;
3697 v.act( incidence, this ); 3699 v.act( incidence, this );
3698 3700
3699 } 3701 }
3700} 3702}
3701 3703
3702void CalendarView::deleteIncidence(Incidence *incidence) 3704void CalendarView::deleteIncidence(Incidence *incidence)
3703{ 3705{
3704 //qDebug(" CalendarView::deleteIncidence "); 3706 //qDebug(" CalendarView::deleteIncidence ");
3705 if ( incidence ) { 3707 if ( incidence ) {
3706 DeleteIncidenceVisitor v; 3708 DeleteIncidenceVisitor v;
3707 v.act( incidence, this ); 3709 v.act( incidence, this );
3708 } 3710 }
3709} 3711}
3710 3712
3711 3713
3712void CalendarView::lookForOutgoingMessages() 3714void CalendarView::lookForOutgoingMessages()
3713{ 3715{
3714 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3716 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3715 ogd->loadMessages(); 3717 ogd->loadMessages();
3716} 3718}
3717 3719
3718void CalendarView::lookForIncomingMessages() 3720void CalendarView::lookForIncomingMessages()
3719{ 3721{
3720 IncomingDialog *icd = mDialogManager->incomingDialog(); 3722 IncomingDialog *icd = mDialogManager->incomingDialog();
3721 icd->retrieve(); 3723 icd->retrieve();
3722} 3724}
3723 3725
3724bool CalendarView::removeCompletedSubTodos( Todo* t ) 3726bool CalendarView::removeCompletedSubTodos( Todo* t )
3725{ 3727{
3726 bool deleteTodo = true; 3728 bool deleteTodo = true;
3727 QPtrList<Incidence> subTodos; 3729 QPtrList<Incidence> subTodos;
3728 Incidence *aTodo; 3730 Incidence *aTodo;
3729 subTodos = t->relations(); 3731 subTodos = t->relations();
3730 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3732 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3731 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3733 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3732 deleteTodo = false; 3734 deleteTodo = false;
3733 } 3735 }
diff --git a/qtcompat/qinputdialog.cpp b/qtcompat/qinputdialog.cpp
index 770b281..64c581e 100644
--- a/qtcompat/qinputdialog.cpp
+++ b/qtcompat/qinputdialog.cpp
@@ -1,495 +1,502 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QInputDialog class 4** Implementation of QInputDialog class
5** 5**
6** Created : 991212 6** Created : 991212
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38//Edited Lutz Rogowski 2004-12-13
39
38#include "qinputdialog.h" 40#include "qinputdialog.h"
39 41
40#include <qlayout.h> 42#include <qlayout.h>
41#include <qlabel.h> 43#include <qlabel.h>
42#include <qlineedit.h> 44#include <qlineedit.h>
43#include <qpushbutton.h> 45#include <qpushbutton.h>
44#include <qspinbox.h> 46#include <qspinbox.h>
45#include <qcombobox.h> 47#include <qcombobox.h>
46#include <qwidgetstack.h> 48#include <qwidgetstack.h>
47#include <qvalidator.h> 49#include <qvalidator.h>
48#include <qapplication.h> 50#include <qapplication.h>
49 51
50class QInputDialogPrivate 52class QInputDialogPrivate
51{ 53{
52public: 54public:
53 friend class QInputDialog; 55 friend class QInputDialog;
54 QLineEdit *lineEdit; 56 QLineEdit *lineEdit;
55 QSpinBox *spinBox; 57 QSpinBox *spinBox;
56 QComboBox *comboBox, *editComboBox; 58 QComboBox *comboBox, *editComboBox;
57 QPushButton *ok; 59 QPushButton *ok;
58 QWidgetStack *stack; 60 QWidgetStack *stack;
59 QInputDialog::Type type; 61 QInputDialog::Type type;
60}; 62};
61 63
62/*! 64/*!
63 \class QInputDialog qinputdialog.h 65 \class QInputDialog qinputdialog.h
64 \brief A convenience dialog to get a simple input from the user 66 \brief A convenience dialog to get a simple input from the user
65 \ingroup dialogs 67 \ingroup dialogs
66 68
67 The QInputDialog is a simple dialog which can be used if you 69 The QInputDialog is a simple dialog which can be used if you
68 need a simple input from the user. This can be text, a number or 70 need a simple input from the user. This can be text, a number or
69 an item from a list. Also a label has to be set to tell the user 71 an item from a list. Also a label has to be set to tell the user
70 what he/she should input. 72 what he/she should input.
71 73
72 In this Qt version only the 4 static convenience functions 74 In this Qt version only the 4 static convenience functions
73 getText(), getInteger(), getDouble() and getItem() of QInputDialog 75 getText(), getInteger(), getDouble() and getItem() of QInputDialog
74 are available. 76 are available.
75 77
76 Use it like this: 78 Use it like this:
77 79
78 \code 80 \code
79 bool ok = FALSE; 81 bool ok = FALSE;
80 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this ); 82 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
81 if ( ok && !text.isEmpty() ) 83 if ( ok && !text.isEmpty() )
82 ;// user entered something and pressed ok 84 ;// user entered something and pressed ok
83 else 85 else
84 ;// user entered nothing or pressed cancel 86 ;// user entered nothing or pressed cancel
85 \endcode 87 \endcode
86 88
87 There are more static convenience methods! 89 There are more static convenience methods!
88 90
89 \sa getText(), getInteger(), getDouble(), getItem() 91 \sa getText(), getInteger(), getDouble(), getItem()
90*/ 92*/
91 93
92/*! 94/*!
93 \enum QInputDialog::Type 95 \enum QInputDialog::Type
94 96
95 This enum type specifies the type of the dialog 97 This enum type specifies the type of the dialog
96 (which kind of input can be done): 98 (which kind of input can be done):
97 99
98 <ul> 100 <ul>
99 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or 101 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
100 (e.g. using a QValidator) a numerical input can be done. Using lineEdit() 102 (e.g. using a QValidator) a numerical input can be done. Using lineEdit()
101 the QLineEdit can be accessed. 103 the QLineEdit can be accessed.
102 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal 104 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
103 input can be done. Using spinBox() the QSpinBox can be accessed. 105 input can be done. Using spinBox() the QSpinBox can be accessed.
104 <li>\c ComboBox - A read-only QComboBox is used for taking the input, 106 <li>\c ComboBox - A read-only QComboBox is used for taking the input,
105 so one item of a list can be chosen. Using comboBox() the QComboBox 107 so one item of a list can be chosen. Using comboBox() the QComboBox
106 can be accessed. 108 can be accessed.
107 <li>\c EditableComboBox - An editable QComboBox is used for taking the input, 109 <li>\c EditableComboBox - An editable QComboBox is used for taking the input,
108 so either one item of a list can be chosen or a text can be entered. Using 110 so either one item of a list can be chosen or a text can be entered. Using
109 editableComboBox() the QComboBox can be accessed. 111 editableComboBox() the QComboBox can be accessed.
110 </ul> 112 </ul>
111*/ 113*/
112 114
113/*! 115/*!
114 Constructs the dialog. \a label is the text which is shown to the user (it should mention 116 Constructs the dialog. \a label is the text which is shown to the user (it should mention
115 to the user what he/she should input), \a parent the parent widget of the dialog, \a name 117 to the user what he/she should input), \a parent the parent widget of the dialog, \a name
116 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops 118 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
117 up modeless. With \a type you specify the type of the dialog. 119 up modeless. With \a type you specify the type of the dialog.
118 120
119 \sa getText(), getInteger(), getDouble(), getItem() 121 \sa getText(), getInteger(), getDouble(), getItem()
120*/ 122*/
121 123
122QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, 124QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
123 bool modal, Type type) 125 bool modal, Type type)
124 : QDialog( parent, name, modal ) 126 : QDialog( parent, name, modal )
125{ 127{
126 if ( parent && parent->icon() &&!parent->icon()->isNull() ) 128 if ( parent && parent->icon() &&!parent->icon()->isNull() )
127 setIcon( *parent->icon() ); 129 setIcon( *parent->icon() );
128 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 130 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
129 QDialog::setIcon( *qApp->mainWidget()->icon() ); 131 QDialog::setIcon( *qApp->mainWidget()->icon() );
130 132
131 d = new QInputDialogPrivate; 133 d = new QInputDialogPrivate;
132 d->lineEdit = 0; 134 d->lineEdit = 0;
133 d->spinBox = 0; 135 d->spinBox = 0;
134 d->comboBox = 0; 136 d->comboBox = 0;
135 137
136 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); 138 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
137 139
138 QLabel* l = new QLabel( label, this ); 140 QLabel* l = new QLabel( label, this );
139 vbox->addWidget( l ); 141 vbox->addWidget( l );
140 142
141 d->stack = new QWidgetStack( this ); 143 d->stack = new QWidgetStack( this );
142 vbox->addWidget( d->stack ); 144 vbox->addWidget( d->stack );
143 d->lineEdit = new QLineEdit( d->stack ); 145 d->lineEdit = new QLineEdit( d->stack );
144 d->spinBox = new QSpinBox( d->stack ); 146 d->spinBox = new QSpinBox( d->stack );
145 d->comboBox = new QComboBox( FALSE, d->stack ); 147 d->comboBox = new QComboBox( FALSE, d->stack );
146 d->editComboBox = new QComboBox( TRUE, d->stack ); 148 d->editComboBox = new QComboBox( TRUE, d->stack );
147 149
148 QHBoxLayout *hbox = new QHBoxLayout( 6 ); 150 QHBoxLayout *hbox = new QHBoxLayout( 6 );
149 vbox->addLayout( hbox, AlignRight ); 151 vbox->addLayout( hbox, AlignRight );
150 152
151 d->ok = new QPushButton( tr( "&OK" ), this ); 153 d->ok = new QPushButton( tr( "&OK" ), this );
152 d->ok->setDefault( TRUE ); 154 d->ok->setDefault( TRUE );
153 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); 155 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
154 156
155 QSize bs( d->ok->sizeHint() ); 157 QSize bs( d->ok->sizeHint() );
156 if ( cancel->sizeHint().width() > bs.width() ) 158 if ( cancel->sizeHint().width() > bs.width() )
157 bs.setWidth( cancel->sizeHint().width() ); 159 bs.setWidth( cancel->sizeHint().width() );
158 160
159 d->ok->setFixedSize( bs ); 161 d->ok->setFixedSize( bs );
160 cancel->setFixedSize( bs ); 162 cancel->setFixedSize( bs );
161 163
162 hbox->addWidget( new QWidget( this ) ); 164 hbox->addWidget( new QWidget( this ) );
163 hbox->addWidget( d->ok ); 165 hbox->addWidget( d->ok );
164 hbox->addWidget( cancel ); 166 hbox->addWidget( cancel );
165 167
166 connect( d->lineEdit, SIGNAL( returnPressed() ), 168 connect( d->lineEdit, SIGNAL( returnPressed() ),
167 this, SLOT( tryAccept() ) ); 169 this, SLOT( tryAccept() ) );
168 connect( d->lineEdit, SIGNAL( textChanged( const QString & ) ), 170 connect( d->lineEdit, SIGNAL( textChanged( const QString & ) ),
169 this, SLOT( textChanged( const QString & ) ) ); 171 this, SLOT( textChanged( const QString & ) ) );
170 172
171 connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); 173 connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
172 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 174 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
173 175
174//US ToDo make size dependent of targetplatform 176//US ToDo make size dependent of targetplatform
175//US resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() ); 177//US resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() );
176 resize( sizeHint().width(), sizeHint().height() ); 178 resize( sizeHint().width(), sizeHint().height() );
177 179
178 setType( type ); 180 setType( type );
179} 181}
180 182
181/*! 183/*!
182 Returns the line edit, which is used in the LineEdit mode 184 Returns the line edit, which is used in the LineEdit mode
183*/ 185*/
184 186
185QLineEdit *QInputDialog::lineEdit() const 187QLineEdit *QInputDialog::lineEdit() const
186{ 188{
187 return d->lineEdit; 189 return d->lineEdit;
188} 190}
189 191
190/*! 192/*!
191 Returns the spinbox, which is used in the SpinBox mode 193 Returns the spinbox, which is used in the SpinBox mode
192*/ 194*/
193 195
194QSpinBox *QInputDialog::spinBox() const 196QSpinBox *QInputDialog::spinBox() const
195{ 197{
196 return d->spinBox; 198 return d->spinBox;
197} 199}
198 200
199/*! 201/*!
200 Returns the combobox, which is used in the ComboBox mode 202 Returns the combobox, which is used in the ComboBox mode
201*/ 203*/
202 204
203QComboBox *QInputDialog::comboBox() const 205QComboBox *QInputDialog::comboBox() const
204{ 206{
205 return d->comboBox; 207 return d->comboBox;
206} 208}
207 209
208/*! 210/*!
209 Returns the combobox, which is used in the EditableComboBox mode 211 Returns the combobox, which is used in the EditableComboBox mode
210*/ 212*/
211 213
212QComboBox *QInputDialog::editableComboBox() const 214QComboBox *QInputDialog::editableComboBox() const
213{ 215{
214 return d->editComboBox; 216 return d->editComboBox;
215} 217}
216 218
217/*! 219/*!
218 Sets the input type of the dialog to \a t. 220 Sets the input type of the dialog to \a t.
219*/ 221*/
220 222
221void QInputDialog::setType( Type t ) 223void QInputDialog::setType( Type t )
222{ 224{
223 switch ( t ) { 225 switch ( t ) {
224 case LineEdit: 226 case LineEdit:
225 d->stack->raiseWidget( d->lineEdit ); 227 d->stack->raiseWidget( d->lineEdit );
226 d->lineEdit->setFocus(); 228 d->lineEdit->setFocus();
227 break; 229 break;
228 case SpinBox: 230 case SpinBox:
229 d->stack->raiseWidget( d->spinBox ); 231 d->stack->raiseWidget( d->spinBox );
230 d->spinBox->setFocus(); 232 d->spinBox->setFocus();
231 break; 233 break;
232 case ComboBox: 234 case ComboBox:
233 d->stack->raiseWidget( d->comboBox ); 235 d->stack->raiseWidget( d->comboBox );
234 d->comboBox->setFocus(); 236 d->comboBox->setFocus();
235 break; 237 break;
236 case EditableComboBox: 238 case EditableComboBox:
237 d->stack->raiseWidget( d->editComboBox ); 239 d->stack->raiseWidget( d->editComboBox );
238 d->editComboBox->setFocus(); 240 d->editComboBox->setFocus();
239 break; 241 break;
240 } 242 }
241 243
242 d->type = t; 244 d->type = t;
243} 245}
244 246
245/*! 247/*!
246 Returns the input type of the dialog. 248 Returns the input type of the dialog.
247 249
248 \sa setType() 250 \sa setType()
249*/ 251*/
250 252
251QInputDialog::Type QInputDialog::type() const 253QInputDialog::Type QInputDialog::type() const
252{ 254{
253 return d->type; 255 return d->type;
254} 256}
255 257
256/*! 258/*!
257 Destructor. 259 Destructor.
258*/ 260*/
259 261
260QInputDialog::~QInputDialog() 262QInputDialog::~QInputDialog()
261{ 263{
262 delete d; 264 delete d;
263} 265}
264 266
265/*! 267/*!
266 Static convenience function to get a textual input from the user. \a caption is the text 268 Static convenience function to get a textual input from the user. \a caption is the text
267 which is displayed in the title bar of the dialog. \a label is the text which 269 which is displayed in the title bar of the dialog. \a label is the text which
268 is shown to the user (it should mention to the user what he/she should input), \a text 270 is shown to the user (it should mention to the user what he/she should input), \a text
269 the default text which will be initially set to the line edit, \a ok a pointer to 271 the default text which will be initially set to the line edit, \a ok a pointer to
270 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 272 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
271 user pressed cancel, \a parent the parent widget of the dialog and \a name 273 user pressed cancel, \a parent the parent widget of the dialog and \a name
272 the name of it. The dialogs pops up modally! 274 the name of it. The dialogs pops up modally!
273 275
274 This method returns the text which has been entered in the line edit. 276 This method returns the text which has been entered in the line edit.
275 277
276 You will use this static method like this: 278 You will use this static method like this:
277 279
278 \code 280 \code
279 bool ok = FALSE; 281 bool ok = FALSE;
280 QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this ); 282 QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
281 if ( ok && !text.isEmpty() ) 283 if ( ok && !text.isEmpty() )
282 ;// user entered something and pressed ok 284 ;// user entered something and pressed ok
283 else 285 else
284 ;// user entered nothing or pressed cancel 286 ;// user entered nothing or pressed cancel
285 \endcode 287 \endcode
286*/ 288*/
287 289
288QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text, 290QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text,
289 bool *ok, QWidget *parent, const char *name ) 291 bool *ok, QWidget *parent, const char *name )
290{ 292{
291 return getText( caption, label, QLineEdit::Normal, text, ok, parent, name ); 293 return getText( caption, label, QLineEdit::Normal, text, ok, parent, name );
292} 294}
293 295
294/*! 296/*!
295 Like above, but accepts an a \a mode which the line edit will use to display text. 297 Like above, but accepts an a \a mode which the line edit will use to display text.
296 298
297 \sa getText() 299 \sa getText()
298*/ 300*/
299 301
300QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode, 302QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode,
301 const QString &text, bool *ok, QWidget *parent, const char *name ) 303 const QString &text, bool *ok, QWidget *parent, const char *name )
302{ 304{
303 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); 305 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
304 dlg->setCaption( caption ); 306 dlg->setCaption( caption );
305 dlg->lineEdit()->setText( text ); 307 dlg->lineEdit()->setText( text );
306 dlg->lineEdit()->setEchoMode( mode ); 308 dlg->lineEdit()->setEchoMode( mode );
307 if ( !text.isEmpty() ) 309 if ( !text.isEmpty() )
308 dlg->lineEdit()->selectAll(); 310 dlg->lineEdit()->selectAll();
309 311
310 bool ok_ = FALSE; 312 bool ok_ = FALSE;
311 QString result; 313 QString result;
312 ok_ = dlg->exec() == QDialog::Accepted; 314 ok_ = dlg->exec() == QDialog::Accepted;
313 if ( ok ) 315 if ( ok )
314 *ok = ok_; 316 *ok = ok_;
315 if ( ok_ ) 317 if ( ok_ )
316 result = dlg->lineEdit()->text(); 318 result = dlg->lineEdit()->text();
317 319
318 delete dlg; 320 delete dlg;
319 return result; 321 return result;
320} 322}
321 323
322/*! 324/*!
323 Static convenience function to get an integral input from the user. \a caption is the text 325 Static convenience function to get an integral input from the user. \a caption is the text
324 which is displayed in the title bar of the dialog. \a label is the text which 326 which is displayed in the title bar of the dialog. \a label is the text which
325 is shown to the user (it should mention to the user what he/she should input), \a num 327 is shown to the user (it should mention to the user what he/she should input), \a num
326 the default number which will be initially set to the spinbox, \a from and \a to the 328 the default number which will be initially set to the spinbox, \a from and \a to the
327 range in which the entered number has to be, \a step the step in which the number can 329 range in which the entered number has to be, \a step the step in which the number can
328 be increased/decreased by the spinbox, \a ok a pointer to 330 be increased/decreased by the spinbox, \a ok a pointer to
329 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 331 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
330 user pressed cancel, \a parent the parent widget of the dialog and \a name 332 user pressed cancel, \a parent the parent widget of the dialog and \a name
331 the name of it. The dialogs pops up modally! 333 the name of it. The dialogs pops up modally!
332 334
333 This method returns the number which has been entered by the user. 335 This method returns the number which has been entered by the user.
334 336
335 You will use this static method like this: 337 You will use this static method like this:
336 338
337 \code 339 \code
338 bool ok = FALSE; 340 bool ok = FALSE;
339 int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this ); 341 int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
340 if ( ok ) 342 if ( ok )
341 ;// user entered something and pressed ok 343 ;// user entered something and pressed ok
342 else 344 else
343 ;// user pressed cancel 345 ;// user pressed cancel
344 \endcode 346 \endcode
345*/ 347*/
346 348
347int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step, 349int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step,
348 bool *ok, QWidget *parent, const char *name ) 350 bool *ok, QWidget *parent, const char *name )
349{ 351{
350 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox ); 352 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox );
351 dlg->setCaption( caption ); 353 dlg->setCaption( caption );
352 dlg->spinBox()->setRange( from, to ); 354 dlg->spinBox()->setRange( from, to );
353 dlg->spinBox()->setSteps( step, 0 ); 355 dlg->spinBox()->setSteps( step, 0 );
354 dlg->spinBox()->setValue( num ); 356 dlg->spinBox()->setValue( num );
355 357
356 bool ok_ = FALSE; 358 bool ok_ = FALSE;
357 int result; 359 int result;
358 ok_ = dlg->exec() == QDialog::Accepted; 360 ok_ = dlg->exec() == QDialog::Accepted;
359 if ( ok ) 361 if ( ok )
360 *ok = ok_; 362 *ok = ok_;
361 result = dlg->spinBox()->value(); 363 result = dlg->spinBox()->value();
362 364
363 delete dlg; 365 delete dlg;
364 return result; 366 return result;
365} 367}
366 368
367/*! 369/*!
368 Static convenience function to get a decimal input from the user. \a caption is the text 370 Static convenience function to get a decimal input from the user. \a caption is the text
369 which is displayed in the title bar of the dialog. \a label is the text which 371 which is displayed in the title bar of the dialog. \a label is the text which
370 is shown to the user (it should mention to the user what he/she should input), \a num 372 is shown to the user (it should mention to the user what he/she should input), \a num
371 the default decimal number which will be initially set to the line edit, \a from and \a to the 373 the default decimal number which will be initially set to the line edit, \a from and \a to the
372 range in which the entered number has to be, \a decimals the number of decimal which 374 range in which the entered number has to be, \a decimals the number of decimal which
373 the number may have, \a ok a pointer to 375 the number may have, \a ok a pointer to
374 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 376 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
375 user pressed cancel, \a parent the parent widget of the dialog and \a name 377 user pressed cancel, \a parent the parent widget of the dialog and \a name
376 the name of it. The dialogs pops up modally! 378 the name of it. The dialogs pops up modally!
377 379
378 This method returns the number which has been entered by the user. 380 This method returns the number which has been entered by the user.
379 381
380 You will use this static method like this: 382 You will use this static method like this:
381 383
382 \code 384 \code
383 bool ok = FALSE; 385 bool ok = FALSE;
384 double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this ); 386 double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );
385 if ( ok ) 387 if ( ok )
386 ;// user entered something and pressed ok 388 ;// user entered something and pressed ok
387 else 389 else
388 ;// user pressed cancel 390 ;// user pressed cancel
389 \endcode 391 \endcode
390*/ 392*/
391 393
392double QInputDialog::getDouble( const QString &caption, const QString &label, double num, 394double QInputDialog::getDouble( const QString &caption, const QString &label, double num,
393 double from, double to, int decimals, 395 double from, double to, int decimals,
394 bool *ok, QWidget *parent, const char *name ) 396 bool *ok, QWidget *parent, const char *name )
395{ 397{
396 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); 398 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
397 dlg->setCaption( caption ); 399 dlg->setCaption( caption );
398 dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) ); 400 dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) );
399 dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) ); 401 dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) );
400 dlg->lineEdit()->selectAll(); 402 dlg->lineEdit()->selectAll();
401 403
402 bool accepted = ( dlg->exec() == QDialog::Accepted ); 404 bool accepted = ( dlg->exec() == QDialog::Accepted );
403 if ( ok ) 405 if ( ok )
404 *ok = accepted; 406 *ok = accepted;
405 407
406 double result = dlg->lineEdit()->text().toDouble(); 408 double result = dlg->lineEdit()->text().toDouble();
407 409
408 delete dlg; 410 delete dlg;
409 return result; 411 return result;
410} 412}
411 413
412/*! 414/*!
413 Static convenience function to let the user select an item from a string list. \a caption is the text 415 Static convenience function to let the user select an item from a string list. \a caption is the text
414 which is displayed in the title bar of the dialog. \a label is the text which 416 which is displayed in the title bar of the dialog. \a label is the text which
415 is shown to the user (it should mention to the user what he/she should input), \a list the 417 is shown to the user (it should mention to the user what he/she should input), \a list the
416 string list which is inserted into the combobox, \a current the number of the item which should 418 string list which is inserted into the combobox, \a current the number of the item which should
417 be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE) 419 be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE)
418 or read-only (if \a editable is FALSE), \a ok a pointer to 420 or read-only (if \a editable is FALSE), \a ok a pointer to
419 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 421 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
420 user pressed cancel, \a parent the parent widget of the dialog and \a name 422 user pressed cancel, \a parent the parent widget of the dialog and \a name
421 the name of it. The dialogs pops up modally! 423 the name of it. The dialogs pops up modally!
422 424
423 This method returns the text of the current item, or if \a editable was TRUE, the current 425 This method returns the text of the current item, or if \a editable was TRUE, the current
424 text of the combobox. 426 text of the combobox.
425 427
426 You will use this static method like this: 428 You will use this static method like this:
427 429
428 \code 430 \code
429 QStringList lst; 431 QStringList lst;
430 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth"; 432 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
431 bool ok = FALSE; 433 bool ok = FALSE;
432 QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this ); 434 QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
433 if ( ok ) 435 if ( ok )
434 ;// user selected an item and pressed ok 436 ;// user selected an item and pressed ok
435 else 437 else
436 ;// user pressed cancel 438 ;// user pressed cancel
437 \endcode 439 \endcode
438*/ 440*/
439 441
440QString QInputDialog::getItem( const QString &caption, const QString &label, const QStringList &list, 442QString QInputDialog::getItem( const QString &caption, const QString &label, const QStringList &list,
441 int current, bool editable, 443 int current, bool editable,
442 bool *ok, QWidget *parent, const char *name ) 444 bool *ok, QWidget *parent, const char *name )
443{ 445{
444 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, editable ? EditableComboBox : ComboBox ); 446 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, editable ? EditableComboBox : ComboBox );
445 dlg->setCaption( caption ); 447 dlg->setCaption( caption );
446 if ( editable ) { 448 if ( editable ) {
447 dlg->editableComboBox()->insertStringList( list ); 449 dlg->editableComboBox()->insertStringList( list );
448 dlg->editableComboBox()->setCurrentItem( current ); 450 dlg->editableComboBox()->setCurrentItem( current );
449 } else { 451 } else {
450 dlg->comboBox()->insertStringList( list ); 452 dlg->comboBox()->insertStringList( list );
451 dlg->comboBox()->setCurrentItem( current ); 453 dlg->comboBox()->setCurrentItem( current );
452 } 454 }
453 455
454 bool ok_ = FALSE; 456 bool ok_ = FALSE;
455 QString result; 457 QString result;
458 int fixWid = 320;
459 if ( QApplication::desktop()->width() <= 240 ) {
460 fixWid = 230;
461 }
462 dlg->setFixedWidth( fixWid);
456 ok_ = dlg->exec() == QDialog::Accepted; 463 ok_ = dlg->exec() == QDialog::Accepted;
457 if ( ok ) 464 if ( ok )
458 *ok = ok_; 465 *ok = ok_;
459 if ( editable ) 466 if ( editable )
460 result = dlg->editableComboBox()->currentText(); 467 result = dlg->editableComboBox()->currentText();
461 else 468 else
462 result = dlg->comboBox()->currentText(); 469 result = dlg->comboBox()->currentText();
463 470
464 delete dlg; 471 delete dlg;
465 return result; 472 return result;
466} 473}
467 474
468/*! 475/*!
469 \internal 476 \internal
470*/ 477*/
471 478
472void QInputDialog::textChanged( const QString &s ) 479void QInputDialog::textChanged( const QString &s )
473{ 480{
474 bool on; 481 bool on;
475 if ( d->lineEdit->validator() ) { 482 if ( d->lineEdit->validator() ) {
476 QString str = d->lineEdit->text(); 483 QString str = d->lineEdit->text();
477 int index = d->lineEdit->cursorPosition(); 484 int index = d->lineEdit->cursorPosition();
478 on = ( d->lineEdit->validator()->validate(str, index) == 485 on = ( d->lineEdit->validator()->validate(str, index) ==
479 QValidator::Acceptable ); 486 QValidator::Acceptable );
480 } else { 487 } else {
481 on = !s.isEmpty(); 488 on = !s.isEmpty();
482 } 489 }
483 d->ok->setEnabled( on ); 490 d->ok->setEnabled( on );
484} 491}
485 492
486/*! 493/*!
487 \internal 494 \internal
488*/ 495*/
489 496
490void QInputDialog::tryAccept() 497void QInputDialog::tryAccept()
491{ 498{
492 if ( !d->lineEdit->text().isEmpty() ) 499 if ( !d->lineEdit->text().isEmpty() )
493 accept(); 500 accept();
494} 501}
495 502