summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 02:17:06 (UTC)
committer zautrix <zautrix>2004-10-09 02:17:06 (UTC)
commitc2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff)
treeb83f7cfe5d4bb681b756fe95446e5e3fc193bc36
parent07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff)
downloadkdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2
import ir fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/kopiWhatsNew.txt8
-rw-r--r--kabc/addressbook.cpp16
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp17
-rw-r--r--kabc/addressee.h1
-rw-r--r--kaddressbook/kabcore.cpp22
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--kaddressbook/kaddressbookmain.cpp12
-rw-r--r--kaddressbook/kaddressbookmain.h2
-rw-r--r--kaddressbook/mainembedded.cpp8
-rw-r--r--korganizer/mainwindow.cpp15
-rw-r--r--libkdepim/ksyncmanager.cpp6
12 files changed, 79 insertions, 31 deletions
diff --git a/bin/kdepim/korganizer/kopiWhatsNew.txt b/bin/kdepim/korganizer/kopiWhatsNew.txt
index eea860c..3f95dcf 100644
--- a/bin/kdepim/korganizer/kopiWhatsNew.txt
+++ b/bin/kdepim/korganizer/kopiWhatsNew.txt
@@ -1,354 +1,360 @@
1Info about the changes in new versions of KO/Pi 1Info about the changes in new versions of KO/Pi
2and KDE-Pim/Pi 2and KDE-Pim/Pi
3 3
4********** VERSION 1.9.7 ************ 4********** VERSION 1.9.7 ************
5 5
6KO/Pi - KA/Pi on Windows: 6KO/Pi - KA/Pi on Windows:
7Now a directory can be defined by the user, where the 7Now a directory can be defined by the user, where the
8application/config data should be saved. 8application/config data should be saved.
9 Define your desired path in the evironment variable 9 Define your desired path in the evironment variable
10 MICROKDEHOME 10 MICROKDEHOME
11 before starting KO/Pi or KA/Pi. 11 before starting KO/Pi or KA/Pi.
12 12
13An easy Kx/Pi to Kx/Pi syncing is now possible 13An easy Kx/Pi to Kx/Pi syncing is now possible
14(it is called Pi-Sync) via network. 14(it is called Pi-Sync) via network.
15Please look at the Sync Howto. 15Please look at the Sync Howto.
16 16
17Exporting of data to mobile phones is now possible. 17Exporting of calendar data and contacts to mobile phones is now possible.
18The SyncHowto is updated with information howto 18The SyncHowto is updated with information howto
19access/sync mobile phones. 19access/sync mobile phones.
20Please look at the Sync Howto. 20Please look at the Sync Howto.
21 21
22Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly.
23Please disable Fastload for the original contact/calendar applications
24and close them.
25KO/Pi and KA/Pi must be running in order to receive the data.
26(KO/Pi and KA/Pi are always running if Fastload for them is enabled!)
27
22 28
23********** VERSION 1.9.6 ************ 29********** VERSION 1.9.6 ************
24 30
25Changes in the external application communication on the Zaurus 31Changes in the external application communication on the Zaurus
26in order to use less RAM when the apps are running. 32in order to use less RAM when the apps are running.
27First syncing of addressbooks (KA/Pi) is possible. 33First syncing of addressbooks (KA/Pi) is possible.
28 34
29 35
30********** VERSION 1.9.5a ************ 36********** VERSION 1.9.5a ************
31 37
32Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. 38Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5.
33Fixed some small bugs. 39Fixed some small bugs.
34KA/Pi shows now the birthday in summary view. 40KA/Pi shows now the birthday in summary view.
35Now OM/Pi and KA/Pi are using the date format defined in KO/Pi 41Now OM/Pi and KA/Pi are using the date format defined in KO/Pi
36for displaying dates. 42for displaying dates.
37 43
38 44
39********** VERSION 1.9.5 ************ 45********** VERSION 1.9.5 ************
40 46
41There is still no Addressbook syncing! 47There is still no Addressbook syncing!
42 48
43New in 1.9.5: 49New in 1.9.5:
44 50
45Many bugfixes. 51Many bugfixes.
46Better searching in KA/Pi. 52Better searching in KA/Pi.
47You can configure in KA/Pi if you want to search only after 53You can configure in KA/Pi if you want to search only after
48<return> key pressed. 54<return> key pressed.
49 55
50Better mail downloading in OM/Pi. 56Better mail downloading in OM/Pi.
51 57
52First experimental alpha version of sync of KO/Pi with mobile phones. 58First experimental alpha version of sync of KO/Pi with mobile phones.
53See gammu documentation for supported phones. 59See gammu documentation for supported phones.
54You 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. 60You 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.
55Quick hint how to use: 61Quick hint how to use:
56NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! 62NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL!
57Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. 63Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp.
58Create syncprofile - mobile device 64Create syncprofile - mobile device
59Remove entry for model. (Leave empty ). 65Remove entry for model. (Leave empty ).
60Enable infrared on Zaurus and your Phone. 66Enable infrared on Zaurus and your Phone.
61Sync. 67Sync.
62To get a more detailed log, start kopi from konsole. 68To get a more detailed log, start kopi from konsole.
63 69
64********** VERSION 1.9.4 ************ 70********** VERSION 1.9.4 ************
65 71
66This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. 72This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus.
67 73
68WARNING: 74WARNING:
69PLEASE BACKUP ALL YOUR DATA! 75PLEASE BACKUP ALL YOUR DATA!
70We have changed a lot and maybe there are some unknown problems. 76We have changed a lot and maybe there are some unknown problems.
71 77
72SYNC HANDLING HAS CHANGED! 78SYNC HANDLING HAS CHANGED!
73Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 79Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
74(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 80(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
75 81
76You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. 82You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs.
77If 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. 83If 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.
78 84
79As programs are available: 85As programs are available:
80KO/Pi (korganizer ipk) - a calendar program. 86KO/Pi (korganizer ipk) - a calendar program.
81KA/Pi (kaddressbook ipk ) - an addressbook 87KA/Pi (kaddressbook ipk ) - an addressbook
82OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. 88OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support.
83 89
84An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. 90An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode.
85(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) 91(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia)
86 92
87All the applications are installed in a "Pim" TAB. 93All the applications are installed in a "Pim" TAB.
88If 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 94If 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
89 95
90All the application are integrated. 96All the application are integrated.
91Such 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. 97Such 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.
92 98
93HINT: 99HINT:
94If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. 100If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number.
95 101
96What's new? 102What's new?
97 103
98SYNC HANDLING HAS CHANGED! 104SYNC HANDLING HAS CHANGED!
99Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 105Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
100(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 106(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
101 107
102New in OM/Pi: 108New in OM/Pi:
103When 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. 109When 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.
104 110
105New in KO/Pi: 111New in KO/Pi:
106French is now available for KO/Pi. 112French is now available for KO/Pi.
107Choose menu:Actions - Configure:TAB locale 113Choose menu:Actions - Configure:TAB locale
108Syncing has changed. 114Syncing has changed.
109Phone sync available soon. 115Phone sync available soon.
110Not much changes, I cannot remember them ... 116Not much changes, I cannot remember them ...
111 117
112New in KA/Pi: 118New in KA/Pi:
113Beaming possible. 119Beaming possible.
114Sharp DTM readonly access possible( create a new DTM resource ); 120Sharp DTM readonly access possible( create a new DTM resource );
115Better searching possible. 121Better searching possible.
116Search is performed only after pressing the return key. 122Search is performed only after pressing the return key.
117Use wildcard * to specify parts of a name. 123Use wildcard * to specify parts of a name.
118 124
119Better 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 * . 125Better 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 * .
120 126
121A big improvement is the new management of the contact access. 127A big improvement is the new management of the contact access.
122In version 1.9.3, every application was using their own addressbook access data. 128In version 1.9.3, every application was using their own addressbook access data.
123That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. 129That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi.
124That was wasting of memory, if you had several hundreds of contacts. 130That was wasting of memory, if you had several hundreds of contacts.
125 131
126Now only KA/Pi accesses the addressbook. 132Now only KA/Pi accesses the addressbook.
127If 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. 133If 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.
128If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. 134If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly.
129That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. 135That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first.
130 136
131New in the KO/Pi alarm applet: 137New in the KO/Pi alarm applet:
132Configure your own timer popup menu! 138Configure your own timer popup menu!
133(Text and minutes for timer countdown) 139(Text and minutes for timer countdown)
134Just edit the file 140Just edit the file
135(yourhomedir)/.kopialarmtimerrc 141(yourhomedir)/.kopialarmtimerrc
136and start/stop a timer to get a new menu with the data of this file. 142and start/stop a timer to get a new menu with the data of this file.
137 143
138********** VERSION 1.9.3 ************ 144********** VERSION 1.9.3 ************
1391) 1451)
140Now KO/Pi on Windows imports directly the calendar data of 146Now KO/Pi on Windows imports directly the calendar data of
141an installed Outlook. Should work with OL version >= 2000. 147an installed Outlook. Should work with OL version >= 2000.
142 148
143********** VERSION 1.9.2 ************ 149********** VERSION 1.9.2 ************
1441) 1501)
145KDE-Pim/Pi has got a new member: 151KDE-Pim/Pi has got a new member:
146KmicroMail (KM/Pi) is a mail program, 152KmicroMail (KM/Pi) is a mail program,
147which can handle IMAP and POP mail access. 153which can handle IMAP and POP mail access.
148It is based on Opie-Mail v3. 154It is based on Opie-Mail v3.
149All dependencies to the Opie libraries ar removed, 155All dependencies to the Opie libraries ar removed,
150such that no additional Opie lib is needed. 156such that no additional Opie lib is needed.
151It is already integrated in KO/Pi and KA/Pi. 157It is already integrated in KO/Pi and KA/Pi.
152It it now available for the Zaurus,probably it 158It it now available for the Zaurus,probably it
153will be available for other platforms later. 159will be available for other platforms later.
154Hint: 160Hint:
155Create your own contact (name + email) 161Create your own contact (name + email)
156in KA/Pi, select this contact and choose menu: 162in KA/Pi, select this contact and choose menu:
157Settings - Set Who Am I. 163Settings - Set Who Am I.
158Now the settings of this contact are used as 164Now the settings of this contact are used as
159the sender data in KM/Pi. 165the sender data in KM/Pi.
1602) 1662)
161KDE-Pim/Pi is split up in five different 167KDE-Pim/Pi is split up in five different
162packages now precompiled for Sharp Zaurus: 168packages now precompiled for Sharp Zaurus:
163--kmicrokdelibs_1.9.2_arm.ipk 169--kmicrokdelibs_1.9.2_arm.ipk
164The libs are needed for any 170The libs are needed for any
165of the following programs: 171of the following programs:
166--kaddressbook_1.9.2_arm.ipk 172--kaddressbook_1.9.2_arm.ipk
167--kmicromail_1.9.2_arm.ipk 173--kmicromail_1.9.2_arm.ipk
168--korganizer_1.9.2_arm.ipk 174--korganizer_1.9.2_arm.ipk
169Independ from that, there is the alarm applet 175Independ from that, there is the alarm applet
170available for KO/Pi, which also offers 176available for KO/Pi, which also offers
171quick access for a new mail or 177quick access for a new mail or
172showing the addressbook.: 178showing the addressbook.:
173--korganizer-alarm_1.9.2_arm.ipk 179--korganizer-alarm_1.9.2_arm.ipk
174Independend means, that the alarm applet 180Independend means, that the alarm applet
175does not need any of the libs or programs above to run. 181does not need any of the libs or programs above to run.
176But it would be quite useless without these programs. 182But it would be quite useless without these programs.
177NOTE: 183NOTE:
178If you get a 184If you get a
179"This application depends on other programs" 185"This application depends on other programs"
180during installation of 186during installation of
181--kmicrokdelibs_1.9.2_arm.ipk 187--kmicrokdelibs_1.9.2_arm.ipk
182you probably do not have to care about that. 188you probably do not have to care about that.
183kmicrokdelibs_1.9.2 will come with some 189kmicrokdelibs_1.9.2 will come with some
184resource plugins, which needs additional libraries. 190resource plugins, which needs additional libraries.
185(E.g. libopie1, if you want to use the 191(E.g. libopie1, if you want to use the
186opie resource connector in KA/Pi). 192opie resource connector in KA/Pi).
187If you do not have this libraries installed, 193If you do not have this libraries installed,
188you simply cannot use the resource. 194you simply cannot use the resource.
189To make it clear: 195To make it clear:
190If the libraries are missing, the applications 196If the libraries are missing, the applications
191using kmicrokdelibs will start, 197using kmicrokdelibs will start,
192because the resources are plugins. 198because the resources are plugins.
1933) 1993)
194KO/Pi and friends are now installable on SD-Card! 200KO/Pi and friends are now installable on SD-Card!
195It is recommended to install all libs and apps 201It is recommended to install all libs and apps
196on the SD card or all in the internal storage. 202on the SD card or all in the internal storage.
197There may be problems, if this is mixed. 203There may be problems, if this is mixed.
1984) 2044)
199Fixed two bugs in the alarm notification on Windows. 205Fixed two bugs in the alarm notification on Windows.
2005) 2065)
201Great improvement! 207Great improvement!
202KO/Pi uses now the latest version of libical. 208KO/Pi uses now the latest version of libical.
203Libical is the library which actually reads 209Libical is the library which actually reads
204the calendar files and extract the data from it. 210the calendar files and extract the data from it.
205With the old version, there were problems 211With the old version, there were problems
206(crashes or program hangs) when licical did read 212(crashes or program hangs) when licical did read
207files, which were not stored from KO/Pi. 213files, which were not stored from KO/Pi.
208I do not know, if the new libical works perfect, 214I do not know, if the new libical works perfect,
209but actually it works much better than 215but actually it works much better than
210the old version. 216the old version.
211There are no problems with compatibility with 217There are no problems with compatibility with
212old calendar files of KO/Pi, of course! 218old calendar files of KO/Pi, of course!
2136) 2196)
214New in KA/Pi: 220New in KA/Pi:
215Opie addressbook resource connector available! 221Opie addressbook resource connector available!
216You will need libopie1 and the opie addressbook, 222You will need libopie1 and the opie addressbook,
217of course. 223of course.
218With the Opie addressbook resource connector, 224With the Opie addressbook resource connector,
219you can access the Opie addressbook readonly in KA/Pi. 225you can access the Opie addressbook readonly in KA/Pi.
220If you want to edit or import the data into KA/Pi, 226If you want to edit or import the data into KA/Pi,
221do this: 227do this:
222a) Create an Opie resource. 228a) Create an Opie resource.
223 (Menu: Settings-Configure Resources). 229 (Menu: Settings-Configure Resources).
224After configuration and restarting KA/Pi you should see 230After configuration and restarting KA/Pi you should see
225the Opie contacts in KA/Pi. 231the Opie contacts in KA/Pi.
226b) Select some or all Opie contacts. 232b) Select some or all Opie contacts.
227(NOTE: +++++ 233(NOTE: +++++
228To know exactly, what contacts are Opie contacts, 234To know exactly, what contacts are Opie contacts,
229do this: Choose menu: 235do this: Choose menu:
230View-Modify View - TAB Fields. 236View-Modify View - TAB Fields.
231Select in the above list "Resource" and click 237Select in the above list "Resource" and click
232down arrow to add it to the "Selected fields". 238down arrow to add it to the "Selected fields".
233Click OK. 239Click OK.
234Now you have a new column "Resource" in your list, 240Now you have a new column "Resource" in your list,
235where you can see, what an Opie resource is. 241where you can see, what an Opie resource is.
236++++ NOTE end.) 242++++ NOTE end.)
237Ok, we do have now some Opie contacts seleted. 243Ok, we do have now some Opie contacts seleted.
238(Use SHIFT or CTRL key in order to multiple select). 244(Use SHIFT or CTRL key in order to multiple select).
239c) Choose menu: Edit-Copy. 245c) Choose menu: Edit-Copy.
240d) Choose menu: Edit-Paste. 246d) Choose menu: Edit-Paste.
241e) Select the resource, you want to add the contacts to. 247e) Select the resource, you want to add the contacts to.
242Congrats! Now you have read/write access to the copied 248Congrats! Now you have read/write access to the copied
243opie contacts as "real" KA/Pi contacts. 249opie contacts as "real" KA/Pi contacts.
244 250
245 251
246********** VERSION 1.9.1 ************ 252********** VERSION 1.9.1 ************
2471) 2531)
248 +++ IMPORTANT 1 +++ 254 +++ IMPORTANT 1 +++
249 255
250The storing place of the default calendar 256The storing place of the default calendar
251file has changed! 257file has changed!
252The default calendar file was 258The default calendar file was
253Applications/korganizer/mycalendar.ics 259Applications/korganizer/mycalendar.ics
254on Zaurus and 260on Zaurus and
255(yourHomeDir)/korganizer/mycalendar.ics 261(yourHomeDir)/korganizer/mycalendar.ics
256on Windows/Linux desktop. Now it is 262on Windows/Linux desktop. Now it is
257(yourHomeDir)/kdepim/korganizer/mycalendar.ics 263(yourHomeDir)/kdepim/korganizer/mycalendar.ics
258on Zaurus, Windows and Linux. 264on Zaurus, Windows and Linux.
259To load the old file, choose menu 265To load the old file, choose menu
260File-Load calendar backup. 266File-Load calendar backup.
261(It should be loaded automatically 267(It should be loaded automatically
262at startup with a warning message displayed). 268at startup with a warning message displayed).
263The place of the configuration file has changed too. 269The place of the configuration file has changed too.
264If you want to use your old KO/Pi config, 270If you want to use your old KO/Pi config,
265copy it to 271copy it to
266(yourHomeDir)/kdepim/config/korganizerrc 272(yourHomeDir)/kdepim/config/korganizerrc
267Please read VERSION 1.9.0 - topic 3) as well! 273Please read VERSION 1.9.0 - topic 3) as well!
268 274
269 +++ IMPORTANT 2 +++ 275 +++ IMPORTANT 2 +++
270 276
271Because of the new paths, you will need 277Because of the new paths, you will need
272a new version of the KO/Pi alarm applet 278a new version of the KO/Pi alarm applet
273for Zaurus. 279for Zaurus.
274Use version >= 1.9.1 280Use version >= 1.9.1
275 281
2762) 2822)
277Now the QWhat'sThis Icon works for items 283Now the QWhat'sThis Icon works for items
278in the month view as well. 284in the month view as well.
279(See VERSION 1.7.8 Topic 1) ). 285(See VERSION 1.7.8 Topic 1) ).
2803) 2863)
281You can import birtsdays/anniversaries 287You can import birtsdays/anniversaries
282from KA/Pi into KO/Pi. 288from KA/Pi into KO/Pi.
283Choose menu File-Import birthdays. 289Choose menu File-Import birthdays.
284If you import twice, already imported items 290If you import twice, already imported items
285will not be imported again, if they 291will not be imported again, if they
286have not been changed in KO/Pi. 292have not been changed in KO/Pi.
2874) 2934)
288When syncing with sharp DTM, now a progress 294When syncing with sharp DTM, now a progress
289is shown, when the data is written back. 295is shown, when the data is written back.
290If there is much data in KO/Pi and no data 296If there is much data in KO/Pi and no data
291in DTM, that can take a long time. 297in DTM, that can take a long time.
292(But only for the first time ). 298(But only for the first time ).
2935) 2995)
294In the search dialog, you can search 300In the search dialog, you can search
295now for the name/email of an attendee 301now for the name/email of an attendee
296of an event/todo. 302of an event/todo.
297To get more space for displaying 303To get more space for displaying
298search results, the buttons 304search results, the buttons
299for "search" and "close" on the 305for "search" and "close" on the
300bottom are removed in the PDA version. 306bottom are removed in the PDA version.
301You have to click OK in the top right 307You have to click OK in the top right
302corner to do a search. 308corner to do a search.
3036) 3096)
304Now it is possible to disable the displaying 310Now it is possible to disable the displaying
305of todo items in the Allday part of the Agenda. 311of todo items in the Allday part of the Agenda.
306Choose Menu Action-Configure, 312Choose Menu Action-Configure,
307TAB Todo View, checkbox 313TAB Todo View, checkbox
308"Allday Agenda view shows todos" 314"Allday Agenda view shows todos"
3097) 3157)
310If FastLoad is enabled, now the settings and the 316If FastLoad is enabled, now the settings and the
311calendar data are saved, when KO/Pi is closed. 317calendar data are saved, when KO/Pi is closed.
312(If no Fastload is enabled, KO/Pi saves 318(If no Fastload is enabled, KO/Pi saves
313the data as well, of course) 319the data as well, of course)
3148) 3208)
315The Agenda View has a minimize-splitter now, 321The Agenda View has a minimize-splitter now,
316such that the height of the allday part can be 322such that the height of the allday part can be
317changed quickly. 323changed quickly.
318 324
319********** VERSION 1.9.0 ************ 325********** VERSION 1.9.0 ************
3201) 3261)
321KO/Pi is now merged with the new microKDE from KA/Pi. 327KO/Pi is now merged with the new microKDE from KA/Pi.
322KO/Pi accesses now KA/Pi as the addressbook. 328KO/Pi accesses now KA/Pi as the addressbook.
323The other ddressbook-plugins are not working any longer. 329The other ddressbook-plugins are not working any longer.
324(It is planned, that later KA/Pi itself uses these plugins) 330(It is planned, that later KA/Pi itself uses these plugins)
325New versions of KO/Pi are only available 331New versions of KO/Pi are only available
326together with KA/Pi as the KDE-Pim/Pi package. 332together with KA/Pi as the KDE-Pim/Pi package.
3272) 3332)
328If you click on an attendee of a meeting in the 334If you click on an attendee of a meeting in the
329event viewer, a detailed summary of the 335event viewer, a detailed summary of the
330attendee is shown. 336attendee is shown.
3313) 3373)
332The place of the configuration file has changed. 338The place of the configuration file has changed.
333If you want to use your old KO/Pi config, copy 339If you want to use your old KO/Pi config, copy
334Applications/korganizer/config_korganizerrc 340Applications/korganizer/config_korganizerrc
335to 341to
336Applications/korganizer/config/korganizerrc 342Applications/korganizer/config/korganizerrc
337 343
338********** VERSION 1.7.8 ************ 344********** VERSION 1.7.8 ************
3391) 3451)
340Now the QWhat'sThis ist working. 346Now the QWhat'sThis ist working.
341Enable the QWhat'sThis icon in the toolbar. 347Enable the QWhat'sThis icon in the toolbar.
342(You have to restart to reload the changed toolbar config). 348(You have to restart to reload the changed toolbar config).
343Now click on the QWhat'sThis Icon 349Now click on the QWhat'sThis Icon
344in the top right corner of KO/Pi. 350in the top right corner of KO/Pi.
345Then click on an item in the Agenda View: 351Then click on an item in the Agenda View:
346You will get a detailed display of the items content. 352You will get a detailed display of the items content.
3472) 3532)
348Some other very minor changes. 354Some other very minor changes.
349But I have forgotten the details ... 355But I have forgotten the details ...
350For that reason I start this log here: 356For that reason I start this log here:
351To document my changes, when I am doing it. 357To document my changes, when I am doing it.
352 358
353********** VERSION 1.7.7 ************ 359********** VERSION 1.7.7 ************
354Stable Version of KO/Pi \ No newline at end of file 360Stable Version of KO/Pi \ No newline at end of file
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index dc3cda1..bf6d053 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,996 +1,1004 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qfile.h> 42#include <qfile.h>
43 43
44#include <kglobal.h> 44#include <kglobal.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kmessagebox.h> 46#include <kmessagebox.h>
47#include <kdebug.h> 47#include <kdebug.h>
48#include <libkcal/syncdefines.h> 48#include <libkcal/syncdefines.h>
49#include "addressbook.h" 49#include "addressbook.h"
50#include "resource.h" 50#include "resource.h"
51#include "vcardconverter.h" 51#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h" 52#include "vcardparser/vcardtool.h"
53 53
54//US #include "addressbook.moc" 54//US #include "addressbook.moc"
55 55
56using namespace KABC; 56using namespace KABC;
57 57
58struct AddressBook::AddressBookData 58struct AddressBook::AddressBookData
59{ 59{
60 Addressee::List mAddressees; 60 Addressee::List mAddressees;
61 Addressee::List mRemovedAddressees; 61 Addressee::List mRemovedAddressees;
62 Field::List mAllFields; 62 Field::List mAllFields;
63 KConfig *mConfig; 63 KConfig *mConfig;
64 KRES::Manager<Resource> *mManager; 64 KRES::Manager<Resource> *mManager;
65//US ErrorHandler *mErrorHandler; 65//US ErrorHandler *mErrorHandler;
66}; 66};
67 67
68struct AddressBook::Iterator::IteratorData 68struct AddressBook::Iterator::IteratorData
69{ 69{
70 Addressee::List::Iterator mIt; 70 Addressee::List::Iterator mIt;
71}; 71};
72 72
73struct AddressBook::ConstIterator::ConstIteratorData 73struct AddressBook::ConstIterator::ConstIteratorData
74{ 74{
75 Addressee::List::ConstIterator mIt; 75 Addressee::List::ConstIterator mIt;
76}; 76};
77 77
78AddressBook::Iterator::Iterator() 78AddressBook::Iterator::Iterator()
79{ 79{
80 d = new IteratorData; 80 d = new IteratorData;
81} 81}
82 82
83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
84{ 84{
85 d = new IteratorData; 85 d = new IteratorData;
86 d->mIt = i.d->mIt; 86 d->mIt = i.d->mIt;
87} 87}
88 88
89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
90{ 90{
91 if( this == &i ) return *this; // guard against self assignment 91 if( this == &i ) return *this; // guard against self assignment
92 delete d; // delete the old data the Iterator was completely constructed before 92 delete d; // delete the old data the Iterator was completely constructed before
93 d = new IteratorData; 93 d = new IteratorData;
94 d->mIt = i.d->mIt; 94 d->mIt = i.d->mIt;
95 return *this; 95 return *this;
96} 96}
97 97
98AddressBook::Iterator::~Iterator() 98AddressBook::Iterator::~Iterator()
99{ 99{
100 delete d; 100 delete d;
101} 101}
102 102
103const Addressee &AddressBook::Iterator::operator*() const 103const Addressee &AddressBook::Iterator::operator*() const
104{ 104{
105 return *(d->mIt); 105 return *(d->mIt);
106} 106}
107 107
108Addressee &AddressBook::Iterator::operator*() 108Addressee &AddressBook::Iterator::operator*()
109{ 109{
110 return *(d->mIt); 110 return *(d->mIt);
111} 111}
112 112
113Addressee *AddressBook::Iterator::operator->() 113Addressee *AddressBook::Iterator::operator->()
114{ 114{
115 return &(*(d->mIt)); 115 return &(*(d->mIt));
116} 116}
117 117
118AddressBook::Iterator &AddressBook::Iterator::operator++() 118AddressBook::Iterator &AddressBook::Iterator::operator++()
119{ 119{
120 (d->mIt)++; 120 (d->mIt)++;
121 return *this; 121 return *this;
122} 122}
123 123
124AddressBook::Iterator &AddressBook::Iterator::operator++(int) 124AddressBook::Iterator &AddressBook::Iterator::operator++(int)
125{ 125{
126 (d->mIt)++; 126 (d->mIt)++;
127 return *this; 127 return *this;
128} 128}
129 129
130AddressBook::Iterator &AddressBook::Iterator::operator--() 130AddressBook::Iterator &AddressBook::Iterator::operator--()
131{ 131{
132 (d->mIt)--; 132 (d->mIt)--;
133 return *this; 133 return *this;
134} 134}
135 135
136AddressBook::Iterator &AddressBook::Iterator::operator--(int) 136AddressBook::Iterator &AddressBook::Iterator::operator--(int)
137{ 137{
138 (d->mIt)--; 138 (d->mIt)--;
139 return *this; 139 return *this;
140} 140}
141 141
142bool AddressBook::Iterator::operator==( const Iterator &it ) 142bool AddressBook::Iterator::operator==( const Iterator &it )
143{ 143{
144 return ( d->mIt == it.d->mIt ); 144 return ( d->mIt == it.d->mIt );
145} 145}
146 146
147bool AddressBook::Iterator::operator!=( const Iterator &it ) 147bool AddressBook::Iterator::operator!=( const Iterator &it )
148{ 148{
149 return ( d->mIt != it.d->mIt ); 149 return ( d->mIt != it.d->mIt );
150} 150}
151 151
152 152
153AddressBook::ConstIterator::ConstIterator() 153AddressBook::ConstIterator::ConstIterator()
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156} 156}
157 157
158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
159{ 159{
160 d = new ConstIteratorData; 160 d = new ConstIteratorData;
161 d->mIt = i.d->mIt; 161 d->mIt = i.d->mIt;
162} 162}
163 163
164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
165{ 165{
166 if( this == &i ) return *this; // guard for self assignment 166 if( this == &i ) return *this; // guard for self assignment
167 delete d; // delete the old data because the Iterator was really constructed before 167 delete d; // delete the old data because the Iterator was really constructed before
168 d = new ConstIteratorData; 168 d = new ConstIteratorData;
169 d->mIt = i.d->mIt; 169 d->mIt = i.d->mIt;
170 return *this; 170 return *this;
171} 171}
172 172
173AddressBook::ConstIterator::~ConstIterator() 173AddressBook::ConstIterator::~ConstIterator()
174{ 174{
175 delete d; 175 delete d;
176} 176}
177 177
178const Addressee &AddressBook::ConstIterator::operator*() const 178const Addressee &AddressBook::ConstIterator::operator*() const
179{ 179{
180 return *(d->mIt); 180 return *(d->mIt);
181} 181}
182 182
183const Addressee* AddressBook::ConstIterator::operator->() const 183const Addressee* AddressBook::ConstIterator::operator->() const
184{ 184{
185 return &(*(d->mIt)); 185 return &(*(d->mIt));
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
195{ 195{
196 (d->mIt)++; 196 (d->mIt)++;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
207{ 207{
208 (d->mIt)--; 208 (d->mIt)--;
209 return *this; 209 return *this;
210} 210}
211 211
212bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
213{ 213{
214 return ( d->mIt == it.d->mIt ); 214 return ( d->mIt == it.d->mIt );
215} 215}
216 216
217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
218{ 218{
219 return ( d->mIt != it.d->mIt ); 219 return ( d->mIt != it.d->mIt );
220} 220}
221 221
222 222
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
234{ 234{
235 init(config, family); 235 init(config, family);
236 236
237} 237}
238 238
239// the default family is "contact" 239// the default family is "contact"
240void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
241{ 241{
242 blockLSEchange = false; 242 blockLSEchange = false;
243 d = new AddressBookData; 243 d = new AddressBookData;
244 QString fami = family; 244 QString fami = family;
245 if (config != 0) { 245 if (config != 0) {
246 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
247 qDebug("creating sync config "); 247 qDebug("creating sync config ");
248 fami = "contact"; 248 fami = "contact";
249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
250 con->setGroup( "General" ); 250 con->setGroup( "General" );
251 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
252 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
253 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
254 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
255 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
256 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
257 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
258 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
259 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
260 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
261 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
262 } else { 262 } else {
263 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
264 } 264 }
265 //con->sync(); 265 //con->sync();
266 d->mConfig = con; 266 d->mConfig = con;
267 } 267 }
268 else 268 else
269 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
270// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
271 } 271 }
272 else { 272 else {
273 d->mConfig = 0; 273 d->mConfig = 0;
274// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
275 } 275 }
276 276
277//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
278 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
279 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
280 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
281 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
282 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
284 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
285 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
287 } 287 }
288 Resource *res = standardResource(); 288 Resource *res = standardResource();
289 if ( !res ) { 289 if ( !res ) {
290 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
291 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
292 if ( res ) 292 if ( res )
293 { 293 {
294 addResource( res ); 294 addResource( res );
295 } 295 }
296 else 296 else
297 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
298 } 298 }
299 setStandardResource( res ); 299 setStandardResource( res );
300 manager->writeConfig(); 300 manager->writeConfig();
301 } 301 }
302 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
303 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
304 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
305 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
307 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
309 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
311 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
313 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
315 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
317 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
318 318
319 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
320 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
321 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
322 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
323 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
324 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
326 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
328 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
329} 329}
330 330
331AddressBook::~AddressBook() 331AddressBook::~AddressBook()
332{ 332{
333 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
334 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
335//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
336 delete d; d = 0; 336 delete d; d = 0;
337} 337}
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 t << "\r\n\r\n"; 402 t << "\r\n\r\n";
403 outFile.close(); 403 outFile.close();
404} 404}
405void AddressBook::importFromFile( QString fileName ) 405void AddressBook::importFromFile( QString fileName, bool replaceLabel )
406{ 406{
407 407
408 KABC::Addressee::List list; 408 KABC::Addressee::List list;
409 QFile file( fileName ); 409 QFile file( fileName );
410 410
411 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
412 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
413 file.close(); 413 file.close();
414 414 qDebug("AddressBook::importFromFile ");
415 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 415 QString data;
416 if ( replaceLabel ) {
417 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
418 data.replace ( QRegExp("LABEL") , "ADR" );
419 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
420 } else
421 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
416 KABC::VCardTool tool; 422 KABC::VCardTool tool;
417 list = tool.parseVCards( data ); 423 list = tool.parseVCards( data );
418 KABC::Addressee::List::Iterator it; 424 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) { 425 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 ); 426 (*it).setResource( 0 );
427 if ( replaceLabel )
428 (*it).removeVoice();
421 insertAddressee( (*it), false, true ); 429 insertAddressee( (*it), false, true );
422 } 430 }
423 431
424} 432}
425 433
426bool AddressBook::saveAB() 434bool AddressBook::saveAB()
427{ 435{
428 bool ok = true; 436 bool ok = true;
429 437
430 deleteRemovedAddressees(); 438 deleteRemovedAddressees();
431 Iterator ait; 439 Iterator ait;
432 for ( ait = begin(); ait != end(); ++ait ) { 440 for ( ait = begin(); ait != end(); ++ait ) {
433 if ( !(*ait).IDStr().isEmpty() ) { 441 if ( !(*ait).IDStr().isEmpty() ) {
434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 442 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
435 } 443 }
436 } 444 }
437 KRES::Manager<Resource>::ActiveIterator it; 445 KRES::Manager<Resource>::ActiveIterator it;
438 KRES::Manager<Resource> *manager = d->mManager; 446 KRES::Manager<Resource> *manager = d->mManager;
439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 447 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
440 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 448 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
441 Ticket *ticket = requestSaveTicket( *it ); 449 Ticket *ticket = requestSaveTicket( *it );
442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 450// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
443 if ( !ticket ) { 451 if ( !ticket ) {
444 error( i18n( "Unable to save to resource '%1'. It is locked." ) 452 error( i18n( "Unable to save to resource '%1'. It is locked." )
445 .arg( (*it)->resourceName() ) ); 453 .arg( (*it)->resourceName() ) );
446 return false; 454 return false;
447 } 455 }
448 456
449 //if ( !save( ticket ) ) 457 //if ( !save( ticket ) )
450 if ( ticket->resource() ) { 458 if ( ticket->resource() ) {
451 if ( ! ticket->resource()->save( ticket ) ) 459 if ( ! ticket->resource()->save( ticket ) )
452 ok = false; 460 ok = false;
453 } else 461 } else
454 ok = false; 462 ok = false;
455 463
456 } 464 }
457 } 465 }
458 return ok; 466 return ok;
459} 467}
460 468
461AddressBook::Iterator AddressBook::begin() 469AddressBook::Iterator AddressBook::begin()
462{ 470{
463 Iterator it = Iterator(); 471 Iterator it = Iterator();
464 it.d->mIt = d->mAddressees.begin(); 472 it.d->mIt = d->mAddressees.begin();
465 return it; 473 return it;
466} 474}
467 475
468AddressBook::ConstIterator AddressBook::begin() const 476AddressBook::ConstIterator AddressBook::begin() const
469{ 477{
470 ConstIterator it = ConstIterator(); 478 ConstIterator it = ConstIterator();
471 it.d->mIt = d->mAddressees.begin(); 479 it.d->mIt = d->mAddressees.begin();
472 return it; 480 return it;
473} 481}
474 482
475AddressBook::Iterator AddressBook::end() 483AddressBook::Iterator AddressBook::end()
476{ 484{
477 Iterator it = Iterator(); 485 Iterator it = Iterator();
478 it.d->mIt = d->mAddressees.end(); 486 it.d->mIt = d->mAddressees.end();
479 return it; 487 return it;
480} 488}
481 489
482AddressBook::ConstIterator AddressBook::end() const 490AddressBook::ConstIterator AddressBook::end() const
483{ 491{
484 ConstIterator it = ConstIterator(); 492 ConstIterator it = ConstIterator();
485 it.d->mIt = d->mAddressees.end(); 493 it.d->mIt = d->mAddressees.end();
486 return it; 494 return it;
487} 495}
488 496
489void AddressBook::clear() 497void AddressBook::clear()
490{ 498{
491 d->mAddressees.clear(); 499 d->mAddressees.clear();
492} 500}
493 501
494Ticket *AddressBook::requestSaveTicket( Resource *resource ) 502Ticket *AddressBook::requestSaveTicket( Resource *resource )
495{ 503{
496 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 504 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
497 505
498 if ( !resource ) 506 if ( !resource )
499 { 507 {
500 qDebug("AddressBook::requestSaveTicket no resource" ); 508 qDebug("AddressBook::requestSaveTicket no resource" );
501 resource = standardResource(); 509 resource = standardResource();
502 } 510 }
503 511
504 KRES::Manager<Resource>::ActiveIterator it; 512 KRES::Manager<Resource>::ActiveIterator it;
505 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 513 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
506 if ( (*it) == resource ) { 514 if ( (*it) == resource ) {
507 if ( (*it)->readOnly() || !(*it)->isOpen() ) 515 if ( (*it)->readOnly() || !(*it)->isOpen() )
508 return 0; 516 return 0;
509 else 517 else
510 return (*it)->requestSaveTicket(); 518 return (*it)->requestSaveTicket();
511 } 519 }
512 } 520 }
513 521
514 return 0; 522 return 0;
515} 523}
516 524
517void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 525void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
518{ 526{
519 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 527 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
520 //qDebug("block insert "); 528 //qDebug("block insert ");
521 return; 529 return;
522 } 530 }
523 //qDebug("inserting.... %s ",a.uid().latin1() ); 531 //qDebug("inserting.... %s ",a.uid().latin1() );
524 bool found = false; 532 bool found = false;
525 Addressee::List::Iterator it; 533 Addressee::List::Iterator it;
526 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 534 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
527 if ( a.uid() == (*it).uid() ) { 535 if ( a.uid() == (*it).uid() ) {
528 536
529 bool changed = false; 537 bool changed = false;
530 Addressee addr = a; 538 Addressee addr = a;
531 if ( addr != (*it) ) 539 if ( addr != (*it) )
532 changed = true; 540 changed = true;
533 541
534 if ( takeResource ) { 542 if ( takeResource ) {
535 Resource * res = (*it).resource(); 543 Resource * res = (*it).resource();
536 (*it) = a; 544 (*it) = a;
537 (*it).setResource( res ); 545 (*it).setResource( res );
538 } else { 546 } else {
539 (*it) = a; 547 (*it) = a;
540 if ( (*it).resource() == 0 ) 548 if ( (*it).resource() == 0 )
541 (*it).setResource( standardResource() ); 549 (*it).setResource( standardResource() );
542 } 550 }
543 if ( changed ) { 551 if ( changed ) {
544 if ( setRev ) { 552 if ( setRev ) {
545 553
546 // get rid of micro seconds 554 // get rid of micro seconds
547 QDateTime dt = QDateTime::currentDateTime(); 555 QDateTime dt = QDateTime::currentDateTime();
548 QTime t = dt.time(); 556 QTime t = dt.time();
549 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 557 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
550 (*it).setRevision( dt ); 558 (*it).setRevision( dt );
551 } 559 }
552 (*it).setChanged( true ); 560 (*it).setChanged( true );
553 } 561 }
554 562
555 found = true; 563 found = true;
556 } else { 564 } else {
557 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 565 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
558 QString name = (*it).uid().mid( 19 ); 566 QString name = (*it).uid().mid( 19 );
559 Addressee b = a; 567 Addressee b = a;
560 QString id = b.getID( name ); 568 QString id = b.getID( name );
561 if ( ! id.isEmpty() ) { 569 if ( ! id.isEmpty() ) {
562 QString des = (*it).note(); 570 QString des = (*it).note();
563 int startN; 571 int startN;
564 if( (startN = des.find( id ) ) >= 0 ) { 572 if( (startN = des.find( id ) ) >= 0 ) {
565 int endN = des.find( ",", startN+1 ); 573 int endN = des.find( ",", startN+1 );
566 des = des.left( startN ) + des.mid( endN+1 ); 574 des = des.left( startN ) + des.mid( endN+1 );
567 (*it).setNote( des ); 575 (*it).setNote( des );
568 } 576 }
569 } 577 }
570 } 578 }
571 } 579 }
572 } 580 }
573 if ( found ) 581 if ( found )
574 return; 582 return;
575 d->mAddressees.append( a ); 583 d->mAddressees.append( a );
576 Addressee& addr = d->mAddressees.last(); 584 Addressee& addr = d->mAddressees.last();
577 if ( addr.resource() == 0 ) 585 if ( addr.resource() == 0 )
578 addr.setResource( standardResource() ); 586 addr.setResource( standardResource() );
579 587
580 addr.setChanged( true ); 588 addr.setChanged( true );
581} 589}
582 590
583void AddressBook::removeAddressee( const Addressee &a ) 591void AddressBook::removeAddressee( const Addressee &a )
584{ 592{
585 Iterator it; 593 Iterator it;
586 Iterator it2; 594 Iterator it2;
587 bool found = false; 595 bool found = false;
588 for ( it = begin(); it != end(); ++it ) { 596 for ( it = begin(); it != end(); ++it ) {
589 if ( a.uid() == (*it).uid() ) { 597 if ( a.uid() == (*it).uid() ) {
590 found = true; 598 found = true;
591 it2 = it; 599 it2 = it;
592 } else { 600 } else {
593 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 601 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
594 QString name = (*it).uid().mid( 19 ); 602 QString name = (*it).uid().mid( 19 );
595 Addressee b = a; 603 Addressee b = a;
596 QString id = b.getID( name ); 604 QString id = b.getID( name );
597 if ( ! id.isEmpty() ) { 605 if ( ! id.isEmpty() ) {
598 QString des = (*it).note(); 606 QString des = (*it).note();
599 if( des.find( id ) < 0 ) { 607 if( des.find( id ) < 0 ) {
600 des += id + ","; 608 des += id + ",";
601 (*it).setNote( des ); 609 (*it).setNote( des );
602 } 610 }
603 } 611 }
604 } 612 }
605 613
606 } 614 }
607 } 615 }
608 616
609 if ( found ) 617 if ( found )
610 removeAddressee( it2 ); 618 removeAddressee( it2 );
611 619
612} 620}
613 621
614void AddressBook::removeSyncAddressees( bool removeDeleted ) 622void AddressBook::removeSyncAddressees( bool removeDeleted )
615{ 623{
616 Iterator it = begin(); 624 Iterator it = begin();
617 Iterator it2 ; 625 Iterator it2 ;
618 QDateTime dt ( QDate( 2004,1,1) ); 626 QDateTime dt ( QDate( 2004,1,1) );
619 while ( it != end() ) { 627 while ( it != end() ) {
620 (*it).setRevision( dt ); 628 (*it).setRevision( dt );
621 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 629 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
622 (*it).setIDStr(""); 630 (*it).setIDStr("");
623 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 631 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
624 it2 = it; 632 it2 = it;
625 //qDebug("removing %s ",(*it).uid().latin1() ); 633 //qDebug("removing %s ",(*it).uid().latin1() );
626 ++it; 634 ++it;
627 removeAddressee( it2 ); 635 removeAddressee( it2 );
628 } else { 636 } else {
629 //qDebug("skipping %s ",(*it).uid().latin1() ); 637 //qDebug("skipping %s ",(*it).uid().latin1() );
630 ++it; 638 ++it;
631 } 639 }
632 } 640 }
633 deleteRemovedAddressees(); 641 deleteRemovedAddressees();
634} 642}
635 643
636void AddressBook::removeAddressee( const Iterator &it ) 644void AddressBook::removeAddressee( const Iterator &it )
637{ 645{
638 d->mRemovedAddressees.append( (*it) ); 646 d->mRemovedAddressees.append( (*it) );
639 d->mAddressees.remove( it.d->mIt ); 647 d->mAddressees.remove( it.d->mIt );
640} 648}
641 649
642AddressBook::Iterator AddressBook::find( const Addressee &a ) 650AddressBook::Iterator AddressBook::find( const Addressee &a )
643{ 651{
644 Iterator it; 652 Iterator it;
645 for ( it = begin(); it != end(); ++it ) { 653 for ( it = begin(); it != end(); ++it ) {
646 if ( a.uid() == (*it).uid() ) { 654 if ( a.uid() == (*it).uid() ) {
647 return it; 655 return it;
648 } 656 }
649 } 657 }
650 return end(); 658 return end();
651} 659}
652 660
653Addressee AddressBook::findByUid( const QString &uid ) 661Addressee AddressBook::findByUid( const QString &uid )
654{ 662{
655 Iterator it; 663 Iterator it;
656 for ( it = begin(); it != end(); ++it ) { 664 for ( it = begin(); it != end(); ++it ) {
657 if ( uid == (*it).uid() ) { 665 if ( uid == (*it).uid() ) {
658 return *it; 666 return *it;
659 } 667 }
660 } 668 }
661 return Addressee(); 669 return Addressee();
662} 670}
663void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 671void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
664{ 672{
665 //qDebug("AddressBook::preExternSync "); 673 //qDebug("AddressBook::preExternSync ");
666 AddressBook::Iterator it; 674 AddressBook::Iterator it;
667 for ( it = begin(); it != end(); ++it ) { 675 for ( it = begin(); it != end(); ++it ) {
668 (*it).setID( csd, (*it).externalUID() ); 676 (*it).setID( csd, (*it).externalUID() );
669 (*it).computeCsum( csd ); 677 (*it).computeCsum( csd );
670 } 678 }
671 mergeAB( aBook ,csd ); 679 mergeAB( aBook ,csd );
672} 680}
673void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 681void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
674{ 682{
675 //qDebug("AddressBook::postExternSync "); 683 //qDebug("AddressBook::postExternSync ");
676 AddressBook::Iterator it; 684 AddressBook::Iterator it;
677 for ( it = begin(); it != end(); ++it ) { 685 for ( it = begin(); it != end(); ++it ) {
678 // qDebug("check uid %s ", (*it).uid().latin1() ); 686 // qDebug("check uid %s ", (*it).uid().latin1() );
679 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 687 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
680 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 688 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
681 Addressee ad = aBook->findByUid( ( (*it).uid() )); 689 Addressee ad = aBook->findByUid( ( (*it).uid() ));
682 if ( ad.isEmpty() ) { 690 if ( ad.isEmpty() ) {
683 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 691 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
684 } else { 692 } else {
685 (*it).computeCsum( csd ); 693 (*it).computeCsum( csd );
686 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 694 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
687 ad.setID( csd, (*it).externalUID() ); 695 ad.setID( csd, (*it).externalUID() );
688 ad.setCsum( csd, (*it).getCsum( csd ) ); 696 ad.setCsum( csd, (*it).getCsum( csd ) );
689 aBook->insertAddressee( ad ); 697 aBook->insertAddressee( ad );
690 } 698 }
691 } 699 }
692 } 700 }
693} 701}
694 702
695bool AddressBook::containsExternalUid( const QString& uid ) 703bool AddressBook::containsExternalUid( const QString& uid )
696{ 704{
697 Iterator it; 705 Iterator it;
698 for ( it = begin(); it != end(); ++it ) { 706 for ( it = begin(); it != end(); ++it ) {
699 if ( uid == (*it).externalUID( ) ) 707 if ( uid == (*it).externalUID( ) )
700 return true; 708 return true;
701 } 709 }
702 return false; 710 return false;
703} 711}
704Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 712Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
705{ 713{
706 Iterator it; 714 Iterator it;
707 for ( it = begin(); it != end(); ++it ) { 715 for ( it = begin(); it != end(); ++it ) {
708 if ( uid == (*it).getID( profile ) ) 716 if ( uid == (*it).getID( profile ) )
709 return (*it); 717 return (*it);
710 } 718 }
711 return Addressee(); 719 return Addressee();
712} 720}
713void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 721void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
714{ 722{
715 Iterator it; 723 Iterator it;
716 Addressee ad; 724 Addressee ad;
717 for ( it = begin(); it != end(); ++it ) { 725 for ( it = begin(); it != end(); ++it ) {
718 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 726 ad = aBook->findByExternUid( (*it).externalUID(), profile );
719 if ( !ad.isEmpty() ) { 727 if ( !ad.isEmpty() ) {
720 (*it).mergeContact( ad ); 728 (*it).mergeContact( ad );
721 } 729 }
722 } 730 }
723#if 0 731#if 0
724 // test only 732 // test only
725 for ( it = begin(); it != end(); ++it ) { 733 for ( it = begin(); it != end(); ++it ) {
726 734
727 qDebug("uid %s ", (*it).uid().latin1()); 735 qDebug("uid %s ", (*it).uid().latin1());
728 } 736 }
729#endif 737#endif
730} 738}
731 739
732#if 0 740#if 0
733Addressee::List AddressBook::getExternLastSyncAddressees() 741Addressee::List AddressBook::getExternLastSyncAddressees()
734{ 742{
735 Addressee::List results; 743 Addressee::List results;
736 744
737 Iterator it; 745 Iterator it;
738 for ( it = begin(); it != end(); ++it ) { 746 for ( it = begin(); it != end(); ++it ) {
739 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 747 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
740 if ( (*it).familyName().left(4) == "!E: " ) 748 if ( (*it).familyName().left(4) == "!E: " )
741 results.append( *it ); 749 results.append( *it );
742 } 750 }
743 } 751 }
744 752
745 return results; 753 return results;
746} 754}
747#endif 755#endif
748void AddressBook::resetTempSyncStat() 756void AddressBook::resetTempSyncStat()
749{ 757{
750 Iterator it; 758 Iterator it;
751 for ( it = begin(); it != end(); ++it ) { 759 for ( it = begin(); it != end(); ++it ) {
752 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 760 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
753 } 761 }
754 762
755} 763}
756 764
757QStringList AddressBook:: uidList() 765QStringList AddressBook:: uidList()
758{ 766{
759 QStringList results; 767 QStringList results;
760 Iterator it; 768 Iterator it;
761 for ( it = begin(); it != end(); ++it ) { 769 for ( it = begin(); it != end(); ++it ) {
762 results.append( (*it).uid() ); 770 results.append( (*it).uid() );
763 } 771 }
764 return results; 772 return results;
765} 773}
766 774
767 775
768Addressee::List AddressBook::allAddressees() 776Addressee::List AddressBook::allAddressees()
769{ 777{
770 return d->mAddressees; 778 return d->mAddressees;
771 779
772} 780}
773 781
774Addressee::List AddressBook::findByName( const QString &name ) 782Addressee::List AddressBook::findByName( const QString &name )
775{ 783{
776 Addressee::List results; 784 Addressee::List results;
777 785
778 Iterator it; 786 Iterator it;
779 for ( it = begin(); it != end(); ++it ) { 787 for ( it = begin(); it != end(); ++it ) {
780 if ( name == (*it).realName() ) { 788 if ( name == (*it).realName() ) {
781 results.append( *it ); 789 results.append( *it );
782 } 790 }
783 } 791 }
784 792
785 return results; 793 return results;
786} 794}
787 795
788Addressee::List AddressBook::findByEmail( const QString &email ) 796Addressee::List AddressBook::findByEmail( const QString &email )
789{ 797{
790 Addressee::List results; 798 Addressee::List results;
791 QStringList mailList; 799 QStringList mailList;
792 800
793 Iterator it; 801 Iterator it;
794 for ( it = begin(); it != end(); ++it ) { 802 for ( it = begin(); it != end(); ++it ) {
795 mailList = (*it).emails(); 803 mailList = (*it).emails();
796 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 804 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
797 if ( email == (*ite) ) { 805 if ( email == (*ite) ) {
798 results.append( *it ); 806 results.append( *it );
799 } 807 }
800 } 808 }
801 } 809 }
802 810
803 return results; 811 return results;
804} 812}
805 813
806Addressee::List AddressBook::findByCategory( const QString &category ) 814Addressee::List AddressBook::findByCategory( const QString &category )
807{ 815{
808 Addressee::List results; 816 Addressee::List results;
809 817
810 Iterator it; 818 Iterator it;
811 for ( it = begin(); it != end(); ++it ) { 819 for ( it = begin(); it != end(); ++it ) {
812 if ( (*it).hasCategory( category) ) { 820 if ( (*it).hasCategory( category) ) {
813 results.append( *it ); 821 results.append( *it );
814 } 822 }
815 } 823 }
816 824
817 return results; 825 return results;
818} 826}
819 827
820void AddressBook::dump() const 828void AddressBook::dump() const
821{ 829{
822 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 830 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
823 831
824 ConstIterator it; 832 ConstIterator it;
825 for( it = begin(); it != end(); ++it ) { 833 for( it = begin(); it != end(); ++it ) {
826 (*it).dump(); 834 (*it).dump();
827 } 835 }
828 836
829 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 837 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
830} 838}
831 839
832QString AddressBook::identifier() 840QString AddressBook::identifier()
833{ 841{
834 QStringList identifier; 842 QStringList identifier;
835 843
836 844
837 KRES::Manager<Resource>::ActiveIterator it; 845 KRES::Manager<Resource>::ActiveIterator it;
838 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 846 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
839 if ( !(*it)->identifier().isEmpty() ) 847 if ( !(*it)->identifier().isEmpty() )
840 identifier.append( (*it)->identifier() ); 848 identifier.append( (*it)->identifier() );
841 } 849 }
842 850
843 return identifier.join( ":" ); 851 return identifier.join( ":" );
844} 852}
845 853
846Field::List AddressBook::fields( int category ) 854Field::List AddressBook::fields( int category )
847{ 855{
848 if ( d->mAllFields.isEmpty() ) { 856 if ( d->mAllFields.isEmpty() ) {
849 d->mAllFields = Field::allFields(); 857 d->mAllFields = Field::allFields();
850 } 858 }
851 859
852 if ( category == Field::All ) return d->mAllFields; 860 if ( category == Field::All ) return d->mAllFields;
853 861
854 Field::List result; 862 Field::List result;
855 Field::List::ConstIterator it; 863 Field::List::ConstIterator it;
856 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 864 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
857 if ( (*it)->category() & category ) result.append( *it ); 865 if ( (*it)->category() & category ) result.append( *it );
858 } 866 }
859 867
860 return result; 868 return result;
861} 869}
862 870
863bool AddressBook::addCustomField( const QString &label, int category, 871bool AddressBook::addCustomField( const QString &label, int category,
864 const QString &key, const QString &app ) 872 const QString &key, const QString &app )
865{ 873{
866 if ( d->mAllFields.isEmpty() ) { 874 if ( d->mAllFields.isEmpty() ) {
867 d->mAllFields = Field::allFields(); 875 d->mAllFields = Field::allFields();
868 } 876 }
869//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 877//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
870 QString a = app.isNull() ? KGlobal::getAppName() : app; 878 QString a = app.isNull() ? KGlobal::getAppName() : app;
871 879
872 QString k = key.isNull() ? label : key; 880 QString k = key.isNull() ? label : key;
873 881
874 Field *field = Field::createCustomField( label, category, k, a ); 882 Field *field = Field::createCustomField( label, category, k, a );
875 883
876 if ( !field ) return false; 884 if ( !field ) return false;
877 885
878 d->mAllFields.append( field ); 886 d->mAllFields.append( field );
879 887
880 return true; 888 return true;
881} 889}
882 890
883QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 891QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
884{ 892{
885 if (!ab.d) return s; 893 if (!ab.d) return s;
886 894
887 return s << ab.d->mAddressees; 895 return s << ab.d->mAddressees;
888} 896}
889 897
890QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 898QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
891{ 899{
892 if (!ab.d) return s; 900 if (!ab.d) return s;
893 901
894 s >> ab.d->mAddressees; 902 s >> ab.d->mAddressees;
895 903
896 return s; 904 return s;
897} 905}
898 906
899bool AddressBook::addResource( Resource *resource ) 907bool AddressBook::addResource( Resource *resource )
900{ 908{
901 if ( !resource->open() ) { 909 if ( !resource->open() ) {
902 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 910 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
903 return false; 911 return false;
904 } 912 }
905 913
906 resource->setAddressBook( this ); 914 resource->setAddressBook( this );
907 915
908 d->mManager->add( resource ); 916 d->mManager->add( resource );
909 return true; 917 return true;
910} 918}
911 919
912bool AddressBook::removeResource( Resource *resource ) 920bool AddressBook::removeResource( Resource *resource )
913{ 921{
914 resource->close(); 922 resource->close();
915 923
916 if ( resource == standardResource() ) 924 if ( resource == standardResource() )
917 d->mManager->setStandardResource( 0 ); 925 d->mManager->setStandardResource( 0 );
918 926
919 resource->setAddressBook( 0 ); 927 resource->setAddressBook( 0 );
920 928
921 d->mManager->remove( resource ); 929 d->mManager->remove( resource );
922 return true; 930 return true;
923} 931}
924 932
925QPtrList<Resource> AddressBook::resources() 933QPtrList<Resource> AddressBook::resources()
926{ 934{
927 QPtrList<Resource> list; 935 QPtrList<Resource> list;
928 936
929// qDebug("AddressBook::resources() 1"); 937// qDebug("AddressBook::resources() 1");
930 938
931 KRES::Manager<Resource>::ActiveIterator it; 939 KRES::Manager<Resource>::ActiveIterator it;
932 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 940 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
933 list.append( *it ); 941 list.append( *it );
934 942
935 return list; 943 return list;
936} 944}
937 945
938/*US 946/*US
939void AddressBook::setErrorHandler( ErrorHandler *handler ) 947void AddressBook::setErrorHandler( ErrorHandler *handler )
940{ 948{
941 delete d->mErrorHandler; 949 delete d->mErrorHandler;
942 d->mErrorHandler = handler; 950 d->mErrorHandler = handler;
943} 951}
944*/ 952*/
945 953
946void AddressBook::error( const QString& msg ) 954void AddressBook::error( const QString& msg )
947{ 955{
948/*US 956/*US
949 if ( !d->mErrorHandler ) // create default error handler 957 if ( !d->mErrorHandler ) // create default error handler
950 d->mErrorHandler = new ConsoleErrorHandler; 958 d->mErrorHandler = new ConsoleErrorHandler;
951 959
952 if ( d->mErrorHandler ) 960 if ( d->mErrorHandler )
953 d->mErrorHandler->error( msg ); 961 d->mErrorHandler->error( msg );
954 else 962 else
955 kdError(5700) << "no error handler defined" << endl; 963 kdError(5700) << "no error handler defined" << endl;
956*/ 964*/
957 kdDebug(5700) << "msg" << endl; 965 kdDebug(5700) << "msg" << endl;
958 qDebug(msg); 966 qDebug(msg);
959} 967}
960 968
961void AddressBook::deleteRemovedAddressees() 969void AddressBook::deleteRemovedAddressees()
962{ 970{
963 Addressee::List::Iterator it; 971 Addressee::List::Iterator it;
964 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 972 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
965 Resource *resource = (*it).resource(); 973 Resource *resource = (*it).resource();
966 if ( resource && !resource->readOnly() && resource->isOpen() ) 974 if ( resource && !resource->readOnly() && resource->isOpen() )
967 resource->removeAddressee( *it ); 975 resource->removeAddressee( *it );
968 } 976 }
969 977
970 d->mRemovedAddressees.clear(); 978 d->mRemovedAddressees.clear();
971} 979}
972 980
973void AddressBook::setStandardResource( Resource *resource ) 981void AddressBook::setStandardResource( Resource *resource )
974{ 982{
975// qDebug("AddressBook::setStandardResource 1"); 983// qDebug("AddressBook::setStandardResource 1");
976 d->mManager->setStandardResource( resource ); 984 d->mManager->setStandardResource( resource );
977} 985}
978 986
979Resource *AddressBook::standardResource() 987Resource *AddressBook::standardResource()
980{ 988{
981 return d->mManager->standardResource(); 989 return d->mManager->standardResource();
982} 990}
983 991
984KRES::Manager<Resource> *AddressBook::resourceManager() 992KRES::Manager<Resource> *AddressBook::resourceManager()
985{ 993{
986 return d->mManager; 994 return d->mManager;
987} 995}
988 996
989void AddressBook::cleanUp() 997void AddressBook::cleanUp()
990{ 998{
991 KRES::Manager<Resource>::ActiveIterator it; 999 KRES::Manager<Resource>::ActiveIterator it;
992 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1000 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
993 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1001 if ( !(*it)->readOnly() && (*it)->isOpen() )
994 (*it)->cleanUp(); 1002 (*it)->cleanUp();
995 } 1003 }
996} 1004}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 3603ec1..cea1b03 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,341 +1,341 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 void export2File( QString fileName ); 145 void export2File( QString fileName );
146 void importFromFile( QString fileName ); 146 void importFromFile( QString fileName, bool replaceLabel = false );
147 /** 147 /**
148 Returns a iterator for first entry of address book. 148 Returns a iterator for first entry of address book.
149 */ 149 */
150 Iterator begin(); 150 Iterator begin();
151 151
152 /** 152 /**
153 Returns a const iterator for first entry of address book. 153 Returns a const iterator for first entry of address book.
154 */ 154 */
155 ConstIterator begin() const; 155 ConstIterator begin() const;
156 156
157 /** 157 /**
158 Returns a iterator for first entry of address book. 158 Returns a iterator for first entry of address book.
159 */ 159 */
160 Iterator end(); 160 Iterator end();
161 161
162 /** 162 /**
163 Returns a const iterator for first entry of address book. 163 Returns a const iterator for first entry of address book.
164 */ 164 */
165 ConstIterator end() const; 165 ConstIterator end() const;
166 166
167 /** 167 /**
168 Removes all entries from address book. 168 Removes all entries from address book.
169 */ 169 */
170 void clear(); 170 void clear();
171 171
172 /** 172 /**
173 Insert an Addressee object into address book. If an object with the same 173 Insert an Addressee object into address book. If an object with the same
174 unique id already exists in the address book it it replaced by the new 174 unique id already exists in the address book it it replaced by the new
175 one. If not the new object is appended to the address book. 175 one. If not the new object is appended to the address book.
176 */ 176 */
177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
178 178
179 /** 179 /**
180 Removes entry from the address book. 180 Removes entry from the address book.
181 */ 181 */
182 void removeAddressee( const Addressee & ); 182 void removeAddressee( const Addressee & );
183 183
184 /** 184 /**
185 This is like @ref removeAddressee() just above, with the difference that 185 This is like @ref removeAddressee() just above, with the difference that
186 the first element is a iterator, returned by @ref begin(). 186 the first element is a iterator, returned by @ref begin().
187 */ 187 */
188 void removeAddressee( const Iterator & ); 188 void removeAddressee( const Iterator & );
189 189
190 /** 190 /**
191 Find the specified entry in address book. Returns end(), if the entry 191 Find the specified entry in address book. Returns end(), if the entry
192 couldn't be found. 192 couldn't be found.
193 */ 193 */
194 Iterator find( const Addressee & ); 194 Iterator find( const Addressee & );
195 195
196 /** 196 /**
197 Find the entry specified by an unique id. Returns an empty Addressee 197 Find the entry specified by an unique id. Returns an empty Addressee
198 object, if the address book does not contain an entry with this id. 198 object, if the address book does not contain an entry with this id.
199 */ 199 */
200 Addressee findByUid( const QString & ); 200 Addressee findByUid( const QString & );
201 201
202 202
203 /** 203 /**
204 Returns a list of all addressees in the address book. This list can 204 Returns a list of all addressees in the address book. This list can
205 be sorted with @ref KABC::AddresseeList for example. 205 be sorted with @ref KABC::AddresseeList for example.
206 */ 206 */
207 Addressee::List allAddressees(); 207 Addressee::List allAddressees();
208 208
209 /** 209 /**
210 Find all entries with the specified name in the address book. Returns 210 Find all entries with the specified name in the address book. Returns
211 an empty list, if no entries could be found. 211 an empty list, if no entries could be found.
212 */ 212 */
213 Addressee::List findByName( const QString & ); 213 Addressee::List findByName( const QString & );
214 214
215 /** 215 /**
216 Find all entries with the specified email address in the address book. 216 Find all entries with the specified email address in the address book.
217 Returns an empty list, if no entries could be found. 217 Returns an empty list, if no entries could be found.
218 */ 218 */
219 Addressee::List findByEmail( const QString & ); 219 Addressee::List findByEmail( const QString & );
220 220
221 /** 221 /**
222 Find all entries wich have the specified category in the address book. 222 Find all entries wich have the specified category in the address book.
223 Returns an empty list, if no entries could be found. 223 Returns an empty list, if no entries could be found.
224 */ 224 */
225 Addressee::List findByCategory( const QString & ); 225 Addressee::List findByCategory( const QString & );
226 226
227 /** 227 /**
228 Return a string identifying this addressbook. 228 Return a string identifying this addressbook.
229 */ 229 */
230 virtual QString identifier(); 230 virtual QString identifier();
231 231
232 /** 232 /**
233 Used for debug output. 233 Used for debug output.
234 */ 234 */
235 void dump() const; 235 void dump() const;
236 236
237 void emitAddressBookLocked() { emit addressBookLocked( this ); } 237 void emitAddressBookLocked() { emit addressBookLocked( this ); }
238 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 238 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
239 void emitAddressBookChanged() { emit addressBookChanged( this ); } 239 void emitAddressBookChanged() { emit addressBookChanged( this ); }
240 240
241 /** 241 /**
242 Return list of all Fields known to the address book which are associated 242 Return list of all Fields known to the address book which are associated
243 with the given field category. 243 with the given field category.
244 */ 244 */
245 Field::List fields( int category = Field::All ); 245 Field::List fields( int category = Field::All );
246 246
247 /** 247 /**
248 Add custom field to address book. 248 Add custom field to address book.
249 249
250 @param label User visible label of the field. 250 @param label User visible label of the field.
251 @param category Ored list of field categories. 251 @param category Ored list of field categories.
252 @param key Identifier used as key for reading and writing the field. 252 @param key Identifier used as key for reading and writing the field.
253 @param app String used as application key for reading and writing 253 @param app String used as application key for reading and writing
254 the field. 254 the field.
255 */ 255 */
256 bool addCustomField( const QString &label, int category = Field::All, 256 bool addCustomField( const QString &label, int category = Field::All,
257 const QString &key = QString::null, 257 const QString &key = QString::null,
258 const QString &app = QString::null ); 258 const QString &app = QString::null );
259 259
260 260
261 /** 261 /**
262 Add address book resource. 262 Add address book resource.
263 */ 263 */
264 bool addResource( Resource * ); 264 bool addResource( Resource * );
265 265
266 /** 266 /**
267 Remove address book resource. 267 Remove address book resource.
268 */ 268 */
269 bool removeResource( Resource * ); 269 bool removeResource( Resource * );
270 270
271 /** 271 /**
272 Return pointer list of all resources. 272 Return pointer list of all resources.
273 */ 273 */
274 QPtrList<Resource> resources(); 274 QPtrList<Resource> resources();
275 275
276 /** 276 /**
277 Set the @p ErrorHandler, that is used by @ref error() to 277 Set the @p ErrorHandler, that is used by @ref error() to
278 provide gui-independend error messages. 278 provide gui-independend error messages.
279 */ 279 */
280 void setErrorHandler( ErrorHandler * ); 280 void setErrorHandler( ErrorHandler * );
281 281
282 /** 282 /**
283 Shows gui independend error messages. 283 Shows gui independend error messages.
284 */ 284 */
285 void error( const QString& ); 285 void error( const QString& );
286 286
287 /** 287 /**
288 Query all resources to clean up their lock files 288 Query all resources to clean up their lock files
289 */ 289 */
290 void cleanUp(); 290 void cleanUp();
291 291
292 // sync stuff 292 // sync stuff
293 //Addressee::List getExternLastSyncAddressees(); 293 //Addressee::List getExternLastSyncAddressees();
294 void resetTempSyncStat(); 294 void resetTempSyncStat();
295 QStringList uidList(); 295 QStringList uidList();
296 void removeSyncAddressees( bool removeDeleted = false ); 296 void removeSyncAddressees( bool removeDeleted = false );
297 void mergeAB( AddressBook *aBook, const QString& profile ); 297 void mergeAB( AddressBook *aBook, const QString& profile );
298 Addressee findByExternUid( const QString& uid , const QString& profile ); 298 Addressee findByExternUid( const QString& uid , const QString& profile );
299 bool containsExternalUid( const QString& uid ); 299 bool containsExternalUid( const QString& uid );
300 300
301 void preExternSync( AddressBook* aBook, const QString& csd ); 301 void preExternSync( AddressBook* aBook, const QString& csd );
302 void postExternSync( AddressBook* aBook, const QString& csd ); 302 void postExternSync( AddressBook* aBook, const QString& csd );
303 signals: 303 signals:
304 /** 304 /**
305 Emitted, when the address book has changed on disk. 305 Emitted, when the address book has changed on disk.
306 */ 306 */
307 void addressBookChanged( AddressBook * ); 307 void addressBookChanged( AddressBook * );
308 308
309 /** 309 /**
310 Emitted, when the address book has been locked for writing. 310 Emitted, when the address book has been locked for writing.
311 */ 311 */
312 void addressBookLocked( AddressBook * ); 312 void addressBookLocked( AddressBook * );
313 313
314 /** 314 /**
315 Emitted, when the address book has been unlocked. 315 Emitted, when the address book has been unlocked.
316 */ 316 */
317 void addressBookUnlocked( AddressBook * ); 317 void addressBookUnlocked( AddressBook * );
318 318
319 protected: 319 protected:
320 void deleteRemovedAddressees(); 320 void deleteRemovedAddressees();
321 void setStandardResource( Resource * ); 321 void setStandardResource( Resource * );
322 Resource *standardResource(); 322 Resource *standardResource();
323 KRES::Manager<Resource> *resourceManager(); 323 KRES::Manager<Resource> *resourceManager();
324 324
325 void init(const QString &config, const QString &family); 325 void init(const QString &config, const QString &family);
326 326
327 private: 327 private:
328//US QPtrList<Resource> mDummy; // Remove in KDE 4 328//US QPtrList<Resource> mDummy; // Remove in KDE 4
329 329
330 330
331 struct AddressBookData; 331 struct AddressBookData;
332 AddressBookData *d; 332 AddressBookData *d;
333 bool blockLSEchange; 333 bool blockLSEchange;
334}; 334};
335 335
336QDataStream &operator<<( QDataStream &, const AddressBook & ); 336QDataStream &operator<<( QDataStream &, const AddressBook & );
337QDataStream &operator>>( QDataStream &, AddressBook & ); 337QDataStream &operator>>( QDataStream &, AddressBook & );
338 338
339} 339}
340 340
341#endif 341#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 19a1845..3f3d5c0 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1918 +1,1935 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318bool Addressee::removeVoice()
319{
320 PhoneNumber::List phoneN = phoneNumbers();
321 PhoneNumber::List::Iterator phoneIt;
322 bool found = false;
323 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
324 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
325 if ((*phoneIt).type() - PhoneNumber::Voice ) {
326 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
327 insertPhoneNumber( (*phoneIt) );
328 found = true;
329 }
330 }
331
332 }
333 return found;
334}
318void Addressee::simplifyAddresses() 335void Addressee::simplifyAddresses()
319{ 336{
320 if ( mData->addresses.count() < 3 ) return ; 337 if ( mData->addresses.count() < 3 ) return ;
321 int count = 0; 338 int count = 0;
322 Address::List list; 339 Address::List list;
323 Address::List::Iterator it; 340 Address::List::Iterator it;
324 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 341 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
325 if ( count > 1 ) 342 if ( count > 1 )
326 list.append( *it ); 343 list.append( *it );
327 ++count; 344 ++count;
328 } 345 }
329 for( it = list.begin(); it != list.end(); ++it ) { 346 for( it = list.begin(); it != list.end(); ++it ) {
330 removeAddress( (*it) ); 347 removeAddress( (*it) );
331 } 348 }
332} 349}
333 350
334// removes all emails but the first 351// removes all emails but the first
335// needed by phone sync 352// needed by phone sync
336void Addressee::simplifyEmails() 353void Addressee::simplifyEmails()
337{ 354{
338 if ( mData->emails.count() == 0 ) return ; 355 if ( mData->emails.count() == 0 ) return ;
339 QString email = mData->emails.first(); 356 QString email = mData->emails.first();
340 detach(); 357 detach();
341 mData->emails.clear(); 358 mData->emails.clear();
342 mData->emails.append( email ); 359 mData->emails.append( email );
343} 360}
344 361
345void Addressee::simplifyPhoneNumbers() 362void Addressee::simplifyPhoneNumbers()
346{ 363{
347 KABC::PhoneNumber::List removeNumbers; 364 KABC::PhoneNumber::List removeNumbers;
348 KABC::PhoneNumber::List::Iterator phoneIter; 365 KABC::PhoneNumber::List::Iterator phoneIter;
349 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 366 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
350 ++phoneIter ) { 367 ++phoneIter ) {
351 if ( ! ( *phoneIter ).simplifyNumber() ) 368 if ( ! ( *phoneIter ).simplifyNumber() )
352 removeNumbers.append( ( *phoneIter ) ); 369 removeNumbers.append( ( *phoneIter ) );
353 } 370 }
354 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 371 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
355 ++phoneIter ) { 372 ++phoneIter ) {
356 removePhoneNumber(( *phoneIter )); 373 removePhoneNumber(( *phoneIter ));
357 } 374 }
358} 375}
359void Addressee::simplifyPhoneNumberTypes() 376void Addressee::simplifyPhoneNumberTypes()
360{ 377{
361 KABC::PhoneNumber::List::Iterator phoneIter; 378 KABC::PhoneNumber::List::Iterator phoneIter;
362 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 379 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
363 ++phoneIter ) 380 ++phoneIter )
364 ( *phoneIter ).simplifyType(); 381 ( *phoneIter ).simplifyType();
365} 382}
366void Addressee::removeID(const QString &prof) 383void Addressee::removeID(const QString &prof)
367{ 384{
368 detach(); 385 detach();
369 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 386 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
370 387
371} 388}
372void Addressee::setID( const QString & prof , const QString & id ) 389void Addressee::setID( const QString & prof , const QString & id )
373{ 390{
374 detach(); 391 detach();
375 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 392 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
376 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 393 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
377} 394}
378void Addressee::setTempSyncStat( int id ) 395void Addressee::setTempSyncStat( int id )
379{ 396{
380 if ( mData->mTempSyncStat == id ) return; 397 if ( mData->mTempSyncStat == id ) return;
381 detach(); 398 detach();
382 mData->mTempSyncStat = id; 399 mData->mTempSyncStat = id;
383} 400}
384int Addressee::tempSyncStat() const 401int Addressee::tempSyncStat() const
385{ 402{
386 return mData->mTempSyncStat; 403 return mData->mTempSyncStat;
387} 404}
388 405
389QString Addressee::getID( const QString & prof) 406QString Addressee::getID( const QString & prof)
390{ 407{
391 return KIdManager::getId ( mData->mExternalId, prof ); 408 return KIdManager::getId ( mData->mExternalId, prof );
392} 409}
393 410
394void Addressee::setCsum( const QString & prof , const QString & id ) 411void Addressee::setCsum( const QString & prof , const QString & id )
395{ 412{
396 detach(); 413 detach();
397 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 414 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
398 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 415 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
399 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 416 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
400} 417}
401 418
402QString Addressee::getCsum( const QString & prof) 419QString Addressee::getCsum( const QString & prof)
403{ 420{
404 return KIdManager::getCsum ( mData->mExternalId, prof ); 421 return KIdManager::getCsum ( mData->mExternalId, prof );
405} 422}
406 423
407void Addressee::setIDStr( const QString & s ) 424void Addressee::setIDStr( const QString & s )
408{ 425{
409 detach(); 426 detach();
410 mData->mExternalId = s; 427 mData->mExternalId = s;
411} 428}
412 429
413QString Addressee::IDStr() const 430QString Addressee::IDStr() const
414{ 431{
415 return mData->mExternalId; 432 return mData->mExternalId;
416} 433}
417 434
418void Addressee::setExternalUID( const QString &id ) 435void Addressee::setExternalUID( const QString &id )
419{ 436{
420 if ( id == mData->externalUID ) return; 437 if ( id == mData->externalUID ) return;
421 detach(); 438 detach();
422 mData->empty = false; 439 mData->empty = false;
423 mData->externalUID = id; 440 mData->externalUID = id;
424} 441}
425 442
426QString Addressee::externalUID() const 443QString Addressee::externalUID() const
427{ 444{
428 return mData->externalUID; 445 return mData->externalUID;
429} 446}
430void Addressee::setOriginalExternalUID( const QString &id ) 447void Addressee::setOriginalExternalUID( const QString &id )
431{ 448{
432 if ( id == mData->originalExternalUID ) return; 449 if ( id == mData->originalExternalUID ) return;
433 detach(); 450 detach();
434 mData->empty = false; 451 mData->empty = false;
435 //qDebug("*******Set orig uid %s ", id.latin1()); 452 //qDebug("*******Set orig uid %s ", id.latin1());
436 mData->originalExternalUID = id; 453 mData->originalExternalUID = id;
437} 454}
438 455
439QString Addressee::originalExternalUID() const 456QString Addressee::originalExternalUID() const
440{ 457{
441 return mData->originalExternalUID; 458 return mData->originalExternalUID;
442} 459}
443 460
444void Addressee::setUid( const QString &id ) 461void Addressee::setUid( const QString &id )
445{ 462{
446 if ( id == mData->uid ) return; 463 if ( id == mData->uid ) return;
447 detach(); 464 detach();
448 //qDebug("****setuid %s ", id.latin1()); 465 //qDebug("****setuid %s ", id.latin1());
449 mData->empty = false; 466 mData->empty = false;
450 mData->uid = id; 467 mData->uid = id;
451} 468}
452 469
453QString Addressee::uid() const 470QString Addressee::uid() const
454{ 471{
455 if ( mData->uid.isEmpty() ) 472 if ( mData->uid.isEmpty() )
456 mData->uid = KApplication::randomString( 10 ); 473 mData->uid = KApplication::randomString( 10 );
457 474
458 return mData->uid; 475 return mData->uid;
459} 476}
460 477
461QString Addressee::uidLabel() 478QString Addressee::uidLabel()
462{ 479{
463 return i18n("Unique Identifier"); 480 return i18n("Unique Identifier");
464} 481}
465 482
466void Addressee::setName( const QString &name ) 483void Addressee::setName( const QString &name )
467{ 484{
468 if ( name == mData->name ) return; 485 if ( name == mData->name ) return;
469 detach(); 486 detach();
470 mData->empty = false; 487 mData->empty = false;
471 mData->name = name; 488 mData->name = name;
472} 489}
473 490
474QString Addressee::name() const 491QString Addressee::name() const
475{ 492{
476 return mData->name; 493 return mData->name;
477} 494}
478 495
479QString Addressee::nameLabel() 496QString Addressee::nameLabel()
480{ 497{
481 return i18n("Name"); 498 return i18n("Name");
482} 499}
483 500
484 501
485void Addressee::setFormattedName( const QString &formattedName ) 502void Addressee::setFormattedName( const QString &formattedName )
486{ 503{
487 if ( formattedName == mData->formattedName ) return; 504 if ( formattedName == mData->formattedName ) return;
488 detach(); 505 detach();
489 mData->empty = false; 506 mData->empty = false;
490 mData->formattedName = formattedName; 507 mData->formattedName = formattedName;
491} 508}
492 509
493QString Addressee::formattedName() const 510QString Addressee::formattedName() const
494{ 511{
495 return mData->formattedName; 512 return mData->formattedName;
496} 513}
497 514
498QString Addressee::formattedNameLabel() 515QString Addressee::formattedNameLabel()
499{ 516{
500 return i18n("Formatted Name"); 517 return i18n("Formatted Name");
501} 518}
502 519
503 520
504void Addressee::setFamilyName( const QString &familyName ) 521void Addressee::setFamilyName( const QString &familyName )
505{ 522{
506 if ( familyName == mData->familyName ) return; 523 if ( familyName == mData->familyName ) return;
507 detach(); 524 detach();
508 mData->empty = false; 525 mData->empty = false;
509 mData->familyName = familyName; 526 mData->familyName = familyName;
510} 527}
511 528
512QString Addressee::familyName() const 529QString Addressee::familyName() const
513{ 530{
514 return mData->familyName; 531 return mData->familyName;
515} 532}
516 533
517QString Addressee::familyNameLabel() 534QString Addressee::familyNameLabel()
518{ 535{
519 return i18n("Family Name"); 536 return i18n("Family Name");
520} 537}
521 538
522 539
523void Addressee::setGivenName( const QString &givenName ) 540void Addressee::setGivenName( const QString &givenName )
524{ 541{
525 if ( givenName == mData->givenName ) return; 542 if ( givenName == mData->givenName ) return;
526 detach(); 543 detach();
527 mData->empty = false; 544 mData->empty = false;
528 mData->givenName = givenName; 545 mData->givenName = givenName;
529} 546}
530 547
531QString Addressee::givenName() const 548QString Addressee::givenName() const
532{ 549{
533 return mData->givenName; 550 return mData->givenName;
534} 551}
535 552
536QString Addressee::givenNameLabel() 553QString Addressee::givenNameLabel()
537{ 554{
538 return i18n("Given Name"); 555 return i18n("Given Name");
539} 556}
540 557
541 558
542void Addressee::setAdditionalName( const QString &additionalName ) 559void Addressee::setAdditionalName( const QString &additionalName )
543{ 560{
544 if ( additionalName == mData->additionalName ) return; 561 if ( additionalName == mData->additionalName ) return;
545 detach(); 562 detach();
546 mData->empty = false; 563 mData->empty = false;
547 mData->additionalName = additionalName; 564 mData->additionalName = additionalName;
548} 565}
549 566
550QString Addressee::additionalName() const 567QString Addressee::additionalName() const
551{ 568{
552 return mData->additionalName; 569 return mData->additionalName;
553} 570}
554 571
555QString Addressee::additionalNameLabel() 572QString Addressee::additionalNameLabel()
556{ 573{
557 return i18n("Additional Names"); 574 return i18n("Additional Names");
558} 575}
559 576
560 577
561void Addressee::setPrefix( const QString &prefix ) 578void Addressee::setPrefix( const QString &prefix )
562{ 579{
563 if ( prefix == mData->prefix ) return; 580 if ( prefix == mData->prefix ) return;
564 detach(); 581 detach();
565 mData->empty = false; 582 mData->empty = false;
566 mData->prefix = prefix; 583 mData->prefix = prefix;
567} 584}
568 585
569QString Addressee::prefix() const 586QString Addressee::prefix() const
570{ 587{
571 return mData->prefix; 588 return mData->prefix;
572} 589}
573 590
574QString Addressee::prefixLabel() 591QString Addressee::prefixLabel()
575{ 592{
576 return i18n("Honorific Prefixes"); 593 return i18n("Honorific Prefixes");
577} 594}
578 595
579 596
580void Addressee::setSuffix( const QString &suffix ) 597void Addressee::setSuffix( const QString &suffix )
581{ 598{
582 if ( suffix == mData->suffix ) return; 599 if ( suffix == mData->suffix ) return;
583 detach(); 600 detach();
584 mData->empty = false; 601 mData->empty = false;
585 mData->suffix = suffix; 602 mData->suffix = suffix;
586} 603}
587 604
588QString Addressee::suffix() const 605QString Addressee::suffix() const
589{ 606{
590 return mData->suffix; 607 return mData->suffix;
591} 608}
592 609
593QString Addressee::suffixLabel() 610QString Addressee::suffixLabel()
594{ 611{
595 return i18n("Honorific Suffixes"); 612 return i18n("Honorific Suffixes");
596} 613}
597 614
598 615
599void Addressee::setNickName( const QString &nickName ) 616void Addressee::setNickName( const QString &nickName )
600{ 617{
601 if ( nickName == mData->nickName ) return; 618 if ( nickName == mData->nickName ) return;
602 detach(); 619 detach();
603 mData->empty = false; 620 mData->empty = false;
604 mData->nickName = nickName; 621 mData->nickName = nickName;
605} 622}
606 623
607QString Addressee::nickName() const 624QString Addressee::nickName() const
608{ 625{
609 return mData->nickName; 626 return mData->nickName;
610} 627}
611 628
612QString Addressee::nickNameLabel() 629QString Addressee::nickNameLabel()
613{ 630{
614 return i18n("Nick Name"); 631 return i18n("Nick Name");
615} 632}
616 633
617 634
618void Addressee::setBirthday( const QDateTime &birthday ) 635void Addressee::setBirthday( const QDateTime &birthday )
619{ 636{
620 if ( birthday == mData->birthday ) return; 637 if ( birthday == mData->birthday ) return;
621 detach(); 638 detach();
622 mData->empty = false; 639 mData->empty = false;
623 mData->birthday = birthday; 640 mData->birthday = birthday;
624} 641}
625 642
626QDateTime Addressee::birthday() const 643QDateTime Addressee::birthday() const
627{ 644{
628 return mData->birthday; 645 return mData->birthday;
629} 646}
630 647
631QString Addressee::birthdayLabel() 648QString Addressee::birthdayLabel()
632{ 649{
633 return i18n("Birthday"); 650 return i18n("Birthday");
634} 651}
635 652
636 653
637QString Addressee::homeAddressStreetLabel() 654QString Addressee::homeAddressStreetLabel()
638{ 655{
639 return i18n("Home Address Street"); 656 return i18n("Home Address Street");
640} 657}
641 658
642 659
643QString Addressee::homeAddressLocalityLabel() 660QString Addressee::homeAddressLocalityLabel()
644{ 661{
645 return i18n("Home Address Locality"); 662 return i18n("Home Address Locality");
646} 663}
647 664
648 665
649QString Addressee::homeAddressRegionLabel() 666QString Addressee::homeAddressRegionLabel()
650{ 667{
651 return i18n("Home Address Region"); 668 return i18n("Home Address Region");
652} 669}
653 670
654 671
655QString Addressee::homeAddressPostalCodeLabel() 672QString Addressee::homeAddressPostalCodeLabel()
656{ 673{
657 return i18n("Home Address Postal Code"); 674 return i18n("Home Address Postal Code");
658} 675}
659 676
660 677
661QString Addressee::homeAddressCountryLabel() 678QString Addressee::homeAddressCountryLabel()
662{ 679{
663 return i18n("Home Address Country"); 680 return i18n("Home Address Country");
664} 681}
665 682
666 683
667QString Addressee::homeAddressLabelLabel() 684QString Addressee::homeAddressLabelLabel()
668{ 685{
669 return i18n("Home Address Label"); 686 return i18n("Home Address Label");
670} 687}
671 688
672 689
673QString Addressee::businessAddressStreetLabel() 690QString Addressee::businessAddressStreetLabel()
674{ 691{
675 return i18n("Business Address Street"); 692 return i18n("Business Address Street");
676} 693}
677 694
678 695
679QString Addressee::businessAddressLocalityLabel() 696QString Addressee::businessAddressLocalityLabel()
680{ 697{
681 return i18n("Business Address Locality"); 698 return i18n("Business Address Locality");
682} 699}
683 700
684 701
685QString Addressee::businessAddressRegionLabel() 702QString Addressee::businessAddressRegionLabel()
686{ 703{
687 return i18n("Business Address Region"); 704 return i18n("Business Address Region");
688} 705}
689 706
690 707
691QString Addressee::businessAddressPostalCodeLabel() 708QString Addressee::businessAddressPostalCodeLabel()
692{ 709{
693 return i18n("Business Address Postal Code"); 710 return i18n("Business Address Postal Code");
694} 711}
695 712
696 713
697QString Addressee::businessAddressCountryLabel() 714QString Addressee::businessAddressCountryLabel()
698{ 715{
699 return i18n("Business Address Country"); 716 return i18n("Business Address Country");
700} 717}
701 718
702 719
703QString Addressee::businessAddressLabelLabel() 720QString Addressee::businessAddressLabelLabel()
704{ 721{
705 return i18n("Business Address Label"); 722 return i18n("Business Address Label");
706} 723}
707 724
708 725
709QString Addressee::homePhoneLabel() 726QString Addressee::homePhoneLabel()
710{ 727{
711 return i18n("Home Phone"); 728 return i18n("Home Phone");
712} 729}
713 730
714 731
715QString Addressee::businessPhoneLabel() 732QString Addressee::businessPhoneLabel()
716{ 733{
717 return i18n("Business Phone"); 734 return i18n("Business Phone");
718} 735}
719 736
720 737
721QString Addressee::mobilePhoneLabel() 738QString Addressee::mobilePhoneLabel()
722{ 739{
723 return i18n("Mobile Phone"); 740 return i18n("Mobile Phone");
724} 741}
725 742
726 743
727QString Addressee::homeFaxLabel() 744QString Addressee::homeFaxLabel()
728{ 745{
729 return i18n("Home Fax"); 746 return i18n("Home Fax");
730} 747}
731 748
732 749
733QString Addressee::businessFaxLabel() 750QString Addressee::businessFaxLabel()
734{ 751{
735 return i18n("Business Fax"); 752 return i18n("Business Fax");
736} 753}
737 754
738 755
739QString Addressee::carPhoneLabel() 756QString Addressee::carPhoneLabel()
740{ 757{
741 return i18n("Car Phone"); 758 return i18n("Car Phone");
742} 759}
743 760
744 761
745QString Addressee::isdnLabel() 762QString Addressee::isdnLabel()
746{ 763{
747 return i18n("ISDN"); 764 return i18n("ISDN");
748} 765}
749 766
750 767
751QString Addressee::pagerLabel() 768QString Addressee::pagerLabel()
752{ 769{
753 return i18n("Pager"); 770 return i18n("Pager");
754} 771}
755 772
756QString Addressee::sipLabel() 773QString Addressee::sipLabel()
757{ 774{
758 return i18n("SIP"); 775 return i18n("SIP");
759} 776}
760 777
761QString Addressee::emailLabel() 778QString Addressee::emailLabel()
762{ 779{
763 return i18n("Email Address"); 780 return i18n("Email Address");
764} 781}
765 782
766 783
767void Addressee::setMailer( const QString &mailer ) 784void Addressee::setMailer( const QString &mailer )
768{ 785{
769 if ( mailer == mData->mailer ) return; 786 if ( mailer == mData->mailer ) return;
770 detach(); 787 detach();
771 mData->empty = false; 788 mData->empty = false;
772 mData->mailer = mailer; 789 mData->mailer = mailer;
773} 790}
774 791
775QString Addressee::mailer() const 792QString Addressee::mailer() const
776{ 793{
777 return mData->mailer; 794 return mData->mailer;
778} 795}
779 796
780QString Addressee::mailerLabel() 797QString Addressee::mailerLabel()
781{ 798{
782 return i18n("Mail Client"); 799 return i18n("Mail Client");
783} 800}
784 801
785 802
786void Addressee::setTimeZone( const TimeZone &timeZone ) 803void Addressee::setTimeZone( const TimeZone &timeZone )
787{ 804{
788 if ( timeZone == mData->timeZone ) return; 805 if ( timeZone == mData->timeZone ) return;
789 detach(); 806 detach();
790 mData->empty = false; 807 mData->empty = false;
791 mData->timeZone = timeZone; 808 mData->timeZone = timeZone;
792} 809}
793 810
794TimeZone Addressee::timeZone() const 811TimeZone Addressee::timeZone() const
795{ 812{
796 return mData->timeZone; 813 return mData->timeZone;
797} 814}
798 815
799QString Addressee::timeZoneLabel() 816QString Addressee::timeZoneLabel()
800{ 817{
801 return i18n("Time Zone"); 818 return i18n("Time Zone");
802} 819}
803 820
804 821
805void Addressee::setGeo( const Geo &geo ) 822void Addressee::setGeo( const Geo &geo )
806{ 823{
807 if ( geo == mData->geo ) return; 824 if ( geo == mData->geo ) return;
808 detach(); 825 detach();
809 mData->empty = false; 826 mData->empty = false;
810 mData->geo = geo; 827 mData->geo = geo;
811} 828}
812 829
813Geo Addressee::geo() const 830Geo Addressee::geo() const
814{ 831{
815 return mData->geo; 832 return mData->geo;
816} 833}
817 834
818QString Addressee::geoLabel() 835QString Addressee::geoLabel()
819{ 836{
820 return i18n("Geographic Position"); 837 return i18n("Geographic Position");
821} 838}
822 839
823 840
824void Addressee::setTitle( const QString &title ) 841void Addressee::setTitle( const QString &title )
825{ 842{
826 if ( title == mData->title ) return; 843 if ( title == mData->title ) return;
827 detach(); 844 detach();
828 mData->empty = false; 845 mData->empty = false;
829 mData->title = title; 846 mData->title = title;
830} 847}
831 848
832QString Addressee::title() const 849QString Addressee::title() const
833{ 850{
834 return mData->title; 851 return mData->title;
835} 852}
836 853
837QString Addressee::titleLabel() 854QString Addressee::titleLabel()
838{ 855{
839 return i18n("Title"); 856 return i18n("Title");
840} 857}
841 858
842 859
843void Addressee::setRole( const QString &role ) 860void Addressee::setRole( const QString &role )
844{ 861{
845 if ( role == mData->role ) return; 862 if ( role == mData->role ) return;
846 detach(); 863 detach();
847 mData->empty = false; 864 mData->empty = false;
848 mData->role = role; 865 mData->role = role;
849} 866}
850 867
851QString Addressee::role() const 868QString Addressee::role() const
852{ 869{
853 return mData->role; 870 return mData->role;
854} 871}
855 872
856QString Addressee::roleLabel() 873QString Addressee::roleLabel()
857{ 874{
858 return i18n("Role"); 875 return i18n("Role");
859} 876}
860 877
861 878
862void Addressee::setOrganization( const QString &organization ) 879void Addressee::setOrganization( const QString &organization )
863{ 880{
864 if ( organization == mData->organization ) return; 881 if ( organization == mData->organization ) return;
865 detach(); 882 detach();
866 mData->empty = false; 883 mData->empty = false;
867 mData->organization = organization; 884 mData->organization = organization;
868} 885}
869 886
870QString Addressee::organization() const 887QString Addressee::organization() const
871{ 888{
872 return mData->organization; 889 return mData->organization;
873} 890}
874 891
875QString Addressee::organizationLabel() 892QString Addressee::organizationLabel()
876{ 893{
877 return i18n("Organization"); 894 return i18n("Organization");
878} 895}
879 896
880 897
881void Addressee::setNote( const QString &note ) 898void Addressee::setNote( const QString &note )
882{ 899{
883 if ( note == mData->note ) return; 900 if ( note == mData->note ) return;
884 detach(); 901 detach();
885 mData->empty = false; 902 mData->empty = false;
886 mData->note = note; 903 mData->note = note;
887} 904}
888 905
889QString Addressee::note() const 906QString Addressee::note() const
890{ 907{
891 return mData->note; 908 return mData->note;
892} 909}
893 910
894QString Addressee::noteLabel() 911QString Addressee::noteLabel()
895{ 912{
896 return i18n("Note"); 913 return i18n("Note");
897} 914}
898 915
899 916
900void Addressee::setProductId( const QString &productId ) 917void Addressee::setProductId( const QString &productId )
901{ 918{
902 if ( productId == mData->productId ) return; 919 if ( productId == mData->productId ) return;
903 detach(); 920 detach();
904 mData->empty = false; 921 mData->empty = false;
905 mData->productId = productId; 922 mData->productId = productId;
906} 923}
907 924
908QString Addressee::productId() const 925QString Addressee::productId() const
909{ 926{
910 return mData->productId; 927 return mData->productId;
911} 928}
912 929
913QString Addressee::productIdLabel() 930QString Addressee::productIdLabel()
914{ 931{
915 return i18n("Product Identifier"); 932 return i18n("Product Identifier");
916} 933}
917 934
918 935
919void Addressee::setRevision( const QDateTime &revision ) 936void Addressee::setRevision( const QDateTime &revision )
920{ 937{
921 if ( revision == mData->revision ) return; 938 if ( revision == mData->revision ) return;
922 detach(); 939 detach();
923 mData->empty = false; 940 mData->empty = false;
924 mData->revision = revision; 941 mData->revision = revision;
925} 942}
926 943
927QDateTime Addressee::revision() const 944QDateTime Addressee::revision() const
928{ 945{
929 return mData->revision; 946 return mData->revision;
930} 947}
931 948
932QString Addressee::revisionLabel() 949QString Addressee::revisionLabel()
933{ 950{
934 return i18n("Revision Date"); 951 return i18n("Revision Date");
935} 952}
936 953
937 954
938void Addressee::setSortString( const QString &sortString ) 955void Addressee::setSortString( const QString &sortString )
939{ 956{
940 if ( sortString == mData->sortString ) return; 957 if ( sortString == mData->sortString ) return;
941 detach(); 958 detach();
942 mData->empty = false; 959 mData->empty = false;
943 mData->sortString = sortString; 960 mData->sortString = sortString;
944} 961}
945 962
946QString Addressee::sortString() const 963QString Addressee::sortString() const
947{ 964{
948 return mData->sortString; 965 return mData->sortString;
949} 966}
950 967
951QString Addressee::sortStringLabel() 968QString Addressee::sortStringLabel()
952{ 969{
953 return i18n("Sort String"); 970 return i18n("Sort String");
954} 971}
955 972
956 973
957void Addressee::setUrl( const KURL &url ) 974void Addressee::setUrl( const KURL &url )
958{ 975{
959 if ( url == mData->url ) return; 976 if ( url == mData->url ) return;
960 detach(); 977 detach();
961 mData->empty = false; 978 mData->empty = false;
962 mData->url = url; 979 mData->url = url;
963} 980}
964 981
965KURL Addressee::url() const 982KURL Addressee::url() const
966{ 983{
967 return mData->url; 984 return mData->url;
968} 985}
969 986
970QString Addressee::urlLabel() 987QString Addressee::urlLabel()
971{ 988{
972 return i18n("URL"); 989 return i18n("URL");
973} 990}
974 991
975 992
976void Addressee::setSecrecy( const Secrecy &secrecy ) 993void Addressee::setSecrecy( const Secrecy &secrecy )
977{ 994{
978 if ( secrecy == mData->secrecy ) return; 995 if ( secrecy == mData->secrecy ) return;
979 detach(); 996 detach();
980 mData->empty = false; 997 mData->empty = false;
981 mData->secrecy = secrecy; 998 mData->secrecy = secrecy;
982} 999}
983 1000
984Secrecy Addressee::secrecy() const 1001Secrecy Addressee::secrecy() const
985{ 1002{
986 return mData->secrecy; 1003 return mData->secrecy;
987} 1004}
988 1005
989QString Addressee::secrecyLabel() 1006QString Addressee::secrecyLabel()
990{ 1007{
991 return i18n("Security Class"); 1008 return i18n("Security Class");
992} 1009}
993 1010
994 1011
995void Addressee::setLogo( const Picture &logo ) 1012void Addressee::setLogo( const Picture &logo )
996{ 1013{
997 if ( logo == mData->logo ) return; 1014 if ( logo == mData->logo ) return;
998 detach(); 1015 detach();
999 mData->empty = false; 1016 mData->empty = false;
1000 mData->logo = logo; 1017 mData->logo = logo;
1001} 1018}
1002 1019
1003Picture Addressee::logo() const 1020Picture Addressee::logo() const
1004{ 1021{
1005 return mData->logo; 1022 return mData->logo;
1006} 1023}
1007 1024
1008QString Addressee::logoLabel() 1025QString Addressee::logoLabel()
1009{ 1026{
1010 return i18n("Logo"); 1027 return i18n("Logo");
1011} 1028}
1012 1029
1013 1030
1014void Addressee::setPhoto( const Picture &photo ) 1031void Addressee::setPhoto( const Picture &photo )
1015{ 1032{
1016 if ( photo == mData->photo ) return; 1033 if ( photo == mData->photo ) return;
1017 detach(); 1034 detach();
1018 mData->empty = false; 1035 mData->empty = false;
1019 mData->photo = photo; 1036 mData->photo = photo;
1020} 1037}
1021 1038
1022Picture Addressee::photo() const 1039Picture Addressee::photo() const
1023{ 1040{
1024 return mData->photo; 1041 return mData->photo;
1025} 1042}
1026 1043
1027QString Addressee::photoLabel() 1044QString Addressee::photoLabel()
1028{ 1045{
1029 return i18n("Photo"); 1046 return i18n("Photo");
1030} 1047}
1031 1048
1032 1049
1033void Addressee::setSound( const Sound &sound ) 1050void Addressee::setSound( const Sound &sound )
1034{ 1051{
1035 if ( sound == mData->sound ) return; 1052 if ( sound == mData->sound ) return;
1036 detach(); 1053 detach();
1037 mData->empty = false; 1054 mData->empty = false;
1038 mData->sound = sound; 1055 mData->sound = sound;
1039} 1056}
1040 1057
1041Sound Addressee::sound() const 1058Sound Addressee::sound() const
1042{ 1059{
1043 return mData->sound; 1060 return mData->sound;
1044} 1061}
1045 1062
1046QString Addressee::soundLabel() 1063QString Addressee::soundLabel()
1047{ 1064{
1048 return i18n("Sound"); 1065 return i18n("Sound");
1049} 1066}
1050 1067
1051 1068
1052void Addressee::setAgent( const Agent &agent ) 1069void Addressee::setAgent( const Agent &agent )
1053{ 1070{
1054 if ( agent == mData->agent ) return; 1071 if ( agent == mData->agent ) return;
1055 detach(); 1072 detach();
1056 mData->empty = false; 1073 mData->empty = false;
1057 mData->agent = agent; 1074 mData->agent = agent;
1058} 1075}
1059 1076
1060Agent Addressee::agent() const 1077Agent Addressee::agent() const
1061{ 1078{
1062 return mData->agent; 1079 return mData->agent;
1063} 1080}
1064 1081
1065QString Addressee::agentLabel() 1082QString Addressee::agentLabel()
1066{ 1083{
1067 return i18n("Agent"); 1084 return i18n("Agent");
1068} 1085}
1069 1086
1070 1087
1071 1088
1072void Addressee::setNameFromString( const QString &str ) 1089void Addressee::setNameFromString( const QString &str )
1073{ 1090{
1074 setFormattedName( str ); 1091 setFormattedName( str );
1075 setName( str ); 1092 setName( str );
1076 1093
1077 static bool first = true; 1094 static bool first = true;
1078 static QStringList titles; 1095 static QStringList titles;
1079 static QStringList suffixes; 1096 static QStringList suffixes;
1080 static QStringList prefixes; 1097 static QStringList prefixes;
1081 1098
1082 if ( first ) { 1099 if ( first ) {
1083 first = false; 1100 first = false;
1084 titles += i18n( "Dr." ); 1101 titles += i18n( "Dr." );
1085 titles += i18n( "Miss" ); 1102 titles += i18n( "Miss" );
1086 titles += i18n( "Mr." ); 1103 titles += i18n( "Mr." );
1087 titles += i18n( "Mrs." ); 1104 titles += i18n( "Mrs." );
1088 titles += i18n( "Ms." ); 1105 titles += i18n( "Ms." );
1089 titles += i18n( "Prof." ); 1106 titles += i18n( "Prof." );
1090 1107
1091 suffixes += i18n( "I" ); 1108 suffixes += i18n( "I" );
1092 suffixes += i18n( "II" ); 1109 suffixes += i18n( "II" );
1093 suffixes += i18n( "III" ); 1110 suffixes += i18n( "III" );
1094 suffixes += i18n( "Jr." ); 1111 suffixes += i18n( "Jr." );
1095 suffixes += i18n( "Sr." ); 1112 suffixes += i18n( "Sr." );
1096 1113
1097 prefixes += "van"; 1114 prefixes += "van";
1098 prefixes += "von"; 1115 prefixes += "von";
1099 prefixes += "de"; 1116 prefixes += "de";
1100 1117
1101 KConfig config( locateLocal( "config", "kabcrc") ); 1118 KConfig config( locateLocal( "config", "kabcrc") );
1102 config.setGroup( "General" ); 1119 config.setGroup( "General" );
1103 titles += config.readListEntry( "Prefixes" ); 1120 titles += config.readListEntry( "Prefixes" );
1104 titles.remove( "" ); 1121 titles.remove( "" );
1105 prefixes += config.readListEntry( "Inclusions" ); 1122 prefixes += config.readListEntry( "Inclusions" );
1106 prefixes.remove( "" ); 1123 prefixes.remove( "" );
1107 suffixes += config.readListEntry( "Suffixes" ); 1124 suffixes += config.readListEntry( "Suffixes" );
1108 suffixes.remove( "" ); 1125 suffixes.remove( "" );
1109 } 1126 }
1110 1127
1111 // clear all name parts 1128 // clear all name parts
1112 setPrefix( "" ); 1129 setPrefix( "" );
1113 setGivenName( "" ); 1130 setGivenName( "" );
1114 setAdditionalName( "" ); 1131 setAdditionalName( "" );
1115 setFamilyName( "" ); 1132 setFamilyName( "" );
1116 setSuffix( "" ); 1133 setSuffix( "" );
1117 1134
1118 if ( str.isEmpty() ) 1135 if ( str.isEmpty() )
1119 return; 1136 return;
1120 1137
1121 int i = str.find(','); 1138 int i = str.find(',');
1122 if( i < 0 ) { 1139 if( i < 0 ) {
1123 QStringList parts = QStringList::split( " ", str ); 1140 QStringList parts = QStringList::split( " ", str );
1124 int leftOffset = 0; 1141 int leftOffset = 0;
1125 int rightOffset = parts.count() - 1; 1142 int rightOffset = parts.count() - 1;
1126 1143
1127 QString suffix; 1144 QString suffix;
1128 while ( rightOffset >= 0 ) { 1145 while ( rightOffset >= 0 ) {
1129 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1146 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1130 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1147 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1131 rightOffset--; 1148 rightOffset--;
1132 } else 1149 } else
1133 break; 1150 break;
1134 } 1151 }
1135 setSuffix( suffix ); 1152 setSuffix( suffix );
1136 1153
1137 if ( rightOffset < 0 ) 1154 if ( rightOffset < 0 )
1138 return; 1155 return;
1139 1156
1140 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1157 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1141 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1158 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1142 rightOffset--; 1159 rightOffset--;
1143 } else 1160 } else
1144 setFamilyName( parts[ rightOffset ] ); 1161 setFamilyName( parts[ rightOffset ] );
1145 1162
1146 QString prefix; 1163 QString prefix;
1147 while ( leftOffset < rightOffset ) { 1164 while ( leftOffset < rightOffset ) {
1148 if ( titles.contains( parts[ leftOffset ] ) ) { 1165 if ( titles.contains( parts[ leftOffset ] ) ) {
1149 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1166 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1150 leftOffset++; 1167 leftOffset++;
1151 } else 1168 } else
1152 break; 1169 break;
1153 } 1170 }
1154 setPrefix( prefix ); 1171 setPrefix( prefix );
1155 1172
1156 if ( leftOffset < rightOffset ) { 1173 if ( leftOffset < rightOffset ) {
1157 setGivenName( parts[ leftOffset ] ); 1174 setGivenName( parts[ leftOffset ] );
1158 leftOffset++; 1175 leftOffset++;
1159 } 1176 }
1160 1177
1161 QString additionalName; 1178 QString additionalName;
1162 while ( leftOffset < rightOffset ) { 1179 while ( leftOffset < rightOffset ) {
1163 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1180 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1164 leftOffset++; 1181 leftOffset++;
1165 } 1182 }
1166 setAdditionalName( additionalName ); 1183 setAdditionalName( additionalName );
1167 } else { 1184 } else {
1168 QString part1 = str.left( i ); 1185 QString part1 = str.left( i );
1169 QString part2 = str.mid( i + 1 ); 1186 QString part2 = str.mid( i + 1 );
1170 1187
1171 QStringList parts = QStringList::split( " ", part1 ); 1188 QStringList parts = QStringList::split( " ", part1 );
1172 int leftOffset = 0; 1189 int leftOffset = 0;
1173 int rightOffset = parts.count() - 1; 1190 int rightOffset = parts.count() - 1;
1174 1191
1175 QString suffix; 1192 QString suffix;
1176 while ( rightOffset >= 0 ) { 1193 while ( rightOffset >= 0 ) {
1177 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1194 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1178 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1195 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1179 rightOffset--; 1196 rightOffset--;
1180 } else 1197 } else
1181 break; 1198 break;
1182 } 1199 }
1183 setSuffix( suffix ); 1200 setSuffix( suffix );
1184 1201
1185 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1202 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1186 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1203 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1187 rightOffset--; 1204 rightOffset--;
1188 } else 1205 } else
1189 setFamilyName( parts[ rightOffset ] ); 1206 setFamilyName( parts[ rightOffset ] );
1190 1207
1191 QString prefix; 1208 QString prefix;
1192 while ( leftOffset < rightOffset ) { 1209 while ( leftOffset < rightOffset ) {
1193 if ( titles.contains( parts[ leftOffset ] ) ) { 1210 if ( titles.contains( parts[ leftOffset ] ) ) {
1194 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1211 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1195 leftOffset++; 1212 leftOffset++;
1196 } else 1213 } else
1197 break; 1214 break;
1198 } 1215 }
1199 1216
1200 parts = QStringList::split( " ", part2 ); 1217 parts = QStringList::split( " ", part2 );
1201 1218
1202 leftOffset = 0; 1219 leftOffset = 0;
1203 rightOffset = parts.count(); 1220 rightOffset = parts.count();
1204 1221
1205 while ( leftOffset < rightOffset ) { 1222 while ( leftOffset < rightOffset ) {
1206 if ( titles.contains( parts[ leftOffset ] ) ) { 1223 if ( titles.contains( parts[ leftOffset ] ) ) {
1207 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1224 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1208 leftOffset++; 1225 leftOffset++;
1209 } else 1226 } else
1210 break; 1227 break;
1211 } 1228 }
1212 setPrefix( prefix ); 1229 setPrefix( prefix );
1213 1230
1214 if ( leftOffset < rightOffset ) { 1231 if ( leftOffset < rightOffset ) {
1215 setGivenName( parts[ leftOffset ] ); 1232 setGivenName( parts[ leftOffset ] );
1216 leftOffset++; 1233 leftOffset++;
1217 } 1234 }
1218 1235
1219 QString additionalName; 1236 QString additionalName;
1220 while ( leftOffset < rightOffset ) { 1237 while ( leftOffset < rightOffset ) {
1221 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1238 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1222 leftOffset++; 1239 leftOffset++;
1223 } 1240 }
1224 setAdditionalName( additionalName ); 1241 setAdditionalName( additionalName );
1225 } 1242 }
1226} 1243}
1227 1244
1228QString Addressee::realName() const 1245QString Addressee::realName() const
1229{ 1246{
1230 if ( !formattedName().isEmpty() ) 1247 if ( !formattedName().isEmpty() )
1231 return formattedName(); 1248 return formattedName();
1232 1249
1233 QString n = assembledName(); 1250 QString n = assembledName();
1234 1251
1235 if ( n.isEmpty() ) 1252 if ( n.isEmpty() )
1236 n = name(); 1253 n = name();
1237 1254
1238 return n; 1255 return n;
1239} 1256}
1240 1257
1241QString Addressee::assembledName() const 1258QString Addressee::assembledName() const
1242{ 1259{
1243 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1260 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1244 familyName() + " " + suffix(); 1261 familyName() + " " + suffix();
1245 1262
1246 return name.simplifyWhiteSpace(); 1263 return name.simplifyWhiteSpace();
1247} 1264}
1248 1265
1249QString Addressee::fullEmail( const QString &email ) const 1266QString Addressee::fullEmail( const QString &email ) const
1250{ 1267{
1251 QString e; 1268 QString e;
1252 if ( email.isNull() ) { 1269 if ( email.isNull() ) {
1253 e = preferredEmail(); 1270 e = preferredEmail();
1254 } else { 1271 } else {
1255 e = email; 1272 e = email;
1256 } 1273 }
1257 if ( e.isEmpty() ) return QString::null; 1274 if ( e.isEmpty() ) return QString::null;
1258 1275
1259 QString text; 1276 QString text;
1260 if ( realName().isEmpty() ) 1277 if ( realName().isEmpty() )
1261 text = e; 1278 text = e;
1262 else 1279 else
1263 text = assembledName() + " <" + e + ">"; 1280 text = assembledName() + " <" + e + ">";
1264 1281
1265 return text; 1282 return text;
1266} 1283}
1267 1284
1268void Addressee::insertEmail( const QString &email, bool preferred ) 1285void Addressee::insertEmail( const QString &email, bool preferred )
1269{ 1286{
1270 detach(); 1287 detach();
1271 1288
1272 QStringList::Iterator it = mData->emails.find( email ); 1289 QStringList::Iterator it = mData->emails.find( email );
1273 1290
1274 if ( it != mData->emails.end() ) { 1291 if ( it != mData->emails.end() ) {
1275 if ( !preferred || it == mData->emails.begin() ) return; 1292 if ( !preferred || it == mData->emails.begin() ) return;
1276 mData->emails.remove( it ); 1293 mData->emails.remove( it );
1277 mData->emails.prepend( email ); 1294 mData->emails.prepend( email );
1278 } else { 1295 } else {
1279 if ( preferred ) { 1296 if ( preferred ) {
1280 mData->emails.prepend( email ); 1297 mData->emails.prepend( email );
1281 } else { 1298 } else {
1282 mData->emails.append( email ); 1299 mData->emails.append( email );
1283 } 1300 }
1284 } 1301 }
1285} 1302}
1286 1303
1287void Addressee::removeEmail( const QString &email ) 1304void Addressee::removeEmail( const QString &email )
1288{ 1305{
1289 detach(); 1306 detach();
1290 1307
1291 QStringList::Iterator it = mData->emails.find( email ); 1308 QStringList::Iterator it = mData->emails.find( email );
1292 if ( it == mData->emails.end() ) return; 1309 if ( it == mData->emails.end() ) return;
1293 1310
1294 mData->emails.remove( it ); 1311 mData->emails.remove( it );
1295} 1312}
1296 1313
1297QString Addressee::preferredEmail() const 1314QString Addressee::preferredEmail() const
1298{ 1315{
1299 if ( mData->emails.count() == 0 ) return QString::null; 1316 if ( mData->emails.count() == 0 ) return QString::null;
1300 else return mData->emails.first(); 1317 else return mData->emails.first();
1301} 1318}
1302 1319
1303QStringList Addressee::emails() const 1320QStringList Addressee::emails() const
1304{ 1321{
1305 return mData->emails; 1322 return mData->emails;
1306} 1323}
1307void Addressee::setEmails( const QStringList& emails ) { 1324void Addressee::setEmails( const QStringList& emails ) {
1308 detach(); 1325 detach();
1309 mData->emails = emails; 1326 mData->emails = emails;
1310} 1327}
1311void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1328void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1312{ 1329{
1313 detach(); 1330 detach();
1314 mData->empty = false; 1331 mData->empty = false;
1315 1332
1316 PhoneNumber::List::Iterator it; 1333 PhoneNumber::List::Iterator it;
1317 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1334 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1318 if ( (*it).id() == phoneNumber.id() ) { 1335 if ( (*it).id() == phoneNumber.id() ) {
1319 *it = phoneNumber; 1336 *it = phoneNumber;
1320 return; 1337 return;
1321 } 1338 }
1322 } 1339 }
1323 mData->phoneNumbers.append( phoneNumber ); 1340 mData->phoneNumbers.append( phoneNumber );
1324} 1341}
1325 1342
1326void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1343void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1327{ 1344{
1328 detach(); 1345 detach();
1329 1346
1330 PhoneNumber::List::Iterator it; 1347 PhoneNumber::List::Iterator it;
1331 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1348 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1332 if ( (*it).id() == phoneNumber.id() ) { 1349 if ( (*it).id() == phoneNumber.id() ) {
1333 mData->phoneNumbers.remove( it ); 1350 mData->phoneNumbers.remove( it );
1334 return; 1351 return;
1335 } 1352 }
1336 } 1353 }
1337} 1354}
1338 1355
1339PhoneNumber Addressee::phoneNumber( int type ) const 1356PhoneNumber Addressee::phoneNumber( int type ) const
1340{ 1357{
1341 PhoneNumber phoneNumber( "", type ); 1358 PhoneNumber phoneNumber( "", type );
1342 PhoneNumber::List::ConstIterator it; 1359 PhoneNumber::List::ConstIterator it;
1343 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1360 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1344 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1361 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1345 if ( (*it).type() & PhoneNumber::Pref ) 1362 if ( (*it).type() & PhoneNumber::Pref )
1346 return (*it); 1363 return (*it);
1347 else if ( phoneNumber.number().isEmpty() ) 1364 else if ( phoneNumber.number().isEmpty() )
1348 phoneNumber = (*it); 1365 phoneNumber = (*it);
1349 } 1366 }
1350 } 1367 }
1351 1368
1352 return phoneNumber; 1369 return phoneNumber;
1353} 1370}
1354 1371
1355PhoneNumber::List Addressee::phoneNumbers() const 1372PhoneNumber::List Addressee::phoneNumbers() const
1356{ 1373{
1357 return mData->phoneNumbers; 1374 return mData->phoneNumbers;
1358} 1375}
1359 1376
1360PhoneNumber::List Addressee::phoneNumbers( int type ) const 1377PhoneNumber::List Addressee::phoneNumbers( int type ) const
1361{ 1378{
1362 PhoneNumber::List list; 1379 PhoneNumber::List list;
1363 1380
1364 PhoneNumber::List::ConstIterator it; 1381 PhoneNumber::List::ConstIterator it;
1365 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1382 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1366 if ( matchBinaryPattern( (*it).type(), type ) ) { 1383 if ( matchBinaryPattern( (*it).type(), type ) ) {
1367 list.append( *it ); 1384 list.append( *it );
1368 } 1385 }
1369 } 1386 }
1370 return list; 1387 return list;
1371} 1388}
1372 1389
1373PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1390PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1374{ 1391{
1375 PhoneNumber::List::ConstIterator it; 1392 PhoneNumber::List::ConstIterator it;
1376 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1393 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1377 if ( (*it).id() == id ) { 1394 if ( (*it).id() == id ) {
1378 return *it; 1395 return *it;
1379 } 1396 }
1380 } 1397 }
1381 return PhoneNumber(); 1398 return PhoneNumber();
1382} 1399}
1383 1400
1384void Addressee::insertKey( const Key &key ) 1401void Addressee::insertKey( const Key &key )
1385{ 1402{
1386 detach(); 1403 detach();
1387 mData->empty = false; 1404 mData->empty = false;
1388 1405
1389 Key::List::Iterator it; 1406 Key::List::Iterator it;
1390 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1407 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1391 if ( (*it).id() == key.id() ) { 1408 if ( (*it).id() == key.id() ) {
1392 *it = key; 1409 *it = key;
1393 return; 1410 return;
1394 } 1411 }
1395 } 1412 }
1396 mData->keys.append( key ); 1413 mData->keys.append( key );
1397} 1414}
1398 1415
1399void Addressee::removeKey( const Key &key ) 1416void Addressee::removeKey( const Key &key )
1400{ 1417{
1401 detach(); 1418 detach();
1402 1419
1403 Key::List::Iterator it; 1420 Key::List::Iterator it;
1404 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1421 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1405 if ( (*it).id() == key.id() ) { 1422 if ( (*it).id() == key.id() ) {
1406 mData->keys.remove( key ); 1423 mData->keys.remove( key );
1407 return; 1424 return;
1408 } 1425 }
1409 } 1426 }
1410} 1427}
1411 1428
1412Key Addressee::key( int type, QString customTypeString ) const 1429Key Addressee::key( int type, QString customTypeString ) const
1413{ 1430{
1414 Key::List::ConstIterator it; 1431 Key::List::ConstIterator it;
1415 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1432 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1416 if ( (*it).type() == type ) { 1433 if ( (*it).type() == type ) {
1417 if ( type == Key::Custom ) { 1434 if ( type == Key::Custom ) {
1418 if ( customTypeString.isEmpty() ) { 1435 if ( customTypeString.isEmpty() ) {
1419 return *it; 1436 return *it;
1420 } else { 1437 } else {
1421 if ( (*it).customTypeString() == customTypeString ) 1438 if ( (*it).customTypeString() == customTypeString )
1422 return (*it); 1439 return (*it);
1423 } 1440 }
1424 } else { 1441 } else {
1425 return *it; 1442 return *it;
1426 } 1443 }
1427 } 1444 }
1428 } 1445 }
1429 return Key( QString(), type ); 1446 return Key( QString(), type );
1430} 1447}
1431void Addressee::setKeys( const Key::List& list ) { 1448void Addressee::setKeys( const Key::List& list ) {
1432 detach(); 1449 detach();
1433 mData->keys = list; 1450 mData->keys = list;
1434} 1451}
1435 1452
1436Key::List Addressee::keys() const 1453Key::List Addressee::keys() const
1437{ 1454{
1438 return mData->keys; 1455 return mData->keys;
1439} 1456}
1440 1457
1441Key::List Addressee::keys( int type, QString customTypeString ) const 1458Key::List Addressee::keys( int type, QString customTypeString ) const
1442{ 1459{
1443 Key::List list; 1460 Key::List list;
1444 1461
1445 Key::List::ConstIterator it; 1462 Key::List::ConstIterator it;
1446 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1463 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1447 if ( (*it).type() == type ) { 1464 if ( (*it).type() == type ) {
1448 if ( type == Key::Custom ) { 1465 if ( type == Key::Custom ) {
1449 if ( customTypeString.isEmpty() ) { 1466 if ( customTypeString.isEmpty() ) {
1450 list.append(*it); 1467 list.append(*it);
1451 } else { 1468 } else {
1452 if ( (*it).customTypeString() == customTypeString ) 1469 if ( (*it).customTypeString() == customTypeString )
1453 list.append(*it); 1470 list.append(*it);
1454 } 1471 }
1455 } else { 1472 } else {
1456 list.append(*it); 1473 list.append(*it);
1457 } 1474 }
1458 } 1475 }
1459 } 1476 }
1460 return list; 1477 return list;
1461} 1478}
1462 1479
1463Key Addressee::findKey( const QString &id ) const 1480Key Addressee::findKey( const QString &id ) const
1464{ 1481{
1465 Key::List::ConstIterator it; 1482 Key::List::ConstIterator it;
1466 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1483 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1467 if ( (*it).id() == id ) { 1484 if ( (*it).id() == id ) {
1468 return *it; 1485 return *it;
1469 } 1486 }
1470 } 1487 }
1471 return Key(); 1488 return Key();
1472} 1489}
1473 1490
1474QString Addressee::asString() const 1491QString Addressee::asString() const
1475{ 1492{
1476 return "Smith, agent Smith..."; 1493 return "Smith, agent Smith...";
1477} 1494}
1478 1495
1479void Addressee::dump() const 1496void Addressee::dump() const
1480{ 1497{
1481 return; 1498 return;
1482 kdDebug(5700) << "Addressee {" << endl; 1499 kdDebug(5700) << "Addressee {" << endl;
1483 1500
1484 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1501 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1485 1502
1486 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1503 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1487 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1504 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1488 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1505 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1489 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1506 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1490 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1507 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1491 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1508 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1492 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1509 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1493 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1510 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1494 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1511 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1495 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1512 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1496 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1513 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1497 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1514 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1498 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1515 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1499 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1516 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1500 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1517 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1501 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1518 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1502 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1519 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1503 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1520 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1504 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1521 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1505 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1522 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1506 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1523 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1507 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1524 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1508 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1525 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1509 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1526 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1510 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1527 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1511 1528
1512 kdDebug(5700) << " Emails {" << endl; 1529 kdDebug(5700) << " Emails {" << endl;
1513 QStringList e = emails(); 1530 QStringList e = emails();
1514 QStringList::ConstIterator it; 1531 QStringList::ConstIterator it;
1515 for( it = e.begin(); it != e.end(); ++it ) { 1532 for( it = e.begin(); it != e.end(); ++it ) {
1516 kdDebug(5700) << " " << (*it) << endl; 1533 kdDebug(5700) << " " << (*it) << endl;
1517 } 1534 }
1518 kdDebug(5700) << " }" << endl; 1535 kdDebug(5700) << " }" << endl;
1519 1536
1520 kdDebug(5700) << " PhoneNumbers {" << endl; 1537 kdDebug(5700) << " PhoneNumbers {" << endl;
1521 PhoneNumber::List p = phoneNumbers(); 1538 PhoneNumber::List p = phoneNumbers();
1522 PhoneNumber::List::ConstIterator it2; 1539 PhoneNumber::List::ConstIterator it2;
1523 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1540 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1524 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1541 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1525 } 1542 }
1526 kdDebug(5700) << " }" << endl; 1543 kdDebug(5700) << " }" << endl;
1527 1544
1528 Address::List a = addresses(); 1545 Address::List a = addresses();
1529 Address::List::ConstIterator it3; 1546 Address::List::ConstIterator it3;
1530 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1547 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1531 (*it3).dump(); 1548 (*it3).dump();
1532 } 1549 }
1533 1550
1534 kdDebug(5700) << " Keys {" << endl; 1551 kdDebug(5700) << " Keys {" << endl;
1535 Key::List k = keys(); 1552 Key::List k = keys();
1536 Key::List::ConstIterator it4; 1553 Key::List::ConstIterator it4;
1537 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1554 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1538 kdDebug(5700) << " Type: " << int((*it4).type()) << 1555 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1539 " Key: " << (*it4).textData() << 1556 " Key: " << (*it4).textData() <<
1540 " CustomString: " << (*it4).customTypeString() << endl; 1557 " CustomString: " << (*it4).customTypeString() << endl;
1541 } 1558 }
1542 kdDebug(5700) << " }" << endl; 1559 kdDebug(5700) << " }" << endl;
1543 1560
1544 kdDebug(5700) << "}" << endl; 1561 kdDebug(5700) << "}" << endl;
1545} 1562}
1546 1563
1547 1564
1548void Addressee::insertAddress( const Address &address ) 1565void Addressee::insertAddress( const Address &address )
1549{ 1566{
1550 detach(); 1567 detach();
1551 mData->empty = false; 1568 mData->empty = false;
1552 1569
1553 Address::List::Iterator it; 1570 Address::List::Iterator it;
1554 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1571 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1555 if ( (*it).id() == address.id() ) { 1572 if ( (*it).id() == address.id() ) {
1556 *it = address; 1573 *it = address;
1557 return; 1574 return;
1558 } 1575 }
1559 } 1576 }
1560 mData->addresses.append( address ); 1577 mData->addresses.append( address );
1561} 1578}
1562 1579
1563void Addressee::removeAddress( const Address &address ) 1580void Addressee::removeAddress( const Address &address )
1564{ 1581{
1565 detach(); 1582 detach();
1566 1583
1567 Address::List::Iterator it; 1584 Address::List::Iterator it;
1568 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1585 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1569 if ( (*it).id() == address.id() ) { 1586 if ( (*it).id() == address.id() ) {
1570 mData->addresses.remove( it ); 1587 mData->addresses.remove( it );
1571 return; 1588 return;
1572 } 1589 }
1573 } 1590 }
1574} 1591}
1575 1592
1576Address Addressee::address( int type ) const 1593Address Addressee::address( int type ) const
1577{ 1594{
1578 Address address( type ); 1595 Address address( type );
1579 Address::List::ConstIterator it; 1596 Address::List::ConstIterator it;
1580 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1597 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1581 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1598 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1582 if ( (*it).type() & Address::Pref ) 1599 if ( (*it).type() & Address::Pref )
1583 return (*it); 1600 return (*it);
1584 else if ( address.isEmpty() ) 1601 else if ( address.isEmpty() )
1585 address = (*it); 1602 address = (*it);
1586 } 1603 }
1587 } 1604 }
1588 1605
1589 return address; 1606 return address;
1590} 1607}
1591 1608
1592Address::List Addressee::addresses() const 1609Address::List Addressee::addresses() const
1593{ 1610{
1594 return mData->addresses; 1611 return mData->addresses;
1595} 1612}
1596 1613
1597Address::List Addressee::addresses( int type ) const 1614Address::List Addressee::addresses( int type ) const
1598{ 1615{
1599 Address::List list; 1616 Address::List list;
1600 1617
1601 Address::List::ConstIterator it; 1618 Address::List::ConstIterator it;
1602 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1619 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1603 if ( matchBinaryPattern( (*it).type(), type ) ) { 1620 if ( matchBinaryPattern( (*it).type(), type ) ) {
1604 list.append( *it ); 1621 list.append( *it );
1605 } 1622 }
1606 } 1623 }
1607 1624
1608 return list; 1625 return list;
1609} 1626}
1610 1627
1611Address Addressee::findAddress( const QString &id ) const 1628Address Addressee::findAddress( const QString &id ) const
1612{ 1629{
1613 Address::List::ConstIterator it; 1630 Address::List::ConstIterator it;
1614 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1631 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1615 if ( (*it).id() == id ) { 1632 if ( (*it).id() == id ) {
1616 return *it; 1633 return *it;
1617 } 1634 }
1618 } 1635 }
1619 return Address(); 1636 return Address();
1620} 1637}
1621 1638
1622void Addressee::insertCategory( const QString &c ) 1639void Addressee::insertCategory( const QString &c )
1623{ 1640{
1624 detach(); 1641 detach();
1625 mData->empty = false; 1642 mData->empty = false;
1626 1643
1627 if ( mData->categories.contains( c ) ) return; 1644 if ( mData->categories.contains( c ) ) return;
1628 1645
1629 mData->categories.append( c ); 1646 mData->categories.append( c );
1630} 1647}
1631 1648
1632void Addressee::removeCategory( const QString &c ) 1649void Addressee::removeCategory( const QString &c )
1633{ 1650{
1634 detach(); 1651 detach();
1635 1652
1636 QStringList::Iterator it = mData->categories.find( c ); 1653 QStringList::Iterator it = mData->categories.find( c );
1637 if ( it == mData->categories.end() ) return; 1654 if ( it == mData->categories.end() ) return;
1638 1655
1639 mData->categories.remove( it ); 1656 mData->categories.remove( it );
1640} 1657}
1641 1658
1642bool Addressee::hasCategory( const QString &c ) const 1659bool Addressee::hasCategory( const QString &c ) const
1643{ 1660{
1644 return ( mData->categories.contains( c ) ); 1661 return ( mData->categories.contains( c ) );
1645} 1662}
1646 1663
1647void Addressee::setCategories( const QStringList &c ) 1664void Addressee::setCategories( const QStringList &c )
1648{ 1665{
1649 detach(); 1666 detach();
1650 mData->empty = false; 1667 mData->empty = false;
1651 1668
1652 mData->categories = c; 1669 mData->categories = c;
1653} 1670}
1654 1671
1655QStringList Addressee::categories() const 1672QStringList Addressee::categories() const
1656{ 1673{
1657 return mData->categories; 1674 return mData->categories;
1658} 1675}
1659 1676
1660void Addressee::insertCustom( const QString &app, const QString &name, 1677void Addressee::insertCustom( const QString &app, const QString &name,
1661 const QString &value ) 1678 const QString &value )
1662{ 1679{
1663 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1680 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1664 1681
1665 detach(); 1682 detach();
1666 mData->empty = false; 1683 mData->empty = false;
1667 1684
1668 QString qualifiedName = app + "-" + name + ":"; 1685 QString qualifiedName = app + "-" + name + ":";
1669 1686
1670 QStringList::Iterator it; 1687 QStringList::Iterator it;
1671 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1688 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1672 if ( (*it).startsWith( qualifiedName ) ) { 1689 if ( (*it).startsWith( qualifiedName ) ) {
1673 (*it) = qualifiedName + value; 1690 (*it) = qualifiedName + value;
1674 return; 1691 return;
1675 } 1692 }
1676 } 1693 }
1677 mData->custom.append( qualifiedName + value ); 1694 mData->custom.append( qualifiedName + value );
1678} 1695}
1679 1696
1680void Addressee::removeCustom( const QString &app, const QString &name) 1697void Addressee::removeCustom( const QString &app, const QString &name)
1681{ 1698{
1682 detach(); 1699 detach();
1683 1700
1684 QString qualifiedName = app + "-" + name + ":"; 1701 QString qualifiedName = app + "-" + name + ":";
1685 1702
1686 QStringList::Iterator it; 1703 QStringList::Iterator it;
1687 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1704 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1688 if ( (*it).startsWith( qualifiedName ) ) { 1705 if ( (*it).startsWith( qualifiedName ) ) {
1689 mData->custom.remove( it ); 1706 mData->custom.remove( it );
1690 return; 1707 return;
1691 } 1708 }
1692 } 1709 }
1693} 1710}
1694 1711
1695QString Addressee::custom( const QString &app, const QString &name ) const 1712QString Addressee::custom( const QString &app, const QString &name ) const
1696{ 1713{
1697 QString qualifiedName = app + "-" + name + ":"; 1714 QString qualifiedName = app + "-" + name + ":";
1698 QString value; 1715 QString value;
1699 1716
1700 QStringList::ConstIterator it; 1717 QStringList::ConstIterator it;
1701 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1718 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1702 if ( (*it).startsWith( qualifiedName ) ) { 1719 if ( (*it).startsWith( qualifiedName ) ) {
1703 value = (*it).mid( (*it).find( ":" ) + 1 ); 1720 value = (*it).mid( (*it).find( ":" ) + 1 );
1704 break; 1721 break;
1705 } 1722 }
1706 } 1723 }
1707 1724
1708 return value; 1725 return value;
1709} 1726}
1710 1727
1711void Addressee::setCustoms( const QStringList &l ) 1728void Addressee::setCustoms( const QStringList &l )
1712{ 1729{
1713 detach(); 1730 detach();
1714 mData->empty = false; 1731 mData->empty = false;
1715 1732
1716 mData->custom = l; 1733 mData->custom = l;
1717} 1734}
1718 1735
1719QStringList Addressee::customs() const 1736QStringList Addressee::customs() const
1720{ 1737{
1721 return mData->custom; 1738 return mData->custom;
1722} 1739}
1723 1740
1724void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1741void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1725 QString &email) 1742 QString &email)
1726{ 1743{
1727 int startPos, endPos, len; 1744 int startPos, endPos, len;
1728 QString partA, partB, result; 1745 QString partA, partB, result;
1729 char endCh = '>'; 1746 char endCh = '>';
1730 1747
1731 startPos = rawEmail.find('<'); 1748 startPos = rawEmail.find('<');
1732 if (startPos < 0) 1749 if (startPos < 0)
1733 { 1750 {
1734 startPos = rawEmail.find('('); 1751 startPos = rawEmail.find('(');
1735 endCh = ')'; 1752 endCh = ')';
1736 } 1753 }
1737 if (startPos < 0) 1754 if (startPos < 0)
1738 { 1755 {
1739 // We couldn't find any separators, so we assume the whole string 1756 // We couldn't find any separators, so we assume the whole string
1740 // is the email address 1757 // is the email address
1741 email = rawEmail; 1758 email = rawEmail;
1742 fullName = ""; 1759 fullName = "";
1743 } 1760 }
1744 else 1761 else
1745 { 1762 {
1746 // We have a start position, try to find an end 1763 // We have a start position, try to find an end
1747 endPos = rawEmail.find(endCh, startPos+1); 1764 endPos = rawEmail.find(endCh, startPos+1);
1748 1765
1749 if (endPos < 0) 1766 if (endPos < 0)
1750 { 1767 {
1751 // We couldn't find the end of the email address. We can only 1768 // We couldn't find the end of the email address. We can only
1752 // assume the entire string is the email address. 1769 // assume the entire string is the email address.
1753 email = rawEmail; 1770 email = rawEmail;
1754 fullName = ""; 1771 fullName = "";
1755 } 1772 }
1756 else 1773 else
1757 { 1774 {
1758 // We have a start and end to the email address 1775 // We have a start and end to the email address
1759 1776
1760 // Grab the name part 1777 // Grab the name part
1761 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1778 fullName = rawEmail.left(startPos).stripWhiteSpace();
1762 1779
1763 // grab the email part 1780 // grab the email part
1764 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1781 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1765 1782
1766 // Check that we do not have any extra characters on the end of the 1783 // Check that we do not have any extra characters on the end of the
1767 // strings 1784 // strings
1768 len = fullName.length(); 1785 len = fullName.length();
1769 if (fullName[0]=='"' && fullName[len-1]=='"') 1786 if (fullName[0]=='"' && fullName[len-1]=='"')
1770 fullName = fullName.mid(1, len-2); 1787 fullName = fullName.mid(1, len-2);
1771 else if (fullName[0]=='<' && fullName[len-1]=='>') 1788 else if (fullName[0]=='<' && fullName[len-1]=='>')
1772 fullName = fullName.mid(1, len-2); 1789 fullName = fullName.mid(1, len-2);
1773 else if (fullName[0]=='(' && fullName[len-1]==')') 1790 else if (fullName[0]=='(' && fullName[len-1]==')')
1774 fullName = fullName.mid(1, len-2); 1791 fullName = fullName.mid(1, len-2);
1775 } 1792 }
1776 } 1793 }
1777} 1794}
1778 1795
1779void Addressee::setResource( Resource *resource ) 1796void Addressee::setResource( Resource *resource )
1780{ 1797{
1781 detach(); 1798 detach();
1782 mData->resource = resource; 1799 mData->resource = resource;
1783} 1800}
1784 1801
1785Resource *Addressee::resource() const 1802Resource *Addressee::resource() const
1786{ 1803{
1787 return mData->resource; 1804 return mData->resource;
1788} 1805}
1789 1806
1790//US 1807//US
1791QString Addressee::resourceLabel() 1808QString Addressee::resourceLabel()
1792{ 1809{
1793 return i18n("Resource"); 1810 return i18n("Resource");
1794} 1811}
1795 1812
1796void Addressee::setChanged( bool value ) 1813void Addressee::setChanged( bool value )
1797{ 1814{
1798 detach(); 1815 detach();
1799 mData->changed = value; 1816 mData->changed = value;
1800} 1817}
1801 1818
1802bool Addressee::changed() const 1819bool Addressee::changed() const
1803{ 1820{
1804 return mData->changed; 1821 return mData->changed;
1805} 1822}
1806 1823
1807QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1824QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1808{ 1825{
1809 if (!a.mData) return s; 1826 if (!a.mData) return s;
1810 1827
1811 s << a.uid(); 1828 s << a.uid();
1812 1829
1813 s << a.mData->name; 1830 s << a.mData->name;
1814 s << a.mData->formattedName; 1831 s << a.mData->formattedName;
1815 s << a.mData->familyName; 1832 s << a.mData->familyName;
1816 s << a.mData->givenName; 1833 s << a.mData->givenName;
1817 s << a.mData->additionalName; 1834 s << a.mData->additionalName;
1818 s << a.mData->prefix; 1835 s << a.mData->prefix;
1819 s << a.mData->suffix; 1836 s << a.mData->suffix;
1820 s << a.mData->nickName; 1837 s << a.mData->nickName;
1821 s << a.mData->birthday; 1838 s << a.mData->birthday;
1822 s << a.mData->mailer; 1839 s << a.mData->mailer;
1823 s << a.mData->timeZone; 1840 s << a.mData->timeZone;
1824 s << a.mData->geo; 1841 s << a.mData->geo;
1825 s << a.mData->title; 1842 s << a.mData->title;
1826 s << a.mData->role; 1843 s << a.mData->role;
1827 s << a.mData->organization; 1844 s << a.mData->organization;
1828 s << a.mData->note; 1845 s << a.mData->note;
1829 s << a.mData->productId; 1846 s << a.mData->productId;
1830 s << a.mData->revision; 1847 s << a.mData->revision;
1831 s << a.mData->sortString; 1848 s << a.mData->sortString;
1832 s << a.mData->url; 1849 s << a.mData->url;
1833 s << a.mData->secrecy; 1850 s << a.mData->secrecy;
1834 s << a.mData->logo; 1851 s << a.mData->logo;
1835 s << a.mData->photo; 1852 s << a.mData->photo;
1836 s << a.mData->sound; 1853 s << a.mData->sound;
1837 s << a.mData->agent; 1854 s << a.mData->agent;
1838 s << a.mData->phoneNumbers; 1855 s << a.mData->phoneNumbers;
1839 s << a.mData->addresses; 1856 s << a.mData->addresses;
1840 s << a.mData->emails; 1857 s << a.mData->emails;
1841 s << a.mData->categories; 1858 s << a.mData->categories;
1842 s << a.mData->custom; 1859 s << a.mData->custom;
1843 s << a.mData->keys; 1860 s << a.mData->keys;
1844 return s; 1861 return s;
1845} 1862}
1846 1863
1847QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1864QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1848{ 1865{
1849 if (!a.mData) return s; 1866 if (!a.mData) return s;
1850 1867
1851 s >> a.mData->uid; 1868 s >> a.mData->uid;
1852 1869
1853 s >> a.mData->name; 1870 s >> a.mData->name;
1854 s >> a.mData->formattedName; 1871 s >> a.mData->formattedName;
1855 s >> a.mData->familyName; 1872 s >> a.mData->familyName;
1856 s >> a.mData->givenName; 1873 s >> a.mData->givenName;
1857 s >> a.mData->additionalName; 1874 s >> a.mData->additionalName;
1858 s >> a.mData->prefix; 1875 s >> a.mData->prefix;
1859 s >> a.mData->suffix; 1876 s >> a.mData->suffix;
1860 s >> a.mData->nickName; 1877 s >> a.mData->nickName;
1861 s >> a.mData->birthday; 1878 s >> a.mData->birthday;
1862 s >> a.mData->mailer; 1879 s >> a.mData->mailer;
1863 s >> a.mData->timeZone; 1880 s >> a.mData->timeZone;
1864 s >> a.mData->geo; 1881 s >> a.mData->geo;
1865 s >> a.mData->title; 1882 s >> a.mData->title;
1866 s >> a.mData->role; 1883 s >> a.mData->role;
1867 s >> a.mData->organization; 1884 s >> a.mData->organization;
1868 s >> a.mData->note; 1885 s >> a.mData->note;
1869 s >> a.mData->productId; 1886 s >> a.mData->productId;
1870 s >> a.mData->revision; 1887 s >> a.mData->revision;
1871 s >> a.mData->sortString; 1888 s >> a.mData->sortString;
1872 s >> a.mData->url; 1889 s >> a.mData->url;
1873 s >> a.mData->secrecy; 1890 s >> a.mData->secrecy;
1874 s >> a.mData->logo; 1891 s >> a.mData->logo;
1875 s >> a.mData->photo; 1892 s >> a.mData->photo;
1876 s >> a.mData->sound; 1893 s >> a.mData->sound;
1877 s >> a.mData->agent; 1894 s >> a.mData->agent;
1878 s >> a.mData->phoneNumbers; 1895 s >> a.mData->phoneNumbers;
1879 s >> a.mData->addresses; 1896 s >> a.mData->addresses;
1880 s >> a.mData->emails; 1897 s >> a.mData->emails;
1881 s >> a.mData->categories; 1898 s >> a.mData->categories;
1882 s >> a.mData->custom; 1899 s >> a.mData->custom;
1883 s >> a.mData->keys; 1900 s >> a.mData->keys;
1884 1901
1885 a.mData->empty = false; 1902 a.mData->empty = false;
1886 1903
1887 return s; 1904 return s;
1888} 1905}
1889bool matchBinaryPattern( int value, int pattern ) 1906bool matchBinaryPattern( int value, int pattern )
1890{ 1907{
1891 /** 1908 /**
1892 We want to match all telephonnumbers/addresses which have the bits in the 1909 We want to match all telephonnumbers/addresses which have the bits in the
1893 pattern set. More are allowed. 1910 pattern set. More are allowed.
1894 if pattern == 0 we have a special handling, then we want only those with 1911 if pattern == 0 we have a special handling, then we want only those with
1895 exactly no bit set. 1912 exactly no bit set.
1896 */ 1913 */
1897 if ( pattern == 0 ) 1914 if ( pattern == 0 )
1898 return ( value == 0 ); 1915 return ( value == 0 );
1899 else 1916 else
1900 return ( pattern == ( pattern & value ) ); 1917 return ( pattern == ( pattern & value ) );
1901} 1918}
1902 1919
1903bool matchBinaryPatternP( int value, int pattern ) 1920bool matchBinaryPatternP( int value, int pattern )
1904{ 1921{
1905 1922
1906 if ( pattern == 0 ) 1923 if ( pattern == 0 )
1907 return ( value == 0 ); 1924 return ( value == 0 );
1908 else 1925 else
1909 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 1926 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
1910} 1927}
1911bool matchBinaryPatternA( int value, int pattern ) 1928bool matchBinaryPatternA( int value, int pattern )
1912{ 1929{
1913 1930
1914 if ( pattern == 0 ) 1931 if ( pattern == 0 )
1915 return ( value == 0 ); 1932 return ( value == 0 );
1916 else 1933 else
1917 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 1934 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
1918} 1935}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 44f0629..9336edc 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,848 +1,849 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice();
124 125
125 /** 126 /**
126 Set unique identifier. 127 Set unique identifier.
127 */ 128 */
128 void setUid( const QString &uid ); 129 void setUid( const QString &uid );
129 /** 130 /**
130 Return unique identifier. 131 Return unique identifier.
131 */ 132 */
132 QString uid() const; 133 QString uid() const;
133 /** 134 /**
134 Return translated label for uid field. 135 Return translated label for uid field.
135 */ 136 */
136 static QString uidLabel(); 137 static QString uidLabel();
137 138
138 /** 139 /**
139 Set name. 140 Set name.
140 */ 141 */
141 void setName( const QString &name ); 142 void setName( const QString &name );
142 /** 143 /**
143 Return name. 144 Return name.
144 */ 145 */
145 QString name() const; 146 QString name() const;
146 /** 147 /**
147 Return translated label for name field. 148 Return translated label for name field.
148 */ 149 */
149 static QString nameLabel(); 150 static QString nameLabel();
150 151
151 /** 152 /**
152 Set formatted name. 153 Set formatted name.
153 */ 154 */
154 void setFormattedName( const QString &formattedName ); 155 void setFormattedName( const QString &formattedName );
155 /** 156 /**
156 Return formatted name. 157 Return formatted name.
157 */ 158 */
158 QString formattedName() const; 159 QString formattedName() const;
159 /** 160 /**
160 Return translated label for formattedName field. 161 Return translated label for formattedName field.
161 */ 162 */
162 static QString formattedNameLabel(); 163 static QString formattedNameLabel();
163 164
164 /** 165 /**
165 Set family name. 166 Set family name.
166 */ 167 */
167 void setFamilyName( const QString &familyName ); 168 void setFamilyName( const QString &familyName );
168 /** 169 /**
169 Return family name. 170 Return family name.
170 */ 171 */
171 QString familyName() const; 172 QString familyName() const;
172 /** 173 /**
173 Return translated label for familyName field. 174 Return translated label for familyName field.
174 */ 175 */
175 static QString familyNameLabel(); 176 static QString familyNameLabel();
176 177
177 /** 178 /**
178 Set given name. 179 Set given name.
179 */ 180 */
180 void setGivenName( const QString &givenName ); 181 void setGivenName( const QString &givenName );
181 /** 182 /**
182 Return given name. 183 Return given name.
183 */ 184 */
184 QString givenName() const; 185 QString givenName() const;
185 /** 186 /**
186 Return translated label for givenName field. 187 Return translated label for givenName field.
187 */ 188 */
188 static QString givenNameLabel(); 189 static QString givenNameLabel();
189 190
190 /** 191 /**
191 Set additional names. 192 Set additional names.
192 */ 193 */
193 void setAdditionalName( const QString &additionalName ); 194 void setAdditionalName( const QString &additionalName );
194 /** 195 /**
195 Return additional names. 196 Return additional names.
196 */ 197 */
197 QString additionalName() const; 198 QString additionalName() const;
198 /** 199 /**
199 Return translated label for additionalName field. 200 Return translated label for additionalName field.
200 */ 201 */
201 static QString additionalNameLabel(); 202 static QString additionalNameLabel();
202 203
203 /** 204 /**
204 Set honorific prefixes. 205 Set honorific prefixes.
205 */ 206 */
206 void setPrefix( const QString &prefix ); 207 void setPrefix( const QString &prefix );
207 /** 208 /**
208 Return honorific prefixes. 209 Return honorific prefixes.
209 */ 210 */
210 QString prefix() const; 211 QString prefix() const;
211 /** 212 /**
212 Return translated label for prefix field. 213 Return translated label for prefix field.
213 */ 214 */
214 static QString prefixLabel(); 215 static QString prefixLabel();
215 216
216 /** 217 /**
217 Set honorific suffixes. 218 Set honorific suffixes.
218 */ 219 */
219 void setSuffix( const QString &suffix ); 220 void setSuffix( const QString &suffix );
220 /** 221 /**
221 Return honorific suffixes. 222 Return honorific suffixes.
222 */ 223 */
223 QString suffix() const; 224 QString suffix() const;
224 /** 225 /**
225 Return translated label for suffix field. 226 Return translated label for suffix field.
226 */ 227 */
227 static QString suffixLabel(); 228 static QString suffixLabel();
228 229
229 /** 230 /**
230 Set nick name. 231 Set nick name.
231 */ 232 */
232 void setNickName( const QString &nickName ); 233 void setNickName( const QString &nickName );
233 /** 234 /**
234 Return nick name. 235 Return nick name.
235 */ 236 */
236 QString nickName() const; 237 QString nickName() const;
237 /** 238 /**
238 Return translated label for nickName field. 239 Return translated label for nickName field.
239 */ 240 */
240 static QString nickNameLabel(); 241 static QString nickNameLabel();
241 242
242 /** 243 /**
243 Set birthday. 244 Set birthday.
244 */ 245 */
245 void setBirthday( const QDateTime &birthday ); 246 void setBirthday( const QDateTime &birthday );
246 /** 247 /**
247 Return birthday. 248 Return birthday.
248 */ 249 */
249 QDateTime birthday() const; 250 QDateTime birthday() const;
250 /** 251 /**
251 Return translated label for birthday field. 252 Return translated label for birthday field.
252 */ 253 */
253 static QString birthdayLabel(); 254 static QString birthdayLabel();
254 255
255 /** 256 /**
256 Return translated label for homeAddressStreet field. 257 Return translated label for homeAddressStreet field.
257 */ 258 */
258 static QString homeAddressStreetLabel(); 259 static QString homeAddressStreetLabel();
259 260
260 /** 261 /**
261 Return translated label for homeAddressLocality field. 262 Return translated label for homeAddressLocality field.
262 */ 263 */
263 static QString homeAddressLocalityLabel(); 264 static QString homeAddressLocalityLabel();
264 265
265 /** 266 /**
266 Return translated label for homeAddressRegion field. 267 Return translated label for homeAddressRegion field.
267 */ 268 */
268 static QString homeAddressRegionLabel(); 269 static QString homeAddressRegionLabel();
269 270
270 /** 271 /**
271 Return translated label for homeAddressPostalCode field. 272 Return translated label for homeAddressPostalCode field.
272 */ 273 */
273 static QString homeAddressPostalCodeLabel(); 274 static QString homeAddressPostalCodeLabel();
274 275
275 /** 276 /**
276 Return translated label for homeAddressCountry field. 277 Return translated label for homeAddressCountry field.
277 */ 278 */
278 static QString homeAddressCountryLabel(); 279 static QString homeAddressCountryLabel();
279 280
280 /** 281 /**
281 Return translated label for homeAddressLabel field. 282 Return translated label for homeAddressLabel field.
282 */ 283 */
283 static QString homeAddressLabelLabel(); 284 static QString homeAddressLabelLabel();
284 285
285 /** 286 /**
286 Return translated label for businessAddressStreet field. 287 Return translated label for businessAddressStreet field.
287 */ 288 */
288 static QString businessAddressStreetLabel(); 289 static QString businessAddressStreetLabel();
289 290
290 /** 291 /**
291 Return translated label for businessAddressLocality field. 292 Return translated label for businessAddressLocality field.
292 */ 293 */
293 static QString businessAddressLocalityLabel(); 294 static QString businessAddressLocalityLabel();
294 295
295 /** 296 /**
296 Return translated label for businessAddressRegion field. 297 Return translated label for businessAddressRegion field.
297 */ 298 */
298 static QString businessAddressRegionLabel(); 299 static QString businessAddressRegionLabel();
299 300
300 /** 301 /**
301 Return translated label for businessAddressPostalCode field. 302 Return translated label for businessAddressPostalCode field.
302 */ 303 */
303 static QString businessAddressPostalCodeLabel(); 304 static QString businessAddressPostalCodeLabel();
304 305
305 /** 306 /**
306 Return translated label for businessAddressCountry field. 307 Return translated label for businessAddressCountry field.
307 */ 308 */
308 static QString businessAddressCountryLabel(); 309 static QString businessAddressCountryLabel();
309 310
310 /** 311 /**
311 Return translated label for businessAddressLabel field. 312 Return translated label for businessAddressLabel field.
312 */ 313 */
313 static QString businessAddressLabelLabel(); 314 static QString businessAddressLabelLabel();
314 315
315 /** 316 /**
316 Return translated label for homePhone field. 317 Return translated label for homePhone field.
317 */ 318 */
318 static QString homePhoneLabel(); 319 static QString homePhoneLabel();
319 320
320 /** 321 /**
321 Return translated label for businessPhone field. 322 Return translated label for businessPhone field.
322 */ 323 */
323 static QString businessPhoneLabel(); 324 static QString businessPhoneLabel();
324 325
325 /** 326 /**
326 Return translated label for mobilePhone field. 327 Return translated label for mobilePhone field.
327 */ 328 */
328 static QString mobilePhoneLabel(); 329 static QString mobilePhoneLabel();
329 330
330 /** 331 /**
331 Return translated label for homeFax field. 332 Return translated label for homeFax field.
332 */ 333 */
333 static QString homeFaxLabel(); 334 static QString homeFaxLabel();
334 335
335 /** 336 /**
336 Return translated label for businessFax field. 337 Return translated label for businessFax field.
337 */ 338 */
338 static QString businessFaxLabel(); 339 static QString businessFaxLabel();
339 340
340 /** 341 /**
341 Return translated label for carPhone field. 342 Return translated label for carPhone field.
342 */ 343 */
343 static QString carPhoneLabel(); 344 static QString carPhoneLabel();
344 345
345 /** 346 /**
346 Return translated label for isdn field. 347 Return translated label for isdn field.
347 */ 348 */
348 static QString isdnLabel(); 349 static QString isdnLabel();
349 350
350 /** 351 /**
351 Return translated label for pager field. 352 Return translated label for pager field.
352 */ 353 */
353 static QString pagerLabel(); 354 static QString pagerLabel();
354 355
355 /** 356 /**
356 Return translated label for sip field. 357 Return translated label for sip field.
357 */ 358 */
358 static QString sipLabel(); 359 static QString sipLabel();
359 360
360 /** 361 /**
361 Return translated label for email field. 362 Return translated label for email field.
362 */ 363 */
363 static QString emailLabel(); 364 static QString emailLabel();
364 365
365 /** 366 /**
366 Set mail client. 367 Set mail client.
367 */ 368 */
368 void setMailer( const QString &mailer ); 369 void setMailer( const QString &mailer );
369 /** 370 /**
370 Return mail client. 371 Return mail client.
371 */ 372 */
372 QString mailer() const; 373 QString mailer() const;
373 /** 374 /**
374 Return translated label for mailer field. 375 Return translated label for mailer field.
375 */ 376 */
376 static QString mailerLabel(); 377 static QString mailerLabel();
377 378
378 /** 379 /**
379 Set time zone. 380 Set time zone.
380 */ 381 */
381 void setTimeZone( const TimeZone &timeZone ); 382 void setTimeZone( const TimeZone &timeZone );
382 /** 383 /**
383 Return time zone. 384 Return time zone.
384 */ 385 */
385 TimeZone timeZone() const; 386 TimeZone timeZone() const;
386 /** 387 /**
387 Return translated label for timeZone field. 388 Return translated label for timeZone field.
388 */ 389 */
389 static QString timeZoneLabel(); 390 static QString timeZoneLabel();
390 391
391 /** 392 /**
392 Set geographic position. 393 Set geographic position.
393 */ 394 */
394 void setGeo( const Geo &geo ); 395 void setGeo( const Geo &geo );
395 /** 396 /**
396 Return geographic position. 397 Return geographic position.
397 */ 398 */
398 Geo geo() const; 399 Geo geo() const;
399 /** 400 /**
400 Return translated label for geo field. 401 Return translated label for geo field.
401 */ 402 */
402 static QString geoLabel(); 403 static QString geoLabel();
403 404
404 /** 405 /**
405 Set title. 406 Set title.
406 */ 407 */
407 void setTitle( const QString &title ); 408 void setTitle( const QString &title );
408 /** 409 /**
409 Return title. 410 Return title.
410 */ 411 */
411 QString title() const; 412 QString title() const;
412 /** 413 /**
413 Return translated label for title field. 414 Return translated label for title field.
414 */ 415 */
415 static QString titleLabel(); 416 static QString titleLabel();
416 417
417 /** 418 /**
418 Set role. 419 Set role.
419 */ 420 */
420 void setRole( const QString &role ); 421 void setRole( const QString &role );
421 /** 422 /**
422 Return role. 423 Return role.
423 */ 424 */
424 QString role() const; 425 QString role() const;
425 /** 426 /**
426 Return translated label for role field. 427 Return translated label for role field.
427 */ 428 */
428 static QString roleLabel(); 429 static QString roleLabel();
429 430
430 /** 431 /**
431 Set organization. 432 Set organization.
432 */ 433 */
433 void setOrganization( const QString &organization ); 434 void setOrganization( const QString &organization );
434 /** 435 /**
435 Return organization. 436 Return organization.
436 */ 437 */
437 QString organization() const; 438 QString organization() const;
438 /** 439 /**
439 Return translated label for organization field. 440 Return translated label for organization field.
440 */ 441 */
441 static QString organizationLabel(); 442 static QString organizationLabel();
442 443
443 /** 444 /**
444 Set note. 445 Set note.
445 */ 446 */
446 void setNote( const QString &note ); 447 void setNote( const QString &note );
447 /** 448 /**
448 Return note. 449 Return note.
449 */ 450 */
450 QString note() const; 451 QString note() const;
451 /** 452 /**
452 Return translated label for note field. 453 Return translated label for note field.
453 */ 454 */
454 static QString noteLabel(); 455 static QString noteLabel();
455 456
456 /** 457 /**
457 Set product identifier. 458 Set product identifier.
458 */ 459 */
459 void setProductId( const QString &productId ); 460 void setProductId( const QString &productId );
460 /** 461 /**
461 Return product identifier. 462 Return product identifier.
462 */ 463 */
463 QString productId() const; 464 QString productId() const;
464 /** 465 /**
465 Return translated label for productId field. 466 Return translated label for productId field.
466 */ 467 */
467 static QString productIdLabel(); 468 static QString productIdLabel();
468 469
469 /** 470 /**
470 Set revision date. 471 Set revision date.
471 */ 472 */
472 void setRevision( const QDateTime &revision ); 473 void setRevision( const QDateTime &revision );
473 /** 474 /**
474 Return revision date. 475 Return revision date.
475 */ 476 */
476 QDateTime revision() const; 477 QDateTime revision() const;
477 /** 478 /**
478 Return translated label for revision field. 479 Return translated label for revision field.
479 */ 480 */
480 static QString revisionLabel(); 481 static QString revisionLabel();
481 482
482 /** 483 /**
483 Set sort string. 484 Set sort string.
484 */ 485 */
485 void setSortString( const QString &sortString ); 486 void setSortString( const QString &sortString );
486 /** 487 /**
487 Return sort string. 488 Return sort string.
488 */ 489 */
489 QString sortString() const; 490 QString sortString() const;
490 /** 491 /**
491 Return translated label for sortString field. 492 Return translated label for sortString field.
492 */ 493 */
493 static QString sortStringLabel(); 494 static QString sortStringLabel();
494 495
495 /** 496 /**
496 Set URL. 497 Set URL.
497 */ 498 */
498 void setUrl( const KURL &url ); 499 void setUrl( const KURL &url );
499 /** 500 /**
500 Return URL. 501 Return URL.
501 */ 502 */
502 KURL url() const; 503 KURL url() const;
503 /** 504 /**
504 Return translated label for url field. 505 Return translated label for url field.
505 */ 506 */
506 static QString urlLabel(); 507 static QString urlLabel();
507 508
508 /** 509 /**
509 Set security class. 510 Set security class.
510 */ 511 */
511 void setSecrecy( const Secrecy &secrecy ); 512 void setSecrecy( const Secrecy &secrecy );
512 /** 513 /**
513 Return security class. 514 Return security class.
514 */ 515 */
515 Secrecy secrecy() const; 516 Secrecy secrecy() const;
516 /** 517 /**
517 Return translated label for secrecy field. 518 Return translated label for secrecy field.
518 */ 519 */
519 static QString secrecyLabel(); 520 static QString secrecyLabel();
520 521
521 /** 522 /**
522 Set logo. 523 Set logo.
523 */ 524 */
524 void setLogo( const Picture &logo ); 525 void setLogo( const Picture &logo );
525 /** 526 /**
526 Return logo. 527 Return logo.
527 */ 528 */
528 Picture logo() const; 529 Picture logo() const;
529 /** 530 /**
530 Return translated label for logo field. 531 Return translated label for logo field.
531 */ 532 */
532 static QString logoLabel(); 533 static QString logoLabel();
533 534
534 /** 535 /**
535 Set photo. 536 Set photo.
536 */ 537 */
537 void setPhoto( const Picture &photo ); 538 void setPhoto( const Picture &photo );
538 /** 539 /**
539 Return photo. 540 Return photo.
540 */ 541 */
541 Picture photo() const; 542 Picture photo() const;
542 /** 543 /**
543 Return translated label for photo field. 544 Return translated label for photo field.
544 */ 545 */
545 static QString photoLabel(); 546 static QString photoLabel();
546 547
547 /** 548 /**
548 Set sound. 549 Set sound.
549 */ 550 */
550 void setSound( const Sound &sound ); 551 void setSound( const Sound &sound );
551 /** 552 /**
552 Return sound. 553 Return sound.
553 */ 554 */
554 Sound sound() const; 555 Sound sound() const;
555 /** 556 /**
556 Return translated label for sound field. 557 Return translated label for sound field.
557 */ 558 */
558 static QString soundLabel(); 559 static QString soundLabel();
559 560
560 /** 561 /**
561 Set agent. 562 Set agent.
562 */ 563 */
563 void setAgent( const Agent &agent ); 564 void setAgent( const Agent &agent );
564 /** 565 /**
565 Return agent. 566 Return agent.
566 */ 567 */
567 Agent agent() const; 568 Agent agent() const;
568 /** 569 /**
569 Return translated label for agent field. 570 Return translated label for agent field.
570 */ 571 */
571 static QString agentLabel(); 572 static QString agentLabel();
572 573
573 /** 574 /**
574 Set name fields by parsing the given string and trying to associate the 575 Set name fields by parsing the given string and trying to associate the
575 parts of the string with according fields. This function should probably 576 parts of the string with according fields. This function should probably
576 be a bit more clever. 577 be a bit more clever.
577 */ 578 */
578 void setNameFromString( const QString & ); 579 void setNameFromString( const QString & );
579 580
580 /** 581 /**
581 Return the name of the addressee. This is calculated from all the name 582 Return the name of the addressee. This is calculated from all the name
582 fields. 583 fields.
583 */ 584 */
584 QString realName() const; 585 QString realName() const;
585 586
586 /** 587 /**
587 Return the name that consists of all name parts. 588 Return the name that consists of all name parts.
588 */ 589 */
589 QString assembledName() const; 590 QString assembledName() const;
590 591
591 /** 592 /**
592 Return email address including real name. 593 Return email address including real name.
593 594
594 @param email Email address to be used to construct the full email string. 595 @param email Email address to be used to construct the full email string.
595 If this is QString::null the preferred email address is used. 596 If this is QString::null the preferred email address is used.
596 */ 597 */
597 QString fullEmail( const QString &email=QString::null ) const; 598 QString fullEmail( const QString &email=QString::null ) const;
598 599
599 /** 600 /**
600 Insert an email address. If the email address already exists in this 601 Insert an email address. If the email address already exists in this
601 addressee it is not duplicated. 602 addressee it is not duplicated.
602 603
603 @param email Email address 604 @param email Email address
604 @param preferred Set to true, if this is the preferred email address of 605 @param preferred Set to true, if this is the preferred email address of
605 the addressee. 606 the addressee.
606 */ 607 */
607 void insertEmail( const QString &email, bool preferred=false ); 608 void insertEmail( const QString &email, bool preferred=false );
608 609
609 /** 610 /**
610 Remove email address. If the email address doesn't exist, nothing happens. 611 Remove email address. If the email address doesn't exist, nothing happens.
611 */ 612 */
612 void removeEmail( const QString &email ); 613 void removeEmail( const QString &email );
613 614
614 /** 615 /**
615 Return preferred email address. This is the first email address or the 616 Return preferred email address. This is the first email address or the
616 last one added with @ref insertEmail() with a set preferred parameter. 617 last one added with @ref insertEmail() with a set preferred parameter.
617 */ 618 */
618 QString preferredEmail() const; 619 QString preferredEmail() const;
619 620
620 /** 621 /**
621 Return list of all email addresses. 622 Return list of all email addresses.
622 */ 623 */
623 QStringList emails() const; 624 QStringList emails() const;
624 625
625 /** 626 /**
626 Set the emails to @param. 627 Set the emails to @param.
627 The first email address gets the preferred one! 628 The first email address gets the preferred one!
628 @param list The list of email addresses. 629 @param list The list of email addresses.
629 */ 630 */
630 void setEmails( const QStringList& list); 631 void setEmails( const QStringList& list);
631 632
632 /** 633 /**
633 Insert a phone number. If a phone number with the same id already exists 634 Insert a phone number. If a phone number with the same id already exists
634 in this addressee it is not duplicated. 635 in this addressee it is not duplicated.
635 */ 636 */
636 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 637 void insertPhoneNumber( const PhoneNumber &phoneNumber );
637 638
638 /** 639 /**
639 Remove phone number. If no phone number with the given id exists for this 640 Remove phone number. If no phone number with the given id exists for this
640 addresse nothing happens. 641 addresse nothing happens.
641 */ 642 */
642 void removePhoneNumber( const PhoneNumber &phoneNumber ); 643 void removePhoneNumber( const PhoneNumber &phoneNumber );
643 644
644 /** 645 /**
645 Return phone number, which matches the given type. 646 Return phone number, which matches the given type.
646 */ 647 */
647 PhoneNumber phoneNumber( int type ) const; 648 PhoneNumber phoneNumber( int type ) const;
648 649
649 /** 650 /**
650 Return list of all phone numbers. 651 Return list of all phone numbers.
651 */ 652 */
652 PhoneNumber::List phoneNumbers() const; 653 PhoneNumber::List phoneNumbers() const;
653 654
654 /** 655 /**
655 Return list of phone numbers with a special type. 656 Return list of phone numbers with a special type.
656 */ 657 */
657 PhoneNumber::List phoneNumbers( int type ) const; 658 PhoneNumber::List phoneNumbers( int type ) const;
658 659
659 /** 660 /**
660 Return phone number with the given id. 661 Return phone number with the given id.
661 */ 662 */
662 PhoneNumber findPhoneNumber( const QString &id ) const; 663 PhoneNumber findPhoneNumber( const QString &id ) const;
663 664
664 /** 665 /**
665 Insert a key. If a key with the same id already exists 666 Insert a key. If a key with the same id already exists
666 in this addressee it is not duplicated. 667 in this addressee it is not duplicated.
667 */ 668 */
668 void insertKey( const Key &key ); 669 void insertKey( const Key &key );
669 670
670 /** 671 /**
671 Remove a key. If no key with the given id exists for this 672 Remove a key. If no key with the given id exists for this
672 addresse nothing happens. 673 addresse nothing happens.
673 */ 674 */
674 void removeKey( const Key &key ); 675 void removeKey( const Key &key );
675 676
676 /** 677 /**
677 Return key, which matches the given type. 678 Return key, which matches the given type.
678 If @p type == Key::Custom you can specify a string 679 If @p type == Key::Custom you can specify a string
679 that should match. If you leave the string empty, the first 680 that should match. If you leave the string empty, the first
680 key with a custom value is returned. 681 key with a custom value is returned.
681 */ 682 */
682 Key key( int type, QString customTypeString = QString::null ) const; 683 Key key( int type, QString customTypeString = QString::null ) const;
683 684
684 /** 685 /**
685 Return list of all keys. 686 Return list of all keys.
686 */ 687 */
687 Key::List keys() const; 688 Key::List keys() const;
688 689
689 /** 690 /**
690 Set the list of keys 691 Set the list of keys
691 @param keys The keys to be set. 692 @param keys The keys to be set.
692 */ 693 */
693 void setKeys( const Key::List& keys); 694 void setKeys( const Key::List& keys);
694 695
695 /** 696 /**
696 Return list of keys with a special type. 697 Return list of keys with a special type.
697 If @p type == Key::Custom you can specify a string 698 If @p type == Key::Custom you can specify a string
698 that should match. If you leave the string empty, all custom 699 that should match. If you leave the string empty, all custom
699 keys will be returned. 700 keys will be returned.
700 */ 701 */
701 Key::List keys( int type, QString customTypeString = QString::null ) const; 702 Key::List keys( int type, QString customTypeString = QString::null ) const;
702 703
703 /** 704 /**
704 Return key with the given id. 705 Return key with the given id.
705 */ 706 */
706 Key findKey( const QString &id ) const; 707 Key findKey( const QString &id ) const;
707 708
708 /** 709 /**
709 Insert an address. If an address with the same id already exists 710 Insert an address. If an address with the same id already exists
710 in this addressee it is not duplicated. 711 in this addressee it is not duplicated.
711 */ 712 */
712 void insertAddress( const Address &address ); 713 void insertAddress( const Address &address );
713 714
714 /** 715 /**
715 Remove address. If no address with the given id exists for this 716 Remove address. If no address with the given id exists for this
716 addresse nothing happens. 717 addresse nothing happens.
717 */ 718 */
718 void removeAddress( const Address &address ); 719 void removeAddress( const Address &address );
719 720
720 /** 721 /**
721 Return address, which matches the given type. 722 Return address, which matches the given type.
722 */ 723 */
723 Address address( int type ) const; 724 Address address( int type ) const;
724 725
725 /** 726 /**
726 Return list of all addresses. 727 Return list of all addresses.
727 */ 728 */
728 Address::List addresses() const; 729 Address::List addresses() const;
729 730
730 /** 731 /**
731 Return list of addresses with a special type. 732 Return list of addresses with a special type.
732 */ 733 */
733 Address::List addresses( int type ) const; 734 Address::List addresses( int type ) const;
734 735
735 /** 736 /**
736 Return address with the given id. 737 Return address with the given id.
737 */ 738 */
738 Address findAddress( const QString &id ) const; 739 Address findAddress( const QString &id ) const;
739 740
740 /** 741 /**
741 Insert category. If the category already exists it is not duplicated. 742 Insert category. If the category already exists it is not duplicated.
742 */ 743 */
743 void insertCategory( const QString & ); 744 void insertCategory( const QString & );
744 745
745 /** 746 /**
746 Remove category. 747 Remove category.
747 */ 748 */
748 void removeCategory( const QString & ); 749 void removeCategory( const QString & );
749 750
750 /** 751 /**
751 Return, if addressee has the given category. 752 Return, if addressee has the given category.
752 */ 753 */
753 bool hasCategory( const QString & ) const; 754 bool hasCategory( const QString & ) const;
754 755
755 /** 756 /**
756 Set categories to given value. 757 Set categories to given value.
757 */ 758 */
758 void setCategories( const QStringList & ); 759 void setCategories( const QStringList & );
759 760
760 /** 761 /**
761 Return list of all set categories. 762 Return list of all set categories.
762 */ 763 */
763 QStringList categories() const; 764 QStringList categories() const;
764 765
765 /** 766 /**
766 Insert custom entry. The entry is identified by the name of the inserting 767 Insert custom entry. The entry is identified by the name of the inserting
767 application and a unique name. If an entry with the given app and name 768 application and a unique name. If an entry with the given app and name
768 already exists its value is replaced with the new given value. 769 already exists its value is replaced with the new given value.
769 */ 770 */
770 void insertCustom( const QString &app, const QString &name, 771 void insertCustom( const QString &app, const QString &name,
771 const QString &value ); 772 const QString &value );
772 773
773 /** 774 /**
774 Remove custom entry. 775 Remove custom entry.
775 */ 776 */
776 void removeCustom( const QString &app, const QString &name ); 777 void removeCustom( const QString &app, const QString &name );
777 778
778 /** 779 /**
779 Return value of custom entry, identified by app and entry name. 780 Return value of custom entry, identified by app and entry name.
780 */ 781 */
781 QString custom( const QString &app, const QString &name ) const; 782 QString custom( const QString &app, const QString &name ) const;
782 783
783 /** 784 /**
784 Set all custom entries. 785 Set all custom entries.
785 */ 786 */
786 void setCustoms( const QStringList & ); 787 void setCustoms( const QStringList & );
787 788
788 /** 789 /**
789 Return list of all custom entries. 790 Return list of all custom entries.
790 */ 791 */
791 QStringList customs() const; 792 QStringList customs() const;
792 793
793 /** 794 /**
794 Parse full email address. The result is given back in fullName and email. 795 Parse full email address. The result is given back in fullName and email.
795 */ 796 */
796 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 797 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
797 QString &email ); 798 QString &email );
798 799
799 /** 800 /**
800 Debug output. 801 Debug output.
801 */ 802 */
802 void dump() const; 803 void dump() const;
803 804
804 /** 805 /**
805 Returns string representation of the addressee. 806 Returns string representation of the addressee.
806 */ 807 */
807 QString asString() const; 808 QString asString() const;
808 809
809 /** 810 /**
810 Set resource where the addressee is from. 811 Set resource where the addressee is from.
811 */ 812 */
812 void setResource( Resource *resource ); 813 void setResource( Resource *resource );
813 814
814 /** 815 /**
815 Return pointer to resource. 816 Return pointer to resource.
816 */ 817 */
817 Resource *resource() const; 818 Resource *resource() const;
818 819
819 /** 820 /**
820 Return resourcelabel. 821 Return resourcelabel.
821 */ 822 */
822 //US 823 //US
823 static QString resourceLabel(); 824 static QString resourceLabel();
824 825
825 /** 826 /**
826 Mark addressee as changed. 827 Mark addressee as changed.
827 */ 828 */
828 void setChanged( bool value ); 829 void setChanged( bool value );
829 830
830 /** 831 /**
831 Return whether the addressee is changed. 832 Return whether the addressee is changed.
832 */ 833 */
833 bool changed() const; 834 bool changed() const;
834 835
835 private: 836 private:
836 Addressee copy(); 837 Addressee copy();
837 void detach(); 838 void detach();
838 839
839 struct AddresseeData; 840 struct AddresseeData;
840 mutable KSharedPtr<AddresseeData> mData; 841 mutable KSharedPtr<AddresseeData> mData;
841}; 842};
842 843
843QDataStream &operator<<( QDataStream &, const Addressee & ); 844QDataStream &operator<<( QDataStream &, const Addressee & );
844QDataStream &operator>>( QDataStream &, Addressee & ); 845QDataStream &operator>>( QDataStream &, Addressee & );
845 846
846} 847}
847 848
848#endif 849#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9b059d3..3a542ba 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2903 +1,2897 @@
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 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 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&))); 295 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&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325 325
326} 326}
327 327
328void KABCore::recieve( QString fn )
329{
330 qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true );
332 topLevelWidget()->raise();
333}
328void KABCore::restoreSettings() 334void KABCore::restoreSettings()
329{ 335{
330 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 336 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
331 337
332 bool state; 338 bool state;
333 339
334 if (mMultipleViewsAtOnce) 340 if (mMultipleViewsAtOnce)
335 state = KABPrefs::instance()->mDetailsPageVisible; 341 state = KABPrefs::instance()->mDetailsPageVisible;
336 else 342 else
337 state = false; 343 state = false;
338 344
339 mActionDetails->setChecked( state ); 345 mActionDetails->setChecked( state );
340 setDetailsVisible( state ); 346 setDetailsVisible( state );
341 347
342 state = KABPrefs::instance()->mJumpButtonBarVisible; 348 state = KABPrefs::instance()->mJumpButtonBarVisible;
343 349
344 mActionJumpBar->setChecked( state ); 350 mActionJumpBar->setChecked( state );
345 setJumpButtonBarVisible( state ); 351 setJumpButtonBarVisible( state );
346/*US 352/*US
347 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 353 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
348 if ( splitterSize.count() == 0 ) { 354 if ( splitterSize.count() == 0 ) {
349 splitterSize.append( width() / 2 ); 355 splitterSize.append( width() / 2 );
350 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
351 } 357 }
352 mMiniSplitter->setSizes( splitterSize ); 358 mMiniSplitter->setSizes( splitterSize );
353 if ( mExtensionBarSplitter ) { 359 if ( mExtensionBarSplitter ) {
354 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 360 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
355 if ( splitterSize.count() == 0 ) { 361 if ( splitterSize.count() == 0 ) {
356 splitterSize.append( width() / 2 ); 362 splitterSize.append( width() / 2 );
357 splitterSize.append( width() / 2 ); 363 splitterSize.append( width() / 2 );
358 } 364 }
359 mExtensionBarSplitter->setSizes( splitterSize ); 365 mExtensionBarSplitter->setSizes( splitterSize );
360 366
361 } 367 }
362*/ 368*/
363 mViewManager->restoreSettings(); 369 mViewManager->restoreSettings();
364 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 370 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
365 mExtensionManager->restoreSettings(); 371 mExtensionManager->restoreSettings();
366#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
367 int wid = width(); 373 int wid = width();
368 if ( wid < 10 ) 374 if ( wid < 10 )
369 wid = 400; 375 wid = 400;
370#else 376#else
371 int wid = QApplication::desktop()->width(); 377 int wid = QApplication::desktop()->width();
372 if ( wid < 640 ) 378 if ( wid < 640 )
373 wid = QApplication::desktop()->height(); 379 wid = QApplication::desktop()->height();
374#endif 380#endif
375 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 381 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
376 if ( true /*splitterSize.count() == 0*/ ) { 382 if ( true /*splitterSize.count() == 0*/ ) {
377 splitterSize.append( wid / 2 ); 383 splitterSize.append( wid / 2 );
378 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
379 } 385 }
380 mMiniSplitter->setSizes( splitterSize ); 386 mMiniSplitter->setSizes( splitterSize );
381 if ( mExtensionBarSplitter ) { 387 if ( mExtensionBarSplitter ) {
382 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 388 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
383 if ( true /*splitterSize.count() == 0*/ ) { 389 if ( true /*splitterSize.count() == 0*/ ) {
384 splitterSize.append( wid / 2 ); 390 splitterSize.append( wid / 2 );
385 splitterSize.append( wid / 2 ); 391 splitterSize.append( wid / 2 );
386 } 392 }
387 mExtensionBarSplitter->setSizes( splitterSize ); 393 mExtensionBarSplitter->setSizes( splitterSize );
388 394
389 } 395 }
390 396
391 397
392} 398}
393 399
394void KABCore::saveSettings() 400void KABCore::saveSettings()
395{ 401{
396 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 402 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
397 if ( mExtensionBarSplitter ) 403 if ( mExtensionBarSplitter )
398 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 404 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
399 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 405 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
400 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 406 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
401#ifndef KAB_EMBEDDED 407#ifndef KAB_EMBEDDED
402 408
403 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 409 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
404 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 410 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
405#endif //KAB_EMBEDDED 411#endif //KAB_EMBEDDED
406 mExtensionManager->saveSettings(); 412 mExtensionManager->saveSettings();
407 mViewManager->saveSettings(); 413 mViewManager->saveSettings();
408 414
409 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 415 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
410} 416}
411 417
412KABC::AddressBook *KABCore::addressBook() const 418KABC::AddressBook *KABCore::addressBook() const
413{ 419{
414 return mAddressBook; 420 return mAddressBook;
415} 421}
416 422
417KConfig *KABCore::config() 423KConfig *KABCore::config()
418{ 424{
419#ifndef KAB_EMBEDDED 425#ifndef KAB_EMBEDDED
420 return KABPrefs::instance()->config(); 426 return KABPrefs::instance()->config();
421#else //KAB_EMBEDDED 427#else //KAB_EMBEDDED
422 return KABPrefs::instance()->getConfig(); 428 return KABPrefs::instance()->getConfig();
423#endif //KAB_EMBEDDED 429#endif //KAB_EMBEDDED
424} 430}
425 431
426KActionCollection *KABCore::actionCollection() const 432KActionCollection *KABCore::actionCollection() const
427{ 433{
428 return mGUIClient->actionCollection(); 434 return mGUIClient->actionCollection();
429} 435}
430 436
431KABC::Field *KABCore::currentSearchField() const 437KABC::Field *KABCore::currentSearchField() const
432{ 438{
433 if (mIncSearchWidget) 439 if (mIncSearchWidget)
434 return mIncSearchWidget->currentField(); 440 return mIncSearchWidget->currentField();
435 else 441 else
436 return 0; 442 return 0;
437} 443}
438 444
439QStringList KABCore::selectedUIDs() const 445QStringList KABCore::selectedUIDs() const
440{ 446{
441 return mViewManager->selectedUids(); 447 return mViewManager->selectedUids();
442} 448}
443 449
444KABC::Resource *KABCore::requestResource( QWidget *parent ) 450KABC::Resource *KABCore::requestResource( QWidget *parent )
445{ 451{
446 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 452 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
447 453
448 QPtrList<KRES::Resource> kresResources; 454 QPtrList<KRES::Resource> kresResources;
449 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 455 QPtrListIterator<KABC::Resource> resIt( kabcResources );
450 KABC::Resource *resource; 456 KABC::Resource *resource;
451 while ( ( resource = resIt.current() ) != 0 ) { 457 while ( ( resource = resIt.current() ) != 0 ) {
452 ++resIt; 458 ++resIt;
453 if ( !resource->readOnly() ) { 459 if ( !resource->readOnly() ) {
454 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 460 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
455 if ( res ) 461 if ( res )
456 kresResources.append( res ); 462 kresResources.append( res );
457 } 463 }
458 } 464 }
459 465
460 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 466 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
461 return static_cast<KABC::Resource*>( res ); 467 return static_cast<KABC::Resource*>( res );
462} 468}
463 469
464#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
465KAboutData *KABCore::createAboutData() 471KAboutData *KABCore::createAboutData()
466#else //KAB_EMBEDDED 472#else //KAB_EMBEDDED
467void KABCore::createAboutData() 473void KABCore::createAboutData()
468#endif //KAB_EMBEDDED 474#endif //KAB_EMBEDDED
469{ 475{
470#ifndef KAB_EMBEDDED 476#ifndef KAB_EMBEDDED
471 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 477 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
472 "3.1", I18N_NOOP( "The KDE Address Book" ), 478 "3.1", I18N_NOOP( "The KDE Address Book" ),
473 KAboutData::License_GPL_V2, 479 KAboutData::License_GPL_V2,
474 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 480 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
475 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 481 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
476 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 482 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
477 about->addAuthor( "Cornelius Schumacher", 483 about->addAuthor( "Cornelius Schumacher",
478 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 484 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
479 "schumacher@kde.org" ); 485 "schumacher@kde.org" );
480 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 486 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
481 "mpilone@slac.com" ); 487 "mpilone@slac.com" );
482 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 488 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
483 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 489 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
484 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 490 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
485 "michel@klaralvdalens-datakonsult.se" ); 491 "michel@klaralvdalens-datakonsult.se" );
486 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 492 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
487 "hansen@kde.org" ); 493 "hansen@kde.org" );
488 494
489 return about; 495 return about;
490#endif //KAB_EMBEDDED 496#endif //KAB_EMBEDDED
491 497
492 QString version; 498 QString version;
493#include <../version> 499#include <../version>
494 QMessageBox::about( this, "About KAddressbook/Pi", 500 QMessageBox::about( this, "About KAddressbook/Pi",
495 "KAddressbook/Platform-independent\n" 501 "KAddressbook/Platform-independent\n"
496 "(KA/Pi) " +version + " - " + 502 "(KA/Pi) " +version + " - " +
497#ifdef DESKTOP_VERSION 503#ifdef DESKTOP_VERSION
498 "Desktop Edition\n" 504 "Desktop Edition\n"
499#else 505#else
500 "PDA-Edition\n" 506 "PDA-Edition\n"
501 "for: Zaurus 5500 / 7x0 / 8x0\n" 507 "for: Zaurus 5500 / 7x0 / 8x0\n"
502#endif 508#endif
503 509
504 "(c) 2004 Ulf Schenk\n" 510 "(c) 2004 Ulf Schenk\n"
505 "(c) 2004 Lutz Rogowski\n" 511 "(c) 2004 Lutz Rogowski\n"
506 "(c) 1997-2003, The KDE PIM Team\n" 512 "(c) 1997-2003, The KDE PIM Team\n"
507 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 513 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
508 "Don Sanders Original author\n" 514 "Don Sanders Original author\n"
509 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 515 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
510 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 516 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
511 "Greg Stern DCOP interface\n" 517 "Greg Stern DCOP interface\n"
512 "Mark Westcot Contact pinning\n" 518 "Mark Westcot Contact pinning\n"
513 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 519 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
514 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 520 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
515#ifdef _WIN32_ 521#ifdef _WIN32_
516 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 522 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
517#endif 523#endif
518 ); 524 );
519} 525}
520 526
521void KABCore::setContactSelected( const QString &uid ) 527void KABCore::setContactSelected( const QString &uid )
522{ 528{
523 KABC::Addressee addr = mAddressBook->findByUid( uid ); 529 KABC::Addressee addr = mAddressBook->findByUid( uid );
524 if ( !mDetails->isHidden() ) 530 if ( !mDetails->isHidden() )
525 mDetails->setAddressee( addr ); 531 mDetails->setAddressee( addr );
526 532
527 if ( !addr.isEmpty() ) { 533 if ( !addr.isEmpty() ) {
528 emit contactSelected( addr.formattedName() ); 534 emit contactSelected( addr.formattedName() );
529 KABC::Picture pic = addr.photo(); 535 KABC::Picture pic = addr.photo();
530 if ( pic.isIntern() ) { 536 if ( pic.isIntern() ) {
531//US emit contactSelected( pic.data() ); 537//US emit contactSelected( pic.data() );
532//US instead use: 538//US instead use:
533 QPixmap px; 539 QPixmap px;
534 if (pic.data().isNull() != true) 540 if (pic.data().isNull() != true)
535 { 541 {
536 px.convertFromImage(pic.data()); 542 px.convertFromImage(pic.data());
537 } 543 }
538 544
539 emit contactSelected( px ); 545 emit contactSelected( px );
540 } 546 }
541 } 547 }
542 548
543 549
544 mExtensionManager->setSelectionChanged(); 550 mExtensionManager->setSelectionChanged();
545 551
546 // update the actions 552 // update the actions
547 bool selected = !uid.isEmpty(); 553 bool selected = !uid.isEmpty();
548 554
549 if ( mReadWrite ) { 555 if ( mReadWrite ) {
550 mActionCut->setEnabled( selected ); 556 mActionCut->setEnabled( selected );
551 mActionPaste->setEnabled( selected ); 557 mActionPaste->setEnabled( selected );
552 } 558 }
553 559
554 mActionCopy->setEnabled( selected ); 560 mActionCopy->setEnabled( selected );
555 mActionDelete->setEnabled( selected ); 561 mActionDelete->setEnabled( selected );
556 mActionEditAddressee->setEnabled( selected ); 562 mActionEditAddressee->setEnabled( selected );
557 mActionMail->setEnabled( selected ); 563 mActionMail->setEnabled( selected );
558 mActionMailVCard->setEnabled( selected ); 564 mActionMailVCard->setEnabled( selected );
559 //if (mActionBeam) 565 //if (mActionBeam)
560 //mActionBeam->setEnabled( selected ); 566 //mActionBeam->setEnabled( selected );
561 567
562 if (mActionBeamVCard) 568 if (mActionBeamVCard)
563 mActionBeamVCard->setEnabled( selected ); 569 mActionBeamVCard->setEnabled( selected );
564 570
565 mActionExport2phone->setEnabled( selected ); 571 mActionExport2phone->setEnabled( selected );
566 mActionWhoAmI->setEnabled( selected ); 572 mActionWhoAmI->setEnabled( selected );
567 mActionCategories->setEnabled( selected ); 573 mActionCategories->setEnabled( selected );
568} 574}
569 575
570void KABCore::sendMail() 576void KABCore::sendMail()
571{ 577{
572 sendMail( mViewManager->selectedEmails().join( ", " ) ); 578 sendMail( mViewManager->selectedEmails().join( ", " ) );
573} 579}
574 580
575void KABCore::sendMail( const QString& emaillist ) 581void KABCore::sendMail( const QString& emaillist )
576{ 582{
577 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 583 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
578 if (emaillist.contains(",") > 0) 584 if (emaillist.contains(",") > 0)
579 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 585 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
580 else 586 else
581 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 587 ExternalAppHandler::instance()->mailToOneContact( emaillist );
582} 588}
583 589
584 590
585 591
586void KABCore::mailVCard() 592void KABCore::mailVCard()
587{ 593{
588 QStringList uids = mViewManager->selectedUids(); 594 QStringList uids = mViewManager->selectedUids();
589 if ( !uids.isEmpty() ) 595 if ( !uids.isEmpty() )
590 mailVCard( uids ); 596 mailVCard( uids );
591} 597}
592 598
593void KABCore::mailVCard( const QStringList& uids ) 599void KABCore::mailVCard( const QStringList& uids )
594{ 600{
595 QStringList urls; 601 QStringList urls;
596 602
597// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 603// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
598 604
599 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 605 QString dirName = "/tmp/" + KApplication::randomString( 8 );
600 606
601 607
602 608
603 QDir().mkdir( dirName, true ); 609 QDir().mkdir( dirName, true );
604 610
605 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 611 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
606 KABC::Addressee a = mAddressBook->findByUid( *it ); 612 KABC::Addressee a = mAddressBook->findByUid( *it );
607 613
608 if ( a.isEmpty() ) 614 if ( a.isEmpty() )
609 continue; 615 continue;
610 616
611 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 617 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
612 618
613 QString fileName = dirName + "/" + name; 619 QString fileName = dirName + "/" + name;
614 620
615 QFile outFile(fileName); 621 QFile outFile(fileName);
616 622
617 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 623 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
618 KABC::VCardConverter converter; 624 KABC::VCardConverter converter;
619 QString vcard; 625 QString vcard;
620 626
621 converter.addresseeToVCard( a, vcard ); 627 converter.addresseeToVCard( a, vcard );
622 628
623 QTextStream t( &outFile ); // use a text stream 629 QTextStream t( &outFile ); // use a text stream
624 t.setEncoding( QTextStream::UnicodeUTF8 ); 630 t.setEncoding( QTextStream::UnicodeUTF8 );
625 t << vcard; 631 t << vcard;
626 632
627 outFile.close(); 633 outFile.close();
628 634
629 urls.append( fileName ); 635 urls.append( fileName );
630 } 636 }
631 } 637 }
632 638
633 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 639 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
634 640
635 641
636/*US 642/*US
637 kapp->invokeMailer( QString::null, QString::null, QString::null, 643 kapp->invokeMailer( QString::null, QString::null, QString::null,
638 QString::null, // subject 644 QString::null, // subject
639 QString::null, // body 645 QString::null, // body
640 QString::null, 646 QString::null,
641 urls ); // attachments 647 urls ); // attachments
642*/ 648*/
643 649
644} 650}
645 651
646/** 652/**
647 Beams the "WhoAmI contact. 653 Beams the "WhoAmI contact.
648*/ 654*/
649void KABCore::beamMySelf() 655void KABCore::beamMySelf()
650{ 656{
651 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 657 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
652 if (!a.isEmpty()) 658 if (!a.isEmpty())
653 { 659 {
654 QStringList uids; 660 QStringList uids;
655 uids << a.uid(); 661 uids << a.uid();
656 662
657 beamVCard(uids); 663 beamVCard(uids);
658 } else { 664 } else {
659 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 665 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
660 666
661 667
662 } 668 }
663} 669}
664 670
665void KABCore::export2phone() 671void KABCore::export2phone()
666{ 672{
667 673
668 KAex2phonePrefs ex2phone; 674 KAex2phonePrefs ex2phone;
669 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 675 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
670 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 676 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
671 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 677 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
672 678
673 if ( !ex2phone.exec() ) { 679 if ( !ex2phone.exec() ) {
674 return; 680 return;
675 } 681 }
676 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 682 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
677 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 683 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
678 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 684 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
679 685
680 686
681 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 687 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
682 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 688 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
683 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 689 KPimGlobalPrefs::instance()->mEx2PhoneModel );
684 690
685 QStringList uids = mViewManager->selectedUids(); 691 QStringList uids = mViewManager->selectedUids();
686 if ( uids.isEmpty() ) 692 if ( uids.isEmpty() )
687 return; 693 return;
688 694
689#ifdef _WIN32_ 695#ifdef _WIN32_
690 QString fileName = locateLocal("tmp", "tempfile.vcf"); 696 QString fileName = locateLocal("tmp", "tempfile.vcf");
691#else 697#else
692 QString fileName = "/tmp/kdepimtemp.vcf"; 698 QString fileName = "/tmp/kdepimtemp.vcf";
693#endif 699#endif
694 700
695 KABC::VCardConverter converter; 701 KABC::VCardConverter converter;
696 QString description; 702 QString description;
697 QString datastream; 703 QString datastream;
698 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 704 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
699 KABC::Addressee a = mAddressBook->findByUid( *it ); 705 KABC::Addressee a = mAddressBook->findByUid( *it );
700 706
701 if ( a.isEmpty() ) 707 if ( a.isEmpty() )
702 continue; 708 continue;
703 a.simplifyEmails(); 709 a.simplifyEmails();
704 a.simplifyPhoneNumbers(); 710 a.simplifyPhoneNumbers();
705 a.simplifyPhoneNumberTypes(); 711 a.simplifyPhoneNumberTypes();
706 a.simplifyAddresses(); 712 a.simplifyAddresses();
707 713
708 if (description.isEmpty()) 714 if (description.isEmpty())
709 description = a.formattedName(); 715 description = a.formattedName();
710 QString vcard; 716 QString vcard;
711 QString vcardnew; 717 QString vcardnew;
712 converter.addresseeToVCard( a, vcard ); 718 converter.addresseeToVCard( a, vcard );
713 int start = 0; 719 int start = 0;
714 int next; 720 int next;
715 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 721 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
716 int semi = vcard.find(";", next); 722 int semi = vcard.find(";", next);
717 int dopp = vcard.find(":", next); 723 int dopp = vcard.find(":", next);
718 int sep; 724 int sep;
719 if ( semi < dopp && semi >= 0 ) 725 if ( semi < dopp && semi >= 0 )
720 sep = semi ; 726 sep = semi ;
721 else 727 else
722 sep = dopp; 728 sep = dopp;
723 vcardnew +=vcard.mid( start, next - start); 729 vcardnew +=vcard.mid( start, next - start);
724 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 730 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
725 start = sep; 731 start = sep;
726 } 732 }
727 vcardnew += vcard.mid( start,vcard.length() ); 733 vcardnew += vcard.mid( start,vcard.length() );
728 vcard = ""; 734 vcard = "";
729 start = 0; 735 start = 0;
730 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 736 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
731 int sep = vcardnew.find(":", next); 737 int sep = vcardnew.find(":", next);
732 vcard +=vcardnew.mid( start, next - start+3); 738 vcard +=vcardnew.mid( start, next - start+3);
733 start = sep; 739 start = sep;
734 } 740 }
735 vcard += vcardnew.mid( start,vcardnew.length() ); 741 vcard += vcardnew.mid( start,vcardnew.length() );
736 vcard.replace ( QRegExp(";;;") , "" ); 742 vcard.replace ( QRegExp(";;;") , "" );
737 vcard.replace ( QRegExp(";;") , "" ); 743 vcard.replace ( QRegExp(";;") , "" );
738 datastream += vcard; 744 datastream += vcard;
739 745
740 } 746 }
741 QFile outFile(fileName); 747 QFile outFile(fileName);
742 if ( outFile.open(IO_WriteOnly) ) { 748 if ( outFile.open(IO_WriteOnly) ) {
743 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 749 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
744 QTextStream t( &outFile ); // use a text stream 750 QTextStream t( &outFile ); // use a text stream
745 t.setEncoding( QTextStream::UnicodeUTF8 ); 751 t.setEncoding( QTextStream::UnicodeUTF8 );
746 t <<datastream; 752 t <<datastream;
747 outFile.close(); 753 outFile.close();
748 if ( PhoneAccess::writeToPhone( fileName ) ) 754 if ( PhoneAccess::writeToPhone( fileName ) )
749 qDebug("Export okay "); 755 qDebug("Export okay ");
750 else 756 else
751 qDebug("Error export contacts "); 757 qDebug("Error export contacts ");
752 758
753 } else { 759 } else {
754 qDebug("Error open temp file "); 760 qDebug("Error open temp file ");
755 return; 761 return;
756 } 762 }
757 763
758 764
759#if 0 765#if 0
760 766
761 setCaption( i18n("Writing to phone...")); 767 setCaption( i18n("Writing to phone..."));
762 if ( PhoneFormat::writeToPhone( cal ) ) 768 if ( PhoneFormat::writeToPhone( cal ) )
763 setCaption( i18n("Export to phone successful!")); 769 setCaption( i18n("Export to phone successful!"));
764 else 770 else
765 setCaption( i18n("Error exporting to phone!")); 771 setCaption( i18n("Error exporting to phone!"));
766#endif 772#endif
767 773
768 774
769} 775}
770void KABCore::beamVCard() 776void KABCore::beamVCard()
771{ 777{
772 QStringList uids = mViewManager->selectedUids(); 778 QStringList uids = mViewManager->selectedUids();
773 if ( !uids.isEmpty() ) 779 if ( !uids.isEmpty() )
774 beamVCard( uids ); 780 beamVCard( uids );
775} 781}
776 782
777 783
778void KABCore::beamVCard(const QStringList& uids) 784void KABCore::beamVCard(const QStringList& uids)
779{ 785{
780/*US 786/*US
781 QString beamFilename; 787 QString beamFilename;
782 Opie::OPimContact c; 788 Opie::OPimContact c;
783 if ( actionPersonal->isOn() ) { 789 if ( actionPersonal->isOn() ) {
784 beamFilename = addressbookPersonalVCardName(); 790 beamFilename = addressbookPersonalVCardName();
785 if ( !QFile::exists( beamFilename ) ) 791 if ( !QFile::exists( beamFilename ) )
786 return; // can't beam a non-existent file 792 return; // can't beam a non-existent file
787 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 793 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
788 beamFilename ); 794 beamFilename );
789 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 795 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
790 Opie::OPimContactAccess::List allList = access->allRecords(); 796 Opie::OPimContactAccess::List allList = access->allRecords();
791 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 797 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
792 c = *it; 798 c = *it;
793 799
794 delete access; 800 delete access;
795 } else { 801 } else {
796 unlink( beamfile ); // delete if exists 802 unlink( beamfile ); // delete if exists
797 mkdir("/tmp/obex/", 0755); 803 mkdir("/tmp/obex/", 0755);
798 c = m_abView -> currentEntry(); 804 c = m_abView -> currentEntry();
799 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 805 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
800 beamfile ); 806 beamfile );
801 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 807 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
802 access->add( c ); 808 access->add( c );
803 access->save(); 809 access->save();
804 delete access; 810 delete access;
805 811
806 beamFilename = beamfile; 812 beamFilename = beamfile;
807 } 813 }
808 814
809 owarn << "Beaming: " << beamFilename << oendl; 815 owarn << "Beaming: " << beamFilename << oendl;
810*/ 816*/
811 817
812#if 0 818#if 0
813 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 819 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
814 820
815 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 821 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
816 822
817 QString name = "contact.vcf"; 823 QString name = "contact.vcf";
818 824
819 QString fileName = dirName + "/" + name; 825 QString fileName = dirName + "/" + name;
820#endif 826#endif
821 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 827 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
822 // 828 //
823 QString fileName = "/tmp/kapibeamfile.vcf"; 829 QString fileName = "/tmp/kapibeamfile.vcf";
824 830
825 831
826 //QDir().mkdir( dirName, true ); 832 //QDir().mkdir( dirName, true );
827 833
828 834
829 KABC::VCardConverter converter; 835 KABC::VCardConverter converter;
830 QString description; 836 QString description;
831 QString datastream; 837 QString datastream;
832 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 838 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
833 KABC::Addressee a = mAddressBook->findByUid( *it ); 839 KABC::Addressee a = mAddressBook->findByUid( *it );
834 840
835 if ( a.isEmpty() ) 841 if ( a.isEmpty() )
836 continue; 842 continue;
837 843
838 if (description.isEmpty()) 844 if (description.isEmpty())
839 description = a.formattedName(); 845 description = a.formattedName();
840 846
841 QString vcard; 847 QString vcard;
842 converter.addresseeToVCard( a, vcard ); 848 converter.addresseeToVCard( a, vcard );
843 int start = 0; 849 int start = 0;
844 int next; 850 int next;
845 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 851 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
846 int semi = vcard.find(";", next); 852 int semi = vcard.find(";", next);
847 int dopp = vcard.find(":", next); 853 int dopp = vcard.find(":", next);
848 int sep; 854 int sep;
849 if ( semi < dopp && semi >= 0 ) 855 if ( semi < dopp && semi >= 0 )
850 sep = semi ; 856 sep = semi ;
851 else 857 else
852 sep = dopp; 858 sep = dopp;
853 datastream +=vcard.mid( start, next - start); 859 datastream +=vcard.mid( start, next - start);
854 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 860 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
855 start = sep; 861 start = sep;
856 } 862 }
857 datastream += vcard.mid( start,vcard.length() ); 863 datastream += vcard.mid( start,vcard.length() );
858 } 864 }
859#ifndef DESKTOP_VERSION 865#ifndef DESKTOP_VERSION
860 QFile outFile(fileName); 866 QFile outFile(fileName);
861 if ( outFile.open(IO_WriteOnly) ) { 867 if ( outFile.open(IO_WriteOnly) ) {
862 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 868 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
863 QTextStream t( &outFile ); // use a text stream 869 QTextStream t( &outFile ); // use a text stream
864 t.setEncoding( QTextStream::UnicodeUTF8 ); 870 t.setEncoding( QTextStream::UnicodeUTF8 );
865 t <<datastream; 871 t <<datastream;
866 outFile.close(); 872 outFile.close();
867 Ir *ir = new Ir( this ); 873 Ir *ir = new Ir( this );
868 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 874 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
869 ir->send( fileName, description, "text/x-vCard" ); 875 ir->send( fileName, description, "text/x-vCard" );
870 } else { 876 } else {
871 qDebug("Error open temp beam file "); 877 qDebug("Error open temp beam file ");
872 return; 878 return;
873 } 879 }
874#endif 880#endif
875 881
876} 882}
877 883
878void KABCore::beamDone( Ir *ir ) 884void KABCore::beamDone( Ir *ir )
879{ 885{
880#ifndef DESKTOP_VERSION 886#ifndef DESKTOP_VERSION
881 delete ir; 887 delete ir;
882#endif 888#endif
883} 889}
884 890
885 891
886void KABCore::browse( const QString& url ) 892void KABCore::browse( const QString& url )
887{ 893{
888#ifndef KAB_EMBEDDED 894#ifndef KAB_EMBEDDED
889 kapp->invokeBrowser( url ); 895 kapp->invokeBrowser( url );
890#else //KAB_EMBEDDED 896#else //KAB_EMBEDDED
891 qDebug("KABCore::browse must be fixed"); 897 qDebug("KABCore::browse must be fixed");
892#endif //KAB_EMBEDDED 898#endif //KAB_EMBEDDED
893} 899}
894 900
895void KABCore::selectAllContacts() 901void KABCore::selectAllContacts()
896{ 902{
897 mViewManager->setSelected( QString::null, true ); 903 mViewManager->setSelected( QString::null, true );
898} 904}
899 905
900void KABCore::deleteContacts() 906void KABCore::deleteContacts()
901{ 907{
902 QStringList uidList = mViewManager->selectedUids(); 908 QStringList uidList = mViewManager->selectedUids();
903 deleteContacts( uidList ); 909 deleteContacts( uidList );
904} 910}
905 911
906void KABCore::deleteContacts( const QStringList &uids ) 912void KABCore::deleteContacts( const QStringList &uids )
907{ 913{
908 if ( uids.count() > 0 ) { 914 if ( uids.count() > 0 ) {
909 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 915 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
910 UndoStack::instance()->push( command ); 916 UndoStack::instance()->push( command );
911 RedoStack::instance()->clear(); 917 RedoStack::instance()->clear();
912 918
913 // now if we deleted anything, refresh 919 // now if we deleted anything, refresh
914 setContactSelected( QString::null ); 920 setContactSelected( QString::null );
915 setModified( true ); 921 setModified( true );
916 } 922 }
917} 923}
918 924
919void KABCore::copyContacts() 925void KABCore::copyContacts()
920{ 926{
921 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 927 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
922 928
923 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 929 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
924 930
925 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 931 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
926 932
927 QClipboard *cb = QApplication::clipboard(); 933 QClipboard *cb = QApplication::clipboard();
928 cb->setText( clipText ); 934 cb->setText( clipText );
929} 935}
930 936
931void KABCore::cutContacts() 937void KABCore::cutContacts()
932{ 938{
933 QStringList uidList = mViewManager->selectedUids(); 939 QStringList uidList = mViewManager->selectedUids();
934 940
935//US if ( uidList.size() > 0 ) { 941//US if ( uidList.size() > 0 ) {
936 if ( uidList.count() > 0 ) { 942 if ( uidList.count() > 0 ) {
937 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 943 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
938 UndoStack::instance()->push( command ); 944 UndoStack::instance()->push( command );
939 RedoStack::instance()->clear(); 945 RedoStack::instance()->clear();
940 946
941 setModified( true ); 947 setModified( true );
942 } 948 }
943} 949}
944 950
945void KABCore::pasteContacts() 951void KABCore::pasteContacts()
946{ 952{
947 QClipboard *cb = QApplication::clipboard(); 953 QClipboard *cb = QApplication::clipboard();
948 954
949 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 955 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
950 956
951 pasteContacts( list ); 957 pasteContacts( list );
952} 958}
953 959
954void KABCore::pasteContacts( KABC::Addressee::List &list ) 960void KABCore::pasteContacts( KABC::Addressee::List &list )
955{ 961{
956 KABC::Resource *resource = requestResource( this ); 962 KABC::Resource *resource = requestResource( this );
957 KABC::Addressee::List::Iterator it; 963 KABC::Addressee::List::Iterator it;
958 for ( it = list.begin(); it != list.end(); ++it ) 964 for ( it = list.begin(); it != list.end(); ++it )
959 (*it).setResource( resource ); 965 (*it).setResource( resource );
960 966
961 PwPasteCommand *command = new PwPasteCommand( this, list ); 967 PwPasteCommand *command = new PwPasteCommand( this, list );
962 UndoStack::instance()->push( command ); 968 UndoStack::instance()->push( command );
963 RedoStack::instance()->clear(); 969 RedoStack::instance()->clear();
964 970
965 setModified( true ); 971 setModified( true );
966} 972}
967 973
968void KABCore::setWhoAmI() 974void KABCore::setWhoAmI()
969{ 975{
970 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 976 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
971 977
972 if ( addrList.count() > 1 ) { 978 if ( addrList.count() > 1 ) {
973 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 979 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
974 return; 980 return;
975 } 981 }
976 982
977 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 983 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
978 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 984 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
979 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 985 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
980} 986}
981 987
982void KABCore::setCategories() 988void KABCore::setCategories()
983{ 989{
984 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 990 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
985 if ( !dlg.exec() ) 991 if ( !dlg.exec() )
986 return; 992 return;
987 993
988 bool merge = false; 994 bool merge = false;
989 QString msg = i18n( "Merge with existing categories?" ); 995 QString msg = i18n( "Merge with existing categories?" );
990 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 996 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
991 merge = true; 997 merge = true;
992 998
993 QStringList categories = dlg.selectedCategories(); 999 QStringList categories = dlg.selectedCategories();
994 1000
995 QStringList uids = mViewManager->selectedUids(); 1001 QStringList uids = mViewManager->selectedUids();
996 QStringList::Iterator it; 1002 QStringList::Iterator it;
997 for ( it = uids.begin(); it != uids.end(); ++it ) { 1003 for ( it = uids.begin(); it != uids.end(); ++it ) {
998 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1004 KABC::Addressee addr = mAddressBook->findByUid( *it );
999 if ( !addr.isEmpty() ) { 1005 if ( !addr.isEmpty() ) {
1000 if ( !merge ) 1006 if ( !merge )
1001 addr.setCategories( categories ); 1007 addr.setCategories( categories );
1002 else { 1008 else {
1003 QStringList addrCategories = addr.categories(); 1009 QStringList addrCategories = addr.categories();
1004 QStringList::Iterator catIt; 1010 QStringList::Iterator catIt;
1005 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1011 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1006 if ( !addrCategories.contains( *catIt ) ) 1012 if ( !addrCategories.contains( *catIt ) )
1007 addrCategories.append( *catIt ); 1013 addrCategories.append( *catIt );
1008 } 1014 }
1009 addr.setCategories( addrCategories ); 1015 addr.setCategories( addrCategories );
1010 } 1016 }
1011 1017
1012 mAddressBook->insertAddressee( addr ); 1018 mAddressBook->insertAddressee( addr );
1013 } 1019 }
1014 } 1020 }
1015 1021
1016 if ( uids.count() > 0 ) 1022 if ( uids.count() > 0 )
1017 setModified( true ); 1023 setModified( true );
1018} 1024}
1019 1025
1020void KABCore::setSearchFields( const KABC::Field::List &fields ) 1026void KABCore::setSearchFields( const KABC::Field::List &fields )
1021{ 1027{
1022 mIncSearchWidget->setFields( fields ); 1028 mIncSearchWidget->setFields( fields );
1023} 1029}
1024 1030
1025void KABCore::incrementalSearch( const QString& text ) 1031void KABCore::incrementalSearch( const QString& text )
1026{ 1032{
1027 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1033 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1028} 1034}
1029 1035
1030void KABCore::setModified() 1036void KABCore::setModified()
1031{ 1037{
1032 setModified( true ); 1038 setModified( true );
1033} 1039}
1034 1040
1035void KABCore::setModifiedWOrefresh() 1041void KABCore::setModifiedWOrefresh()
1036{ 1042{
1037 // qDebug("KABCore::setModifiedWOrefresh() "); 1043 // qDebug("KABCore::setModifiedWOrefresh() ");
1038 mModified = true; 1044 mModified = true;
1039 mActionSave->setEnabled( mModified ); 1045 mActionSave->setEnabled( mModified );
1040#ifdef DESKTOP_VERSION 1046#ifdef DESKTOP_VERSION
1041 mDetails->refreshView(); 1047 mDetails->refreshView();
1042#endif 1048#endif
1043 1049
1044} 1050}
1045void KABCore::setModified( bool modified ) 1051void KABCore::setModified( bool modified )
1046{ 1052{
1047 mModified = modified; 1053 mModified = modified;
1048 mActionSave->setEnabled( mModified ); 1054 mActionSave->setEnabled( mModified );
1049 1055
1050 if ( modified ) 1056 if ( modified )
1051 mJumpButtonBar->recreateButtons(); 1057 mJumpButtonBar->recreateButtons();
1052 1058
1053 mViewManager->refreshView(); 1059 mViewManager->refreshView();
1054 mDetails->refreshView(); 1060 mDetails->refreshView();
1055 1061
1056} 1062}
1057 1063
1058bool KABCore::modified() const 1064bool KABCore::modified() const
1059{ 1065{
1060 return mModified; 1066 return mModified;
1061} 1067}
1062 1068
1063void KABCore::contactModified( const KABC::Addressee &addr ) 1069void KABCore::contactModified( const KABC::Addressee &addr )
1064{ 1070{
1065 1071
1066 Command *command = 0; 1072 Command *command = 0;
1067 QString uid; 1073 QString uid;
1068 1074
1069 // check if it exists already 1075 // check if it exists already
1070 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1076 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1071 if ( origAddr.isEmpty() ) 1077 if ( origAddr.isEmpty() )
1072 command = new PwNewCommand( mAddressBook, addr ); 1078 command = new PwNewCommand( mAddressBook, addr );
1073 else { 1079 else {
1074 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1080 command = new PwEditCommand( mAddressBook, origAddr, addr );
1075 uid = addr.uid(); 1081 uid = addr.uid();
1076 } 1082 }
1077 1083
1078 UndoStack::instance()->push( command ); 1084 UndoStack::instance()->push( command );
1079 RedoStack::instance()->clear(); 1085 RedoStack::instance()->clear();
1080 1086
1081 setModified( true ); 1087 setModified( true );
1082} 1088}
1083 1089
1084void KABCore::newContact() 1090void KABCore::newContact()
1085{ 1091{
1086 1092
1087 1093
1088 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1094 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1089 1095
1090 QPtrList<KRES::Resource> kresResources; 1096 QPtrList<KRES::Resource> kresResources;
1091 QPtrListIterator<KABC::Resource> it( kabcResources ); 1097 QPtrListIterator<KABC::Resource> it( kabcResources );
1092 KABC::Resource *resource; 1098 KABC::Resource *resource;
1093 while ( ( resource = it.current() ) != 0 ) { 1099 while ( ( resource = it.current() ) != 0 ) {
1094 ++it; 1100 ++it;
1095 if ( !resource->readOnly() ) { 1101 if ( !resource->readOnly() ) {
1096 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1102 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1097 if ( res ) 1103 if ( res )
1098 kresResources.append( res ); 1104 kresResources.append( res );
1099 } 1105 }
1100 } 1106 }
1101 1107
1102 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1108 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1103 resource = static_cast<KABC::Resource*>( res ); 1109 resource = static_cast<KABC::Resource*>( res );
1104 1110
1105 if ( resource ) { 1111 if ( resource ) {
1106 KABC::Addressee addr; 1112 KABC::Addressee addr;
1107 addr.setResource( resource ); 1113 addr.setResource( resource );
1108 mEditorDialog->setAddressee( addr ); 1114 mEditorDialog->setAddressee( addr );
1109 KApplication::execDialog ( mEditorDialog ); 1115 KApplication::execDialog ( mEditorDialog );
1110 1116
1111 } else 1117 } else
1112 return; 1118 return;
1113 1119
1114 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1120 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1115 1121
1116 1122
1117} 1123}
1118 1124
1119void KABCore::addEmail( QString aStr ) 1125void KABCore::addEmail( QString aStr )
1120{ 1126{
1121#ifndef KAB_EMBEDDED 1127#ifndef KAB_EMBEDDED
1122 QString fullName, email; 1128 QString fullName, email;
1123 1129
1124 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1130 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1125 1131
1126 // Try to lookup the addressee matching the email address 1132 // Try to lookup the addressee matching the email address
1127 bool found = false; 1133 bool found = false;
1128 QStringList emailList; 1134 QStringList emailList;
1129 KABC::AddressBook::Iterator it; 1135 KABC::AddressBook::Iterator it;
1130 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1136 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1131 emailList = (*it).emails(); 1137 emailList = (*it).emails();
1132 if ( emailList.contains( email ) > 0 ) { 1138 if ( emailList.contains( email ) > 0 ) {
1133 found = true; 1139 found = true;
1134 (*it).setNameFromString( fullName ); 1140 (*it).setNameFromString( fullName );
1135 editContact( (*it).uid() ); 1141 editContact( (*it).uid() );
1136 } 1142 }
1137 } 1143 }
1138 1144
1139 if ( !found ) { 1145 if ( !found ) {
1140 KABC::Addressee addr; 1146 KABC::Addressee addr;
1141 addr.setNameFromString( fullName ); 1147 addr.setNameFromString( fullName );
1142 addr.insertEmail( email, true ); 1148 addr.insertEmail( email, true );
1143 1149
1144 mAddressBook->insertAddressee( addr ); 1150 mAddressBook->insertAddressee( addr );
1145 mViewManager->refreshView( addr.uid() ); 1151 mViewManager->refreshView( addr.uid() );
1146 editContact( addr.uid() ); 1152 editContact( addr.uid() );
1147 } 1153 }
1148#else //KAB_EMBEDDED 1154#else //KAB_EMBEDDED
1149 qDebug("KABCore::addEmail finsih method"); 1155 qDebug("KABCore::addEmail finsih method");
1150#endif //KAB_EMBEDDED 1156#endif //KAB_EMBEDDED
1151} 1157}
1152 1158
1153void KABCore::importVCard( const KURL &url, bool showPreview ) 1159void KABCore::importVCard( const KURL &url, bool showPreview )
1154{ 1160{
1155 mXXPortManager->importVCard( url, showPreview ); 1161 mXXPortManager->importVCard( url, showPreview );
1156} 1162}
1157void KABCore::importFromOL() 1163void KABCore::importFromOL()
1158{ 1164{
1159#ifdef _WIN32_ 1165#ifdef _WIN32_
1160 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1166 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1161 idgl->exec(); 1167 idgl->exec();
1162 KABC::Addressee::List list = idgl->getAddressList(); 1168 KABC::Addressee::List list = idgl->getAddressList();
1163 if ( list.count() > 0 ) { 1169 if ( list.count() > 0 ) {
1164 KABC::Addressee::List listNew; 1170 KABC::Addressee::List listNew;
1165 KABC::Addressee::List listExisting; 1171 KABC::Addressee::List listExisting;
1166 KABC::Addressee::List::Iterator it; 1172 KABC::Addressee::List::Iterator it;
1167 KABC::AddressBook::Iterator iter; 1173 KABC::AddressBook::Iterator iter;
1168 for ( it = list.begin(); it != list.end(); ++it ) { 1174 for ( it = list.begin(); it != list.end(); ++it ) {
1169 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1175 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1170 listNew.append( (*it) ); 1176 listNew.append( (*it) );
1171 else 1177 else
1172 listExisting.append( (*it) ); 1178 listExisting.append( (*it) );
1173 } 1179 }
1174 if ( listExisting.count() > 0 ) 1180 if ( listExisting.count() > 0 )
1175 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1181 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1176 if ( listNew.count() > 0 ) { 1182 if ( listNew.count() > 0 ) {
1177 pasteWithNewUid = false; 1183 pasteWithNewUid = false;
1178 pasteContacts( listNew ); 1184 pasteContacts( listNew );
1179 pasteWithNewUid = true; 1185 pasteWithNewUid = true;
1180 } 1186 }
1181 } 1187 }
1182 delete idgl; 1188 delete idgl;
1183#endif 1189#endif
1184} 1190}
1185 1191
1186void KABCore::importVCard( const QString &vCard, bool showPreview ) 1192void KABCore::importVCard( const QString &vCard, bool showPreview )
1187{ 1193{
1188 mXXPortManager->importVCard( vCard, showPreview ); 1194 mXXPortManager->importVCard( vCard, showPreview );
1189} 1195}
1190 1196
1191//US added a second method without defaultparameter 1197//US added a second method without defaultparameter
1192void KABCore::editContact2() { 1198void KABCore::editContact2() {
1193 editContact( QString::null ); 1199 editContact( QString::null );
1194} 1200}
1195 1201
1196void KABCore::editContact( const QString &uid ) 1202void KABCore::editContact( const QString &uid )
1197{ 1203{
1198 1204
1199 if ( mExtensionManager->isQuickEditVisible() ) 1205 if ( mExtensionManager->isQuickEditVisible() )
1200 return; 1206 return;
1201 1207
1202 // First, locate the contact entry 1208 // First, locate the contact entry
1203 QString localUID = uid; 1209 QString localUID = uid;
1204 if ( localUID.isNull() ) { 1210 if ( localUID.isNull() ) {
1205 QStringList uidList = mViewManager->selectedUids(); 1211 QStringList uidList = mViewManager->selectedUids();
1206 if ( uidList.count() > 0 ) 1212 if ( uidList.count() > 0 )
1207 localUID = *( uidList.at( 0 ) ); 1213 localUID = *( uidList.at( 0 ) );
1208 } 1214 }
1209 1215
1210 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1216 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1211 if ( !addr.isEmpty() ) { 1217 if ( !addr.isEmpty() ) {
1212 mEditorDialog->setAddressee( addr ); 1218 mEditorDialog->setAddressee( addr );
1213 KApplication::execDialog ( mEditorDialog ); 1219 KApplication::execDialog ( mEditorDialog );
1214 } 1220 }
1215} 1221}
1216 1222
1217/** 1223/**
1218 Shows or edits the detail view for the given uid. If the uid is QString::null, 1224 Shows or edits the detail view for the given uid. If the uid is QString::null,
1219 the method will try to find a selected addressee in the view. 1225 the method will try to find a selected addressee in the view.
1220 */ 1226 */
1221void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1227void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1222{ 1228{
1223 if ( mMultipleViewsAtOnce ) 1229 if ( mMultipleViewsAtOnce )
1224 { 1230 {
1225 editContact( uid ); 1231 editContact( uid );
1226 } 1232 }
1227 else 1233 else
1228 { 1234 {
1229 setDetailsVisible( true ); 1235 setDetailsVisible( true );
1230 mActionDetails->setChecked(true); 1236 mActionDetails->setChecked(true);
1231 } 1237 }
1232 1238
1233} 1239}
1234 1240
1235void KABCore::save() 1241void KABCore::save()
1236{ 1242{
1237 if (syncManager->blockSave()) 1243 if (syncManager->blockSave())
1238 return; 1244 return;
1239 if ( !mModified ) 1245 if ( !mModified )
1240 return; 1246 return;
1241 1247
1242 syncManager->setBlockSave(true); 1248 syncManager->setBlockSave(true);
1243 QString text = i18n( "There was an error while attempting to save\n the " 1249 QString text = i18n( "There was an error while attempting to save\n the "
1244 "address book. Please check that some \nother application is " 1250 "address book. Please check that some \nother application is "
1245 "not using it. " ); 1251 "not using it. " );
1246 statusMessage(i18n("Saving addressbook ... ")); 1252 statusMessage(i18n("Saving addressbook ... "));
1247#ifndef KAB_EMBEDDED 1253#ifndef KAB_EMBEDDED
1248 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1254 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1249 if ( !b || !b->save() ) { 1255 if ( !b || !b->save() ) {
1250 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1256 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1251 } 1257 }
1252#else //KAB_EMBEDDED 1258#else //KAB_EMBEDDED
1253 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1259 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1254 if ( !b || !b->save() ) { 1260 if ( !b || !b->save() ) {
1255 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1261 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1256 } 1262 }
1257#endif //KAB_EMBEDDED 1263#endif //KAB_EMBEDDED
1258 1264
1259 statusMessage(i18n("Addressbook saved!")); 1265 statusMessage(i18n("Addressbook saved!"));
1260 setModified( false ); 1266 setModified( false );
1261 syncManager->setBlockSave(false); 1267 syncManager->setBlockSave(false);
1262} 1268}
1263 1269
1264void KABCore::statusMessage(QString mess , int time ) 1270void KABCore::statusMessage(QString mess , int time )
1265{ 1271{
1266 //topLevelWidget()->setCaption( mess ); 1272 //topLevelWidget()->setCaption( mess );
1267 // pending setting timer to revome message 1273 // pending setting timer to revome message
1268} 1274}
1269void KABCore::undo() 1275void KABCore::undo()
1270{ 1276{
1271 UndoStack::instance()->undo(); 1277 UndoStack::instance()->undo();
1272 1278
1273 // Refresh the view 1279 // Refresh the view
1274 mViewManager->refreshView(); 1280 mViewManager->refreshView();
1275} 1281}
1276 1282
1277void KABCore::redo() 1283void KABCore::redo()
1278{ 1284{
1279 RedoStack::instance()->redo(); 1285 RedoStack::instance()->redo();
1280 1286
1281 // Refresh the view 1287 // Refresh the view
1282 mViewManager->refreshView(); 1288 mViewManager->refreshView();
1283} 1289}
1284 1290
1285void KABCore::setJumpButtonBarVisible( bool visible ) 1291void KABCore::setJumpButtonBarVisible( bool visible )
1286{ 1292{
1287 if (mMultipleViewsAtOnce) 1293 if (mMultipleViewsAtOnce)
1288 { 1294 {
1289 if ( visible ) 1295 if ( visible )
1290 mJumpButtonBar->show(); 1296 mJumpButtonBar->show();
1291 else 1297 else
1292 mJumpButtonBar->hide(); 1298 mJumpButtonBar->hide();
1293 } 1299 }
1294 else 1300 else
1295 { 1301 {
1296 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1302 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1297 if (mViewManager->isVisible()) 1303 if (mViewManager->isVisible())
1298 { 1304 {
1299 if ( visible ) 1305 if ( visible )
1300 mJumpButtonBar->show(); 1306 mJumpButtonBar->show();
1301 else 1307 else
1302 mJumpButtonBar->hide(); 1308 mJumpButtonBar->hide();
1303 } 1309 }
1304 else 1310 else
1305 { 1311 {
1306 mJumpButtonBar->hide(); 1312 mJumpButtonBar->hide();
1307 } 1313 }
1308 } 1314 }
1309} 1315}
1310 1316
1311 1317
1312void KABCore::setDetailsToState() 1318void KABCore::setDetailsToState()
1313{ 1319{
1314 setDetailsVisible( mActionDetails->isChecked() ); 1320 setDetailsVisible( mActionDetails->isChecked() );
1315} 1321}
1316 1322
1317 1323
1318 1324
1319void KABCore::setDetailsVisible( bool visible ) 1325void KABCore::setDetailsVisible( bool visible )
1320{ 1326{
1321 if (visible && mDetails->isHidden()) 1327 if (visible && mDetails->isHidden())
1322 { 1328 {
1323 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1329 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1324 if ( addrList.count() > 0 ) 1330 if ( addrList.count() > 0 )
1325 mDetails->setAddressee( addrList[ 0 ] ); 1331 mDetails->setAddressee( addrList[ 0 ] );
1326 } 1332 }
1327 1333
1328 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1334 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1329 // the listview and the detailview. We do that by changing the splitbar size. 1335 // the listview and the detailview. We do that by changing the splitbar size.
1330 if (mMultipleViewsAtOnce) 1336 if (mMultipleViewsAtOnce)
1331 { 1337 {
1332 if ( visible ) 1338 if ( visible )
1333 mDetails->show(); 1339 mDetails->show();
1334 else 1340 else
1335 mDetails->hide(); 1341 mDetails->hide();
1336 } 1342 }
1337 else 1343 else
1338 { 1344 {
1339 if ( visible ) { 1345 if ( visible ) {
1340 mViewManager->hide(); 1346 mViewManager->hide();
1341 mDetails->show(); 1347 mDetails->show();
1342 } 1348 }
1343 else { 1349 else {
1344 mViewManager->show(); 1350 mViewManager->show();
1345 mDetails->hide(); 1351 mDetails->hide();
1346 } 1352 }
1347 setJumpButtonBarVisible( !visible ); 1353 setJumpButtonBarVisible( !visible );
1348 } 1354 }
1349 1355
1350} 1356}
1351 1357
1352void KABCore::extensionChanged( int id ) 1358void KABCore::extensionChanged( int id )
1353{ 1359{
1354 //change the details view only for non desktop systems 1360 //change the details view only for non desktop systems
1355#ifndef DESKTOP_VERSION 1361#ifndef DESKTOP_VERSION
1356 1362
1357 if (id == 0) 1363 if (id == 0)
1358 { 1364 {
1359 //the user disabled the extension. 1365 //the user disabled the extension.
1360 1366
1361 if (mMultipleViewsAtOnce) 1367 if (mMultipleViewsAtOnce)
1362 { // enable detailsview again 1368 { // enable detailsview again
1363 setDetailsVisible( true ); 1369 setDetailsVisible( true );
1364 mActionDetails->setChecked( true ); 1370 mActionDetails->setChecked( true );
1365 } 1371 }
1366 else 1372 else
1367 { //go back to the listview 1373 { //go back to the listview
1368 setDetailsVisible( false ); 1374 setDetailsVisible( false );
1369 mActionDetails->setChecked( false ); 1375 mActionDetails->setChecked( false );
1370 mActionDetails->setEnabled(true); 1376 mActionDetails->setEnabled(true);
1371 } 1377 }
1372 1378
1373 } 1379 }
1374 else 1380 else
1375 { 1381 {
1376 //the user enabled the extension. 1382 //the user enabled the extension.
1377 setDetailsVisible( false ); 1383 setDetailsVisible( false );
1378 mActionDetails->setChecked( false ); 1384 mActionDetails->setChecked( false );
1379 1385
1380 if (!mMultipleViewsAtOnce) 1386 if (!mMultipleViewsAtOnce)
1381 { 1387 {
1382 mActionDetails->setEnabled(false); 1388 mActionDetails->setEnabled(false);
1383 } 1389 }
1384 1390
1385 mExtensionManager->setSelectionChanged(); 1391 mExtensionManager->setSelectionChanged();
1386 1392
1387 } 1393 }
1388 1394
1389#endif// DESKTOP_VERSION 1395#endif// DESKTOP_VERSION
1390 1396
1391} 1397}
1392 1398
1393 1399
1394void KABCore::extensionModified( const KABC::Addressee::List &list ) 1400void KABCore::extensionModified( const KABC::Addressee::List &list )
1395{ 1401{
1396 1402
1397 if ( list.count() != 0 ) { 1403 if ( list.count() != 0 ) {
1398 KABC::Addressee::List::ConstIterator it; 1404 KABC::Addressee::List::ConstIterator it;
1399 for ( it = list.begin(); it != list.end(); ++it ) 1405 for ( it = list.begin(); it != list.end(); ++it )
1400 mAddressBook->insertAddressee( *it ); 1406 mAddressBook->insertAddressee( *it );
1401 if ( list.count() > 1 ) 1407 if ( list.count() > 1 )
1402 setModified(); 1408 setModified();
1403 else 1409 else
1404 setModifiedWOrefresh(); 1410 setModifiedWOrefresh();
1405 } 1411 }
1406 if ( list.count() == 0 ) 1412 if ( list.count() == 0 )
1407 mViewManager->refreshView(); 1413 mViewManager->refreshView();
1408 else 1414 else
1409 mViewManager->refreshView( list[ 0 ].uid() ); 1415 mViewManager->refreshView( list[ 0 ].uid() );
1410 1416
1411 1417
1412 1418
1413} 1419}
1414 1420
1415QString KABCore::getNameByPhone( const QString &phone ) 1421QString KABCore::getNameByPhone( const QString &phone )
1416{ 1422{
1417#ifndef KAB_EMBEDDED 1423#ifndef KAB_EMBEDDED
1418 QRegExp r( "[/*/-/ ]" ); 1424 QRegExp r( "[/*/-/ ]" );
1419 QString localPhone( phone ); 1425 QString localPhone( phone );
1420 1426
1421 bool found = false; 1427 bool found = false;
1422 QString ownerName = ""; 1428 QString ownerName = "";
1423 KABC::AddressBook::Iterator iter; 1429 KABC::AddressBook::Iterator iter;
1424 KABC::PhoneNumber::List::Iterator phoneIter; 1430 KABC::PhoneNumber::List::Iterator phoneIter;
1425 KABC::PhoneNumber::List phoneList; 1431 KABC::PhoneNumber::List phoneList;
1426 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1432 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1427 phoneList = (*iter).phoneNumbers(); 1433 phoneList = (*iter).phoneNumbers();
1428 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1434 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1429 ++phoneIter) { 1435 ++phoneIter) {
1430 // Get rid of separator chars so just the numbers are compared. 1436 // Get rid of separator chars so just the numbers are compared.
1431 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1437 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1432 ownerName = (*iter).formattedName(); 1438 ownerName = (*iter).formattedName();
1433 found = true; 1439 found = true;
1434 } 1440 }
1435 } 1441 }
1436 } 1442 }
1437 1443
1438 return ownerName; 1444 return ownerName;
1439#else //KAB_EMBEDDED 1445#else //KAB_EMBEDDED
1440 qDebug("KABCore::getNameByPhone finsih method"); 1446 qDebug("KABCore::getNameByPhone finsih method");
1441 return ""; 1447 return "";
1442#endif //KAB_EMBEDDED 1448#endif //KAB_EMBEDDED
1443 1449
1444} 1450}
1445 1451
1446void KABCore::openConfigDialog() 1452void KABCore::openConfigDialog()
1447{ 1453{
1448 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1454 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1449 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1455 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1450 ConfigureDialog->addModule(kabcfg ); 1456 ConfigureDialog->addModule(kabcfg );
1451 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1457 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1452 ConfigureDialog->addModule(kdelibcfg ); 1458 ConfigureDialog->addModule(kdelibcfg );
1453 1459
1454 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1460 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1455 this, SLOT( configurationChanged() ) ); 1461 this, SLOT( configurationChanged() ) );
1456 connect( ConfigureDialog, SIGNAL( okClicked() ), 1462 connect( ConfigureDialog, SIGNAL( okClicked() ),
1457 this, SLOT( configurationChanged() ) ); 1463 this, SLOT( configurationChanged() ) );
1458 saveSettings(); 1464 saveSettings();
1459#ifndef DESKTOP_VERSION 1465#ifndef DESKTOP_VERSION
1460 ConfigureDialog->showMaximized(); 1466 ConfigureDialog->showMaximized();
1461#endif 1467#endif
1462 if ( ConfigureDialog->exec() ) 1468 if ( ConfigureDialog->exec() )
1463 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1469 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1464 delete ConfigureDialog; 1470 delete ConfigureDialog;
1465} 1471}
1466 1472
1467void KABCore::openLDAPDialog() 1473void KABCore::openLDAPDialog()
1468{ 1474{
1469#ifndef KAB_EMBEDDED 1475#ifndef KAB_EMBEDDED
1470 if ( !mLdapSearchDialog ) { 1476 if ( !mLdapSearchDialog ) {
1471 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1477 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1472 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1478 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1473 SLOT( refreshView() ) ); 1479 SLOT( refreshView() ) );
1474 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1480 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1475 SLOT( setModified() ) ); 1481 SLOT( setModified() ) );
1476 } else 1482 } else
1477 mLdapSearchDialog->restoreSettings(); 1483 mLdapSearchDialog->restoreSettings();
1478 1484
1479 if ( mLdapSearchDialog->isOK() ) 1485 if ( mLdapSearchDialog->isOK() )
1480 mLdapSearchDialog->exec(); 1486 mLdapSearchDialog->exec();
1481#else //KAB_EMBEDDED 1487#else //KAB_EMBEDDED
1482 qDebug("KABCore::openLDAPDialog() finsih method"); 1488 qDebug("KABCore::openLDAPDialog() finsih method");
1483#endif //KAB_EMBEDDED 1489#endif //KAB_EMBEDDED
1484} 1490}
1485 1491
1486void KABCore::print() 1492void KABCore::print()
1487{ 1493{
1488#ifndef KAB_EMBEDDED 1494#ifndef KAB_EMBEDDED
1489 KPrinter printer; 1495 KPrinter printer;
1490 if ( !printer.setup( this ) ) 1496 if ( !printer.setup( this ) )
1491 return; 1497 return;
1492 1498
1493 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1499 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1494 mViewManager->selectedUids(), this ); 1500 mViewManager->selectedUids(), this );
1495 1501
1496 wizard.exec(); 1502 wizard.exec();
1497#else //KAB_EMBEDDED 1503#else //KAB_EMBEDDED
1498 qDebug("KABCore::print() finsih method"); 1504 qDebug("KABCore::print() finsih method");
1499#endif //KAB_EMBEDDED 1505#endif //KAB_EMBEDDED
1500 1506
1501} 1507}
1502 1508
1503 1509
1504void KABCore::addGUIClient( KXMLGUIClient *client ) 1510void KABCore::addGUIClient( KXMLGUIClient *client )
1505{ 1511{
1506 if ( mGUIClient ) 1512 if ( mGUIClient )
1507 mGUIClient->insertChildClient( client ); 1513 mGUIClient->insertChildClient( client );
1508 else 1514 else
1509 KMessageBox::error( this, "no KXMLGUICLient"); 1515 KMessageBox::error( this, "no KXMLGUICLient");
1510} 1516}
1511 1517
1512 1518
1513void KABCore::configurationChanged() 1519void KABCore::configurationChanged()
1514{ 1520{
1515 mExtensionManager->reconfigure(); 1521 mExtensionManager->reconfigure();
1516} 1522}
1517 1523
1518void KABCore::addressBookChanged() 1524void KABCore::addressBookChanged()
1519{ 1525{
1520/*US 1526/*US
1521 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1527 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1522 while ( it.current() ) { 1528 while ( it.current() ) {
1523 if ( it.current()->dirty() ) { 1529 if ( it.current()->dirty() ) {
1524 QString text = i18n( "Data has been changed externally. Unsaved " 1530 QString text = i18n( "Data has been changed externally. Unsaved "
1525 "changes will be lost." ); 1531 "changes will be lost." );
1526 KMessageBox::information( this, text ); 1532 KMessageBox::information( this, text );
1527 } 1533 }
1528 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1534 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1529 ++it; 1535 ++it;
1530 } 1536 }
1531*/ 1537*/
1532 if (mEditorDialog) 1538 if (mEditorDialog)
1533 { 1539 {
1534 if (mEditorDialog->dirty()) 1540 if (mEditorDialog->dirty())
1535 { 1541 {
1536 QString text = i18n( "Data has been changed externally. Unsaved " 1542 QString text = i18n( "Data has been changed externally. Unsaved "
1537 "changes will be lost." ); 1543 "changes will be lost." );
1538 KMessageBox::information( this, text ); 1544 KMessageBox::information( this, text );
1539 } 1545 }
1540 QString currentuid = mEditorDialog->addressee().uid(); 1546 QString currentuid = mEditorDialog->addressee().uid();
1541 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1547 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1542 } 1548 }
1543 mViewManager->refreshView(); 1549 mViewManager->refreshView();
1544// mDetails->refreshView(); 1550// mDetails->refreshView();
1545 1551
1546 1552
1547} 1553}
1548 1554
1549AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1555AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1550 const char *name ) 1556 const char *name )
1551{ 1557{
1552 1558
1553 if ( mEditorDialog == 0 ) { 1559 if ( mEditorDialog == 0 ) {
1554 mEditorDialog = new AddresseeEditorDialog( this, parent, 1560 mEditorDialog = new AddresseeEditorDialog( this, parent,
1555 name ? name : "editorDialog" ); 1561 name ? name : "editorDialog" );
1556 1562
1557 1563
1558 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1564 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1559 SLOT( contactModified( const KABC::Addressee& ) ) ); 1565 SLOT( contactModified( const KABC::Addressee& ) ) );
1560 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1566 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1561 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1567 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1562 } 1568 }
1563 1569
1564 return mEditorDialog; 1570 return mEditorDialog;
1565} 1571}
1566 1572
1567void KABCore::slotEditorDestroyed( const QString &uid ) 1573void KABCore::slotEditorDestroyed( const QString &uid )
1568{ 1574{
1569 //mEditorDict.remove( uid ); 1575 //mEditorDict.remove( uid );
1570} 1576}
1571 1577
1572void KABCore::initGUI() 1578void KABCore::initGUI()
1573{ 1579{
1574#ifndef KAB_EMBEDDED 1580#ifndef KAB_EMBEDDED
1575 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1581 QHBoxLayout *topLayout = new QHBoxLayout( this );
1576 topLayout->setSpacing( KDialogBase::spacingHint() ); 1582 topLayout->setSpacing( KDialogBase::spacingHint() );
1577 1583
1578 mExtensionBarSplitter = new QSplitter( this ); 1584 mExtensionBarSplitter = new QSplitter( this );
1579 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1585 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1580 1586
1581 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1587 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1582 1588
1583 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1589 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1584 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1590 mIncSearchWidget = new IncSearchWidget( viewSpace );
1585 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1591 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1586 SLOT( incrementalSearch( const QString& ) ) ); 1592 SLOT( incrementalSearch( const QString& ) ) );
1587 1593
1588 mViewManager = new ViewManager( this, viewSpace ); 1594 mViewManager = new ViewManager( this, viewSpace );
1589 viewSpace->setStretchFactor( mViewManager, 1 ); 1595 viewSpace->setStretchFactor( mViewManager, 1 );
1590 1596
1591 mDetails = new ViewContainer( mDetailsSplitter ); 1597 mDetails = new ViewContainer( mDetailsSplitter );
1592 1598
1593 mJumpButtonBar = new JumpButtonBar( this, this ); 1599 mJumpButtonBar = new JumpButtonBar( this, this );
1594 1600
1595 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1601 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1596 1602
1597 topLayout->addWidget( mExtensionBarSplitter ); 1603 topLayout->addWidget( mExtensionBarSplitter );
1598 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1604 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1599 topLayout->addWidget( mJumpButtonBar ); 1605 topLayout->addWidget( mJumpButtonBar );
1600 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1606 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1601 1607
1602 mXXPortManager = new XXPortManager( this, this ); 1608 mXXPortManager = new XXPortManager( this, this );
1603 1609
1604#else //KAB_EMBEDDED 1610#else //KAB_EMBEDDED
1605 //US initialize viewMenu before settingup viewmanager. 1611 //US initialize viewMenu before settingup viewmanager.
1606 // Viewmanager needs this menu to plugin submenues. 1612 // Viewmanager needs this menu to plugin submenues.
1607 viewMenu = new QPopupMenu( this ); 1613 viewMenu = new QPopupMenu( this );
1608 settingsMenu = new QPopupMenu( this ); 1614 settingsMenu = new QPopupMenu( this );
1609 //filterMenu = new QPopupMenu( this ); 1615 //filterMenu = new QPopupMenu( this );
1610 ImportMenu = new QPopupMenu( this ); 1616 ImportMenu = new QPopupMenu( this );
1611 ExportMenu = new QPopupMenu( this ); 1617 ExportMenu = new QPopupMenu( this );
1612 syncMenu = new QPopupMenu( this ); 1618 syncMenu = new QPopupMenu( this );
1613 changeMenu= new QPopupMenu( this ); 1619 changeMenu= new QPopupMenu( this );
1614 1620
1615//US since we have no splitter for the embedded system, setup 1621//US since we have no splitter for the embedded system, setup
1616// a layout with two frames. One left and one right. 1622// a layout with two frames. One left and one right.
1617 1623
1618 QBoxLayout *topLayout; 1624 QBoxLayout *topLayout;
1619 1625
1620 // = new QHBoxLayout( this ); 1626 // = new QHBoxLayout( this );
1621// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1627// QBoxLayout *topLayout = (QBoxLayout*)layout();
1622 1628
1623// QWidget *mainBox = new QWidget( this ); 1629// QWidget *mainBox = new QWidget( this );
1624// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1630// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1625 1631
1626#ifdef DESKTOP_VERSION 1632#ifdef DESKTOP_VERSION
1627 topLayout = new QHBoxLayout( this ); 1633 topLayout = new QHBoxLayout( this );
1628 1634
1629 1635
1630 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1636 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1631 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1637 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1632 1638
1633 topLayout->addWidget(mMiniSplitter ); 1639 topLayout->addWidget(mMiniSplitter );
1634 1640
1635 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1641 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1636 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1642 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1637 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1643 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1638 mDetails = new ViewContainer( mMiniSplitter ); 1644 mDetails = new ViewContainer( mMiniSplitter );
1639 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1645 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1640#else 1646#else
1641 if ( QApplication::desktop()->width() > 480 ) { 1647 if ( QApplication::desktop()->width() > 480 ) {
1642 topLayout = new QHBoxLayout( this ); 1648 topLayout = new QHBoxLayout( this );
1643 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1649 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1644 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1650 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1645 } else { 1651 } else {
1646 1652
1647 topLayout = new QHBoxLayout( this ); 1653 topLayout = new QHBoxLayout( this );
1648 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1654 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1649 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1655 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1650 } 1656 }
1651 1657
1652 topLayout->addWidget(mMiniSplitter ); 1658 topLayout->addWidget(mMiniSplitter );
1653 mViewManager = new ViewManager( this, mMiniSplitter ); 1659 mViewManager = new ViewManager( this, mMiniSplitter );
1654 mDetails = new ViewContainer( mMiniSplitter ); 1660 mDetails = new ViewContainer( mMiniSplitter );
1655 1661
1656 1662
1657 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1663 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1658#endif 1664#endif
1659 //eh->hide(); 1665 //eh->hide();
1660 // topLayout->addWidget(mExtensionManager ); 1666 // topLayout->addWidget(mExtensionManager );
1661 1667
1662 1668
1663/*US 1669/*US
1664#ifndef KAB_NOSPLITTER 1670#ifndef KAB_NOSPLITTER
1665 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1671 QHBoxLayout *topLayout = new QHBoxLayout( this );
1666//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1672//US topLayout->setSpacing( KDialogBase::spacingHint() );
1667 topLayout->setSpacing( 10 ); 1673 topLayout->setSpacing( 10 );
1668 1674
1669 mDetailsSplitter = new QSplitter( this ); 1675 mDetailsSplitter = new QSplitter( this );
1670 1676
1671 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1677 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1672 1678
1673 mViewManager = new ViewManager( this, viewSpace ); 1679 mViewManager = new ViewManager( this, viewSpace );
1674 viewSpace->setStretchFactor( mViewManager, 1 ); 1680 viewSpace->setStretchFactor( mViewManager, 1 );
1675 1681
1676 mDetails = new ViewContainer( mDetailsSplitter ); 1682 mDetails = new ViewContainer( mDetailsSplitter );
1677 1683
1678 topLayout->addWidget( mDetailsSplitter ); 1684 topLayout->addWidget( mDetailsSplitter );
1679 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1685 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1680#else //KAB_NOSPLITTER 1686#else //KAB_NOSPLITTER
1681 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1687 QHBoxLayout *topLayout = new QHBoxLayout( this );
1682//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1688//US topLayout->setSpacing( KDialogBase::spacingHint() );
1683 topLayout->setSpacing( 10 ); 1689 topLayout->setSpacing( 10 );
1684 1690
1685// mDetailsSplitter = new QSplitter( this ); 1691// mDetailsSplitter = new QSplitter( this );
1686 1692
1687 QVBox *viewSpace = new QVBox( this ); 1693 QVBox *viewSpace = new QVBox( this );
1688 1694
1689 mViewManager = new ViewManager( this, viewSpace ); 1695 mViewManager = new ViewManager( this, viewSpace );
1690 viewSpace->setStretchFactor( mViewManager, 1 ); 1696 viewSpace->setStretchFactor( mViewManager, 1 );
1691 1697
1692 mDetails = new ViewContainer( this ); 1698 mDetails = new ViewContainer( this );
1693 1699
1694 topLayout->addWidget( viewSpace ); 1700 topLayout->addWidget( viewSpace );
1695// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1701// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1696 topLayout->addWidget( mDetails ); 1702 topLayout->addWidget( mDetails );
1697#endif //KAB_NOSPLITTER 1703#endif //KAB_NOSPLITTER
1698*/ 1704*/
1699 1705
1700 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1706 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1701 syncManager->setBlockSave(false); 1707 syncManager->setBlockSave(false);
1702 1708
1703 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1709 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1704 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1710 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1705 syncManager->setDefaultFileName( sentSyncFile()); 1711 syncManager->setDefaultFileName( sentSyncFile());
1706 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1712 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1707 1713
1708#endif //KAB_EMBEDDED 1714#endif //KAB_EMBEDDED
1709 initActions(); 1715 initActions();
1710 1716
1711#ifdef KAB_EMBEDDED 1717#ifdef KAB_EMBEDDED
1712 addActionsManually(); 1718 addActionsManually();
1713 //US make sure the export and import menues are initialized before creating the xxPortManager. 1719 //US make sure the export and import menues are initialized before creating the xxPortManager.
1714 mXXPortManager = new XXPortManager( this, this ); 1720 mXXPortManager = new XXPortManager( this, this );
1715 1721
1716 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1722 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1717 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1723 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1718 // mActionQuit->plug ( mMainWindow->toolBar()); 1724 // mActionQuit->plug ( mMainWindow->toolBar());
1719 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1725 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1720 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1726 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1721 // mIncSearchWidget->hide(); 1727 // mIncSearchWidget->hide();
1722 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1728 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1723 SLOT( incrementalSearch( const QString& ) ) ); 1729 SLOT( incrementalSearch( const QString& ) ) );
1724 1730
1725 1731
1726 mJumpButtonBar = new JumpButtonBar( this, this ); 1732 mJumpButtonBar = new JumpButtonBar( this, this );
1727 1733
1728 topLayout->addWidget( mJumpButtonBar ); 1734 topLayout->addWidget( mJumpButtonBar );
1729//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1735//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1730 1736
1731// mMainWindow->getIconToolBar()->raise(); 1737// mMainWindow->getIconToolBar()->raise();
1732 1738
1733#endif //KAB_EMBEDDED 1739#endif //KAB_EMBEDDED
1734 1740
1735} 1741}
1736void KABCore::initActions() 1742void KABCore::initActions()
1737{ 1743{
1738//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1744//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1739 1745
1740#ifndef KAB_EMBEDDED 1746#ifndef KAB_EMBEDDED
1741 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1747 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1742 SLOT( clipboardDataChanged() ) ); 1748 SLOT( clipboardDataChanged() ) );
1743#endif //KAB_EMBEDDED 1749#endif //KAB_EMBEDDED
1744 1750
1745 // file menu 1751 // file menu
1746 if ( mIsPart ) { 1752 if ( mIsPart ) {
1747 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1753 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1748 SLOT( sendMail() ), actionCollection(), 1754 SLOT( sendMail() ), actionCollection(),
1749 "kaddressbook_mail" ); 1755 "kaddressbook_mail" );
1750 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1756 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1751 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1757 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1752 1758
1753 } else { 1759 } else {
1754 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1760 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1755 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1761 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1756 } 1762 }
1757 1763
1758 1764
1759 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1765 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1760 SLOT( save() ), actionCollection(), "file_sync" ); 1766 SLOT( save() ), actionCollection(), "file_sync" );
1761 1767
1762 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1768 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1763 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1769 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1764 1770
1765 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1771 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1766 this, SLOT( mailVCard() ), 1772 this, SLOT( mailVCard() ),
1767 actionCollection(), "file_mail_vcard"); 1773 actionCollection(), "file_mail_vcard");
1768 1774
1769 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1775 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1770 SLOT( export2phone() ), actionCollection(), 1776 SLOT( export2phone() ), actionCollection(),
1771 "kaddressbook_ex2phone" ); 1777 "kaddressbook_ex2phone" );
1772 1778
1773 mActionBeamVCard = 0; 1779 mActionBeamVCard = 0;
1774 mActionBeam = 0; 1780 mActionBeam = 0;
1775 1781
1776#ifndef DESKTOP_VERSION 1782#ifndef DESKTOP_VERSION
1777 if ( Ir::supported() ) { 1783 if ( Ir::supported() ) {
1778 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1784 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1779 SLOT( beamVCard() ), actionCollection(), 1785 SLOT( beamVCard() ), actionCollection(),
1780 "kaddressbook_beam_vcard" ); 1786 "kaddressbook_beam_vcard" );
1781 1787
1782 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1788 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1783 SLOT( beamMySelf() ), actionCollection(), 1789 SLOT( beamMySelf() ), actionCollection(),
1784 "kaddressbook_beam_myself" ); 1790 "kaddressbook_beam_myself" );
1785 } 1791 }
1786#endif 1792#endif
1787 1793
1788 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1794 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1789 this, SLOT( editContact2() ), 1795 this, SLOT( editContact2() ),
1790 actionCollection(), "file_properties" ); 1796 actionCollection(), "file_properties" );
1791 1797
1792#ifdef KAB_EMBEDDED 1798#ifdef KAB_EMBEDDED
1793 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1799 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1794 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1800 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1795 mMainWindow, SLOT( exit() ), 1801 mMainWindow, SLOT( exit() ),
1796 actionCollection(), "quit" ); 1802 actionCollection(), "quit" );
1797#endif //KAB_EMBEDDED 1803#endif //KAB_EMBEDDED
1798 1804
1799 // edit menu 1805 // edit menu
1800 if ( mIsPart ) { 1806 if ( mIsPart ) {
1801 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1807 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1802 SLOT( copyContacts() ), actionCollection(), 1808 SLOT( copyContacts() ), actionCollection(),
1803 "kaddressbook_copy" ); 1809 "kaddressbook_copy" );
1804 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1810 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1805 SLOT( cutContacts() ), actionCollection(), 1811 SLOT( cutContacts() ), actionCollection(),
1806 "kaddressbook_cut" ); 1812 "kaddressbook_cut" );
1807 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1813 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1808 SLOT( pasteContacts() ), actionCollection(), 1814 SLOT( pasteContacts() ), actionCollection(),
1809 "kaddressbook_paste" ); 1815 "kaddressbook_paste" );
1810 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1816 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1811 SLOT( selectAllContacts() ), actionCollection(), 1817 SLOT( selectAllContacts() ), actionCollection(),
1812 "kaddressbook_select_all" ); 1818 "kaddressbook_select_all" );
1813 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1819 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1814 SLOT( undo() ), actionCollection(), 1820 SLOT( undo() ), actionCollection(),
1815 "kaddressbook_undo" ); 1821 "kaddressbook_undo" );
1816 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1822 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1817 this, SLOT( redo() ), actionCollection(), 1823 this, SLOT( redo() ), actionCollection(),
1818 "kaddressbook_redo" ); 1824 "kaddressbook_redo" );
1819 } else { 1825 } else {
1820 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1826 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1821 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1827 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1822 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1828 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1823 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1829 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1824 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1830 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1825 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1831 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1826 } 1832 }
1827 1833
1828 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1834 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1829 Key_Delete, this, SLOT( deleteContacts() ), 1835 Key_Delete, this, SLOT( deleteContacts() ),
1830 actionCollection(), "edit_delete" ); 1836 actionCollection(), "edit_delete" );
1831 1837
1832 mActionUndo->setEnabled( false ); 1838 mActionUndo->setEnabled( false );
1833 mActionRedo->setEnabled( false ); 1839 mActionRedo->setEnabled( false );
1834 1840
1835 // settings menu 1841 // settings menu
1836#ifdef KAB_EMBEDDED 1842#ifdef KAB_EMBEDDED
1837//US special menuentry to configure the addressbook resources. On KDE 1843//US special menuentry to configure the addressbook resources. On KDE
1838// you do that through the control center !!! 1844// you do that through the control center !!!
1839 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1845 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1840 SLOT( configureResources() ), actionCollection(), 1846 SLOT( configureResources() ), actionCollection(),
1841 "kaddressbook_configure_resources" ); 1847 "kaddressbook_configure_resources" );
1842#endif //KAB_EMBEDDED 1848#endif //KAB_EMBEDDED
1843 1849
1844 if ( mIsPart ) { 1850 if ( mIsPart ) {
1845 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1851 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1846 SLOT( openConfigDialog() ), actionCollection(), 1852 SLOT( openConfigDialog() ), actionCollection(),
1847 "kaddressbook_configure" ); 1853 "kaddressbook_configure" );
1848 1854
1849 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1855 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1850 this, SLOT( configureKeyBindings() ), actionCollection(), 1856 this, SLOT( configureKeyBindings() ), actionCollection(),
1851 "kaddressbook_configure_shortcuts" ); 1857 "kaddressbook_configure_shortcuts" );
1852#ifdef KAB_EMBEDDED 1858#ifdef KAB_EMBEDDED
1853 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1859 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1854 mActionConfigureToolbars->setEnabled( false ); 1860 mActionConfigureToolbars->setEnabled( false );
1855#endif //KAB_EMBEDDED 1861#endif //KAB_EMBEDDED
1856 1862
1857 } else { 1863 } else {
1858 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1864 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1859 1865
1860 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1866 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1861 } 1867 }
1862 1868
1863 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1869 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1864 actionCollection(), "options_show_jump_bar" ); 1870 actionCollection(), "options_show_jump_bar" );
1865 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1871 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1866 1872
1867 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1873 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1868 actionCollection(), "options_show_details" ); 1874 actionCollection(), "options_show_details" );
1869 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1875 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1870 1876
1871 // misc 1877 // misc
1872 // only enable LDAP lookup if we can handle the protocol 1878 // only enable LDAP lookup if we can handle the protocol
1873#ifndef KAB_EMBEDDED 1879#ifndef KAB_EMBEDDED
1874 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1880 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1875 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1881 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1876 this, SLOT( openLDAPDialog() ), actionCollection(), 1882 this, SLOT( openLDAPDialog() ), actionCollection(),
1877 "ldap_lookup" ); 1883 "ldap_lookup" );
1878 } 1884 }
1879#else //KAB_EMBEDDED 1885#else //KAB_EMBEDDED
1880 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1886 //qDebug("KABCore::initActions() LDAP has to be implemented");
1881#endif //KAB_EMBEDDED 1887#endif //KAB_EMBEDDED
1882 1888
1883 1889
1884 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1890 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1885 SLOT( setWhoAmI() ), actionCollection(), 1891 SLOT( setWhoAmI() ), actionCollection(),
1886 "set_personal" ); 1892 "set_personal" );
1887 1893
1888 1894
1889 1895
1890 1896
1891 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1897 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1892 SLOT( setCategories() ), actionCollection(), 1898 SLOT( setCategories() ), actionCollection(),
1893 "edit_set_categories" ); 1899 "edit_set_categories" );
1894 1900
1895 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1901 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1896 SLOT( removeVoice() ), actionCollection(), 1902 SLOT( removeVoice() ), actionCollection(),
1897 "remove_voice" ); 1903 "remove_voice" );
1898 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1904 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1899 SLOT( importFromOL() ), actionCollection(), 1905 SLOT( importFromOL() ), actionCollection(),
1900 "import_OL" ); 1906 "import_OL" );
1901#ifdef KAB_EMBEDDED 1907#ifdef KAB_EMBEDDED
1902 mActionLicence = new KAction( i18n( "Licence" ), 0, 1908 mActionLicence = new KAction( i18n( "Licence" ), 0,
1903 this, SLOT( showLicence() ), actionCollection(), 1909 this, SLOT( showLicence() ), actionCollection(),
1904 "licence_about_data" ); 1910 "licence_about_data" );
1905 mActionFaq = new KAction( i18n( "Faq" ), 0, 1911 mActionFaq = new KAction( i18n( "Faq" ), 0,
1906 this, SLOT( faq() ), actionCollection(), 1912 this, SLOT( faq() ), actionCollection(),
1907 "faq_about_data" ); 1913 "faq_about_data" );
1908 1914
1909 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1915 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1910 this, SLOT( createAboutData() ), actionCollection(), 1916 this, SLOT( createAboutData() ), actionCollection(),
1911 "kaddressbook_about_data" ); 1917 "kaddressbook_about_data" );
1912#endif //KAB_EMBEDDED 1918#endif //KAB_EMBEDDED
1913 1919
1914 clipboardDataChanged(); 1920 clipboardDataChanged();
1915 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1921 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1916 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1922 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1917} 1923}
1918 1924
1919//US we need this function, to plug all actions into the correct menues. 1925//US we need this function, to plug all actions into the correct menues.
1920// KDE uses a XML format to plug the actions, but we work her without this overhead. 1926// KDE uses a XML format to plug the actions, but we work her without this overhead.
1921void KABCore::addActionsManually() 1927void KABCore::addActionsManually()
1922{ 1928{
1923//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1929//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1924 1930
1925#ifdef KAB_EMBEDDED 1931#ifdef KAB_EMBEDDED
1926 QPopupMenu *fileMenu = new QPopupMenu( this ); 1932 QPopupMenu *fileMenu = new QPopupMenu( this );
1927 QPopupMenu *editMenu = new QPopupMenu( this ); 1933 QPopupMenu *editMenu = new QPopupMenu( this );
1928 QPopupMenu *helpMenu = new QPopupMenu( this ); 1934 QPopupMenu *helpMenu = new QPopupMenu( this );
1929 1935
1930 KToolBar* tb = mMainWindow->toolBar(); 1936 KToolBar* tb = mMainWindow->toolBar();
1931 1937
1932#ifdef DESKTOP_VERSION 1938#ifdef DESKTOP_VERSION
1933 QMenuBar* mb = mMainWindow->menuBar(); 1939 QMenuBar* mb = mMainWindow->menuBar();
1934 1940
1935 //US setup menubar. 1941 //US setup menubar.
1936 //Disable the following block if you do not want to have a menubar. 1942 //Disable the following block if you do not want to have a menubar.
1937 mb->insertItem( "&File", fileMenu ); 1943 mb->insertItem( "&File", fileMenu );
1938 mb->insertItem( "&Edit", editMenu ); 1944 mb->insertItem( "&Edit", editMenu );
1939 mb->insertItem( "&View", viewMenu ); 1945 mb->insertItem( "&View", viewMenu );
1940 mb->insertItem( "&Settings", settingsMenu ); 1946 mb->insertItem( "&Settings", settingsMenu );
1941 mb->insertItem( i18n("Synchronize"), syncMenu ); 1947 mb->insertItem( i18n("Synchronize"), syncMenu );
1942 mb->insertItem( "&Change selected", changeMenu ); 1948 mb->insertItem( "&Change selected", changeMenu );
1943 mb->insertItem( "&Help", helpMenu ); 1949 mb->insertItem( "&Help", helpMenu );
1944 mIncSearchWidget = new IncSearchWidget( tb ); 1950 mIncSearchWidget = new IncSearchWidget( tb );
1945 // tb->insertWidget(-1, 0, mIncSearchWidget); 1951 // tb->insertWidget(-1, 0, mIncSearchWidget);
1946 1952
1947#else 1953#else
1948 //US setup toolbar 1954 //US setup toolbar
1949 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1955 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1950 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1956 QPopupMenu *popupBarTB = new QPopupMenu( this );
1951 menuBarTB->insertItem( "ME", popupBarTB); 1957 menuBarTB->insertItem( "ME", popupBarTB);
1952 tb->insertWidget(-1, 0, menuBarTB); 1958 tb->insertWidget(-1, 0, menuBarTB);
1953 mIncSearchWidget = new IncSearchWidget( tb ); 1959 mIncSearchWidget = new IncSearchWidget( tb );
1954 1960
1955 tb->enableMoving(false); 1961 tb->enableMoving(false);
1956 popupBarTB->insertItem( "&File", fileMenu ); 1962 popupBarTB->insertItem( "&File", fileMenu );
1957 popupBarTB->insertItem( "&Edit", editMenu ); 1963 popupBarTB->insertItem( "&Edit", editMenu );
1958 popupBarTB->insertItem( "&View", viewMenu ); 1964 popupBarTB->insertItem( "&View", viewMenu );
1959 popupBarTB->insertItem( "&Settings", settingsMenu ); 1965 popupBarTB->insertItem( "&Settings", settingsMenu );
1960 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1966 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1961 mViewManager->getFilterAction()->plug ( popupBarTB); 1967 mViewManager->getFilterAction()->plug ( popupBarTB);
1962 popupBarTB->insertItem( "&Change selected", changeMenu ); 1968 popupBarTB->insertItem( "&Change selected", changeMenu );
1963 popupBarTB->insertItem( "&Help", helpMenu ); 1969 popupBarTB->insertItem( "&Help", helpMenu );
1964 if (QApplication::desktop()->width() > 320 ) { 1970 if (QApplication::desktop()->width() > 320 ) {
1965 // mViewManager->getFilterAction()->plug ( tb); 1971 // mViewManager->getFilterAction()->plug ( tb);
1966 } 1972 }
1967#endif 1973#endif
1968 // mActionQuit->plug ( mMainWindow->toolBar()); 1974 // mActionQuit->plug ( mMainWindow->toolBar());
1969 1975
1970 1976
1971 1977
1972 //US Now connect the actions with the menue entries. 1978 //US Now connect the actions with the menue entries.
1973 mActionPrint->plug( fileMenu ); 1979 mActionPrint->plug( fileMenu );
1974 mActionMail->plug( fileMenu ); 1980 mActionMail->plug( fileMenu );
1975 fileMenu->insertSeparator(); 1981 fileMenu->insertSeparator();
1976 1982
1977 mActionNewContact->plug( fileMenu ); 1983 mActionNewContact->plug( fileMenu );
1978 mActionNewContact->plug( tb ); 1984 mActionNewContact->plug( tb );
1979 1985
1980 mActionEditAddressee->plug( fileMenu ); 1986 mActionEditAddressee->plug( fileMenu );
1981 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1987 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1982 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1988 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1983 mActionEditAddressee->plug( tb ); 1989 mActionEditAddressee->plug( tb );
1984 1990
1985 fileMenu->insertSeparator(); 1991 fileMenu->insertSeparator();
1986 mActionSave->plug( fileMenu ); 1992 mActionSave->plug( fileMenu );
1987 fileMenu->insertItem( "&Import", ImportMenu ); 1993 fileMenu->insertItem( "&Import", ImportMenu );
1988 fileMenu->insertItem( "&Export", ExportMenu ); 1994 fileMenu->insertItem( "&Export", ExportMenu );
1989 fileMenu->insertSeparator(); 1995 fileMenu->insertSeparator();
1990 mActionMailVCard->plug( fileMenu ); 1996 mActionMailVCard->plug( fileMenu );
1991#ifndef DESKTOP_VERSION 1997#ifndef DESKTOP_VERSION
1992 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1998 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1993 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1999 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1994#endif 2000#endif
1995 fileMenu->insertSeparator(); 2001 fileMenu->insertSeparator();
1996 mActionQuit->plug( fileMenu ); 2002 mActionQuit->plug( fileMenu );
1997#ifdef _WIN32_ 2003#ifdef _WIN32_
1998 mActionImportOL->plug( ImportMenu ); 2004 mActionImportOL->plug( ImportMenu );
1999#endif 2005#endif
2000 // edit menu 2006 // edit menu
2001 mActionUndo->plug( editMenu ); 2007 mActionUndo->plug( editMenu );
2002 mActionRedo->plug( editMenu ); 2008 mActionRedo->plug( editMenu );
2003 editMenu->insertSeparator(); 2009 editMenu->insertSeparator();
2004 mActionCut->plug( editMenu ); 2010 mActionCut->plug( editMenu );
2005 mActionCopy->plug( editMenu ); 2011 mActionCopy->plug( editMenu );
2006 mActionPaste->plug( editMenu ); 2012 mActionPaste->plug( editMenu );
2007 mActionDelete->plug( editMenu ); 2013 mActionDelete->plug( editMenu );
2008 editMenu->insertSeparator(); 2014 editMenu->insertSeparator();
2009 mActionSelectAll->plug( editMenu ); 2015 mActionSelectAll->plug( editMenu );
2010 2016
2011 mActionRemoveVoice->plug( changeMenu ); 2017 mActionRemoveVoice->plug( changeMenu );
2012 // settings menu 2018 // settings menu
2013//US special menuentry to configure the addressbook resources. On KDE 2019//US special menuentry to configure the addressbook resources. On KDE
2014// you do that through the control center !!! 2020// you do that through the control center !!!
2015 mActionConfigResources->plug( settingsMenu ); 2021 mActionConfigResources->plug( settingsMenu );
2016 settingsMenu->insertSeparator(); 2022 settingsMenu->insertSeparator();
2017 2023
2018 mActionConfigKAddressbook->plug( settingsMenu ); 2024 mActionConfigKAddressbook->plug( settingsMenu );
2019 2025
2020 if ( mIsPart ) { 2026 if ( mIsPart ) {
2021 mActionConfigShortcuts->plug( settingsMenu ); 2027 mActionConfigShortcuts->plug( settingsMenu );
2022 mActionConfigureToolbars->plug( settingsMenu ); 2028 mActionConfigureToolbars->plug( settingsMenu );
2023 2029
2024 } else { 2030 } else {
2025 mActionKeyBindings->plug( settingsMenu ); 2031 mActionKeyBindings->plug( settingsMenu );
2026 } 2032 }
2027 2033
2028 settingsMenu->insertSeparator(); 2034 settingsMenu->insertSeparator();
2029 2035
2030 mActionJumpBar->plug( settingsMenu ); 2036 mActionJumpBar->plug( settingsMenu );
2031 mActionDetails->plug( settingsMenu ); 2037 mActionDetails->plug( settingsMenu );
2032 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2038 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2033 mActionDetails->plug( tb ); 2039 mActionDetails->plug( tb );
2034 settingsMenu->insertSeparator(); 2040 settingsMenu->insertSeparator();
2035 2041
2036 mActionWhoAmI->plug( settingsMenu ); 2042 mActionWhoAmI->plug( settingsMenu );
2037 mActionCategories->plug( settingsMenu ); 2043 mActionCategories->plug( settingsMenu );
2038 2044
2039 mActionLicence->plug( helpMenu ); 2045 mActionLicence->plug( helpMenu );
2040 mActionFaq->plug( helpMenu ); 2046 mActionFaq->plug( helpMenu );
2041 mActionAboutKAddressbook->plug( helpMenu ); 2047 mActionAboutKAddressbook->plug( helpMenu );
2042 2048
2043 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2049 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2044 2050
2045 mActionSave->plug( tb ); 2051 mActionSave->plug( tb );
2046 mViewManager->getFilterAction()->plug ( tb); 2052 mViewManager->getFilterAction()->plug ( tb);
2047 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2053 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2048 mActionUndo->plug( tb ); 2054 mActionUndo->plug( tb );
2049 mActionDelete->plug( tb ); 2055 mActionDelete->plug( tb );
2050 mActionRedo->plug( tb ); 2056 mActionRedo->plug( tb );
2051 } 2057 }
2052 } 2058 }
2053 //mActionQuit->plug ( tb ); 2059 //mActionQuit->plug ( tb );
2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2060 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2055 2061
2056 //US link the searchwidget first to this. 2062 //US link the searchwidget first to this.
2057 // The real linkage to the toolbar happens later. 2063 // The real linkage to the toolbar happens later.
2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2064//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2059//US tb->insertItem( mIncSearchWidget ); 2065//US tb->insertItem( mIncSearchWidget );
2060/*US 2066/*US
2061 mIncSearchWidget = new IncSearchWidget( tb ); 2067 mIncSearchWidget = new IncSearchWidget( tb );
2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2068 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2063 SLOT( incrementalSearch( const QString& ) ) ); 2069 SLOT( incrementalSearch( const QString& ) ) );
2064 2070
2065 mJumpButtonBar = new JumpButtonBar( this, this ); 2071 mJumpButtonBar = new JumpButtonBar( this, this );
2066 2072
2067//US topLayout->addWidget( mJumpButtonBar ); 2073//US topLayout->addWidget( mJumpButtonBar );
2068 this->layout()->add( mJumpButtonBar ); 2074 this->layout()->add( mJumpButtonBar );
2069*/ 2075*/
2070 2076
2071#endif //KAB_EMBEDDED 2077#endif //KAB_EMBEDDED
2072 2078
2073 mActionExport2phone->plug( ExportMenu ); 2079 mActionExport2phone->plug( ExportMenu );
2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2080 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2075 syncManager->fillSyncMenu(); 2081 syncManager->fillSyncMenu();
2076 2082
2077} 2083}
2078void KABCore::showLicence() 2084void KABCore::showLicence()
2079{ 2085{
2080 KApplication::showLicence(); 2086 KApplication::showLicence();
2081} 2087}
2082void KABCore::removeVoice() 2088void KABCore::removeVoice()
2083{ 2089{
2084 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 ) 2090 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 )
2085 return; 2091 return;
2086 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2092 KABC::Addressee::List list = mViewManager->selectedAddressees();
2087 KABC::Addressee::List::Iterator it; 2093 KABC::Addressee::List::Iterator it;
2088 for ( it = list.begin(); it != list.end(); ++it ) { 2094 for ( it = list.begin(); it != list.end(); ++it ) {
2089 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 2095
2090 PhoneNumber::List::Iterator phoneIt; 2096 if ( (*it).removeVoice() )
2091 bool found = false;
2092 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
2093 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
2094 if ((*phoneIt).type() - PhoneNumber::Voice ) {
2095 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
2096 (*it).insertPhoneNumber( (*phoneIt) );
2097 found = true;
2098 }
2099 }
2100
2101 }
2102 if ( found )
2103 contactModified((*it) ); 2097 contactModified((*it) );
2104 } 2098 }
2105} 2099}
2106 2100
2107 2101
2108 2102
2109void KABCore::clipboardDataChanged() 2103void KABCore::clipboardDataChanged()
2110{ 2104{
2111 2105
2112 if ( mReadWrite ) 2106 if ( mReadWrite )
2113 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2107 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2114 2108
2115} 2109}
2116 2110
2117void KABCore::updateActionMenu() 2111void KABCore::updateActionMenu()
2118{ 2112{
2119 UndoStack *undo = UndoStack::instance(); 2113 UndoStack *undo = UndoStack::instance();
2120 RedoStack *redo = RedoStack::instance(); 2114 RedoStack *redo = RedoStack::instance();
2121 2115
2122 if ( undo->isEmpty() ) 2116 if ( undo->isEmpty() )
2123 mActionUndo->setText( i18n( "Undo" ) ); 2117 mActionUndo->setText( i18n( "Undo" ) );
2124 else 2118 else
2125 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2119 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2126 2120
2127 mActionUndo->setEnabled( !undo->isEmpty() ); 2121 mActionUndo->setEnabled( !undo->isEmpty() );
2128 2122
2129 if ( !redo->top() ) 2123 if ( !redo->top() )
2130 mActionRedo->setText( i18n( "Redo" ) ); 2124 mActionRedo->setText( i18n( "Redo" ) );
2131 else 2125 else
2132 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2126 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2133 2127
2134 mActionRedo->setEnabled( !redo->isEmpty() ); 2128 mActionRedo->setEnabled( !redo->isEmpty() );
2135} 2129}
2136 2130
2137void KABCore::configureKeyBindings() 2131void KABCore::configureKeyBindings()
2138{ 2132{
2139#ifndef KAB_EMBEDDED 2133#ifndef KAB_EMBEDDED
2140 KKeyDialog::configure( actionCollection(), true ); 2134 KKeyDialog::configure( actionCollection(), true );
2141#else //KAB_EMBEDDED 2135#else //KAB_EMBEDDED
2142 qDebug("KABCore::configureKeyBindings() not implemented"); 2136 qDebug("KABCore::configureKeyBindings() not implemented");
2143#endif //KAB_EMBEDDED 2137#endif //KAB_EMBEDDED
2144} 2138}
2145 2139
2146#ifdef KAB_EMBEDDED 2140#ifdef KAB_EMBEDDED
2147void KABCore::configureResources() 2141void KABCore::configureResources()
2148{ 2142{
2149 KRES::KCMKResources dlg( this, "" , 0 ); 2143 KRES::KCMKResources dlg( this, "" , 0 );
2150 2144
2151 if ( !dlg.exec() ) 2145 if ( !dlg.exec() )
2152 return; 2146 return;
2153 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2147 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2154} 2148}
2155#endif //KAB_EMBEDDED 2149#endif //KAB_EMBEDDED
2156 2150
2157 2151
2158/* this method will be called through the QCop interface from Ko/Pi to select addresses 2152/* this method will be called through the QCop interface from Ko/Pi to select addresses
2159 * for the attendees list of an event. 2153 * for the attendees list of an event.
2160 */ 2154 */
2161void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2155void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2162{ 2156{
2163 QStringList nameList; 2157 QStringList nameList;
2164 QStringList emailList; 2158 QStringList emailList;
2165 QStringList uidList; 2159 QStringList uidList;
2166 2160
2167 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2161 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2168 uint i=0; 2162 uint i=0;
2169 for (i=0; i < list.count(); i++) 2163 for (i=0; i < list.count(); i++)
2170 { 2164 {
2171 nameList.append(list[i].realName()); 2165 nameList.append(list[i].realName());
2172 emailList.append(list[i].preferredEmail()); 2166 emailList.append(list[i].preferredEmail());
2173 uidList.append(list[i].uid()); 2167 uidList.append(list[i].uid());
2174 } 2168 }
2175 2169
2176 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2170 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2177 2171
2178} 2172}
2179 2173
2180/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2174/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2181 * to put them into the calendar. 2175 * to put them into the calendar.
2182 */ 2176 */
2183void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2177void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2184{ 2178{
2185 // qDebug("KABCore::requestForBirthdayList"); 2179 // qDebug("KABCore::requestForBirthdayList");
2186 QStringList birthdayList; 2180 QStringList birthdayList;
2187 QStringList anniversaryList; 2181 QStringList anniversaryList;
2188 QStringList realNameList; 2182 QStringList realNameList;
2189 QStringList preferredEmailList; 2183 QStringList preferredEmailList;
2190 QStringList assembledNameList; 2184 QStringList assembledNameList;
2191 QStringList uidList; 2185 QStringList uidList;
2192 2186
2193 KABC::AddressBook::Iterator it; 2187 KABC::AddressBook::Iterator it;
2194 2188
2195 int count = 0; 2189 int count = 0;
2196 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2190 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2197 ++count; 2191 ++count;
2198 } 2192 }
2199 QProgressBar bar(count,0 ); 2193 QProgressBar bar(count,0 );
2200 int w = 300; 2194 int w = 300;
2201 if ( QApplication::desktop()->width() < 320 ) 2195 if ( QApplication::desktop()->width() < 320 )
2202 w = 220; 2196 w = 220;
2203 int h = bar.sizeHint().height() ; 2197 int h = bar.sizeHint().height() ;
2204 int dw = QApplication::desktop()->width(); 2198 int dw = QApplication::desktop()->width();
2205 int dh = QApplication::desktop()->height(); 2199 int dh = QApplication::desktop()->height();
2206 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2200 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2207 bar.show(); 2201 bar.show();
2208 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2202 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2209 qApp->processEvents(); 2203 qApp->processEvents();
2210 2204
2211 QDate bday; 2205 QDate bday;
2212 QString anni; 2206 QString anni;
2213 QString formattedbday; 2207 QString formattedbday;
2214 2208
2215 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2209 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2216 { 2210 {
2217 if ( ! bar.isVisible() ) 2211 if ( ! bar.isVisible() )
2218 return; 2212 return;
2219 bar.setProgress( count++ ); 2213 bar.setProgress( count++ );
2220 qApp->processEvents(); 2214 qApp->processEvents();
2221 bday = (*it).birthday().date(); 2215 bday = (*it).birthday().date();
2222 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2216 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2223 2217
2224 if ( bday.isValid() || !anni.isEmpty()) 2218 if ( bday.isValid() || !anni.isEmpty())
2225 { 2219 {
2226 if (bday.isValid()) 2220 if (bday.isValid())
2227 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2221 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2228 else 2222 else
2229 formattedbday = "NOTVALID"; 2223 formattedbday = "NOTVALID";
2230 if (anni.isEmpty()) 2224 if (anni.isEmpty())
2231 anni = "INVALID"; 2225 anni = "INVALID";
2232 2226
2233 birthdayList.append(formattedbday); 2227 birthdayList.append(formattedbday);
2234 anniversaryList.append(anni); //should be ISODate 2228 anniversaryList.append(anni); //should be ISODate
2235 realNameList.append((*it).realName()); 2229 realNameList.append((*it).realName());
2236 preferredEmailList.append((*it).preferredEmail()); 2230 preferredEmailList.append((*it).preferredEmail());
2237 assembledNameList.append((*it).assembledName()); 2231 assembledNameList.append((*it).assembledName());
2238 uidList.append((*it).uid()); 2232 uidList.append((*it).uid());
2239 2233
2240 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() ); 2234 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() );
2241 } 2235 }
2242 } 2236 }
2243 2237
2244 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2238 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2245 2239
2246} 2240}
2247 2241
2248/* this method will be called through the QCop interface from other apps to show details of a contact. 2242/* this method will be called through the QCop interface from other apps to show details of a contact.
2249 */ 2243 */
2250void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2244void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2251{ 2245{
2252 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2246 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2253 2247
2254 QString foundUid = QString::null; 2248 QString foundUid = QString::null;
2255 if ( ! uid.isEmpty() ) { 2249 if ( ! uid.isEmpty() ) {
2256 Addressee adrr = mAddressBook->findByUid( uid ); 2250 Addressee adrr = mAddressBook->findByUid( uid );
2257 if ( !adrr.isEmpty() ) { 2251 if ( !adrr.isEmpty() ) {
2258 foundUid = uid; 2252 foundUid = uid;
2259 } 2253 }
2260 if ( email == "sendbacklist" ) { 2254 if ( email == "sendbacklist" ) {
2261 //qDebug("ssssssssssssssssssssssend "); 2255 //qDebug("ssssssssssssssssssssssend ");
2262 QStringList nameList; 2256 QStringList nameList;
2263 QStringList emailList; 2257 QStringList emailList;
2264 QStringList uidList; 2258 QStringList uidList;
2265 nameList.append(adrr.realName()); 2259 nameList.append(adrr.realName());
2266 emailList = adrr.emails(); 2260 emailList = adrr.emails();
2267 uidList.append( adrr.preferredEmail()); 2261 uidList.append( adrr.preferredEmail());
2268 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2262 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2269 return; 2263 return;
2270 } 2264 }
2271 2265
2272 } 2266 }
2273 2267
2274 if ( email == "sendbacklist" ) 2268 if ( email == "sendbacklist" )
2275 return; 2269 return;
2276 if (foundUid.isEmpty()) 2270 if (foundUid.isEmpty())
2277 { 2271 {
2278 //find the uid of the person first 2272 //find the uid of the person first
2279 Addressee::List namelist; 2273 Addressee::List namelist;
2280 Addressee::List emaillist; 2274 Addressee::List emaillist;
2281 2275
2282 if (!name.isEmpty()) 2276 if (!name.isEmpty())
2283 namelist = mAddressBook->findByName( name ); 2277 namelist = mAddressBook->findByName( name );
2284 2278
2285 if (!email.isEmpty()) 2279 if (!email.isEmpty())
2286 emaillist = mAddressBook->findByEmail( email ); 2280 emaillist = mAddressBook->findByEmail( email );
2287 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2281 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2288 //check if we have a match in Namelist and Emaillist 2282 //check if we have a match in Namelist and Emaillist
2289 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2283 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2290 foundUid = emaillist[0].uid(); 2284 foundUid = emaillist[0].uid();
2291 } 2285 }
2292 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2286 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2293 foundUid = namelist[0].uid(); 2287 foundUid = namelist[0].uid();
2294 else 2288 else
2295 { 2289 {
2296 for (int i = 0; i < namelist.count(); i++) 2290 for (int i = 0; i < namelist.count(); i++)
2297 { 2291 {
2298 for (int j = 0; j < emaillist.count(); j++) 2292 for (int j = 0; j < emaillist.count(); j++)
2299 { 2293 {
2300 if (namelist[i] == emaillist[j]) 2294 if (namelist[i] == emaillist[j])
2301 { 2295 {
2302 foundUid = namelist[i].uid(); 2296 foundUid = namelist[i].uid();
2303 } 2297 }
2304 } 2298 }
2305 } 2299 }
2306 } 2300 }
2307 } 2301 }
2308 else 2302 else
2309 { 2303 {
2310 foundUid = uid; 2304 foundUid = uid;
2311 } 2305 }
2312 2306
2313 if (!foundUid.isEmpty()) 2307 if (!foundUid.isEmpty())
2314 { 2308 {
2315 2309
2316 // raise Ka/Pi if it is in the background 2310 // raise Ka/Pi if it is in the background
2317#ifndef DESKTOP_VERSION 2311#ifndef DESKTOP_VERSION
2318#ifndef KORG_NODCOP 2312#ifndef KORG_NODCOP
2319 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2313 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2320#endif 2314#endif
2321#endif 2315#endif
2322 2316
2323 mMainWindow->showMaximized(); 2317 mMainWindow->showMaximized();
2324 mMainWindow-> raise(); 2318 mMainWindow-> raise();
2325 2319
2326 mViewManager->setSelected( "", false); 2320 mViewManager->setSelected( "", false);
2327 mViewManager->refreshView( "" ); 2321 mViewManager->refreshView( "" );
2328 mViewManager->setSelected( foundUid, true ); 2322 mViewManager->setSelected( foundUid, true );
2329 mViewManager->refreshView( foundUid ); 2323 mViewManager->refreshView( foundUid );
2330 2324
2331 if ( !mMultipleViewsAtOnce ) 2325 if ( !mMultipleViewsAtOnce )
2332 { 2326 {
2333 setDetailsVisible( true ); 2327 setDetailsVisible( true );
2334 mActionDetails->setChecked(true); 2328 mActionDetails->setChecked(true);
2335 } 2329 }
2336 } 2330 }
2337} 2331}
2338 2332
2339 2333
2340void KABCore::faq() 2334void KABCore::faq()
2341{ 2335{
2342 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2336 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2343} 2337}
2344 2338
2345#include <libkcal/syncdefines.h> 2339#include <libkcal/syncdefines.h>
2346 2340
2347KABC::Addressee KABCore::getLastSyncAddressee() 2341KABC::Addressee KABCore::getLastSyncAddressee()
2348{ 2342{
2349 Addressee lse; 2343 Addressee lse;
2350 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2344 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2351 2345
2352 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2346 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2353 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2347 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2354 if (lse.isEmpty()) { 2348 if (lse.isEmpty()) {
2355 qDebug("Creating new last-syncAddressee "); 2349 qDebug("Creating new last-syncAddressee ");
2356 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2350 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2357 QString sum = ""; 2351 QString sum = "";
2358 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2352 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2359 sum = "E: "; 2353 sum = "E: ";
2360 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2354 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2361 lse.setRevision( mLastAddressbookSync ); 2355 lse.setRevision( mLastAddressbookSync );
2362 lse.setCategories( i18n("SyncEvent") ); 2356 lse.setCategories( i18n("SyncEvent") );
2363 mAddressBook->insertAddressee( lse ); 2357 mAddressBook->insertAddressee( lse );
2364 } 2358 }
2365 return lse; 2359 return lse;
2366} 2360}
2367int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2361int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2368{ 2362{
2369 2363
2370 //void setZaurusId(int id); 2364 //void setZaurusId(int id);
2371 // int zaurusId() const; 2365 // int zaurusId() const;
2372 // void setZaurusUid(int id); 2366 // void setZaurusUid(int id);
2373 // int zaurusUid() const; 2367 // int zaurusUid() const;
2374 // void setZaurusStat(int id); 2368 // void setZaurusStat(int id);
2375 // int zaurusStat() const; 2369 // int zaurusStat() const;
2376 // 0 equal 2370 // 0 equal
2377 // 1 take local 2371 // 1 take local
2378 // 2 take remote 2372 // 2 take remote
2379 // 3 cancel 2373 // 3 cancel
2380 QDateTime lastSync = mLastAddressbookSync; 2374 QDateTime lastSync = mLastAddressbookSync;
2381 QDateTime localMod = local->revision(); 2375 QDateTime localMod = local->revision();
2382 QDateTime remoteMod = remote->revision(); 2376 QDateTime remoteMod = remote->revision();
2383 2377
2384 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2378 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2385 2379
2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2380 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2387 bool remCh, locCh; 2381 bool remCh, locCh;
2388 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2382 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2389 2383
2390 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2384 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2391 locCh = ( localMod > mLastAddressbookSync ); 2385 locCh = ( localMod > mLastAddressbookSync );
2392 if ( !remCh && ! locCh ) { 2386 if ( !remCh && ! locCh ) {
2393 //qDebug("both not changed "); 2387 //qDebug("both not changed ");
2394 lastSync = localMod.addDays(1); 2388 lastSync = localMod.addDays(1);
2395 if ( mode <= SYNC_PREF_ASK ) 2389 if ( mode <= SYNC_PREF_ASK )
2396 return 0; 2390 return 0;
2397 } else { 2391 } else {
2398 if ( locCh ) { 2392 if ( locCh ) {
2399 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2393 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2400 lastSync = localMod.addDays( -1 ); 2394 lastSync = localMod.addDays( -1 );
2401 if ( !remCh ) 2395 if ( !remCh )
2402 remoteMod =( lastSync.addDays( -1 ) ); 2396 remoteMod =( lastSync.addDays( -1 ) );
2403 } else { 2397 } else {
2404 //qDebug(" not loc changed "); 2398 //qDebug(" not loc changed ");
2405 lastSync = localMod.addDays( 1 ); 2399 lastSync = localMod.addDays( 1 );
2406 if ( remCh ) 2400 if ( remCh )
2407 remoteMod =( lastSync.addDays( 1 ) ); 2401 remoteMod =( lastSync.addDays( 1 ) );
2408 2402
2409 } 2403 }
2410 } 2404 }
2411 full = true; 2405 full = true;
2412 if ( mode < SYNC_PREF_ASK ) 2406 if ( mode < SYNC_PREF_ASK )
2413 mode = SYNC_PREF_ASK; 2407 mode = SYNC_PREF_ASK;
2414 } else { 2408 } else {
2415 if ( localMod == remoteMod ) 2409 if ( localMod == remoteMod )
2416 return 0; 2410 return 0;
2417 2411
2418 } 2412 }
2419 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2413 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2420 2414
2421 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2415 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2422 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2416 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2423 //full = true; //debug only 2417 //full = true; //debug only
2424 if ( full ) { 2418 if ( full ) {
2425 bool equ = ( (*local) == (*remote) ); 2419 bool equ = ( (*local) == (*remote) );
2426 if ( equ ) { 2420 if ( equ ) {
2427 //qDebug("equal "); 2421 //qDebug("equal ");
2428 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2422 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2429 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2423 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2430 } 2424 }
2431 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2425 if ( mode < SYNC_PREF_FORCE_LOCAL )
2432 return 0; 2426 return 0;
2433 2427
2434 }//else //debug only 2428 }//else //debug only
2435 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2429 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2436 } 2430 }
2437 int result; 2431 int result;
2438 bool localIsNew; 2432 bool localIsNew;
2439 //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() ); 2433 //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() );
2440 2434
2441 if ( full && mode < SYNC_PREF_NEWEST ) 2435 if ( full && mode < SYNC_PREF_NEWEST )
2442 mode = SYNC_PREF_ASK; 2436 mode = SYNC_PREF_ASK;
2443 2437
2444 switch( mode ) { 2438 switch( mode ) {
2445 case SYNC_PREF_LOCAL: 2439 case SYNC_PREF_LOCAL:
2446 if ( lastSync > remoteMod ) 2440 if ( lastSync > remoteMod )
2447 return 1; 2441 return 1;
2448 if ( lastSync > localMod ) 2442 if ( lastSync > localMod )
2449 return 2; 2443 return 2;
2450 return 1; 2444 return 1;
2451 break; 2445 break;
2452 case SYNC_PREF_REMOTE: 2446 case SYNC_PREF_REMOTE:
2453 if ( lastSync > remoteMod ) 2447 if ( lastSync > remoteMod )
2454 return 1; 2448 return 1;
2455 if ( lastSync > localMod ) 2449 if ( lastSync > localMod )
2456 return 2; 2450 return 2;
2457 return 2; 2451 return 2;
2458 break; 2452 break;
2459 case SYNC_PREF_NEWEST: 2453 case SYNC_PREF_NEWEST:
2460 if ( localMod > remoteMod ) 2454 if ( localMod > remoteMod )
2461 return 1; 2455 return 1;
2462 else 2456 else
2463 return 2; 2457 return 2;
2464 break; 2458 break;
2465 case SYNC_PREF_ASK: 2459 case SYNC_PREF_ASK:
2466 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2460 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2467 if ( lastSync > remoteMod ) 2461 if ( lastSync > remoteMod )
2468 return 1; 2462 return 1;
2469 if ( lastSync > localMod ) 2463 if ( lastSync > localMod )
2470 return 2; 2464 return 2;
2471 localIsNew = localMod >= remoteMod; 2465 localIsNew = localMod >= remoteMod;
2472 //qDebug("conflict! ************************************** "); 2466 //qDebug("conflict! ************************************** ");
2473 { 2467 {
2474 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2468 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2475 result = acd.executeD(localIsNew); 2469 result = acd.executeD(localIsNew);
2476 return result; 2470 return result;
2477 } 2471 }
2478 break; 2472 break;
2479 case SYNC_PREF_FORCE_LOCAL: 2473 case SYNC_PREF_FORCE_LOCAL:
2480 return 1; 2474 return 1;
2481 break; 2475 break;
2482 case SYNC_PREF_FORCE_REMOTE: 2476 case SYNC_PREF_FORCE_REMOTE:
2483 return 2; 2477 return 2;
2484 break; 2478 break;
2485 2479
2486 default: 2480 default:
2487 // SYNC_PREF_TAKE_BOTH not implemented 2481 // SYNC_PREF_TAKE_BOTH not implemented
2488 break; 2482 break;
2489 } 2483 }
2490 return 0; 2484 return 0;
2491} 2485}
2492 2486
2493 2487
2494bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2488bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2495{ 2489{
2496 bool syncOK = true; 2490 bool syncOK = true;
2497 int addedAddressee = 0; 2491 int addedAddressee = 0;
2498 int addedAddresseeR = 0; 2492 int addedAddresseeR = 0;
2499 int deletedAddresseeR = 0; 2493 int deletedAddresseeR = 0;
2500 int deletedAddresseeL = 0; 2494 int deletedAddresseeL = 0;
2501 int changedLocal = 0; 2495 int changedLocal = 0;
2502 int changedRemote = 0; 2496 int changedRemote = 0;
2503 2497
2504 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2498 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2505 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2499 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2506 2500
2507 //QPtrList<Addressee> el = local->rawAddressees(); 2501 //QPtrList<Addressee> el = local->rawAddressees();
2508 Addressee addresseeR; 2502 Addressee addresseeR;
2509 QString uid; 2503 QString uid;
2510 int take; 2504 int take;
2511 Addressee addresseeL; 2505 Addressee addresseeL;
2512 Addressee addresseeRSync; 2506 Addressee addresseeRSync;
2513 Addressee addresseeLSync; 2507 Addressee addresseeLSync;
2514 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2508 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2515 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2509 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2516 bool fullDateRange = false; 2510 bool fullDateRange = false;
2517 local->resetTempSyncStat(); 2511 local->resetTempSyncStat();
2518 mLastAddressbookSync = QDateTime::currentDateTime(); 2512 mLastAddressbookSync = QDateTime::currentDateTime();
2519 QDateTime modifiedCalendar = mLastAddressbookSync;; 2513 QDateTime modifiedCalendar = mLastAddressbookSync;;
2520 addresseeLSync = getLastSyncAddressee(); 2514 addresseeLSync = getLastSyncAddressee();
2521 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2515 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2522 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2516 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2523 if ( !addresseeR.isEmpty() ) { 2517 if ( !addresseeR.isEmpty() ) {
2524 addresseeRSync = addresseeR; 2518 addresseeRSync = addresseeR;
2525 remote->removeAddressee(addresseeR ); 2519 remote->removeAddressee(addresseeR );
2526 2520
2527 } else { 2521 } else {
2528 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2522 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2529 addresseeRSync = addresseeLSync ; 2523 addresseeRSync = addresseeLSync ;
2530 } else { 2524 } else {
2531 qDebug("FULLDATE 1"); 2525 qDebug("FULLDATE 1");
2532 fullDateRange = true; 2526 fullDateRange = true;
2533 Addressee newAdd; 2527 Addressee newAdd;
2534 addresseeRSync = newAdd; 2528 addresseeRSync = newAdd;
2535 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2529 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2536 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2530 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2537 addresseeRSync.setRevision( mLastAddressbookSync ); 2531 addresseeRSync.setRevision( mLastAddressbookSync );
2538 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2532 addresseeRSync.setCategories( i18n("SyncAddressee") );
2539 } 2533 }
2540 } 2534 }
2541 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2535 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2542 qDebug("FULLDATE 2"); 2536 qDebug("FULLDATE 2");
2543 fullDateRange = true; 2537 fullDateRange = true;
2544 } 2538 }
2545 if ( ! fullDateRange ) { 2539 if ( ! fullDateRange ) {
2546 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2540 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2547 2541
2548 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2542 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2549 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2543 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2550 fullDateRange = true; 2544 fullDateRange = true;
2551 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2545 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2552 } 2546 }
2553 } 2547 }
2554 // fullDateRange = true; // debug only! 2548 // fullDateRange = true; // debug only!
2555 if ( fullDateRange ) 2549 if ( fullDateRange )
2556 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2550 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2557 else 2551 else
2558 mLastAddressbookSync = addresseeLSync.revision(); 2552 mLastAddressbookSync = addresseeLSync.revision();
2559 // for resyncing if own file has changed 2553 // for resyncing if own file has changed
2560 // PENDING fixme later when implemented 2554 // PENDING fixme later when implemented
2561#if 0 2555#if 0
2562 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2556 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2563 mLastAddressbookSync = loadedFileVersion; 2557 mLastAddressbookSync = loadedFileVersion;
2564 qDebug("setting mLastAddressbookSync "); 2558 qDebug("setting mLastAddressbookSync ");
2565 } 2559 }
2566#endif 2560#endif
2567 2561
2568 //qDebug("*************************** "); 2562 //qDebug("*************************** ");
2569 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2563 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2570 QStringList er = remote->uidList(); 2564 QStringList er = remote->uidList();
2571 Addressee inR ;//= er.first(); 2565 Addressee inR ;//= er.first();
2572 Addressee inL; 2566 Addressee inL;
2573 2567
2574 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2568 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2575 2569
2576 int modulo = (er.count()/10)+1; 2570 int modulo = (er.count()/10)+1;
2577 int incCounter = 0; 2571 int incCounter = 0;
2578 while ( incCounter < er.count()) { 2572 while ( incCounter < er.count()) {
2579 if (syncManager->isProgressBarCanceled()) 2573 if (syncManager->isProgressBarCanceled())
2580 return false; 2574 return false;
2581 if ( incCounter % modulo == 0 ) 2575 if ( incCounter % modulo == 0 )
2582 syncManager->showProgressBar(incCounter); 2576 syncManager->showProgressBar(incCounter);
2583 2577
2584 uid = er[ incCounter ]; 2578 uid = er[ incCounter ];
2585 bool skipIncidence = false; 2579 bool skipIncidence = false;
2586 if ( uid.left(19) == QString("last-syncAddressee-") ) 2580 if ( uid.left(19) == QString("last-syncAddressee-") )
2587 skipIncidence = true; 2581 skipIncidence = true;
2588 QString idS,OidS; 2582 QString idS,OidS;
2589 qApp->processEvents(); 2583 qApp->processEvents();
2590 if ( !skipIncidence ) { 2584 if ( !skipIncidence ) {
2591 inL = local->findByUid( uid ); 2585 inL = local->findByUid( uid );
2592 inR = remote->findByUid( uid ); 2586 inR = remote->findByUid( uid );
2593 //inL.setResource( 0 ); 2587 //inL.setResource( 0 );
2594 //inR.setResource( 0 ); 2588 //inR.setResource( 0 );
2595 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2589 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2596 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2590 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2597 //qDebug("take %d %s ", take, inL.summary().latin1()); 2591 //qDebug("take %d %s ", take, inL.summary().latin1());
2598 if ( take == 3 ) 2592 if ( take == 3 )
2599 return false; 2593 return false;
2600 if ( take == 1 ) {// take local 2594 if ( take == 1 ) {// take local
2601 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2595 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2602 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2596 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2603 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2597 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2604 local->insertAddressee( inL, false ); 2598 local->insertAddressee( inL, false );
2605 idS = inR.externalUID(); 2599 idS = inR.externalUID();
2606 OidS = inR.originalExternalUID(); 2600 OidS = inR.originalExternalUID();
2607 } 2601 }
2608 else 2602 else
2609 idS = inR.IDStr(); 2603 idS = inR.IDStr();
2610 remote->removeAddressee( inR ); 2604 remote->removeAddressee( inR );
2611 inR = inL; 2605 inR = inL;
2612 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2606 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2613 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2607 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2614 inR.setOriginalExternalUID( OidS ); 2608 inR.setOriginalExternalUID( OidS );
2615 inR.setExternalUID( idS ); 2609 inR.setExternalUID( idS );
2616 } else { 2610 } else {
2617 inR.setIDStr( idS ); 2611 inR.setIDStr( idS );
2618 } 2612 }
2619 inR.setResource( 0 ); 2613 inR.setResource( 0 );
2620 remote->insertAddressee( inR , false); 2614 remote->insertAddressee( inR , false);
2621 ++changedRemote; 2615 ++changedRemote;
2622 } else { // take == 2 take remote 2616 } else { // take == 2 take remote
2623 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2617 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2624 if ( inR.revision().date().year() < 2004 ) 2618 if ( inR.revision().date().year() < 2004 )
2625 inR.setRevision( modifiedCalendar ); 2619 inR.setRevision( modifiedCalendar );
2626 } 2620 }
2627 idS = inL.IDStr(); 2621 idS = inL.IDStr();
2628 local->removeAddressee( inL ); 2622 local->removeAddressee( inL );
2629 inL = inR; 2623 inL = inR;
2630 inL.setIDStr( idS ); 2624 inL.setIDStr( idS );
2631 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2625 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2632 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2626 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2633 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2627 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2634 } 2628 }
2635 inL.setResource( 0 ); 2629 inL.setResource( 0 );
2636 local->insertAddressee( inL , false ); 2630 local->insertAddressee( inL , false );
2637 ++changedLocal; 2631 ++changedLocal;
2638 } 2632 }
2639 } 2633 }
2640 } else { // no conflict 2634 } else { // no conflict
2641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2635 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2642 QString des = addresseeLSync.note(); 2636 QString des = addresseeLSync.note();
2643 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2637 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2644 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2638 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2645 remote->insertAddressee( inR, false ); 2639 remote->insertAddressee( inR, false );
2646 ++deletedAddresseeR; 2640 ++deletedAddresseeR;
2647 } else { 2641 } else {
2648 inR.setRevision( modifiedCalendar ); 2642 inR.setRevision( modifiedCalendar );
2649 remote->insertAddressee( inR, false ); 2643 remote->insertAddressee( inR, false );
2650 inL = inR; 2644 inL = inR;
2651 inL.setResource( 0 ); 2645 inL.setResource( 0 );
2652 local->insertAddressee( inL , false); 2646 local->insertAddressee( inL , false);
2653 ++addedAddressee; 2647 ++addedAddressee;
2654 } 2648 }
2655 } else { 2649 } else {
2656 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2650 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2657 inR.setRevision( modifiedCalendar ); 2651 inR.setRevision( modifiedCalendar );
2658 remote->insertAddressee( inR, false ); 2652 remote->insertAddressee( inR, false );
2659 inR.setResource( 0 ); 2653 inR.setResource( 0 );
2660 local->insertAddressee( inR, false ); 2654 local->insertAddressee( inR, false );
2661 ++addedAddressee; 2655 ++addedAddressee;
2662 } else { 2656 } else {
2663 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2657 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2664 remote->removeAddressee( inR ); 2658 remote->removeAddressee( inR );
2665 ++deletedAddresseeR; 2659 ++deletedAddresseeR;
2666 } 2660 }
2667 } 2661 }
2668 } 2662 }
2669 } 2663 }
2670 ++incCounter; 2664 ++incCounter;
2671 } 2665 }
2672 er.clear(); 2666 er.clear();
2673 QStringList el = local->uidList(); 2667 QStringList el = local->uidList();
2674 modulo = (el.count()/10)+1; 2668 modulo = (el.count()/10)+1;
2675 2669
2676 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2670 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2677 incCounter = 0; 2671 incCounter = 0;
2678 while ( incCounter < el.count()) { 2672 while ( incCounter < el.count()) {
2679 qApp->processEvents(); 2673 qApp->processEvents();
2680 if (syncManager->isProgressBarCanceled()) 2674 if (syncManager->isProgressBarCanceled())
2681 return false; 2675 return false;
2682 if ( incCounter % modulo == 0 ) 2676 if ( incCounter % modulo == 0 )
2683 syncManager->showProgressBar(incCounter); 2677 syncManager->showProgressBar(incCounter);
2684 uid = el[ incCounter ]; 2678 uid = el[ incCounter ];
2685 bool skipIncidence = false; 2679 bool skipIncidence = false;
2686 if ( uid.left(19) == QString("last-syncAddressee-") ) 2680 if ( uid.left(19) == QString("last-syncAddressee-") )
2687 skipIncidence = true; 2681 skipIncidence = true;
2688 if ( !skipIncidence ) { 2682 if ( !skipIncidence ) {
2689 inL = local->findByUid( uid ); 2683 inL = local->findByUid( uid );
2690 inR = remote->findByUid( uid ); 2684 inR = remote->findByUid( uid );
2691 if ( inR.isEmpty() ) { 2685 if ( inR.isEmpty() ) {
2692 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2693 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2687 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2688 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2695 local->removeAddressee( inL ); 2689 local->removeAddressee( inL );
2696 ++deletedAddresseeL; 2690 ++deletedAddresseeL;
2697 } else { 2691 } else {
2698 if ( ! syncManager->mWriteBackExistingOnly ) { 2692 if ( ! syncManager->mWriteBackExistingOnly ) {
2699 inL.removeID(mCurrentSyncDevice ); 2693 inL.removeID(mCurrentSyncDevice );
2700 ++addedAddresseeR; 2694 ++addedAddresseeR;
2701 inL.setRevision( modifiedCalendar ); 2695 inL.setRevision( modifiedCalendar );
2702 local->insertAddressee( inL, false ); 2696 local->insertAddressee( inL, false );
2703 inR = inL; 2697 inR = inL;
2704 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2698 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2705 inR.setResource( 0 ); 2699 inR.setResource( 0 );
2706 remote->insertAddressee( inR, false ); 2700 remote->insertAddressee( inR, false );
2707 } 2701 }
2708 } 2702 }
2709 } else { 2703 } else {
2710 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2704 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2711 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2705 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2712 local->removeAddressee( inL ); 2706 local->removeAddressee( inL );
2713 ++deletedAddresseeL; 2707 ++deletedAddresseeL;
2714 } else { 2708 } else {
2715 if ( ! syncManager->mWriteBackExistingOnly ) { 2709 if ( ! syncManager->mWriteBackExistingOnly ) {
2716 ++addedAddresseeR; 2710 ++addedAddresseeR;
2717 inL.setRevision( modifiedCalendar ); 2711 inL.setRevision( modifiedCalendar );
2718 local->insertAddressee( inL, false ); 2712 local->insertAddressee( inL, false );
2719 inR = inL; 2713 inR = inL;
2720 inR.setResource( 0 ); 2714 inR.setResource( 0 );
2721 remote->insertAddressee( inR, false ); 2715 remote->insertAddressee( inR, false );
2722 } 2716 }
2723 } 2717 }
2724 } 2718 }
2725 } 2719 }
2726 } 2720 }
2727 ++incCounter; 2721 ++incCounter;
2728 } 2722 }
2729 el.clear(); 2723 el.clear();
2730 syncManager->hideProgressBar(); 2724 syncManager->hideProgressBar();
2731 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2725 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2732 // get rid of micro seconds 2726 // get rid of micro seconds
2733 QTime t = mLastAddressbookSync.time(); 2727 QTime t = mLastAddressbookSync.time();
2734 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2728 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2735 addresseeLSync.setRevision( mLastAddressbookSync ); 2729 addresseeLSync.setRevision( mLastAddressbookSync );
2736 addresseeRSync.setRevision( mLastAddressbookSync ); 2730 addresseeRSync.setRevision( mLastAddressbookSync );
2737 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2731 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2738 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2732 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2739 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2733 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2740 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2734 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2741 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2735 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2742 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2736 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2743 addresseeRSync.setNote( "" ) ; 2737 addresseeRSync.setNote( "" ) ;
2744 addresseeLSync.setNote( "" ); 2738 addresseeLSync.setNote( "" );
2745 2739
2746 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2740 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2747 remote->insertAddressee( addresseeRSync, false ); 2741 remote->insertAddressee( addresseeRSync, false );
2748 local->insertAddressee( addresseeLSync, false ); 2742 local->insertAddressee( addresseeLSync, false );
2749 QString mes; 2743 QString mes;
2750 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 ); 2744 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 );
2751 if ( syncManager->mShowSyncSummary ) { 2745 if ( syncManager->mShowSyncSummary ) {
2752 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2746 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2753 } 2747 }
2754 qDebug( mes ); 2748 qDebug( mes );
2755 return syncOK; 2749 return syncOK;
2756} 2750}
2757 2751
2758 2752
2759//this is a overwritten callbackmethods from the syncinterface 2753//this is a overwritten callbackmethods from the syncinterface
2760bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2754bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2761{ 2755{
2762 2756
2763 //pending prepare addresseeview for output 2757 //pending prepare addresseeview for output
2764 //pending detect, if remote file has REV field. if not switch to external sync 2758 //pending detect, if remote file has REV field. if not switch to external sync
2765 mGlobalSyncMode = SYNC_MODE_NORMAL; 2759 mGlobalSyncMode = SYNC_MODE_NORMAL;
2766 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2760 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2767 2761
2768 AddressBook abLocal(filename,"syncContact"); 2762 AddressBook abLocal(filename,"syncContact");
2769 bool syncOK = false; 2763 bool syncOK = false;
2770 if ( abLocal.load() ) { 2764 if ( abLocal.load() ) {
2771 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2765 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2772 bool external = false; 2766 bool external = false;
2773 bool isXML = false; 2767 bool isXML = false;
2774 if ( filename.right(4) == ".xml") { 2768 if ( filename.right(4) == ".xml") {
2775 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2769 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2776 isXML = true; 2770 isXML = true;
2777 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2771 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2778 } else { 2772 } else {
2779 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2773 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2780 if ( ! lse.isEmpty() ) { 2774 if ( ! lse.isEmpty() ) {
2781 if ( lse.familyName().left(4) == "!E: " ) 2775 if ( lse.familyName().left(4) == "!E: " )
2782 external = true; 2776 external = true;
2783 } else { 2777 } else {
2784 bool found = false; 2778 bool found = false;
2785 AddressBook::Iterator it; 2779 AddressBook::Iterator it;
2786 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2780 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2787 if ( (*it).revision().date().year() > 2003 ) { 2781 if ( (*it).revision().date().year() > 2003 ) {
2788 found = true; 2782 found = true;
2789 break; 2783 break;
2790 } 2784 }
2791 } 2785 }
2792 external = ! found; 2786 external = ! found;
2793 } 2787 }
2794 2788
2795 if ( external ) { 2789 if ( external ) {
2796 qDebug("Setting vcf mode to external "); 2790 qDebug("Setting vcf mode to external ");
2797 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2791 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2798 AddressBook::Iterator it; 2792 AddressBook::Iterator it;
2799 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2793 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2800 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2794 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2801 (*it).computeCsum( mCurrentSyncDevice ); 2795 (*it).computeCsum( mCurrentSyncDevice );
2802 } 2796 }
2803 } 2797 }
2804 } 2798 }
2805 //AddressBook::Iterator it; 2799 //AddressBook::Iterator it;
2806 //QStringList vcards; 2800 //QStringList vcards;
2807 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2801 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2808 // qDebug("Name %s ", (*it).familyName().latin1()); 2802 // qDebug("Name %s ", (*it).familyName().latin1());
2809 //} 2803 //}
2810 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2804 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2811 if ( syncOK ) { 2805 if ( syncOK ) {
2812 if ( syncManager->mWriteBackFile ) 2806 if ( syncManager->mWriteBackFile )
2813 { 2807 {
2814 if ( external ) 2808 if ( external )
2815 abLocal.removeSyncAddressees( !isXML); 2809 abLocal.removeSyncAddressees( !isXML);
2816 qDebug("Saving remote AB "); 2810 qDebug("Saving remote AB ");
2817 abLocal.saveAB(); 2811 abLocal.saveAB();
2818 if ( isXML ) { 2812 if ( isXML ) {
2819 // afterwrite processing 2813 // afterwrite processing
2820 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2814 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2821 } 2815 }
2822 } 2816 }
2823 } 2817 }
2824 setModified(); 2818 setModified();
2825 2819
2826 } 2820 }
2827 if ( syncOK ) 2821 if ( syncOK )
2828 mViewManager->refreshView(); 2822 mViewManager->refreshView();
2829 return syncOK; 2823 return syncOK;
2830#if 0 2824#if 0
2831 2825
2832 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2826 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2833 getEventViewerDialog()->setSyncMode( true ); 2827 getEventViewerDialog()->setSyncMode( true );
2834 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2828 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2835 getEventViewerDialog()->setSyncMode( false ); 2829 getEventViewerDialog()->setSyncMode( false );
2836 if ( syncOK ) { 2830 if ( syncOK ) {
2837 if ( KOPrefs::instance()->mWriteBackFile ) 2831 if ( KOPrefs::instance()->mWriteBackFile )
2838 { 2832 {
2839 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2833 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2840 storage->save(); 2834 storage->save();
2841 } 2835 }
2842 } 2836 }
2843 setModified(); 2837 setModified();
2844 } 2838 }
2845 2839
2846#endif 2840#endif
2847} 2841}
2848 2842
2849 2843
2850//this is a overwritten callbackmethods from the syncinterface 2844//this is a overwritten callbackmethods from the syncinterface
2851bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2845bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2852{ 2846{
2853 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2847 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2854 2848
2855 AddressBook abLocal( resource,"syncContact"); 2849 AddressBook abLocal( resource,"syncContact");
2856 bool syncOK = false; 2850 bool syncOK = false;
2857 if ( abLocal.load() ) { 2851 if ( abLocal.load() ) {
2858 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2852 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2859 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2853 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2860 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2854 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2861 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2855 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2862 if ( syncOK ) { 2856 if ( syncOK ) {
2863 if ( syncManager->mWriteBackFile ) { 2857 if ( syncManager->mWriteBackFile ) {
2864 abLocal.saveAB(); 2858 abLocal.saveAB();
2865 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2859 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2866 } 2860 }
2867 } 2861 }
2868 setModified(); 2862 setModified();
2869 } 2863 }
2870 if ( syncOK ) 2864 if ( syncOK )
2871 mViewManager->refreshView(); 2865 mViewManager->refreshView();
2872 return syncOK; 2866 return syncOK;
2873 2867
2874} 2868}
2875 2869
2876void KABCore::getFile( bool success ) 2870void KABCore::getFile( bool success )
2877{ 2871{
2878 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2872 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2879 if ( ! success ) { 2873 if ( ! success ) {
2880 setCaption( i18n("Error receiving file. Nothing changed!") ); 2874 setCaption( i18n("Error receiving file. Nothing changed!") );
2881 return; 2875 return;
2882 } 2876 }
2883 mAddressBook->importFromFile( sentSyncFile() ); 2877 mAddressBook->importFromFile( sentSyncFile() );
2884 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2878 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2885 mViewManager->refreshView(); 2879 mViewManager->refreshView();
2886} 2880}
2887void KABCore::syncFileRequest() 2881void KABCore::syncFileRequest()
2888{ 2882{
2889 mAddressBook->export2File( sentSyncFile() ); 2883 mAddressBook->export2File( sentSyncFile() );
2890} 2884}
2891QString KABCore::sentSyncFile() 2885QString KABCore::sentSyncFile()
2892{ 2886{
2893#ifdef _WIN32_ 2887#ifdef _WIN32_
2894 return locateLocal( "tmp", "copysyncab.vcf" ); 2888 return locateLocal( "tmp", "copysyncab.vcf" );
2895#else 2889#else
2896 return QString( "/tmp/copysyncab.vcf" ); 2890 return QString( "/tmp/copysyncab.vcf" );
2897#endif 2891#endif
2898} 2892}
2899 2893
2900void KABCore::setCaptionBack() 2894void KABCore::setCaptionBack()
2901{ 2895{
2902 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2896 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2903} 2897}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c628399..43c5f99 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,482 +1,483 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <ksyncmanager.h> 35#include <ksyncmanager.h>
36 36
37namespace KABC { 37namespace KABC {
38class AddressBook; 38class AddressBook;
39} 39}
40 40
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42class KAboutData; 42class KAboutData;
43class KConfig; 43class KConfig;
44 44
45class KAddressBookService; 45class KAddressBookService;
46class LDAPSearchDialog; 46class LDAPSearchDialog;
47#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
48class KAddressBookMain; 48class KAddressBookMain;
49//US class QAction; 49//US class QAction;
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51class KCMultiDialog; 51class KCMultiDialog;
52class KXMLGUIClient; 52class KXMLGUIClient;
53class ExtensionManager; 53class ExtensionManager;
54class XXPortManager; 54class XXPortManager;
55class JumpButtonBar; 55class JumpButtonBar;
56class IncSearchWidget; 56class IncSearchWidget;
57class KDGanttMinimizeSplitter; 57class KDGanttMinimizeSplitter;
58class KAction; 58class KAction;
59class KActionCollection; 59class KActionCollection;
60class KToggleAction; 60class KToggleAction;
61class KSyncProfile; 61class KSyncProfile;
62 62
63class QAction; 63class QAction;
64class QMenuBar; 64class QMenuBar;
65class QSplitter; 65class QSplitter;
66class ViewContainer; 66class ViewContainer;
67class ViewManager; 67class ViewManager;
68class AddresseeEditorDialog; 68class AddresseeEditorDialog;
69class Ir; 69class Ir;
70 70
71class KABCore : public QWidget, public KSyncInterface 71class KABCore : public QWidget, public KSyncInterface
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75 public: 75 public:
76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
77 77
78 78
79 ~KABCore(); 79 ~KABCore();
80 80
81 81
82#ifdef KAB_EMBEDDED 82#ifdef KAB_EMBEDDED
83 //US added functionality 83 //US added functionality
84 QPopupMenu* getViewMenu() {return viewMenu;} 84 QPopupMenu* getViewMenu() {return viewMenu;}
85 QPopupMenu* getFilterMenu() {return filterMenu;} 85 QPopupMenu* getFilterMenu() {return filterMenu;}
86 QPopupMenu* getSettingsMenu() {return settingsMenu;} 86 QPopupMenu* getSettingsMenu() {return settingsMenu;}
87 void addActionsManually(); 87 void addActionsManually();
88#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
89 /** 89 /**
90 Restores the global settings. 90 Restores the global settings.
91 */ 91 */
92 void restoreSettings(); 92 void restoreSettings();
93 93
94 /** 94 /**
95 Saves the global settings. 95 Saves the global settings.
96 */ 96 */
97 void saveSettings(); 97 void saveSettings();
98 98
99 /** 99 /**
100 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
101 */ 101 */
102 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
103 103
104 /** 104 /**
105 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
106 */ 106 */
107 static KConfig *config(); 107 static KConfig *config();
108 108
109 /** 109 /**
110 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 111 other classes can register their actions easily.
112 */ 112 */
113 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
114 114
115 /** 115 /**
116 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
117 */ 117 */
118 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
119 119
120 /** 120 /**
121 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
122 */ 122 */
123 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
124 124
125 /** 125 /**
126 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
128 the user. 128 the user.
129 */ 129 */
130 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
131 131
132#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 135
136#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141 public slots: 141 public slots:
142#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
143 void createAboutData(); 143 void createAboutData();
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
147 void showLicence(); 147 void showLicence();
148 void faq(); 148 void faq();
149 149
150 /** 150 /**
151 Is called whenever a contact is selected in the view. 151 Is called whenever a contact is selected in the view.
152 */ 152 */
153 void setContactSelected( const QString &uid ); 153 void setContactSelected( const QString &uid );
154 154
155 /** 155 /**
156 Opens the preferred mail composer with all selected contacts as 156 Opens the preferred mail composer with all selected contacts as
157 arguments. 157 arguments.
158 */ 158 */
159 void sendMail(); 159 void sendMail();
160 160
161 /** 161 /**
162 Opens the preferred mail composer with the given contacts as 162 Opens the preferred mail composer with the given contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail( const QString& email ); 165 void sendMail( const QString& email );
166 166
167 167
168 void mailVCard(); 168 void mailVCard();
169 void mailVCard(const QStringList& uids); 169 void mailVCard(const QStringList& uids);
170 170
171 /** 171 /**
172 Beams the "WhoAmI contact. 172 Beams the "WhoAmI contact.
173 */ 173 */
174 void beamMySelf(); 174 void beamMySelf();
175 175
176 void beamVCard(); 176 void beamVCard();
177 void export2phone(); 177 void export2phone();
178 void beamVCard(const QStringList& uids); 178 void beamVCard(const QStringList& uids);
179 void beamDone( Ir *ir ); 179 void beamDone( Ir *ir );
180 180
181 181
182 /** 182 /**
183 Starts the preferred web browser with the given URL as argument. 183 Starts the preferred web browser with the given URL as argument.
184 */ 184 */
185 void browse( const QString& url ); 185 void browse( const QString& url );
186 186
187 /** 187 /**
188 Select all contacts in the view. 188 Select all contacts in the view.
189 */ 189 */
190 void selectAllContacts(); 190 void selectAllContacts();
191 191
192 /** 192 /**
193 Deletes all selected contacts from the address book. 193 Deletes all selected contacts from the address book.
194 */ 194 */
195 void deleteContacts(); 195 void deleteContacts();
196 196
197 /** 197 /**
198 Deletes given contacts from the address book. 198 Deletes given contacts from the address book.
199 199
200 @param uids The uids of the contacts, which shall be deleted. 200 @param uids The uids of the contacts, which shall be deleted.
201 */ 201 */
202 void deleteContacts( const QStringList &uids ); 202 void deleteContacts( const QStringList &uids );
203 203
204 /** 204 /**
205 Copys the selected contacts into clipboard for later pasting. 205 Copys the selected contacts into clipboard for later pasting.
206 */ 206 */
207 void copyContacts(); 207 void copyContacts();
208 208
209 /** 209 /**
210 Cuts the selected contacts and stores them for later pasting. 210 Cuts the selected contacts and stores them for later pasting.
211 */ 211 */
212 void cutContacts(); 212 void cutContacts();
213 213
214 /** 214 /**
215 Paste contacts from clipboard into the address book. 215 Paste contacts from clipboard into the address book.
216 */ 216 */
217 void pasteContacts(); 217 void pasteContacts();
218 218
219 /** 219 /**
220 Paste given contacts into the address book. 220 Paste given contacts into the address book.
221 221
222 @param list The list of addressee, which shall be pasted. 222 @param list The list of addressee, which shall be pasted.
223 */ 223 */
224 void pasteContacts( KABC::Addressee::List &list ); 224 void pasteContacts( KABC::Addressee::List &list );
225 225
226 /** 226 /**
227 Sets the whoAmI contact, that is used by many other programs to 227 Sets the whoAmI contact, that is used by many other programs to
228 get personal information about the current user. 228 get personal information about the current user.
229 */ 229 */
230 void setWhoAmI(); 230 void setWhoAmI();
231 231
232 /** 232 /**
233 Displays the category dialog and applies the result to all 233 Displays the category dialog and applies the result to all
234 selected contacts. 234 selected contacts.
235 */ 235 */
236 void setCategories(); 236 void setCategories();
237 237
238 /** 238 /**
239 Sets the field list of the Incremental Search Widget. 239 Sets the field list of the Incremental Search Widget.
240 */ 240 */
241 void setSearchFields( const KABC::Field::List &fields ); 241 void setSearchFields( const KABC::Field::List &fields );
242 242
243 /** 243 /**
244 Search with the current search field for a contact, that matches 244 Search with the current search field for a contact, that matches
245 the given text, and selects it in the view. 245 the given text, and selects it in the view.
246 */ 246 */
247 void incrementalSearch( const QString& text ); 247 void incrementalSearch( const QString& text );
248 248
249 /** 249 /**
250 Marks the address book as modified. 250 Marks the address book as modified.
251 */ 251 */
252 void setModified(); 252 void setModified();
253 /** 253 /**
254 Marks the address book as modified without refreshing the view. 254 Marks the address book as modified without refreshing the view.
255 */ 255 */
256 void setModifiedWOrefresh(); 256 void setModifiedWOrefresh();
257 257
258 /** 258 /**
259 Marks the address book as modified concerning the argument. 259 Marks the address book as modified concerning the argument.
260 */ 260 */
261 void setModified( bool modified ); 261 void setModified( bool modified );
262 262
263 /** 263 /**
264 Returns whether the address book is modified. 264 Returns whether the address book is modified.
265 */ 265 */
266 bool modified() const; 266 bool modified() const;
267 267
268 /** 268 /**
269 Called whenever an contact is modified in the contact editor 269 Called whenever an contact is modified in the contact editor
270 dialog or the quick edit. 270 dialog or the quick edit.
271 */ 271 */
272 void contactModified( const KABC::Addressee &addr ); 272 void contactModified( const KABC::Addressee &addr );
273 273
274 /** 274 /**
275 DCOP METHODS. 275 DCOP METHODS.
276 */ 276 */
277 void addEmail( QString addr ); 277 void addEmail( QString addr );
278 void importVCard( const KURL& url, bool showPreview ); 278 void importVCard( const KURL& url, bool showPreview );
279 void importVCard( const QString& vCard, bool showPreview ); 279 void importVCard( const QString& vCard, bool showPreview );
280 void newContact(); 280 void newContact();
281 QString getNameByPhone( const QString& phone ); 281 QString getNameByPhone( const QString& phone );
282 /** 282 /**
283 END DCOP METHODS 283 END DCOP METHODS
284 */ 284 */
285 285
286 /** 286 /**
287 Saves the contents of the AddressBook back to disk. 287 Saves the contents of the AddressBook back to disk.
288 */ 288 */
289 void save(); 289 void save();
290 290
291 /** 291 /**
292 Undos the last command using the undo stack. 292 Undos the last command using the undo stack.
293 */ 293 */
294 void undo(); 294 void undo();
295 295
296 /** 296 /**
297 Redos the last command that was undone, using the redo stack. 297 Redos the last command that was undone, using the redo stack.
298 */ 298 */
299 void redo(); 299 void redo();
300 300
301 /** 301 /**
302 Shows the edit dialog for the given uid. If the uid is QString::null, 302 Shows the edit dialog for the given uid. If the uid is QString::null,
303 the method will try to find a selected addressee in the view. 303 the method will try to find a selected addressee in the view.
304 */ 304 */
305 void editContact( const QString &uid /*US = QString::null*/ ); 305 void editContact( const QString &uid /*US = QString::null*/ );
306//US added a second method without defaultparameter 306//US added a second method without defaultparameter
307 void editContact2(); 307 void editContact2();
308 308
309 /** 309 /**
310 Shows or edits the detail view for the given uid. If the uid is QString::null, 310 Shows or edits the detail view for the given uid. If the uid is QString::null,
311 the method will try to find a selected addressee in the view. 311 the method will try to find a selected addressee in the view.
312 */ 312 */
313 void executeContact( const QString &uid /*US = QString::null*/ ); 313 void executeContact( const QString &uid /*US = QString::null*/ );
314 314
315 /** 315 /**
316 Launches the configuration dialog. 316 Launches the configuration dialog.
317 */ 317 */
318 void openConfigDialog(); 318 void openConfigDialog();
319 319
320 /** 320 /**
321 Launches the ldap search dialog. 321 Launches the ldap search dialog.
322 */ 322 */
323 void openLDAPDialog(); 323 void openLDAPDialog();
324 324
325 /** 325 /**
326 Creates a KAddressBookPrinter, which will display the print 326 Creates a KAddressBookPrinter, which will display the print
327 dialog and do the printing. 327 dialog and do the printing.
328 */ 328 */
329 void print(); 329 void print();
330 330
331 /** 331 /**
332 Registers a new GUI client, so plugins can register its actions. 332 Registers a new GUI client, so plugins can register its actions.
333 */ 333 */
334 void addGUIClient( KXMLGUIClient *client ); 334 void addGUIClient( KXMLGUIClient *client );
335 335
336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
339 339
340 340
341 signals: 341 signals:
342 void contactSelected( const QString &name ); 342 void contactSelected( const QString &name );
343 void contactSelected( const QPixmap &pixmap ); 343 void contactSelected( const QPixmap &pixmap );
344 public slots: 344 public slots:
345 void recieve(QString cmsg );
345 void getFile( bool success ); 346 void getFile( bool success );
346 void syncFileRequest(); 347 void syncFileRequest();
347 void setDetailsVisible( bool visible ); 348 void setDetailsVisible( bool visible );
348 void setDetailsToState(); 349 void setDetailsToState();
349 // void slotSyncMenu( int ); 350 // void slotSyncMenu( int );
350 private slots: 351 private slots:
351 void setJumpButtonBarVisible( bool visible ); 352 void setJumpButtonBarVisible( bool visible );
352 void setCaptionBack(); 353 void setCaptionBack();
353 void importFromOL(); 354 void importFromOL();
354 void extensionModified( const KABC::Addressee::List &list ); 355 void extensionModified( const KABC::Addressee::List &list );
355 void extensionChanged( int id ); 356 void extensionChanged( int id );
356 void clipboardDataChanged(); 357 void clipboardDataChanged();
357 void updateActionMenu(); 358 void updateActionMenu();
358 void configureKeyBindings(); 359 void configureKeyBindings();
359 void removeVoice(); 360 void removeVoice();
360#ifdef KAB_EMBEDDED 361#ifdef KAB_EMBEDDED
361 void configureResources(); 362 void configureResources();
362#endif //KAB_EMBEDDED 363#endif //KAB_EMBEDDED
363 364
364 void slotEditorDestroyed( const QString &uid ); 365 void slotEditorDestroyed( const QString &uid );
365 void configurationChanged(); 366 void configurationChanged();
366 void addressBookChanged(); 367 void addressBookChanged();
367 368
368 private: 369 private:
369 void initGUI(); 370 void initGUI();
370 void initActions(); 371 void initActions();
371 372
372 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 373 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
373 const char *name = 0 ); 374 const char *name = 0 );
374 375
375 KXMLGUIClient *mGUIClient; 376 KXMLGUIClient *mGUIClient;
376 377
377 KABC::AddressBook *mAddressBook; 378 KABC::AddressBook *mAddressBook;
378 379
379 ViewManager *mViewManager; 380 ViewManager *mViewManager;
380 // QSplitter *mDetailsSplitter; 381 // QSplitter *mDetailsSplitter;
381 KDGanttMinimizeSplitter *mExtensionBarSplitter; 382 KDGanttMinimizeSplitter *mExtensionBarSplitter;
382 ViewContainer *mDetails; 383 ViewContainer *mDetails;
383 KDGanttMinimizeSplitter* mMiniSplitter; 384 KDGanttMinimizeSplitter* mMiniSplitter;
384 XXPortManager *mXXPortManager; 385 XXPortManager *mXXPortManager;
385 JumpButtonBar *mJumpButtonBar; 386 JumpButtonBar *mJumpButtonBar;
386 IncSearchWidget *mIncSearchWidget; 387 IncSearchWidget *mIncSearchWidget;
387 ExtensionManager *mExtensionManager; 388 ExtensionManager *mExtensionManager;
388 389
389 KCMultiDialog *mConfigureDialog; 390 KCMultiDialog *mConfigureDialog;
390 391
391#ifndef KAB_EMBEDDED 392#ifndef KAB_EMBEDDED
392 LDAPSearchDialog *mLdapSearchDialog; 393 LDAPSearchDialog *mLdapSearchDialog;
393#endif //KAB_EMBEDDED 394#endif //KAB_EMBEDDED
394 // QDict<AddresseeEditorDialog> mEditorDict; 395 // QDict<AddresseeEditorDialog> mEditorDict;
395 AddresseeEditorDialog *mEditorDialog; 396 AddresseeEditorDialog *mEditorDialog;
396 bool mReadWrite; 397 bool mReadWrite;
397 bool mModified; 398 bool mModified;
398 bool mIsPart; 399 bool mIsPart;
399 bool mMultipleViewsAtOnce; 400 bool mMultipleViewsAtOnce;
400 401
401 402
402 //US file menu 403 //US file menu
403 KAction *mActionMail; 404 KAction *mActionMail;
404 KAction *mActionBeam; 405 KAction *mActionBeam;
405 KAction *mActionExport2phone; 406 KAction *mActionExport2phone;
406 KAction* mActionPrint; 407 KAction* mActionPrint;
407 KAction* mActionNewContact; 408 KAction* mActionNewContact;
408 KAction *mActionSave; 409 KAction *mActionSave;
409 KAction *mActionEditAddressee; 410 KAction *mActionEditAddressee;
410 KAction *mActionMailVCard; 411 KAction *mActionMailVCard;
411 KAction *mActionBeamVCard; 412 KAction *mActionBeamVCard;
412 413
413 KAction *mActionQuit; 414 KAction *mActionQuit;
414 415
415 //US edit menu 416 //US edit menu
416 KAction *mActionCopy; 417 KAction *mActionCopy;
417 KAction *mActionCut; 418 KAction *mActionCut;
418 KAction *mActionPaste; 419 KAction *mActionPaste;
419 KAction *mActionSelectAll; 420 KAction *mActionSelectAll;
420 KAction *mActionUndo; 421 KAction *mActionUndo;
421 KAction *mActionRedo; 422 KAction *mActionRedo;
422 KAction *mActionDelete; 423 KAction *mActionDelete;
423 424
424 //US settings menu 425 //US settings menu
425 KAction *mActionConfigResources; 426 KAction *mActionConfigResources;
426 KAction *mActionConfigKAddressbook; 427 KAction *mActionConfigKAddressbook;
427 KAction *mActionConfigShortcuts; 428 KAction *mActionConfigShortcuts;
428 KAction *mActionConfigureToolbars; 429 KAction *mActionConfigureToolbars;
429 KAction *mActionKeyBindings; 430 KAction *mActionKeyBindings;
430 KToggleAction *mActionJumpBar; 431 KToggleAction *mActionJumpBar;
431 KToggleAction *mActionDetails; 432 KToggleAction *mActionDetails;
432 KAction *mActionWhoAmI; 433 KAction *mActionWhoAmI;
433 KAction *mActionCategories; 434 KAction *mActionCategories;
434 KAction *mActionAboutKAddressbook; 435 KAction *mActionAboutKAddressbook;
435 KAction *mActionLicence; 436 KAction *mActionLicence;
436 KAction *mActionFaq; 437 KAction *mActionFaq;
437 438
438 KAction *mActionDeleteView; 439 KAction *mActionDeleteView;
439 440
440 QPopupMenu *viewMenu; 441 QPopupMenu *viewMenu;
441 QPopupMenu *filterMenu; 442 QPopupMenu *filterMenu;
442 QPopupMenu *settingsMenu; 443 QPopupMenu *settingsMenu;
443 QPopupMenu *changeMenu; 444 QPopupMenu *changeMenu;
444//US QAction *mActionSave; 445//US QAction *mActionSave;
445 QPopupMenu *ImportMenu; 446 QPopupMenu *ImportMenu;
446 QPopupMenu *ExportMenu; 447 QPopupMenu *ExportMenu;
447 //LR additional methods 448 //LR additional methods
448 KAction *mActionRemoveVoice; 449 KAction *mActionRemoveVoice;
449 KAction * mActionImportOL; 450 KAction * mActionImportOL;
450 451
451#ifndef KAB_EMBEDDED 452#ifndef KAB_EMBEDDED
452 KAddressBookService *mAddressBookService; 453 KAddressBookService *mAddressBookService;
453#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
454 455
455 class KABCorePrivate; 456 class KABCorePrivate;
456 KABCorePrivate *d; 457 KABCorePrivate *d;
457 //US bool mBlockSaveFlag; 458 //US bool mBlockSaveFlag;
458 459
459#ifdef KAB_EMBEDDED 460#ifdef KAB_EMBEDDED
460 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 461 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
461#endif //KAB_EMBEDDED 462#endif //KAB_EMBEDDED
462 463
463 //this are the overwritten callbackmethods from the syncinterface 464 //this are the overwritten callbackmethods from the syncinterface
464 virtual bool sync(KSyncManager* manager, QString filename, int mode); 465 virtual bool sync(KSyncManager* manager, QString filename, int mode);
465 virtual bool syncExternal(KSyncManager* manager, QString resource); 466 virtual bool syncExternal(KSyncManager* manager, QString resource);
466 467
467 468
468 // LR ******************************* 469 // LR *******************************
469 // sync stuff! 470 // sync stuff!
470 QString sentSyncFile(); 471 QString sentSyncFile();
471 QPopupMenu *syncMenu; 472 QPopupMenu *syncMenu;
472 KSyncManager* syncManager; 473 KSyncManager* syncManager;
473 int mGlobalSyncMode; 474 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 475 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 KABC::Addressee getLastSyncAddressee(); 476 KABC::Addressee getLastSyncAddressee();
476 QDateTime mLastAddressbookSync; 477 QDateTime mLastAddressbookSync;
477 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 478 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
478 // ********************* 479 // *********************
479 480
480}; 481};
481 482
482#endif 483#endif
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index f48f214..8c4ca09 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,240 +1,250 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@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#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 50
51 setIcon(SmallIcon( "ka24" ) ); 51 setIcon(SmallIcon( "ka24" ) );
52#if 0 52#if 0
53 //US for embedded systems, create the toolbar before we initiate KABCore. 53 //US for embedded systems, create the toolbar before we initiate KABCore.
54 // KABCore will fill the toolbar with menues and icons 54 // KABCore will fill the toolbar with menues and icons
55 QMainWindow::ToolBarDock tbd; 55 QMainWindow::ToolBarDock tbd;
56 tbd = Top; 56 tbd = Top;
57 iconToolBar = new QToolBar( this ); 57 iconToolBar = new QToolBar( this );
58 addToolBar (iconToolBar , tbd ); 58 addToolBar (iconToolBar , tbd );
59 iconToolBar->setHorizontalStretchable(true); 59 iconToolBar->setHorizontalStretchable(true);
60//US iconToolBar->setWidth(300); 60//US iconToolBar->setWidth(300);
61#endif // 0 61#endif // 0
62 62
63 mCore = new KABCore( this, true, this ); 63 mCore = new KABCore( this, true, this );
64 64
65#ifdef KAB_EMBEDDED 65#ifdef KAB_EMBEDDED
66 setCaption( i18n( "KAddressbook/Pi" ) ); 66 setCaption( i18n( "KAddressbook/Pi" ) );
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 setCaption( i18n( "Address Book Browser" ) ); 68 setCaption( i18n( "Address Book Browser" ) );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 //mCore->restoreSettings(); 71 //mCore->restoreSettings();
72 72
73 initActions(); 73 initActions();
74 74
75 setCentralWidget( mCore ); 75 setCentralWidget( mCore );
76 76
77//US statusBar()->show(); 77//US statusBar()->show();
78 78
79#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
80 setStandardToolBarMenuEnabled(true); 80 setStandardToolBarMenuEnabled(true);
81 81
82 createGUI( "kaddressbookui.rc", false ); 82 createGUI( "kaddressbookui.rc", false );
83 83
84 84
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 setAutoSaveSettings(); 86 setAutoSaveSettings();
87 qApp->processEvents(); 87 qApp->processEvents();
88 mCore->restoreSettings(); 88 mCore->restoreSettings();
89} 89}
90 90
91KAddressBookMain::~KAddressBookMain() 91KAddressBookMain::~KAddressBookMain()
92{ 92{
93 // mCore->saveSettings(); 93 // mCore->saveSettings();
94} 94}
95 95void KAddressBookMain::recieve( const QCString& cmsg, const QByteArray& data )
96{
97 qDebug("KA: QCOP message received: %s ", cmsg.data() );
98 if ( cmsg == "setDocument(QString)" ) {
99 QDataStream stream( data, IO_ReadOnly );
100 QString fileName;
101 stream >> fileName;
102 mCore->recieve( fileName );
103 return;
104 }
105}
96void KAddressBookMain::showMinimized () 106void KAddressBookMain::showMinimized ()
97{ 107{
98 QWidget::showMinimized () ; 108 QWidget::showMinimized () ;
99} 109}
100void KAddressBookMain::addEmail( QString addr ) 110void KAddressBookMain::addEmail( QString addr )
101{ 111{
102 mCore->addEmail( addr ); 112 mCore->addEmail( addr );
103} 113}
104 114
105#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
106ASYNC KAddressBookMain::showContactEditor( QString uid ) 116ASYNC KAddressBookMain::showContactEditor( QString uid )
107{ 117{
108 mCore->editContact( uid ); 118 mCore->editContact( uid );
109} 119}
110#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
111void KAddressBookMain::newContact() 121void KAddressBookMain::newContact()
112{ 122{
113 mCore->newContact(); 123 mCore->newContact();
114} 124}
115 125
116QString KAddressBookMain::getNameByPhone( QString phone ) 126QString KAddressBookMain::getNameByPhone( QString phone )
117{ 127{
118 return mCore->getNameByPhone( phone ); 128 return mCore->getNameByPhone( phone );
119} 129}
120 130
121void KAddressBookMain::save() 131void KAddressBookMain::save()
122{ 132{
123 mCore->save(); 133 mCore->save();
124} 134}
125 135
126void KAddressBookMain::exit() 136void KAddressBookMain::exit()
127{ 137{
128 close( ); 138 close( );
129} 139}
130 140
131void KAddressBookMain::saveProperties( KConfig* ) 141void KAddressBookMain::saveProperties( KConfig* )
132{ 142{
133} 143}
134 144
135void KAddressBookMain::readProperties( KConfig* ) 145void KAddressBookMain::readProperties( KConfig* )
136{ 146{
137} 147}
138 148
139void KAddressBookMain::initActions() 149void KAddressBookMain::initActions()
140{ 150{
141#ifndef KAB_EMBEDDED 151#ifndef KAB_EMBEDDED
142 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 152 KStdAction::quit( this, SLOT( close() ), actionCollection() );
143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 153 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
144#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
145 //US: transfered the setup of the actions into KABCore 155 //US: transfered the setup of the actions into KABCore
146#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
147 157
148 158
149} 159}
150 160
151//US new method to setup menues and toolbars on embedded systems 161//US new method to setup menues and toolbars on embedded systems
152#ifdef KAB_EMBEDDED 162#ifdef KAB_EMBEDDED
153/* 163/*
154QToolBar * KAddressBookMain::getIconToolBar() 164QToolBar * KAddressBookMain::getIconToolBar()
155{ 165{
156 return iconToolBar; 166 return iconToolBar;
157} 167}
158*/ 168*/
159 169
160void KAddressBookMain::createGUI() 170void KAddressBookMain::createGUI()
161{ 171{
162 172
163 173
164 174
165} 175}
166#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
167 177
168void KAddressBookMain::configureToolbars() 178void KAddressBookMain::configureToolbars()
169{ 179{
170#ifndef KAB_EMBEDDED 180#ifndef KAB_EMBEDDED
171 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 181 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
172 182
173 KEditToolbar dlg( factory() ); 183 KEditToolbar dlg( factory() );
174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 184 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
175 185
176 dlg.exec(); 186 dlg.exec();
177#else //KAB_EMBEDDED 187#else //KAB_EMBEDDED
178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 188 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
179#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
180} 190}
181 191
182void KAddressBookMain::slotNewToolbarConfig() 192void KAddressBookMain::slotNewToolbarConfig()
183{ 193{
184#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
185 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 195 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
186#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 197 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
188#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
189} 199}
190 200
191void KAddressBookMain::configureKeys() 201void KAddressBookMain::configureKeys()
192{ 202{
193#ifndef KAB_EMBEDDED 203#ifndef KAB_EMBEDDED
194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 204 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
195#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 206 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
197#endif //KAB_EMBEDDED 207#endif //KAB_EMBEDDED
198} 208}
199 209
200void KAddressBookMain::closeEvent( QCloseEvent* ce ) 210void KAddressBookMain::closeEvent( QCloseEvent* ce )
201{ 211{
202 bool mModified = mCore->modified(); 212 bool mModified = mCore->modified();
203 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 213 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
204 214
205 QString mess = i18n( "Close KA/Pi?"); 215 QString mess = i18n( "Close KA/Pi?");
206 if ( mModified == true ) 216 if ( mModified == true )
207 mess += i18n( "\nChanges will be saved!"); 217 mess += i18n( "\nChanges will be saved!");
208 else 218 else
209 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 219 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
210 220
211 bool mQuit = true; 221 bool mQuit = true;
212 222
213 223
214 if (mAskForQuit) 224 if (mAskForQuit)
215 { 225 {
216 226
217 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 227 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
218 if (res == 0) 228 if (res == 0)
219 mQuit = true; 229 mQuit = true;
220 else 230 else
221 mQuit = false; 231 mQuit = false;
222 } 232 }
223 233
224 if (mQuit == false) 234 if (mQuit == false)
225 return; 235 return;
226 236
227 if (mModified == true) 237 if (mModified == true)
228 { 238 {
229 save(); 239 save();
230 mCore->saveSettings(); 240 mCore->saveSettings();
231 KABPrefs::instance()->writeConfig(); 241 KABPrefs::instance()->writeConfig();
232 } 242 }
233 243
234 ce->accept(); 244 ce->accept();
235} 245}
236 246
237#ifndef KAB_EMBEDDED 247#ifndef KAB_EMBEDDED
238#include "kaddressbookmain.moc" 248#include "kaddressbookmain.moc"
239#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
240 250
diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h
index cf6f899..40d2bdd 100644
--- a/kaddressbook/kaddressbookmain.h
+++ b/kaddressbook/kaddressbookmain.h
@@ -1,122 +1,122 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKMAIN_H 24#ifndef KADDRESSBOOKMAIN_H
25#define KADDRESSBOOKMAIN_H 25#define KADDRESSBOOKMAIN_H
26 26
27#include <qptrlist.h> 27#include <qptrlist.h>
28 28
29#ifdef KAB_EMBEDDED 29#ifdef KAB_EMBEDDED
30class QToolBar; 30class QToolBar;
31#include <qaction.h> 31#include <qaction.h>
32//#include <qmainwindow.h> 32//#include <qmainwindow.h>
33#include <kmainwindow.h> 33#include <kmainwindow.h>
34#else //KAB_EMBEDDED 34#else //KAB_EMBEDDED
35#include <kaction.h> 35#include <kaction.h>
36#include <kapplication.h> 36#include <kapplication.h>
37#include <kmainwindow.h> 37#include <kmainwindow.h>
38#include "kaddressbookiface.h" 38#include "kaddressbookiface.h"
39#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
40 40
41class KABCore; 41class KABCore;
42class KConfig; 42class KConfig;
43 43
44/** 44/**
45 This class serves as the main window for KAddressBook. It handles the 45 This class serves as the main window for KAddressBook. It handles the
46 menus, toolbars, and status bars. 46 menus, toolbars, and status bars.
47 47
48 @short Main window class 48 @short Main window class
49 @author Don Sanders <dsanders@kde.org> 49 @author Don Sanders <dsanders@kde.org>
50 @version 0.1 50 @version 0.1
51 */ 51 */
52#ifdef KAB_EMBEDDED 52#ifdef KAB_EMBEDDED
53class KAddressBookMain : public KMainWindow 53class KAddressBookMain : public KMainWindow
54#else //KAB_EMBEDDED 54#else //KAB_EMBEDDED
55//MOC_SKIP_BEGIN 55//MOC_SKIP_BEGIN
56class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface 56class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface
57//MOC_SKIP_END 57//MOC_SKIP_END
58#endif //KAB_EMBEDDED 58#endif //KAB_EMBEDDED
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62 public: 62 public:
63 KAddressBookMain(); 63 KAddressBookMain();
64 virtual ~KAddressBookMain(); 64 virtual ~KAddressBookMain();
65 65
66#ifdef KAB_EMBEDDED 66#ifdef KAB_EMBEDDED
67// QPEToolBar * getIconToolBar(); 67// QPEToolBar * getIconToolBar();
68 // QToolBar * getIconToolBar(); 68 // QToolBar * getIconToolBar();
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 71
72 public slots: 72 public slots:
73 void showMinimized () ; 73 void showMinimized () ;
74 virtual void addEmail( QString addr ); 74 virtual void addEmail( QString addr );
75#ifndef KAB_EMBEDDED 75#ifndef KAB_EMBEDDED
76//MOC_SKIP_BEGIN 76//MOC_SKIP_BEGIN
77 virtual ASYNC showContactEditor( QString uid ); 77 virtual ASYNC showContactEditor( QString uid );
78//MOC_SKIP_END 78//MOC_SKIP_END
79#endif //KAB_EMBEDDED 79#endif //KAB_EMBEDDED
80 virtual void newContact(); 80 virtual void newContact();
81 virtual QString getNameByPhone( QString phone ); 81 virtual QString getNameByPhone( QString phone );
82 virtual void save(); 82 virtual void save();
83 virtual void exit(); 83 virtual void exit();
84 84 void recieve( const QCString& cmsg, const QByteArray& data );
85 protected: 85 protected:
86 void initActions(); 86 void initActions();
87#ifdef KAB_EMBEDDED 87#ifdef KAB_EMBEDDED
88 //US new method to setup menues and toolbars on embedded systems 88 //US new method to setup menues and toolbars on embedded systems
89 void createGUI(); 89 void createGUI();
90#endif //KAB_EMBEDDED 90#endif //KAB_EMBEDDED
91 91
92 /** 92 /**
93 This function is called when it is time for the app to save its 93 This function is called when it is time for the app to save its
94 properties for session management purposes. 94 properties for session management purposes.
95 */ 95 */
96 void saveProperties( KConfig* ); 96 void saveProperties( KConfig* );
97 97
98 /** 98 /**
99 This function is called when this app is restored. The KConfig 99 This function is called when this app is restored. The KConfig
100 object points to the session management config file that was saved 100 object points to the session management config file that was saved
101 with @ref saveProperties 101 with @ref saveProperties
102 */ 102 */
103 void readProperties( KConfig* ); 103 void readProperties( KConfig* );
104 104
105 void closeEvent( QCloseEvent* ce ); 105 void closeEvent( QCloseEvent* ce );
106 106
107 protected slots: 107 protected slots:
108 void configureToolbars(); 108 void configureToolbars();
109 void configureKeys(); 109 void configureKeys();
110 110
111 void slotNewToolbarConfig(); 111 void slotNewToolbarConfig();
112 112
113 private: 113 private:
114 KABCore *mCore; 114 KABCore *mCore;
115 115
116#ifdef KAB_EMBEDDED 116#ifdef KAB_EMBEDDED
117 // QToolBar *iconToolBar; 117 // QToolBar *iconToolBar;
118#endif //KAB_EMBEDDED 118#endif //KAB_EMBEDDED
119 119
120}; 120};
121 121
122#endif 122#endif
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 965fb06..6dd97b8 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,212 +1,218 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h>
3#include <stdlib.h> 4#include <stdlib.h>
4#else 5#else
5#include <qapplication.h> 6#include <qapplication.h>
6#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 8#include <qplatinumstyle.h>
8#include <qmainwindow.h> 9#include <qmainwindow.h>
9#endif 10#endif
10 11
11#include <kstandarddirs.h> 12#include <kstandarddirs.h>
12#include <qregexp.h> 13#include <qregexp.h>
13#include <kglobal.h> 14#include <kglobal.h>
14#include <stdio.h> 15#include <stdio.h>
15#include <qdir.h> 16#include <qdir.h>
16#include "kaddressbookmain.h" 17#include "kaddressbookmain.h"
17#include "externalapphandler.h" 18#include "externalapphandler.h"
18#include <libkdepim/kpimglobalprefs.h> 19#include <libkdepim/kpimglobalprefs.h>
19 20
20int main( int argc, char **argv ) 21int main( int argc, char **argv )
21{ 22{
22#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
23 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
24 a.setKeepRunning (); 25 a.setKeepRunning ();
25#else 26#else
26 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
27 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
28 QString hdir = QDir::homeDirPath(); 29 QString hdir = QDir::homeDirPath();
29 // there is a bug when creating dirs for WIN 98 30 // there is a bug when creating dirs for WIN 98
30 // it is difficult to fix, because we have no WIN 98 runnung 31 // it is difficult to fix, because we have no WIN 98 runnung
31 // such that we try it to create the dirs at startup here 32 // such that we try it to create the dirs at startup here
32 if ( hdir == "C:\\" ) { // win 98 or ME 33 if ( hdir == "C:\\" ) { // win 98 or ME
33 QDir app_dir; 34 QDir app_dir;
34 if ( !app_dir.exists("C:\\kdepim") ) 35 if ( !app_dir.exists("C:\\kdepim") )
35 app_dir.mkdir ("C:\\kdepim"); 36 app_dir.mkdir ("C:\\kdepim");
36 if ( !app_dir.exists("C:\\kdepim\\apps") ) 37 if ( !app_dir.exists("C:\\kdepim\\apps") )
37 app_dir.mkdir ("C:\\kdepim\\apps"); 38 app_dir.mkdir ("C:\\kdepim\\apps");
38 if ( !app_dir.exists("C:\\kdepim\\config") ) 39 if ( !app_dir.exists("C:\\kdepim\\config") )
39 app_dir.mkdir ("C:\\kdepim\\config"); 40 app_dir.mkdir ("C:\\kdepim\\config");
40 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 41 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
41 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 42 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
42 } 43 }
43#endif 44#endif
44 45
45 bool exitHelp = false; 46 bool exitHelp = false;
46 if ( argc > 1 ) { 47 if ( argc > 1 ) {
47 QString command = argv[1]; 48 QString command = argv[1];
48 if ( command == "-help" ){ 49 if ( command == "-help" ){
49 printf("KA/E command line commands:\n"); 50 printf("KA/E command line commands:\n");
50 printf(" no command: Start KA/E in usual way\n"); 51 printf(" no command: Start KA/E in usual way\n");
51 printf(" -help: This output\n"); 52 printf(" -help: This output\n");
52 printf(" KA/E is exiting now. Bye!\n"); 53 printf(" KA/E is exiting now. Bye!\n");
53 exitHelp = true; 54 exitHelp = true;
54 } 55 }
55 } 56 }
56 if ( ! exitHelp ) { 57 if ( ! exitHelp ) {
57 58
58 KGlobal::setAppName( "kaddressbook" ); 59 KGlobal::setAppName( "kaddressbook" );
59#ifndef DESKTOP_VERSION 60#ifndef DESKTOP_VERSION
60 if ( QApplication::desktop()->width() > 320 ) 61 if ( QApplication::desktop()->width() > 320 )
61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
62 else 63 else
63 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 64 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
64#else 65#else
65 QString fileName ; 66 QString fileName ;
66 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 67 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
67 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 68 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
68 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 69 QApplication::addLibraryPath ( qApp->applicationDirPath () );
69 70
70#endif 71#endif
71 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 72 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
72 KAddressBookMain m ; 73 KAddressBookMain m ;
73//US MainWindow m; 74//US MainWindow m;
74 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 75 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
75 76
76 { 77 {
77 KPimGlobalPrefs::instance()->setGlobalConfig(); 78 KPimGlobalPrefs::instance()->setGlobalConfig();
78 } 79 }
79#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
80 a.showMainWidget( &m ); 81 a.showMainWidget( &m );
82 QCopChannel* c1 = new QCopChannel("QPE/Application/addressbook",&m, "channelAB" ) ;
83 QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
81#else 84#else
82 a.setMainWidget( &m ); 85 a.setMainWidget( &m );
83 m.resize (640, 480 ); 86 m.resize (640, 480 );
84 m.show(); 87 m.show();
85#endif 88#endif
86 a.exec(); 89 a.exec();
90#ifndef DESKTOP_VERSION
91 delete c1;
92#endif
87 93
88 } 94 }
89 qDebug("KA: Bye! "); 95 qDebug("KA: Bye! ");
90} 96}
91 97
92/* 98/*
93#include <stdlib.h> 99#include <stdlib.h>
94 100
95#include <qstring.h> 101#include <qstring.h>
96 102
97#include <kabc/stdaddressbook.h> 103#include <kabc/stdaddressbook.h>
98#include <kaboutdata.h> 104#include <kaboutdata.h>
99#include <kcmdlineargs.h> 105#include <kcmdlineargs.h>
100#include <kcrash.h> 106#include <kcrash.h>
101#include <kdebug.h> 107#include <kdebug.h>
102#include <klocale.h> 108#include <klocale.h>
103#include <kstartupinfo.h> 109#include <kstartupinfo.h>
104#include <kuniqueapplication.h> 110#include <kuniqueapplication.h>
105#include <kwin.h> 111#include <kwin.h>
106 112
107#include "kaddressbookmain.h" 113#include "kaddressbookmain.h"
108#include "kabcore.h" 114#include "kabcore.h"
109 115
110extern "C" { 116extern "C" {
111 117
112void crashHandler( int ) 118void crashHandler( int )
113{ 119{
114 KABC::StdAddressBook::handleCrash(); 120 KABC::StdAddressBook::handleCrash();
115 ::exit( 0 ); 121 ::exit( 0 );
116} 122}
117 123
118} 124}
119 125
120class KAddressBookApp : public KUniqueApplication { 126class KAddressBookApp : public KUniqueApplication {
121 public: 127 public:
122 KAddressBookApp() : mMainWin( 0 ) {} 128 KAddressBookApp() : mMainWin( 0 ) {}
123 ~KAddressBookApp() {} 129 ~KAddressBookApp() {}
124 130
125 int newInstance(); 131 int newInstance();
126 132
127 private: 133 private:
128 KAddressBookMain *mMainWin; 134 KAddressBookMain *mMainWin;
129}; 135};
130 136
131int KAddressBookApp::newInstance() 137int KAddressBookApp::newInstance()
132{ 138{
133 if ( isRestored() ) { 139 if ( isRestored() ) {
134 // There can only be one main window 140 // There can only be one main window
135 if ( KMainWindow::canBeRestored( 1 ) ) { 141 if ( KMainWindow::canBeRestored( 1 ) ) {
136 mMainWin = new KAddressBookMain; 142 mMainWin = new KAddressBookMain;
137 mMainWin->show(); 143 mMainWin->show();
138 mMainWin->restore( 1 ); 144 mMainWin->restore( 1 );
139 } 145 }
140 } else { 146 } else {
141 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 147 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
142 148
143 QCString addrStr = args->getOption( "addr" ); 149 QCString addrStr = args->getOption( "addr" );
144 QCString uidStr = args->getOption( "uid" ); 150 QCString uidStr = args->getOption( "uid" );
145 QString addr; 151 QString addr;
146 QString uid; 152 QString uid;
147 if ( !addrStr.isEmpty() ) 153 if ( !addrStr.isEmpty() )
148 addr = QString::fromLocal8Bit( addrStr ); 154 addr = QString::fromLocal8Bit( addrStr );
149 if ( !uidStr.isEmpty() ) 155 if ( !uidStr.isEmpty() )
150 uid = QString::fromLocal8Bit( uidStr ); 156 uid = QString::fromLocal8Bit( uidStr );
151 157
152 158
153 if ( args->isSet( "editor-only" ) ) { 159 if ( args->isSet( "editor-only" ) ) {
154 if ( !mMainWin ) 160 if ( !mMainWin )
155 mMainWin = new KAddressBookMain; 161 mMainWin = new KAddressBookMain;
156 KStartupInfo::appStarted(); 162 KStartupInfo::appStarted();
157 mMainWin->hide(); 163 mMainWin->hide();
158 } else { 164 } else {
159 if ( mMainWin ) { 165 if ( mMainWin ) {
160 mMainWin->show(); 166 mMainWin->show();
161 KWin::setActiveWindow( mMainWin->winId() ); 167 KWin::setActiveWindow( mMainWin->winId() );
162 } else { 168 } else {
163 mMainWin = new KAddressBookMain; 169 mMainWin = new KAddressBookMain;
164 mMainWin->show(); 170 mMainWin->show();
165 } 171 }
166 } 172 }
167 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 173 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
168 if ( !addr.isEmpty() ) 174 if ( !addr.isEmpty() )
169 mMainWin->addEmail( addr ); 175 mMainWin->addEmail( addr );
170 176
171 if ( !uid.isEmpty() ) 177 if ( !uid.isEmpty() )
172 mMainWin->showContactEditor( uid ); 178 mMainWin->showContactEditor( uid );
173 if ( args->isSet( "new-contact" ) ) { 179 if ( args->isSet( "new-contact" ) ) {
174 mMainWin->newContact(); 180 mMainWin->newContact();
175 } 181 }
176 } 182 }
177 183
178 KCrash::setEmergencySaveFunction( crashHandler ); 184 KCrash::setEmergencySaveFunction( crashHandler );
179 185
180 return 0; 186 return 0;
181} 187}
182 188
183// the dummy argument is required, because KMail apparently sends an empty 189// the dummy argument is required, because KMail apparently sends an empty
184// argument. 190// argument.
185static KCmdLineOptions kmoptions[] = 191static KCmdLineOptions kmoptions[] =
186{ 192{
187 { "a", 0 , 0 }, 193 { "a", 0 , 0 },
188 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 194 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
189 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 195 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
190 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 196 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
191 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 197 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
192 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 198 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
193 { 0, 0, 0} 199 { 0, 0, 0}
194}; 200};
195 201
196int main( int argc, char *argv[] ) 202int main( int argc, char *argv[] )
197{ 203{
198 KLocale::setMainCatalogue( "kaddressbook" ); 204 KLocale::setMainCatalogue( "kaddressbook" );
199 205
200 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 206 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
201 KCmdLineArgs::addCmdLineOptions( kmoptions ); 207 KCmdLineArgs::addCmdLineOptions( kmoptions );
202 KUniqueApplication::addCmdLineOptions(); 208 KUniqueApplication::addCmdLineOptions();
203 209
204 if ( !KAddressBookApp::start() ) 210 if ( !KAddressBookApp::start() )
205 exit( 0 ); 211 exit( 0 );
206 212
207 KAddressBookApp app; 213 KAddressBookApp app;
208 KGlobal::locale()->insertCatalogue( "libkdepim" ); 214 KGlobal::locale()->insertCatalogue( "libkdepim" );
209 215
210 return app.exec(); 216 return app.exec();
211} 217}
212*/ 218*/
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 3c16458..a69a0bd 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1831 +1,1832 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
232 } 232 }
233 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
238 238
239 239
240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
241 mView->setModified( false ); 241 mView->setModified( false );
242 mBlockAtStartup = false; 242 mBlockAtStartup = false;
243 mView->setModified( false ); 243 mView->setModified( false );
244 setCentralWidget( mView ); 244 setCentralWidget( mView );
245 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
246 mView->show(); 246 mView->show();
247 delete splash; 247 delete splash;
248 if ( newFile ) 248 if ( newFile )
249 mView->updateConfig(); 249 mView->updateConfig();
250 // qApp->processEvents(); 250 // qApp->processEvents();
251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
252 //fillSyncMenu(); 252 //fillSyncMenu();
253 253
254 254
255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
258 mSyncManager->setDefaultFileName( defaultFileName()); 258 mSyncManager->setDefaultFileName( defaultFileName());
259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
260 mSyncManager->fillSyncMenu(); 260 mSyncManager->fillSyncMenu();
261 261
262 262
263 263
264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
265 if ( showWarning ) { 265 if ( showWarning ) {
266 KMessageBox::information( this, 266 KMessageBox::information( this,
267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
268 qApp->processEvents(); 268 qApp->processEvents();
269 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
270 } 270 }
271 271
272 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
273#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
275#endif 275#endif
276} 276}
277MainWindow::~MainWindow() 277MainWindow::~MainWindow()
278{ 278{
279 //qDebug("MainWindow::~MainWindow() "); 279 //qDebug("MainWindow::~MainWindow() ");
280 //save toolbar location 280 //save toolbar location
281 delete mCalendar; 281 delete mCalendar;
282 delete mSyncManager; 282 delete mSyncManager;
283 283
284 284
285} 285}
286void MainWindow::showMaximized () 286void MainWindow::showMaximized ()
287{ 287{
288#ifndef DESKTOP_VERSION 288#ifndef DESKTOP_VERSION
289 if ( ! globalFlagBlockStartup ) 289 if ( ! globalFlagBlockStartup )
290 if ( mClosed ) 290 if ( mClosed )
291 mView->goToday(); 291 mView->goToday();
292#endif 292#endif
293 QWidget::showMaximized () ; 293 QWidget::showMaximized () ;
294 mClosed = false; 294 mClosed = false;
295} 295}
296void MainWindow::closeEvent( QCloseEvent* ce ) 296void MainWindow::closeEvent( QCloseEvent* ce )
297{ 297{
298 298
299 299
300 300
301 if ( ! KOPrefs::instance()->mAskForQuit ) { 301 if ( ! KOPrefs::instance()->mAskForQuit ) {
302 saveOnClose(); 302 saveOnClose();
303 mClosed = true; 303 mClosed = true;
304 ce->accept(); 304 ce->accept();
305 return; 305 return;
306 306
307 } 307 }
308 308
309 switch( QMessageBox::information( this, "KO/Pi", 309 switch( QMessageBox::information( this, "KO/Pi",
310 i18n("Do you really want\nto close KO/Pi?"), 310 i18n("Do you really want\nto close KO/Pi?"),
311 i18n("Close"), i18n("No"), 311 i18n("Close"), i18n("No"),
312 0, 0 ) ) { 312 0, 0 ) ) {
313 case 0: 313 case 0:
314 saveOnClose(); 314 saveOnClose();
315 mClosed = true; 315 mClosed = true;
316 ce->accept(); 316 ce->accept();
317 break; 317 break;
318 case 1: 318 case 1:
319 ce->ignore(); 319 ce->ignore();
320 break; 320 break;
321 case 2: 321 case 2:
322 322
323 default: 323 default:
324 break; 324 break;
325 } 325 }
326 326
327 327
328} 328}
329 329
330void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 330void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
331{ 331{
332 QDataStream stream( data, IO_ReadOnly ); 332 QDataStream stream( data, IO_ReadOnly );
333 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 333 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
334 //QString datamess; 334 //QString datamess;
335 //qDebug("message "); 335 //qDebug("message ");
336 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 336 qDebug("KO: QCOP message received: %s ", cmsg.data() );
337 337
338 if ( cmsg == "-writeFile" ) { 338 if ( cmsg == "setDocument(QString)" ) {
339 // I made from the "-writeFile" an "-writeAlarm" 339 QDataStream stream( data, IO_ReadOnly );
340 mView->viewManager()->showWhatsNextView(); 340 QString fileName;
341 mCalendar->checkAlarmForIncidence( 0, true); 341 stream >> fileName;
342 showMaximized(); 342 qDebug("filename %s ", fileName.latin1());
343 raise(); 343 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
344 mSyncManager->slotSyncMenu( 1002 );
344 return; 345 return;
345 } 346 }
346 347
347 if ( cmsg == "-writeFile" ) { 348 if ( cmsg == "-writeFile" ) {
348 // I made from the "-writeFile" an "-writeAlarm" 349 // I made from the "-writeFile" an "-writeAlarm"
349 mView->viewManager()->showWhatsNextView(); 350 mView->viewManager()->showWhatsNextView();
350 mCalendar->checkAlarmForIncidence( 0, true); 351 mCalendar->checkAlarmForIncidence( 0, true);
351 showMaximized(); 352 showMaximized();
352 raise(); 353 raise();
353 return; 354 return;
354 355
355 } 356 }
356 if ( cmsg == "-writeFileSilent" ) { 357 if ( cmsg == "-writeFileSilent" ) {
357 // I made from the "-writeFile" an "-writeAlarm" 358 // I made from the "-writeFile" an "-writeAlarm"
358 // mView->viewManager()->showWhatsNextView(); 359 // mView->viewManager()->showWhatsNextView();
359 mCalendar->checkAlarmForIncidence( 0, true); 360 mCalendar->checkAlarmForIncidence( 0, true);
360 //showMaximized(); 361 //showMaximized();
361 //raise(); 362 //raise();
362 hide(); 363 hide();
363 return; 364 return;
364 } 365 }
365 if ( cmsg == "-newCountdown" ) { 366 if ( cmsg == "-newCountdown" ) {
366 qDebug("newCountdown "); 367 qDebug("newCountdown ");
367 368
368 } 369 }
369 QString msg ; 370 QString msg ;
370 QString allmsg = cmsg; 371 QString allmsg = cmsg;
371 while ( allmsg.length() > 0 ) { 372 while ( allmsg.length() > 0 ) {
372 int nextC = allmsg.find( "-", 1 ); 373 int nextC = allmsg.find( "-", 1 );
373 if ( nextC == -1 ) { 374 if ( nextC == -1 ) {
374 msg = allmsg; 375 msg = allmsg;
375 allmsg = ""; 376 allmsg = "";
376 } else{ 377 } else{
377 msg = allmsg.left( nextC ); 378 msg = allmsg.left( nextC );
378 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 379 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
379 } 380 }
380 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 381 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
381 if ( msg == "-newEvent" ) { 382 if ( msg == "-newEvent" ) {
382 mView->newEvent(); 383 mView->newEvent();
383 } 384 }
384 if ( msg == "-newTodo" ) { 385 if ( msg == "-newTodo" ) {
385 mView->newTodo(); 386 mView->newTodo();
386 387
387 } 388 }
388 if ( msg == "-showWN" ) { 389 if ( msg == "-showWN" ) {
389 mView->viewManager()->showWhatsNextView(); 390 mView->viewManager()->showWhatsNextView();
390 } 391 }
391 if ( msg == "-showTodo" ) { 392 if ( msg == "-showTodo" ) {
392 mView->viewManager()->showTodoView(); 393 mView->viewManager()->showTodoView();
393 } 394 }
394 if ( msg == "-showList" ) { 395 if ( msg == "-showList" ) {
395 mView->viewManager()->showListView(); 396 mView->viewManager()->showListView();
396 } 397 }
397 else if ( msg == "-showDay" ) { 398 else if ( msg == "-showDay" ) {
398 mView->viewManager()->showDayView(); 399 mView->viewManager()->showDayView();
399 } 400 }
400 else if ( msg == "-showWWeek" ) { 401 else if ( msg == "-showWWeek" ) {
401 mView->viewManager()->showWorkWeekView(); 402 mView->viewManager()->showWorkWeekView();
402 } 403 }
403 else if ( msg == "-ringSync" ) { 404 else if ( msg == "-ringSync" ) {
404 mSyncManager->multiSync( false ); 405 mSyncManager->multiSync( false );
405 } 406 }
406 else if ( msg == "-showWeek" ) { 407 else if ( msg == "-showWeek" ) {
407 mView->viewManager()->showWeekView(); 408 mView->viewManager()->showWeekView();
408 } 409 }
409 else if ( msg == "-showTodo" ) { 410 else if ( msg == "-showTodo" ) {
410 mView->viewManager()->showTodoView(); 411 mView->viewManager()->showTodoView();
411 } 412 }
412 else if ( msg == "-showJournal" ) { 413 else if ( msg == "-showJournal" ) {
413 mView->dateNavigator()->selectDates( 1 ); 414 mView->dateNavigator()->selectDates( 1 );
414 mView->dateNavigator()->selectToday(); 415 mView->dateNavigator()->selectToday();
415 mView->viewManager()->showJournalView(); 416 mView->viewManager()->showJournalView();
416 } 417 }
417 else if ( msg == "-showKO" ) { 418 else if ( msg == "-showKO" ) {
418 mView->viewManager()->showNextXView(); 419 mView->viewManager()->showNextXView();
419 } 420 }
420 else if ( msg == "-showWNext" || msg == "nextView()" ) { 421 else if ( msg == "-showWNext" || msg == "nextView()" ) {
421 mView->viewManager()->showWhatsNextView(); 422 mView->viewManager()->showWhatsNextView();
422 } 423 }
423 else if ( msg == "-showNextXView" ) { 424 else if ( msg == "-showNextXView" ) {
424 mView->viewManager()->showNextXView(); 425 mView->viewManager()->showNextXView();
425 } 426 }
426 427
427 428
428 } 429 }
429 430
430 showMaximized(); 431 showMaximized();
431 raise(); 432 raise();
432} 433}
433 434
434QPixmap MainWindow::loadPixmap( QString name ) 435QPixmap MainWindow::loadPixmap( QString name )
435{ 436{
436 return SmallIcon( name ); 437 return SmallIcon( name );
437 438
438} 439}
439void MainWindow::initActions() 440void MainWindow::initActions()
440{ 441{
441 //KOPrefs::instance()->mShowFullMenu 442 //KOPrefs::instance()->mShowFullMenu
442 iconToolBar->clear(); 443 iconToolBar->clear();
443 KOPrefs *p = KOPrefs::instance(); 444 KOPrefs *p = KOPrefs::instance();
444 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 445 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
445 446
446 QPopupMenu *viewMenu = new QPopupMenu( this ); 447 QPopupMenu *viewMenu = new QPopupMenu( this );
447 QPopupMenu *actionMenu = new QPopupMenu( this ); 448 QPopupMenu *actionMenu = new QPopupMenu( this );
448 QPopupMenu *importMenu = new QPopupMenu( this ); 449 QPopupMenu *importMenu = new QPopupMenu( this );
449 selectFilterMenu = new QPopupMenu( this ); 450 selectFilterMenu = new QPopupMenu( this );
450 selectFilterMenu->setCheckable( true ); 451 selectFilterMenu->setCheckable( true );
451 syncMenu = new QPopupMenu( this ); 452 syncMenu = new QPopupMenu( this );
452 configureAgendaMenu = new QPopupMenu( this ); 453 configureAgendaMenu = new QPopupMenu( this );
453 configureToolBarMenu = new QPopupMenu( this ); 454 configureToolBarMenu = new QPopupMenu( this );
454 QPopupMenu *helpMenu = new QPopupMenu( this ); 455 QPopupMenu *helpMenu = new QPopupMenu( this );
455 if ( KOPrefs::instance()->mShowFullMenu ) { 456 if ( KOPrefs::instance()->mShowFullMenu ) {
456 QMenuBar *menuBar1; 457 QMenuBar *menuBar1;
457 menuBar1 = menuBar(); 458 menuBar1 = menuBar();
458 menuBar1->insertItem( i18n("File"), importMenu ); 459 menuBar1->insertItem( i18n("File"), importMenu );
459 menuBar1->insertItem( i18n("View"), viewMenu ); 460 menuBar1->insertItem( i18n("View"), viewMenu );
460 menuBar1->insertItem( i18n("Actions"), actionMenu ); 461 menuBar1->insertItem( i18n("Actions"), actionMenu );
461 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 462 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
462 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 463 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
463 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 464 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
464 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 465 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
465 menuBar1->insertItem( i18n("Help"), helpMenu ); 466 menuBar1->insertItem( i18n("Help"), helpMenu );
466 } else { 467 } else {
467 QPEMenuBar *menuBar1; 468 QPEMenuBar *menuBar1;
468 menuBar1 = new QPEMenuBar( iconToolBar ); 469 menuBar1 = new QPEMenuBar( iconToolBar );
469 QPopupMenu *menuBar = new QPopupMenu( this ); 470 QPopupMenu *menuBar = new QPopupMenu( this );
470 menuBar1->insertItem( i18n("ME"), menuBar); 471 menuBar1->insertItem( i18n("ME"), menuBar);
471 menuBar->insertItem( i18n("File"), importMenu ); 472 menuBar->insertItem( i18n("File"), importMenu );
472 menuBar->insertItem( i18n("View"), viewMenu ); 473 menuBar->insertItem( i18n("View"), viewMenu );
473 menuBar->insertItem( i18n("Actions"), actionMenu ); 474 menuBar->insertItem( i18n("Actions"), actionMenu );
474 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 475 menuBar->insertItem( i18n("Synchronize"), syncMenu );
475 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 476 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
476 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 477 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
477 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 478 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
478 menuBar->insertItem( i18n("Help"), helpMenu ); 479 menuBar->insertItem( i18n("Help"), helpMenu );
479 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 480 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
480 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 481 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
481 } 482 }
482 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 483 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
483 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 484 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
484 485
485 // ****************** 486 // ******************
486 QAction *action; 487 QAction *action;
487 QIconSet icon; 488 QIconSet icon;
488 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 489 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
489 configureToolBarMenu->setCheckable( true ); 490 configureToolBarMenu->setCheckable( true );
490 491
491 QString pathString = ""; 492 QString pathString = "";
492 if ( !p->mToolBarMiniIcons ) { 493 if ( !p->mToolBarMiniIcons ) {
493 if ( QApplication::desktop()->width() < 480 ) 494 if ( QApplication::desktop()->width() < 480 )
494 pathString += "icons16/"; 495 pathString += "icons16/";
495 } else 496 } else
496 pathString += "iconsmini/"; 497 pathString += "iconsmini/";
497 configureAgendaMenu->setCheckable( true ); 498 configureAgendaMenu->setCheckable( true );
498 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 499 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
499 configureAgendaMenu->insertSeparator(); 500 configureAgendaMenu->insertSeparator();
500 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 501 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
501 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 502 configureAgendaMenu->insertItem(i18n("Small"), 6 );
502 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 503 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
503 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 504 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
504 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 505 configureAgendaMenu->insertItem(i18n("Large"), 12 );
505 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 506 configureAgendaMenu->insertItem(i18n("Big"), 14 );
506 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 507 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
507 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 508 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
508 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 509 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
509 510
510 icon = loadPixmap( pathString + "configure" ); 511 icon = loadPixmap( pathString + "configure" );
511 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 512 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
512 action->addTo( actionMenu ); 513 action->addTo( actionMenu );
513 connect( action, SIGNAL( activated() ), 514 connect( action, SIGNAL( activated() ),
514 mView, SLOT( edit_options() ) ); 515 mView, SLOT( edit_options() ) );
515 actionMenu->insertSeparator(); 516 actionMenu->insertSeparator();
516 icon = loadPixmap( pathString + "newevent" ); 517 icon = loadPixmap( pathString + "newevent" );
517 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 518 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
518 configureToolBarMenu->insertSeparator(); 519 configureToolBarMenu->insertSeparator();
519 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 520 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
520 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 521 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
521 ne_action->addTo( actionMenu ); 522 ne_action->addTo( actionMenu );
522 connect( ne_action, SIGNAL( activated() ), 523 connect( ne_action, SIGNAL( activated() ),
523 mView, SLOT( newEvent() ) ); 524 mView, SLOT( newEvent() ) );
524 icon = loadPixmap( pathString + "newtodo" ); 525 icon = loadPixmap( pathString + "newtodo" );
525 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 526 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
526 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 527 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
527 nt_action->addTo( actionMenu ); 528 nt_action->addTo( actionMenu );
528 connect( nt_action, SIGNAL( activated() ), 529 connect( nt_action, SIGNAL( activated() ),
529 mView, SLOT( newTodo() ) ); 530 mView, SLOT( newTodo() ) );
530 icon = loadPixmap( pathString + "navi" ); 531 icon = loadPixmap( pathString + "navi" );
531 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 532 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
532 action->addTo( viewMenu ); 533 action->addTo( viewMenu );
533 connect( action, SIGNAL( activated() ), 534 connect( action, SIGNAL( activated() ),
534 mView, SLOT( toggleDateNavigatorWidget() ) ); 535 mView, SLOT( toggleDateNavigatorWidget() ) );
535 icon = loadPixmap( pathString + "filter" ); 536 icon = loadPixmap( pathString + "filter" );
536 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 537 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
537 action->addTo( viewMenu ); 538 action->addTo( viewMenu );
538 connect( action, SIGNAL( activated() ), 539 connect( action, SIGNAL( activated() ),
539 mView, SLOT( toggleFilter() ) ); 540 mView, SLOT( toggleFilter() ) );
540 541
541 542
542 viewMenu->insertSeparator(); 543 viewMenu->insertSeparator();
543 icon = loadPixmap( pathString + "picker" ); 544 icon = loadPixmap( pathString + "picker" );
544 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 545 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
545 action->addTo( viewMenu ); 546 action->addTo( viewMenu );
546 connect( action, SIGNAL( activated() ), 547 connect( action, SIGNAL( activated() ),
547 mView, SLOT( showDatePicker() ) ); 548 mView, SLOT( showDatePicker() ) );
548 action->addTo( iconToolBar ); 549 action->addTo( iconToolBar );
549 viewMenu->insertSeparator(); 550 viewMenu->insertSeparator();
550 icon = loadPixmap( pathString + "list" ); 551 icon = loadPixmap( pathString + "list" );
551 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 552 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
552 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 553 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
553 showlist_action->addTo( viewMenu ); 554 showlist_action->addTo( viewMenu );
554 connect( showlist_action, SIGNAL( activated() ), 555 connect( showlist_action, SIGNAL( activated() ),
555 mView->viewManager(), SLOT( showListView() ) ); 556 mView->viewManager(), SLOT( showListView() ) );
556 557
557 558
558 icon = loadPixmap( pathString + "day" ); 559 icon = loadPixmap( pathString + "day" );
559 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 560 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
560 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 561 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
561 day1_action->addTo( viewMenu ); 562 day1_action->addTo( viewMenu );
562 // action->addTo( toolBar ); 563 // action->addTo( toolBar );
563 connect( day1_action, SIGNAL( activated() ), 564 connect( day1_action, SIGNAL( activated() ),
564 mView->viewManager(), SLOT( showDayView() ) ); 565 mView->viewManager(), SLOT( showDayView() ) );
565 566
566 icon = loadPixmap( pathString + "workweek" ); 567 icon = loadPixmap( pathString + "workweek" );
567 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 568 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
568 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 569 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
569 day5_action->addTo( viewMenu ); 570 day5_action->addTo( viewMenu );
570 connect( day5_action, SIGNAL( activated() ), 571 connect( day5_action, SIGNAL( activated() ),
571 mView->viewManager(), SLOT( showWorkWeekView() ) ); 572 mView->viewManager(), SLOT( showWorkWeekView() ) );
572 573
573 icon = loadPixmap( pathString + "week" ); 574 icon = loadPixmap( pathString + "week" );
574 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 575 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
575 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 576 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
576 day7_action->addTo( viewMenu ); 577 day7_action->addTo( viewMenu );
577 connect( day7_action, SIGNAL( activated() ), 578 connect( day7_action, SIGNAL( activated() ),
578 mView->viewManager(), SLOT( showWeekView() ) ); 579 mView->viewManager(), SLOT( showWeekView() ) );
579 580
580 icon = loadPixmap( pathString + "month" ); 581 icon = loadPixmap( pathString + "month" );
581 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 582 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
582 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 583 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
583 month_action->addTo( viewMenu ); 584 month_action->addTo( viewMenu );
584 connect( month_action, SIGNAL( activated() ), 585 connect( month_action, SIGNAL( activated() ),
585 mView->viewManager(), SLOT( showMonthView() ) ); 586 mView->viewManager(), SLOT( showMonthView() ) );
586 587
587 icon = loadPixmap( pathString + "todo" ); 588 icon = loadPixmap( pathString + "todo" );
588 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 589 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
589 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 590 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
590 todoview_action->addTo( viewMenu ); 591 todoview_action->addTo( viewMenu );
591 connect( todoview_action, SIGNAL( activated() ), 592 connect( todoview_action, SIGNAL( activated() ),
592 mView->viewManager(), SLOT( showTodoView() ) ); 593 mView->viewManager(), SLOT( showTodoView() ) );
593 594
594 icon = loadPixmap( pathString + "journal" ); 595 icon = loadPixmap( pathString + "journal" );
595 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 596 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
596 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 597 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
597 viewjournal_action->addTo( viewMenu ); 598 viewjournal_action->addTo( viewMenu );
598 connect( viewjournal_action, SIGNAL( activated() ), 599 connect( viewjournal_action, SIGNAL( activated() ),
599 mView->viewManager(), SLOT( showJournalView() ) ); 600 mView->viewManager(), SLOT( showJournalView() ) );
600 601
601 icon = loadPixmap( pathString + "xdays" ); 602 icon = loadPixmap( pathString + "xdays" );
602 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 603 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
603 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 604 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
604 xdays_action->addTo( viewMenu ); 605 xdays_action->addTo( viewMenu );
605 connect( xdays_action, SIGNAL( activated() ), 606 connect( xdays_action, SIGNAL( activated() ),
606 mView->viewManager(), SLOT( showNextXView() ) ); 607 mView->viewManager(), SLOT( showNextXView() ) );
607 608
608 icon = loadPixmap( pathString + "whatsnext" ); 609 icon = loadPixmap( pathString + "whatsnext" );
609 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 610 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
610 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 611 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
611 whatsnext_action->addTo( viewMenu ); 612 whatsnext_action->addTo( viewMenu );
612 connect( whatsnext_action, SIGNAL( activated() ), 613 connect( whatsnext_action, SIGNAL( activated() ),
613 mView->viewManager(), SLOT( showWhatsNextView() ) ); 614 mView->viewManager(), SLOT( showWhatsNextView() ) );
614 615
615#if 0 616#if 0
616 action = new QAction( "view_timespan", "Time Span", 0, this ); 617 action = new QAction( "view_timespan", "Time Span", 0, this );
617 action->addTo( viewMenu ); 618 action->addTo( viewMenu );
618 connect( action, SIGNAL( activated() ), 619 connect( action, SIGNAL( activated() ),
619 mView->viewManager(), SLOT( showTimeSpanView() ) ); 620 mView->viewManager(), SLOT( showTimeSpanView() ) );
620#endif 621#endif
621 622
622 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 623 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
623 this ); 624 this );
624 mNewSubTodoAction->addTo( actionMenu ); 625 mNewSubTodoAction->addTo( actionMenu );
625 connect( mNewSubTodoAction, SIGNAL( activated() ), 626 connect( mNewSubTodoAction, SIGNAL( activated() ),
626 mView, SLOT( newSubTodo() ) ); 627 mView, SLOT( newSubTodo() ) );
627 628
628 actionMenu->insertSeparator(); 629 actionMenu->insertSeparator();
629 630
630 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 631 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
631 mShowAction->addTo( actionMenu ); 632 mShowAction->addTo( actionMenu );
632 connect( mShowAction, SIGNAL( activated() ), 633 connect( mShowAction, SIGNAL( activated() ),
633 mView, SLOT( showIncidence() ) ); 634 mView, SLOT( showIncidence() ) );
634 635
635 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 636 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
636 mEditAction->addTo( actionMenu ); 637 mEditAction->addTo( actionMenu );
637 connect( mEditAction, SIGNAL( activated() ), 638 connect( mEditAction, SIGNAL( activated() ),
638 mView, SLOT( editIncidence() ) ); 639 mView, SLOT( editIncidence() ) );
639 640
640 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 641 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
641 mDeleteAction->addTo( actionMenu ); 642 mDeleteAction->addTo( actionMenu );
642 connect( mDeleteAction, SIGNAL( activated() ), 643 connect( mDeleteAction, SIGNAL( activated() ),
643 mView, SLOT( deleteIncidence() ) ); 644 mView, SLOT( deleteIncidence() ) );
644 645
645 646
646 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 647 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
647 mCloneAction->addTo( actionMenu ); 648 mCloneAction->addTo( actionMenu );
648 connect( mCloneAction, SIGNAL( activated() ), 649 connect( mCloneAction, SIGNAL( activated() ),
649 mView, SLOT( cloneIncidence() ) ); 650 mView, SLOT( cloneIncidence() ) );
650 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 651 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
651 mMoveAction->addTo( actionMenu ); 652 mMoveAction->addTo( actionMenu );
652 connect( mMoveAction, SIGNAL( activated() ), 653 connect( mMoveAction, SIGNAL( activated() ),
653 mView, SLOT( moveIncidence() ) ); 654 mView, SLOT( moveIncidence() ) );
654 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 655 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
655 mBeamAction->addTo( actionMenu ); 656 mBeamAction->addTo( actionMenu );
656 connect( mBeamAction, SIGNAL( activated() ), 657 connect( mBeamAction, SIGNAL( activated() ),
657 mView, SLOT( beamIncidence() ) ); 658 mView, SLOT( beamIncidence() ) );
658 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 659 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
659 mCancelAction->addTo( actionMenu ); 660 mCancelAction->addTo( actionMenu );
660 connect( mCancelAction, SIGNAL( activated() ), 661 connect( mCancelAction, SIGNAL( activated() ),
661 mView, SLOT( toggleCancelIncidence() ) ); 662 mView, SLOT( toggleCancelIncidence() ) );
662 663
663 actionMenu->insertSeparator(); 664 actionMenu->insertSeparator();
664 665
665 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 666 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
666 this ); 667 this );
667 action->addTo( actionMenu ); 668 action->addTo( actionMenu );
668 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 669 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
669 670
670 icon = loadPixmap( pathString + "search" ); 671 icon = loadPixmap( pathString + "search" );
671 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 672 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
672 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 673 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
673 search_action->addTo( actionMenu ); 674 search_action->addTo( actionMenu );
674 connect( search_action, SIGNAL( activated() ), 675 connect( search_action, SIGNAL( activated() ),
675 mView->dialogManager(), SLOT( showSearchDialog() ) ); 676 mView->dialogManager(), SLOT( showSearchDialog() ) );
676 677
677 icon = loadPixmap( pathString + "today" ); 678 icon = loadPixmap( pathString + "today" );
678 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 679 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
679 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 680 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
680 today_action->addTo( actionMenu ); 681 today_action->addTo( actionMenu );
681 connect( today_action, SIGNAL( activated() ), 682 connect( today_action, SIGNAL( activated() ),
682 mView, SLOT( goToday() ) ); 683 mView, SLOT( goToday() ) );
683 684
684 if ( KOPrefs::instance()->mShowFullMenu ) { 685 if ( KOPrefs::instance()->mShowFullMenu ) {
685 actionMenu->insertSeparator(); 686 actionMenu->insertSeparator();
686 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 687 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
687 688
688 } 689 }
689 // actionMenu->insertSeparator(); 690 // actionMenu->insertSeparator();
690 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 691 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
691 this ); 692 this );
692 action->addTo( importMenu ); 693 action->addTo( importMenu );
693 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 694 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
694 action = new QAction( "import_quick", i18n("Import last file"), 0, 695 action = new QAction( "import_quick", i18n("Import last file"), 0,
695 this ); 696 this );
696 action->addTo( importMenu ); 697 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 698 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
698 importMenu->insertSeparator(); 699 importMenu->insertSeparator();
699 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 700 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
700 this ); 701 this );
701 action->addTo( importMenu ); 702 action->addTo( importMenu );
702 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 703 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
703#ifndef DESKTOP_VERSION 704#ifndef DESKTOP_VERSION
704 importMenu->insertSeparator(); 705 importMenu->insertSeparator();
705 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 706 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
706 this ); 707 this );
707 action->addTo( importMenu ); 708 action->addTo( importMenu );
708 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 709 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
709#else 710#else
710#ifdef _WIN32_ 711#ifdef _WIN32_
711 importMenu->insertSeparator(); 712 importMenu->insertSeparator();
712 action = new QAction( "import_ol", i18n("Import from OL"), 0, 713 action = new QAction( "import_ol", i18n("Import from OL"), 0,
713 this ); 714 this );
714 action->addTo( importMenu ); 715 action->addTo( importMenu );
715 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 716 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
716#endif 717#endif
717#endif 718#endif
718 719
719 importMenu->insertSeparator(); 720 importMenu->insertSeparator();
720 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 721 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
721 this ); 722 this );
722 action->addTo( importMenu ); 723 action->addTo( importMenu );
723 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 724 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
724 725
725 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 726 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
726 this ); 727 this );
727 action->addTo( importMenu ); 728 action->addTo( importMenu );
728 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 729 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
729 730
730 importMenu->insertSeparator(); 731 importMenu->insertSeparator();
731 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 732 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
732 this ); 733 this );
733 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 734 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
734 735
735 736
736 //LR 737 //LR
737 QPopupMenu *ex2phone = new QPopupMenu( this ); 738 QPopupMenu *ex2phone = new QPopupMenu( this );
738 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 739 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
739 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 740 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
740 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 741 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
741 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 742 importMenu->insertItem( i18n("Export to phone"), ex2phone );
742 743
743 importMenu->insertSeparator(); 744 importMenu->insertSeparator();
744 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 745 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
745 this ); 746 this );
746 action->addTo( importMenu ); 747 action->addTo( importMenu );
747 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 748 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
748#ifndef DESKTOP_VERSION 749#ifndef DESKTOP_VERSION
749 importMenu->insertSeparator(); 750 importMenu->insertSeparator();
750 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 751 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
751 this ); 752 this );
752 action->addTo( importMenu ); 753 action->addTo( importMenu );
753 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 754 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
754 755
755 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 756 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
756 this ); 757 this );
757 action->addTo( importMenu ); 758 action->addTo( importMenu );
758 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 759 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
759#else 760#else
760 importMenu->insertSeparator(); 761 importMenu->insertSeparator();
761 icon = loadPixmap( pathString + "print" ); 762 icon = loadPixmap( pathString + "print" );
762 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 763 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
763 action->addTo( importMenu ); 764 action->addTo( importMenu );
764 connect( action, SIGNAL( activated() ), 765 connect( action, SIGNAL( activated() ),
765 this, SLOT( printCal() ) ); 766 this, SLOT( printCal() ) );
766 767
767 icon = loadPixmap( pathString + "print" ); 768 icon = loadPixmap( pathString + "print" );
768 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 769 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
769 action->addTo( importMenu ); 770 action->addTo( importMenu );
770 connect( action, SIGNAL( activated() ), 771 connect( action, SIGNAL( activated() ),
771 this, SLOT( printSel() ) ); 772 this, SLOT( printSel() ) );
772#endif 773#endif
773 importMenu->insertSeparator(); 774 importMenu->insertSeparator();
774 action = new QAction( "beam all", i18n("Save"), 0, 775 action = new QAction( "beam all", i18n("Save"), 0,
775 this ); 776 this );
776 action->addTo( importMenu ); 777 action->addTo( importMenu );
777 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 778 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
778 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 779 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
779 this ); 780 this );
780 action->addTo( importMenu ); 781 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 782 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
782 783
783 //menuBar->insertItem( "Configure",configureMenu ); 784 //menuBar->insertItem( "Configure",configureMenu );
784 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 785 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
785 icon = loadPixmap( "korganizer/korganizer" ); 786 icon = loadPixmap( "korganizer/korganizer" );
786 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 787 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
787 action->addTo( helpMenu ); 788 action->addTo( helpMenu );
788 connect( action, SIGNAL( activated() ), 789 connect( action, SIGNAL( activated() ),
789 SLOT( keyBindings() ) ); 790 SLOT( keyBindings() ) );
790 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 791 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
791 action->addTo( helpMenu ); 792 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 793 connect( action, SIGNAL( activated() ),
793 SLOT( features() ) ); 794 SLOT( features() ) );
794 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 795 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
795 action->addTo( helpMenu ); 796 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 797 connect( action, SIGNAL( activated() ),
797 SLOT( aboutAutoSaving() ) ); 798 SLOT( aboutAutoSaving() ) );
798 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 799 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
799 action->addTo( helpMenu ); 800 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 801 connect( action, SIGNAL( activated() ),
801 SLOT( aboutKnownBugs() ) ); 802 SLOT( aboutKnownBugs() ) );
802 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 803 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
803 action->addTo( helpMenu ); 804 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 805 connect( action, SIGNAL( activated() ),
805 SLOT( usertrans() ) ); 806 SLOT( usertrans() ) );
806 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 807 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
807 action->addTo( helpMenu ); 808 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 809 connect( action, SIGNAL( activated() ),
809 SLOT( synchowto() ) ); 810 SLOT( synchowto() ) );
810 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 811 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
811 action->addTo( helpMenu ); 812 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 813 connect( action, SIGNAL( activated() ),
813 SLOT( whatsNew() ) ); 814 SLOT( whatsNew() ) );
814 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 815 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
815 action->addTo( helpMenu ); 816 action->addTo( helpMenu );
816 connect( action, SIGNAL( activated() ), 817 connect( action, SIGNAL( activated() ),
817 SLOT( faq() ) ); 818 SLOT( faq() ) );
818 819
819 820
820 action = new QAction( "about", i18n("About..."), 0, this ); 821 action = new QAction( "about", i18n("About..."), 0, this );
821 action->addTo( helpMenu ); 822 action->addTo( helpMenu );
822 connect( action, SIGNAL( activated() ), 823 connect( action, SIGNAL( activated() ),
823 SLOT( about() ) ); 824 SLOT( about() ) );
824 action = new QAction( "licence", i18n("Licence..."), 0, this ); 825 action = new QAction( "licence", i18n("Licence..."), 0, this );
825 action->addTo( helpMenu ); 826 action->addTo( helpMenu );
826 connect( action, SIGNAL( activated() ), 827 connect( action, SIGNAL( activated() ),
827 SLOT( licence() ) ); 828 SLOT( licence() ) );
828 //menuBar->insertSeparator(); 829 //menuBar->insertSeparator();
829 830
830 // ****************************************************** 831 // ******************************************************
831 // menubar icons 832 // menubar icons
832 833
833 834
834 iconToolBar->setHorizontalStretchable (true ); 835 iconToolBar->setHorizontalStretchable (true );
835 //menuBar->insertItem( iconToolBar ); 836 //menuBar->insertItem( iconToolBar );
836 //xdays_action 837 //xdays_action
837 if (p-> mShowIconNewEvent) 838 if (p-> mShowIconNewEvent)
838 ne_action->addTo( iconToolBar ); 839 ne_action->addTo( iconToolBar );
839 if (p->mShowIconNewTodo ) 840 if (p->mShowIconNewTodo )
840 nt_action->addTo( iconToolBar ); 841 nt_action->addTo( iconToolBar );
841 if (p-> mShowIconSearch) 842 if (p-> mShowIconSearch)
842 search_action->addTo( iconToolBar ); 843 search_action->addTo( iconToolBar );
843 if (p-> mShowIconNext) 844 if (p-> mShowIconNext)
844 whatsnext_action->addTo( iconToolBar ); 845 whatsnext_action->addTo( iconToolBar );
845 if (p-> mShowIconNextDays) 846 if (p-> mShowIconNextDays)
846 xdays_action->addTo( iconToolBar ); 847 xdays_action->addTo( iconToolBar );
847 if (p-> mShowIconList) 848 if (p-> mShowIconList)
848 showlist_action->addTo( iconToolBar ); 849 showlist_action->addTo( iconToolBar );
849 if (p-> mShowIconDay1) 850 if (p-> mShowIconDay1)
850 day1_action->addTo( iconToolBar ); 851 day1_action->addTo( iconToolBar );
851 if (p-> mShowIconDay5) 852 if (p-> mShowIconDay5)
852 day5_action->addTo( iconToolBar ); 853 day5_action->addTo( iconToolBar );
853 if (p-> mShowIconDay7) 854 if (p-> mShowIconDay7)
854 day7_action->addTo( iconToolBar ); 855 day7_action->addTo( iconToolBar );
855 if (p-> mShowIconMonth) 856 if (p-> mShowIconMonth)
856 month_action->addTo( iconToolBar ); 857 month_action->addTo( iconToolBar );
857 if (p-> mShowIconTodoview) 858 if (p-> mShowIconTodoview)
858 todoview_action->addTo( iconToolBar ); 859 todoview_action->addTo( iconToolBar );
859 if (p-> mShowIconJournal) 860 if (p-> mShowIconJournal)
860 viewjournal_action->addTo( iconToolBar ); 861 viewjournal_action->addTo( iconToolBar );
861 icon = loadPixmap( pathString + "2leftarrowB" ); 862 icon = loadPixmap( pathString + "2leftarrowB" );
862 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 863 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
863 if (p-> mShowIconBackFast) { 864 if (p-> mShowIconBackFast) {
864 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 865 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
865 connect( action, SIGNAL( activated() ), 866 connect( action, SIGNAL( activated() ),
866 mView, SLOT( goPreviousMonth() ) ); 867 mView, SLOT( goPreviousMonth() ) );
867 action->addTo( iconToolBar ); 868 action->addTo( iconToolBar );
868 } 869 }
869 icon = loadPixmap( pathString + "1leftarrowB" ); 870 icon = loadPixmap( pathString + "1leftarrowB" );
870 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 871 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
871 if (p-> mShowIconBack) { 872 if (p-> mShowIconBack) {
872 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 873 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
873 connect( action, SIGNAL( activated() ), 874 connect( action, SIGNAL( activated() ),
874 mView, SLOT( goPrevious() ) ); 875 mView, SLOT( goPrevious() ) );
875 action->addTo( iconToolBar ); 876 action->addTo( iconToolBar );
876 } 877 }
877 if (p-> mShowIconToday) 878 if (p-> mShowIconToday)
878 today_action->addTo( iconToolBar ); 879 today_action->addTo( iconToolBar );
879 icon = loadPixmap( pathString + "1rightarrowB" ); 880 icon = loadPixmap( pathString + "1rightarrowB" );
880 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 881 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
881 if (p-> mShowIconForward) { 882 if (p-> mShowIconForward) {
882 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 883 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
883 connect( action, SIGNAL( activated() ), 884 connect( action, SIGNAL( activated() ),
884 mView, SLOT( goNext() ) ); 885 mView, SLOT( goNext() ) );
885 action->addTo( iconToolBar ); 886 action->addTo( iconToolBar );
886 } 887 }
887 icon = loadPixmap( pathString + "2rightarrowB" ); 888 icon = loadPixmap( pathString + "2rightarrowB" );
888 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 889 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
889 if (p-> mShowIconForwardFast) { 890 if (p-> mShowIconForwardFast) {
890 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 891 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
891 connect( action, SIGNAL( activated() ), 892 connect( action, SIGNAL( activated() ),
892 mView, SLOT( goNextMonth() ) ); 893 mView, SLOT( goNextMonth() ) );
893 action->addTo( iconToolBar ); 894 action->addTo( iconToolBar );
894 } 895 }
895 896
896 897
897 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 898 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
898 899
899 if (p-> mShowIconNewEvent) 900 if (p-> mShowIconNewEvent)
900 configureToolBarMenu->setItemChecked( 10, true ); 901 configureToolBarMenu->setItemChecked( 10, true );
901 if (p->mShowIconNewTodo ) 902 if (p->mShowIconNewTodo )
902 configureToolBarMenu->setItemChecked( 20, true ); 903 configureToolBarMenu->setItemChecked( 20, true );
903 if (p-> mShowIconSearch) 904 if (p-> mShowIconSearch)
904 configureToolBarMenu->setItemChecked( 120, true ); 905 configureToolBarMenu->setItemChecked( 120, true );
905 if (p-> mShowIconList) 906 if (p-> mShowIconList)
906 configureToolBarMenu->setItemChecked( 30, true ); 907 configureToolBarMenu->setItemChecked( 30, true );
907 if (p-> mShowIconDay1) 908 if (p-> mShowIconDay1)
908 configureToolBarMenu->setItemChecked( 40, true ); 909 configureToolBarMenu->setItemChecked( 40, true );
909 if (p-> mShowIconDay5) 910 if (p-> mShowIconDay5)
910 configureToolBarMenu->setItemChecked( 50, true ); 911 configureToolBarMenu->setItemChecked( 50, true );
911 if (p-> mShowIconDay7) 912 if (p-> mShowIconDay7)
912 configureToolBarMenu->setItemChecked( 60, true ); 913 configureToolBarMenu->setItemChecked( 60, true );
913 if (p-> mShowIconMonth) 914 if (p-> mShowIconMonth)
914 configureToolBarMenu->setItemChecked( 70, true ); 915 configureToolBarMenu->setItemChecked( 70, true );
915 if (p-> mShowIconTodoview) 916 if (p-> mShowIconTodoview)
916 configureToolBarMenu->setItemChecked( 80, true ); 917 configureToolBarMenu->setItemChecked( 80, true );
917 if (p-> mShowIconBackFast) 918 if (p-> mShowIconBackFast)
918 configureToolBarMenu->setItemChecked( 200, true ); 919 configureToolBarMenu->setItemChecked( 200, true );
919 if (p-> mShowIconBack) 920 if (p-> mShowIconBack)
920 configureToolBarMenu->setItemChecked( 210, true ); 921 configureToolBarMenu->setItemChecked( 210, true );
921 if (p-> mShowIconToday) 922 if (p-> mShowIconToday)
922 configureToolBarMenu->setItemChecked( 130, true ); 923 configureToolBarMenu->setItemChecked( 130, true );
923 if (p-> mShowIconForward) 924 if (p-> mShowIconForward)
924 configureToolBarMenu->setItemChecked( 220, true ); 925 configureToolBarMenu->setItemChecked( 220, true );
925 if (p-> mShowIconForwardFast) 926 if (p-> mShowIconForwardFast)
926 configureToolBarMenu->setItemChecked( 230, true ); 927 configureToolBarMenu->setItemChecked( 230, true );
927 if (p-> mShowIconNextDays) 928 if (p-> mShowIconNextDays)
928 configureToolBarMenu->setItemChecked( 100, true ); 929 configureToolBarMenu->setItemChecked( 100, true );
929 if (p-> mShowIconNext) 930 if (p-> mShowIconNext)
930 configureToolBarMenu->setItemChecked( 110, true ); 931 configureToolBarMenu->setItemChecked( 110, true );
931 if (p-> mShowIconJournal) 932 if (p-> mShowIconJournal)
932 configureToolBarMenu->setItemChecked( 90, true ); 933 configureToolBarMenu->setItemChecked( 90, true );
933 if (p-> mShowIconWhatsThis) 934 if (p-> mShowIconWhatsThis)
934 configureToolBarMenu->setItemChecked( 300, true ); 935 configureToolBarMenu->setItemChecked( 300, true );
935 936
936 QLabel* dummy = new QLabel( iconToolBar ); 937 QLabel* dummy = new QLabel( iconToolBar );
937 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 938 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
938 if (!p-> mShowIconStretch) 939 if (!p-> mShowIconStretch)
939 iconToolBar->setStretchableWidget ( dummy ) ; 940 iconToolBar->setStretchableWidget ( dummy ) ;
940 else 941 else
941 configureToolBarMenu->setItemChecked( 5, true ); 942 configureToolBarMenu->setItemChecked( 5, true );
942 if (p-> mShowIconWhatsThis) 943 if (p-> mShowIconWhatsThis)
943 QWhatsThis::whatsThisButton ( iconToolBar ); 944 QWhatsThis::whatsThisButton ( iconToolBar );
944 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 945 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
945 configureAgenda( p->mHourSize ); 946 configureAgenda( p->mHourSize );
946 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 947 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
947} 948}
948 949
949void MainWindow::exportToPhone( int mode ) 950void MainWindow::exportToPhone( int mode )
950{ 951{
951 952
952 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 953 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
953 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 954 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
954 KOex2phonePrefs ex2phone; 955 KOex2phonePrefs ex2phone;
955 956
956 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 957 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
957 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 958 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
958 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 959 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
959 if ( mode == 1 ) 960 if ( mode == 1 )
960 ex2phone.setCaption(i18n("Export complete calendar")); 961 ex2phone.setCaption(i18n("Export complete calendar"));
961 if ( mode == 2 ) 962 if ( mode == 2 )
962 ex2phone.setCaption(i18n("Export filtered calendar")); 963 ex2phone.setCaption(i18n("Export filtered calendar"));
963 964
964 if ( !ex2phone.exec() ) { 965 if ( !ex2phone.exec() ) {
965 return; 966 return;
966 } 967 }
967 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 968 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
968 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 969 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
969 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 970 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
970 971
971 int inFuture = 0; 972 int inFuture = 0;
972 if ( ex2phone.mWriteBackFuture->isChecked() ) 973 if ( ex2phone.mWriteBackFuture->isChecked() )
973 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 974 inFuture = ex2phone.mWriteBackFutureWeeks->value();
974 QPtrList<Incidence> delSel; 975 QPtrList<Incidence> delSel;
975 if ( mode == 1 ) 976 if ( mode == 1 )
976 delSel = mCalendar->rawIncidences(); 977 delSel = mCalendar->rawIncidences();
977 if ( mode == 2 ) 978 if ( mode == 2 )
978 delSel = mCalendar->incidences(); 979 delSel = mCalendar->incidences();
979 CalendarLocal* cal = new CalendarLocal(); 980 CalendarLocal* cal = new CalendarLocal();
980 cal->setLocalTime(); 981 cal->setLocalTime();
981 Incidence *incidence = delSel.first(); 982 Incidence *incidence = delSel.first();
982 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 983 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
983 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 984 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
984 while ( incidence ) { 985 while ( incidence ) {
985 if ( incidence->type() != "Journal" ) { 986 if ( incidence->type() != "Journal" ) {
986 bool add = true; 987 bool add = true;
987 if ( inFuture ) { 988 if ( inFuture ) {
988 QDateTime dt; 989 QDateTime dt;
989 if ( incidence->type() == "Todo" ) { 990 if ( incidence->type() == "Todo" ) {
990 Todo * t = (Todo*)incidence; 991 Todo * t = (Todo*)incidence;
991 if ( t->hasDueDate() ) 992 if ( t->hasDueDate() )
992 dt = t->dtDue(); 993 dt = t->dtDue();
993 else 994 else
994 dt = cur.addSecs( 62 ); 995 dt = cur.addSecs( 62 );
995 } 996 }
996 else { 997 else {
997 bool ok; 998 bool ok;
998 dt = incidence->getNextOccurence( cur, &ok ); 999 dt = incidence->getNextOccurence( cur, &ok );
999 if ( !ok ) 1000 if ( !ok )
1000 dt = cur.addSecs( -62 ); 1001 dt = cur.addSecs( -62 );
1001 } 1002 }
1002 if ( dt < cur || dt > end ) { 1003 if ( dt < cur || dt > end ) {
1003 add = false; 1004 add = false;
1004 } 1005 }
1005 } 1006 }
1006 if ( add ) { 1007 if ( add ) {
1007 Incidence *in = incidence->clone(); 1008 Incidence *in = incidence->clone();
1008 cal->addIncidence( in ); 1009 cal->addIncidence( in );
1009 } 1010 }
1010 } 1011 }
1011 incidence = delSel.next(); 1012 incidence = delSel.next();
1012 } 1013 }
1013 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1014 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1014 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1015 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1015 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1016 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1016 1017
1017 setCaption( i18n("Writing to phone...")); 1018 setCaption( i18n("Writing to phone..."));
1018 if ( PhoneFormat::writeToPhone( cal ) ) 1019 if ( PhoneFormat::writeToPhone( cal ) )
1019 setCaption( i18n("Export to phone successful!")); 1020 setCaption( i18n("Export to phone successful!"));
1020 else 1021 else
1021 setCaption( i18n("Error exporting to phone!")); 1022 setCaption( i18n("Error exporting to phone!"));
1022 delete cal; 1023 delete cal;
1023} 1024}
1024 1025
1025 1026
1026void MainWindow::setDefaultPreferences() 1027void MainWindow::setDefaultPreferences()
1027{ 1028{
1028 KOPrefs *p = KOPrefs::instance(); 1029 KOPrefs *p = KOPrefs::instance();
1029 1030
1030 p->mCompactDialogs = true; 1031 p->mCompactDialogs = true;
1031 p->mConfirm = true; 1032 p->mConfirm = true;
1032 // p->mEnableQuickTodo = false; 1033 // p->mEnableQuickTodo = false;
1033 1034
1034} 1035}
1035 1036
1036QString MainWindow::resourcePath() 1037QString MainWindow::resourcePath()
1037{ 1038{
1038 return KGlobal::iconLoader()->iconPath(); 1039 return KGlobal::iconLoader()->iconPath();
1039} 1040}
1040 1041
1041void MainWindow::displayText( QString text ,QString cap ) 1042void MainWindow::displayText( QString text ,QString cap )
1042{ 1043{
1043 QDialog dia( this, "name", true ); ; 1044 QDialog dia( this, "name", true ); ;
1044 dia.setCaption( cap ); 1045 dia.setCaption( cap );
1045 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1046 QVBoxLayout* lay = new QVBoxLayout( &dia );
1046 lay->setSpacing( 3 ); 1047 lay->setSpacing( 3 );
1047 lay->setMargin( 3 ); 1048 lay->setMargin( 3 );
1048 QTextBrowser tb ( &dia ); 1049 QTextBrowser tb ( &dia );
1049 lay->addWidget( &tb ); 1050 lay->addWidget( &tb );
1050 tb.setText( text ); 1051 tb.setText( text );
1051#ifdef DESKTOP_VERSION 1052#ifdef DESKTOP_VERSION
1052 dia.resize( 640, 480); 1053 dia.resize( 640, 480);
1053#else 1054#else
1054 dia.showMaximized(); 1055 dia.showMaximized();
1055#endif 1056#endif
1056 dia.exec(); 1057 dia.exec();
1057} 1058}
1058void MainWindow::displayFile( QString fn, QString cap ) 1059void MainWindow::displayFile( QString fn, QString cap )
1059{ 1060{
1060 QString fileName = resourcePath() + fn; 1061 QString fileName = resourcePath() + fn;
1061 QString text; 1062 QString text;
1062 QFile file( fileName ); 1063 QFile file( fileName );
1063 if (!file.open( IO_ReadOnly ) ) { 1064 if (!file.open( IO_ReadOnly ) ) {
1064 return ; 1065 return ;
1065 1066
1066 } 1067 }
1067 QTextStream ts( &file ); 1068 QTextStream ts( &file );
1068 text = ts.read(); 1069 text = ts.read();
1069 file.close(); 1070 file.close();
1070 displayText( text, cap); 1071 displayText( text, cap);
1071} 1072}
1072void MainWindow::features() 1073void MainWindow::features()
1073{ 1074{
1074 1075
1075 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1076 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1076} 1077}
1077 1078
1078void MainWindow::usertrans() 1079void MainWindow::usertrans()
1079{ 1080{
1080 1081
1081 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1082 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1082} 1083}
1083 1084
1084void MainWindow::synchowto() 1085void MainWindow::synchowto()
1085{ 1086{
1086#if 0 1087#if 0
1087 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1088 QPtrList<Incidence> er = mCalendar->rawIncidences();
1088 Incidence* inR = er.first(); 1089 Incidence* inR = er.first();
1089 VCalFormat vf; 1090 VCalFormat vf;
1090 QString strout; 1091 QString strout;
1091 while ( inR ) { 1092 while ( inR ) {
1092 if ( inR->type() == "Todo" ) 1093 if ( inR->type() == "Todo" )
1093 strout = vf.todoToString( (Todo *) inR ); 1094 strout = vf.todoToString( (Todo *) inR );
1094 if ( inR->type() == "Event" ) 1095 if ( inR->type() == "Event" )
1095 strout = vf.eventToString( (Event *) inR ); 1096 strout = vf.eventToString( (Event *) inR );
1096 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1097 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1097 inR = er.next(); 1098 inR = er.next();
1098 } 1099 }
1099#endif 1100#endif
1100 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1101 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1101} 1102}
1102void MainWindow::faq() 1103void MainWindow::faq()
1103{ 1104{
1104 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1105 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1105 1106
1106} 1107}
1107void MainWindow::whatsNew() 1108void MainWindow::whatsNew()
1108{ 1109{
1109 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1110 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1110 1111
1111} 1112}
1112void MainWindow::licence() 1113void MainWindow::licence()
1113{ 1114{
1114 KApplication::showLicence(); 1115 KApplication::showLicence();
1115 1116
1116} 1117}
1117void MainWindow::about() 1118void MainWindow::about()
1118{ 1119{
1119 QString version; 1120 QString version;
1120#include <../version> 1121#include <../version>
1121 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1122 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1122 i18n("KOrganizer/Platform-independent\n") + 1123 i18n("KOrganizer/Platform-independent\n") +
1123 "(KO/Pi) " + version + " - " + 1124 "(KO/Pi) " + version + " - " +
1124 1125
1125#ifdef DESKTOP_VERSION 1126#ifdef DESKTOP_VERSION
1126 i18n("Desktop Edition\n") + 1127 i18n("Desktop Edition\n") +
1127#else 1128#else
1128 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1129 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1129#endif 1130#endif
1130 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1131 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1131} 1132}
1132void MainWindow::keyBindings() 1133void MainWindow::keyBindings()
1133{ 1134{
1134 QString cap = i18n("Key bindings KOrganizer/Pi"); 1135 QString cap = i18n("Key bindings KOrganizer/Pi");
1135 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1136 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1136 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1137 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1137 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1138 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1138 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1139 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1139 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1140 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1140 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1141 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1141 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1142 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1142 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1143 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1143 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1144 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1144 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1145 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1145 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1146 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1146 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1147 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1147 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1148 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1148 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1149 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1149 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1150 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1150 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1151 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1151 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1152 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1152 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1153 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1153 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1154 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1154 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1155 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1155 i18n("<p><h3>In agenda view:</h3></p>\n") + 1156 i18n("<p><h3>In agenda view:</h3></p>\n") +
1156 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1157 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1157 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1158 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1158 i18n("<p><h3>In todo view:</h3></p>\n") + 1159 i18n("<p><h3>In todo view:</h3></p>\n") +
1159 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1160 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1160 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1161 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1161 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1162 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1162 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1163 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1163 i18n("<p><h3>In list view:</h3></p>\n") + 1164 i18n("<p><h3>In list view:</h3></p>\n") +
1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1165 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1165 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1166 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1166 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1167 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1167 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1168 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1168 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1169 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1169 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1170 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1170 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1171 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1171 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1172 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1172 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1173 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1173 i18n("<p><b>E</b>: Edit item</p>\n") + 1174 i18n("<p><b>E</b>: Edit item</p>\n") +
1174 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1175 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1175 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1176 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1176 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1177 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1177 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1178 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1178 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1179 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1179 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1180 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1180 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1181 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1181 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1182 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1182 i18n("<p><b>White</b>: Item readonly</p>\n"); 1183 i18n("<p><b>White</b>: Item readonly</p>\n");
1183 displayText( text, cap); 1184 displayText( text, cap);
1184 1185
1185} 1186}
1186void MainWindow::aboutAutoSaving() 1187void MainWindow::aboutAutoSaving()
1187{ 1188{
1188 QMessageBox* msg; 1189 QMessageBox* msg;
1189 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1190 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1190 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1191 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1191 QMessageBox::Ok, 1192 QMessageBox::Ok,
1192 QMessageBox::NoButton, 1193 QMessageBox::NoButton,
1193 QMessageBox::NoButton); 1194 QMessageBox::NoButton);
1194 msg->exec(); 1195 msg->exec();
1195 delete msg; 1196 delete msg;
1196 1197
1197 1198
1198} 1199}
1199void MainWindow::aboutKnownBugs() 1200void MainWindow::aboutKnownBugs()
1200{ 1201{
1201 QMessageBox* msg; 1202 QMessageBox* msg;
1202 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1203 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1203 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1204 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1204 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1205 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1205 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1206 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1206 i18n("\nor report them in the bugtracker on\n") + 1207 i18n("\nor report them in the bugtracker on\n") +
1207 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1208 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1208 QMessageBox::NoIcon, 1209 QMessageBox::NoIcon,
1209 QMessageBox::Ok, 1210 QMessageBox::Ok,
1210 QMessageBox::NoButton, 1211 QMessageBox::NoButton,
1211 QMessageBox::NoButton); 1212 QMessageBox::NoButton);
1212 msg->exec(); 1213 msg->exec();
1213 delete msg; 1214 delete msg;
1214 1215
1215} 1216}
1216 1217
1217QString MainWindow::defaultFileName() 1218QString MainWindow::defaultFileName()
1218{ 1219{
1219 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1220 return locateLocal( "data", "korganizer/mycalendar.ics" );
1220} 1221}
1221QString MainWindow::syncFileName() 1222QString MainWindow::syncFileName()
1222{ 1223{
1223#ifdef _WIN32_ 1224#ifdef _WIN32_
1224 return locateLocal( "tmp", "synccalendar.ics" ); 1225 return locateLocal( "tmp", "synccalendar.ics" );
1225#else 1226#else
1226 return QString( "/tmp/kopitempfile.ics" ); 1227 return QString( "/tmp/kopitempfile.ics" );
1227#endif 1228#endif
1228} 1229}
1229 1230
1230void MainWindow::processIncidenceSelection( Incidence *incidence ) 1231void MainWindow::processIncidenceSelection( Incidence *incidence )
1231{ 1232{
1232 if ( !incidence ) { 1233 if ( !incidence ) {
1233 enableIncidenceActions( false ); 1234 enableIncidenceActions( false );
1234 1235
1235 mNewSubTodoAction->setEnabled( false ); 1236 mNewSubTodoAction->setEnabled( false );
1236 setCaptionToDates(); 1237 setCaptionToDates();
1237 return; 1238 return;
1238 1239
1239 } 1240 }
1240 1241
1241 //KGlobal::locale()->formatDateTime(nextA, true); 1242 //KGlobal::locale()->formatDateTime(nextA, true);
1242 QString startString = ""; 1243 QString startString = "";
1243 if ( incidence->type() != "Todo" ) { 1244 if ( incidence->type() != "Todo" ) {
1244 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1245 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1245 if ( incidence->doesFloat() ) { 1246 if ( incidence->doesFloat() ) {
1246 startString += ": "+incidence->dtStartDateStr( true ); 1247 startString += ": "+incidence->dtStartDateStr( true );
1247 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1248 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1248 1249
1249 } else { 1250 } else {
1250 startString = ": "+incidence->dtStartStr(true); 1251 startString = ": "+incidence->dtStartStr(true);
1251 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1252 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1252 1253
1253 } 1254 }
1254 1255
1255 } else { 1256 } else {
1256 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1257 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1257 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1258 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1258 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1259 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1259 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1260 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1260 } 1261 }
1261 1262
1262 } 1263 }
1263 else 1264 else
1264 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1265 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1265 if ( !incidence->location().isEmpty() ) 1266 if ( !incidence->location().isEmpty() )
1266 startString += " (" +incidence->location()+")"; 1267 startString += " (" +incidence->location()+")";
1267 setCaption( incidence->summary()+startString); 1268 setCaption( incidence->summary()+startString);
1268 1269
1269 enableIncidenceActions( true ); 1270 enableIncidenceActions( true );
1270 1271
1271 if ( incidence->type() == "Event" ) { 1272 if ( incidence->type() == "Event" ) {
1272 mShowAction->setText( i18n("Show Event...") ); 1273 mShowAction->setText( i18n("Show Event...") );
1273 mEditAction->setText( i18n("Edit Event...") ); 1274 mEditAction->setText( i18n("Edit Event...") );
1274 mDeleteAction->setText( i18n("Delete Event...") ); 1275 mDeleteAction->setText( i18n("Delete Event...") );
1275 1276
1276 mNewSubTodoAction->setEnabled( false ); 1277 mNewSubTodoAction->setEnabled( false );
1277 } else if ( incidence->type() == "Todo" ) { 1278 } else if ( incidence->type() == "Todo" ) {
1278 mShowAction->setText( i18n("Show Todo...") ); 1279 mShowAction->setText( i18n("Show Todo...") );
1279 mEditAction->setText( i18n("Edit Todo...") ); 1280 mEditAction->setText( i18n("Edit Todo...") );
1280 mDeleteAction->setText( i18n("Delete Todo...") ); 1281 mDeleteAction->setText( i18n("Delete Todo...") );
1281 1282
1282 mNewSubTodoAction->setEnabled( true ); 1283 mNewSubTodoAction->setEnabled( true );
1283 } else { 1284 } else {
1284 mShowAction->setText( i18n("Show...") ); 1285 mShowAction->setText( i18n("Show...") );
1285 mShowAction->setText( i18n("Edit...") ); 1286 mShowAction->setText( i18n("Edit...") );
1286 mShowAction->setText( i18n("Delete...") ); 1287 mShowAction->setText( i18n("Delete...") );
1287 1288
1288 mNewSubTodoAction->setEnabled( false ); 1289 mNewSubTodoAction->setEnabled( false );
1289 } 1290 }
1290} 1291}
1291 1292
1292void MainWindow::enableIncidenceActions( bool enabled ) 1293void MainWindow::enableIncidenceActions( bool enabled )
1293{ 1294{
1294 mShowAction->setEnabled( enabled ); 1295 mShowAction->setEnabled( enabled );
1295 mEditAction->setEnabled( enabled ); 1296 mEditAction->setEnabled( enabled );
1296 mDeleteAction->setEnabled( enabled ); 1297 mDeleteAction->setEnabled( enabled );
1297 1298
1298 mCloneAction->setEnabled( enabled ); 1299 mCloneAction->setEnabled( enabled );
1299 mMoveAction->setEnabled( enabled ); 1300 mMoveAction->setEnabled( enabled );
1300 mBeamAction->setEnabled( enabled ); 1301 mBeamAction->setEnabled( enabled );
1301 mCancelAction->setEnabled( enabled ); 1302 mCancelAction->setEnabled( enabled );
1302} 1303}
1303 1304
1304void MainWindow::importOL() 1305void MainWindow::importOL()
1305{ 1306{
1306#ifdef _WIN32_ 1307#ifdef _WIN32_
1307 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1308 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1308 id->exec(); 1309 id->exec();
1309 delete id; 1310 delete id;
1310 mView->updateView(); 1311 mView->updateView();
1311#endif 1312#endif
1312} 1313}
1313void MainWindow::importBday() 1314void MainWindow::importBday()
1314{ 1315{
1315 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1316 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1316 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1317 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1317 i18n("Import!"), i18n("Cancel"), 0, 1318 i18n("Import!"), i18n("Cancel"), 0,
1318 0, 1 ); 1319 0, 1 );
1319 if ( result == 0 ) { 1320 if ( result == 0 ) {
1320 mView->importBday(); 1321 mView->importBday();
1321 1322
1322 } 1323 }
1323 1324
1324 1325
1325} 1326}
1326void MainWindow::importQtopia() 1327void MainWindow::importQtopia()
1327{ 1328{
1328#ifndef DESKTOP_VERSION 1329#ifndef DESKTOP_VERSION
1329 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1330 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1330 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1331 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1331 i18n("Import!"), i18n("Cancel"), 0, 1332 i18n("Import!"), i18n("Cancel"), 0,
1332 0, 1 ); 1333 0, 1 );
1333 if ( result == 0 ) { 1334 if ( result == 0 ) {
1334 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1335 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1335 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1336 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1336 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1337 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1337 mView->importQtopia( categories, datebook, todolist ); 1338 mView->importQtopia( categories, datebook, todolist );
1338 } 1339 }
1339#else 1340#else
1340 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1341 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1341 i18n("Not supported \non desktop!\n"), 1342 i18n("Not supported \non desktop!\n"),
1342 i18n("Ok"), i18n("Cancel"), 0, 1343 i18n("Ok"), i18n("Cancel"), 0,
1343 0, 1 ); 1344 0, 1 );
1344 1345
1345#endif 1346#endif
1346} 1347}
1347 1348
1348void MainWindow::saveOnClose() 1349void MainWindow::saveOnClose()
1349{ 1350{
1350 KOPrefs *p = KOPrefs::instance(); 1351 KOPrefs *p = KOPrefs::instance();
1351 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1352 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1352 p->mToolBarUp = iconToolBar->x() > width()/2 || 1353 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1353 iconToolBar->y() > height()/2; 1354 iconToolBar->y() > height()/2;
1354 mView->writeSettings(); 1355 mView->writeSettings();
1355 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1356 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1356 save(); 1357 save();
1357} 1358}
1358void MainWindow::slotModifiedChanged( bool changed ) 1359void MainWindow::slotModifiedChanged( bool changed )
1359{ 1360{
1360 if ( mBlockAtStartup ) 1361 if ( mBlockAtStartup )
1361 return; 1362 return;
1362 int msec; 1363 int msec;
1363 // we store the changes after 1 minute, 1364 // we store the changes after 1 minute,
1364 // and for safety reasons after 10 minutes again 1365 // and for safety reasons after 10 minutes again
1365 if ( !mSyncManager->blockSave() ) 1366 if ( !mSyncManager->blockSave() )
1366 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1367 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1367 else 1368 else
1368 msec = 1000 * 600; 1369 msec = 1000 * 600;
1369 mSaveTimer.start( msec, true ); // 1 minute 1370 mSaveTimer.start( msec, true ); // 1 minute
1370 qDebug("KO: Saving File in %d secs!", msec/1000); 1371 qDebug("KO: Saving File in %d secs!", msec/1000);
1371 mCalendarModifiedFlag = true; 1372 mCalendarModifiedFlag = true;
1372} 1373}
1373void MainWindow::save() 1374void MainWindow::save()
1374{ 1375{
1375 if ( mSyncManager->blockSave() ) 1376 if ( mSyncManager->blockSave() )
1376 return; 1377 return;
1377 mSyncManager->setBlockSave(true); 1378 mSyncManager->setBlockSave(true);
1378 if ( mView->checkFileVersion( defaultFileName()) ) { 1379 if ( mView->checkFileVersion( defaultFileName()) ) {
1379 1380
1380 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1381 QTime neededSaveTime = QDateTime::currentDateTime().time();
1381 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1382 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1382 qDebug("KO: Start saving data to file!"); 1383 qDebug("KO: Start saving data to file!");
1383 mView->saveCalendar( defaultFileName() ); 1384 mView->saveCalendar( defaultFileName() );
1384 1385
1385 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1386 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1386 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1387 qDebug("KO: Needed %d ms for saving.",msNeeded );
1387 QString savemes; 1388 QString savemes;
1388 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1389 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1389 setCaption(savemes); 1390 setCaption(savemes);
1390 } else 1391 } else
1391 setCaption(i18n("Saving cancelled!")); 1392 setCaption(i18n("Saving cancelled!"));
1392 mCalendarModifiedFlag = false; 1393 mCalendarModifiedFlag = false;
1393 mSyncManager->setBlockSave( false ); 1394 mSyncManager->setBlockSave( false );
1394} 1395}
1395 1396
1396void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1397void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1397{ 1398{
1398 if ( !e->isAutoRepeat() ) { 1399 if ( !e->isAutoRepeat() ) {
1399 mFlagKeyPressed = false; 1400 mFlagKeyPressed = false;
1400 } 1401 }
1401} 1402}
1402void MainWindow::keyPressEvent ( QKeyEvent * e ) 1403void MainWindow::keyPressEvent ( QKeyEvent * e )
1403{ 1404{
1404 qApp->processEvents(); 1405 qApp->processEvents();
1405 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1406 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1406 e->ignore(); 1407 e->ignore();
1407 // qDebug(" ignore %d",e->isAutoRepeat() ); 1408 // qDebug(" ignore %d",e->isAutoRepeat() );
1408 return; 1409 return;
1409 } 1410 }
1410 if (! e->isAutoRepeat() ) 1411 if (! e->isAutoRepeat() )
1411 mFlagKeyPressed = true; 1412 mFlagKeyPressed = true;
1412 KOPrefs *p = KOPrefs::instance(); 1413 KOPrefs *p = KOPrefs::instance();
1413 bool showSelectedDates = false; 1414 bool showSelectedDates = false;
1414 int size; 1415 int size;
1415 int pro = 0; 1416 int pro = 0;
1416 //qDebug("MainWindow::keyPressEvent "); 1417 //qDebug("MainWindow::keyPressEvent ");
1417 switch ( e->key() ) { 1418 switch ( e->key() ) {
1418 case Qt::Key_Right: 1419 case Qt::Key_Right:
1419 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1420 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1420 mView->goNextMonth(); 1421 mView->goNextMonth();
1421 else 1422 else
1422 mView->goNext(); 1423 mView->goNext();
1423 showSelectedDates = true; 1424 showSelectedDates = true;
1424 break; 1425 break;
1425 case Qt::Key_Left: 1426 case Qt::Key_Left:
1426 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1427 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1427 mView->goPreviousMonth(); 1428 mView->goPreviousMonth();
1428 else 1429 else
1429 mView->goPrevious(); 1430 mView->goPrevious();
1430 showSelectedDates = true; 1431 showSelectedDates = true;
1431 break; 1432 break;
1432 case Qt::Key_Down: 1433 case Qt::Key_Down:
1433 mView->viewManager()->agendaView()->scrollOneHourDown(); 1434 mView->viewManager()->agendaView()->scrollOneHourDown();
1434 break; 1435 break;
1435 case Qt::Key_Up: 1436 case Qt::Key_Up:
1436 mView->viewManager()->agendaView()->scrollOneHourUp(); 1437 mView->viewManager()->agendaView()->scrollOneHourUp();
1437 break; 1438 break;
1438 case Qt::Key_I: 1439 case Qt::Key_I:
1439 mView->showIncidence(); 1440 mView->showIncidence();
1440 break; 1441 break;
1441 case Qt::Key_Delete: 1442 case Qt::Key_Delete:
1442 case Qt::Key_Backspace: 1443 case Qt::Key_Backspace:
1443 mView->deleteIncidence(); 1444 mView->deleteIncidence();
1444 break; 1445 break;
1445 case Qt::Key_D: 1446 case Qt::Key_D:
1446 mView->viewManager()->showDayView(); 1447 mView->viewManager()->showDayView();
1447 showSelectedDates = true; 1448 showSelectedDates = true;
1448 break; 1449 break;
1449 case Qt::Key_O: 1450 case Qt::Key_O:
1450 mView->toggleFilerEnabled( ); 1451 mView->toggleFilerEnabled( );
1451 break; 1452 break;
1452 case Qt::Key_0: 1453 case Qt::Key_0:
1453 case Qt::Key_1: 1454 case Qt::Key_1:
1454 case Qt::Key_2: 1455 case Qt::Key_2:
1455 case Qt::Key_3: 1456 case Qt::Key_3:
1456 case Qt::Key_4: 1457 case Qt::Key_4:
1457 case Qt::Key_5: 1458 case Qt::Key_5:
1458 case Qt::Key_6: 1459 case Qt::Key_6:
1459 case Qt::Key_7: 1460 case Qt::Key_7:
1460 case Qt::Key_8: 1461 case Qt::Key_8:
1461 case Qt::Key_9: 1462 case Qt::Key_9:
1462 pro = e->key()-48; 1463 pro = e->key()-48;
1463 if ( pro == 0 ) 1464 if ( pro == 0 )
1464 pro = 10; 1465 pro = 10;
1465 if ( e->state() == Qt::ControlButton) 1466 if ( e->state() == Qt::ControlButton)
1466 pro += 10; 1467 pro += 10;
1467 break; 1468 break;
1468 case Qt::Key_M: 1469 case Qt::Key_M:
1469 mView->viewManager()->showMonthView(); 1470 mView->viewManager()->showMonthView();
1470 showSelectedDates = true; 1471 showSelectedDates = true;
1471 break; 1472 break;
1472 case Qt::Key_Insert: 1473 case Qt::Key_Insert:
1473 mView->newEvent(); 1474 mView->newEvent();
1474 break; 1475 break;
1475 case Qt::Key_S : 1476 case Qt::Key_S :
1476 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1477 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1477 mView->newSubTodo(); 1478 mView->newSubTodo();
1478 else 1479 else
1479 mView->dialogManager()->showSearchDialog(); 1480 mView->dialogManager()->showSearchDialog();
1480 break; 1481 break;
1481 case Qt::Key_Y : 1482 case Qt::Key_Y :
1482 case Qt::Key_Z : 1483 case Qt::Key_Z :
1483 mView->viewManager()->showWorkWeekView(); 1484 mView->viewManager()->showWorkWeekView();
1484 showSelectedDates = true; 1485 showSelectedDates = true;
1485 break; 1486 break;
1486 case Qt::Key_U : 1487 case Qt::Key_U :
1487 mView->viewManager()->showWeekView(); 1488 mView->viewManager()->showWeekView();
1488 showSelectedDates = true; 1489 showSelectedDates = true;
1489 break; 1490 break;
1490 case Qt::Key_H : 1491 case Qt::Key_H :
1491 keyBindings(); 1492 keyBindings();
1492 break; 1493 break;
1493 case Qt::Key_W: 1494 case Qt::Key_W:
1494 mView->viewManager()->showWhatsNextView(); 1495 mView->viewManager()->showWhatsNextView();
1495 break; 1496 break;
1496 case Qt::Key_L: 1497 case Qt::Key_L:
1497 mView->viewManager()->showListView(); 1498 mView->viewManager()->showListView();
1498 break; 1499 break;
1499 case Qt::Key_N: 1500 case Qt::Key_N:
1500 mView->viewManager()->showNextXView(); 1501 mView->viewManager()->showNextXView();
1501 showSelectedDates = true; 1502 showSelectedDates = true;
1502 break; 1503 break;
1503 case Qt::Key_V: 1504 case Qt::Key_V:
1504 mView->viewManager()->showTodoView(); 1505 mView->viewManager()->showTodoView();
1505 break; 1506 break;
1506 case Qt::Key_C: 1507 case Qt::Key_C:
1507 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1508 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1508 break; 1509 break;
1509 case Qt::Key_P: 1510 case Qt::Key_P:
1510 mView->showDatePicker( ); 1511 mView->showDatePicker( );
1511 break; 1512 break;
1512 case Qt::Key_F: 1513 case Qt::Key_F:
1513 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1514 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1514 mView->editFilters(); 1515 mView->editFilters();
1515 else 1516 else
1516 mView->toggleFilter(); 1517 mView->toggleFilter();
1517 break; 1518 break;
1518 case Qt::Key_X: 1519 case Qt::Key_X:
1519 mView->toggleDateNavigatorWidget(); 1520 mView->toggleDateNavigatorWidget();
1520 break; 1521 break;
1521 case Qt::Key_Space: 1522 case Qt::Key_Space:
1522 mView->toggleExpand(); 1523 mView->toggleExpand();
1523 break; 1524 break;
1524 case Qt::Key_A: 1525 case Qt::Key_A:
1525 mView->toggleAllDaySize(); 1526 mView->toggleAllDaySize();
1526 break; 1527 break;
1527 case Qt::Key_T: 1528 case Qt::Key_T:
1528 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1529 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1529 mView->newTodo(); 1530 mView->newTodo();
1530 else { 1531 else {
1531 mView->goToday(); 1532 mView->goToday();
1532 showSelectedDates = true; 1533 showSelectedDates = true;
1533 } 1534 }
1534 break; 1535 break;
1535 case Qt::Key_J: 1536 case Qt::Key_J:
1536 mView->viewManager()->showJournalView(); 1537 mView->viewManager()->showJournalView();
1537 break; 1538 break;
1538 case Qt::Key_B: 1539 case Qt::Key_B:
1539 mView->editIncidenceDescription();; 1540 mView->editIncidenceDescription();;
1540 break; 1541 break;
1541 // case Qt::Key_Return: 1542 // case Qt::Key_Return:
1542 case Qt::Key_E: 1543 case Qt::Key_E:
1543 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1544 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1544 mView->newEvent(); 1545 mView->newEvent();
1545 else 1546 else
1546 mView->editIncidence(); 1547 mView->editIncidence();
1547 break; 1548 break;
1548 case Qt::Key_Plus: 1549 case Qt::Key_Plus:
1549 size = p->mHourSize +2; 1550 size = p->mHourSize +2;
1550 if ( size <= 18 ) 1551 if ( size <= 18 )
1551 configureAgenda( size ); 1552 configureAgenda( size );
1552 break; 1553 break;
1553 case Qt::Key_Minus: 1554 case Qt::Key_Minus:
1554 size = p->mHourSize - 2; 1555 size = p->mHourSize - 2;
1555 if ( size >= 4 ) 1556 if ( size >= 4 )
1556 configureAgenda( size ); 1557 configureAgenda( size );
1557 break; 1558 break;
1558 1559
1559 1560
1560 default: 1561 default:
1561 e->ignore(); 1562 e->ignore();
1562 } 1563 }
1563 if ( pro > 0 ) { 1564 if ( pro > 0 ) {
1564 mView->selectFilter( pro-1 ); 1565 mView->selectFilter( pro-1 );
1565 } 1566 }
1566 if ( showSelectedDates ) { 1567 if ( showSelectedDates ) {
1567 ;// setCaptionToDates(); 1568 ;// setCaptionToDates();
1568 } 1569 }
1569 1570
1570} 1571}
1571 1572
1572void MainWindow::fillFilterMenu() 1573void MainWindow::fillFilterMenu()
1573{ 1574{
1574 selectFilterMenu->clear(); 1575 selectFilterMenu->clear();
1575 bool disable = false; 1576 bool disable = false;
1576 if ( mView->filterView()->filtersEnabled() ) { 1577 if ( mView->filterView()->filtersEnabled() ) {
1577 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1578 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1578 } 1579 }
1579 else { 1580 else {
1580 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1581 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1581 disable = true; 1582 disable = true;
1582 } 1583 }
1583 selectFilterMenu->insertSeparator(); 1584 selectFilterMenu->insertSeparator();
1584 QPtrList<CalFilter> fili = mView->filters(); 1585 QPtrList<CalFilter> fili = mView->filters();
1585 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1586 CalFilter *curfilter = mView->filterView()->selectedFilter();
1586 CalFilter *filter = fili.first(); 1587 CalFilter *filter = fili.first();
1587 int iii = 1; 1588 int iii = 1;
1588 while(filter) { 1589 while(filter) {
1589 selectFilterMenu->insertItem( filter->name(), iii ); 1590 selectFilterMenu->insertItem( filter->name(), iii );
1590 if ( filter == curfilter) 1591 if ( filter == curfilter)
1591 selectFilterMenu->setItemChecked( iii, true ); 1592 selectFilterMenu->setItemChecked( iii, true );
1592 if ( disable ) 1593 if ( disable )
1593 selectFilterMenu->setItemEnabled( iii, false ); 1594 selectFilterMenu->setItemEnabled( iii, false );
1594 filter = fili.next(); 1595 filter = fili.next();
1595 ++iii; 1596 ++iii;
1596 } 1597 }
1597} 1598}
1598void MainWindow::selectFilter( int fil ) 1599void MainWindow::selectFilter( int fil )
1599{ 1600{
1600 if ( fil == 0 ) { 1601 if ( fil == 0 ) {
1601 mView->toggleFilerEnabled( ); 1602 mView->toggleFilerEnabled( );
1602 } else { 1603 } else {
1603 mView->selectFilter( fil-1 ); 1604 mView->selectFilter( fil-1 );
1604 } 1605 }
1605} 1606}
1606void MainWindow::configureToolBar( int item ) 1607void MainWindow::configureToolBar( int item )
1607{ 1608{
1608 1609
1609 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1610 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1610 KOPrefs *p = KOPrefs::instance(); 1611 KOPrefs *p = KOPrefs::instance();
1611 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1612 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1612 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1613 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1613 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1614 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1614 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1615 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1615 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1616 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1616 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1617 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1617 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1618 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1618 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1619 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1619 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1620 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1620 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1621 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1621 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1622 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1622 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1623 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1623 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1624 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1624 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1625 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1625 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1626 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1626 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1627 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1627 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1628 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1628 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1629 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1629 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1630 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1630 // initActions(); 1631 // initActions();
1631} 1632}
1632 1633
1633void MainWindow::setCaptionToDates() 1634void MainWindow::setCaptionToDates()
1634{ 1635{
1635 QString selDates; 1636 QString selDates;
1636 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1637 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1637 if (mView->startDate() < mView->endDate() ) 1638 if (mView->startDate() < mView->endDate() )
1638 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1639 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1639 setCaption( i18n("Dates: ") + selDates ); 1640 setCaption( i18n("Dates: ") + selDates );
1640 1641
1641} 1642}
1642// parameter item == 0: reinit 1643// parameter item == 0: reinit
1643void MainWindow::configureAgenda( int item ) 1644void MainWindow::configureAgenda( int item )
1644{ 1645{
1645 1646
1646 KOPrefs *p = KOPrefs::instance(); 1647 KOPrefs *p = KOPrefs::instance();
1647 1648
1648 int i; 1649 int i;
1649 if ( item == 1 ) { 1650 if ( item == 1 ) {
1650 mView->toggleAllDaySize(); 1651 mView->toggleAllDaySize();
1651 return; 1652 return;
1652 } 1653 }
1653 // do not allow 4 for widgets higher than 480 1654 // do not allow 4 for widgets higher than 480
1654 // if ( QApplication::desktop()->height() > 480 ) { 1655 // if ( QApplication::desktop()->height() > 480 ) {
1655// if ( item == 4 ) 1656// if ( item == 4 )
1656// item = 6; 1657// item = 6;
1657// } 1658// }
1658 for ( i = 4; i <= 18; i= i+2 ) 1659 for ( i = 4; i <= 18; i= i+2 )
1659 configureAgendaMenu->setItemChecked( i, false ); 1660 configureAgendaMenu->setItemChecked( i, false );
1660 configureAgendaMenu->setItemChecked( item, true ); 1661 configureAgendaMenu->setItemChecked( item, true );
1661 if ( p->mHourSize == item ) 1662 if ( p->mHourSize == item )
1662 return; 1663 return;
1663 p->mHourSize=item; 1664 p->mHourSize=item;
1664 mView->viewManager()->agendaView()->updateConfig(); 1665 mView->viewManager()->agendaView()->updateConfig();
1665} 1666}
1666 1667
1667void MainWindow::saveCalendar() 1668void MainWindow::saveCalendar()
1668{ 1669{
1669 QString fn = KOPrefs::instance()->mLastSaveFile; 1670 QString fn = KOPrefs::instance()->mLastSaveFile;
1670 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1671 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1671 1672
1672 if ( fn == "" ) 1673 if ( fn == "" )
1673 return; 1674 return;
1674 QFileInfo info; 1675 QFileInfo info;
1675 info.setFile( fn ); 1676 info.setFile( fn );
1676 QString mes; 1677 QString mes;
1677 bool createbup = true; 1678 bool createbup = true;
1678 if ( info. exists() ) { 1679 if ( info. exists() ) {
1679 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1680 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1680 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1681 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1681 i18n("Overwrite!"), i18n("Cancel"), 0, 1682 i18n("Overwrite!"), i18n("Cancel"), 0,
1682 0, 1 ); 1683 0, 1 );
1683 if ( result != 0 ) { 1684 if ( result != 0 ) {
1684 createbup = false; 1685 createbup = false;
1685 } 1686 }
1686 } 1687 }
1687 if ( createbup ) { 1688 if ( createbup ) {
1688 mView->saveCalendar( fn ); 1689 mView->saveCalendar( fn );
1689 mes = i18n("KO/Pi:Saved %1").arg(fn); 1690 mes = i18n("KO/Pi:Saved %1").arg(fn);
1690 KOPrefs::instance()->mLastSaveFile = fn; 1691 KOPrefs::instance()->mLastSaveFile = fn;
1691 setCaption(mes); 1692 setCaption(mes);
1692 } 1693 }
1693} 1694}
1694void MainWindow::loadCalendar() 1695void MainWindow::loadCalendar()
1695{ 1696{
1696 1697
1697 QString fn = KOPrefs::instance()->mLastLoadFile; 1698 QString fn = KOPrefs::instance()->mLastLoadFile;
1698 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1699 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1699 1700
1700 if ( fn == "" ) 1701 if ( fn == "" )
1701 return; 1702 return;
1702 QFileInfo info; 1703 QFileInfo info;
1703 info.setFile( fn ); 1704 info.setFile( fn );
1704 QString mess; 1705 QString mess;
1705 bool loadbup = true; 1706 bool loadbup = true;
1706 if ( info. exists() ) { 1707 if ( info. exists() ) {
1707 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1708 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1708 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1709 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1709 mess, 1710 mess,
1710 i18n("Load!"), i18n("Cancel"), 0, 1711 i18n("Load!"), i18n("Cancel"), 0,
1711 0, 1 ); 1712 0, 1 );
1712 if ( result != 0 ) { 1713 if ( result != 0 ) {
1713 loadbup = false; 1714 loadbup = false;
1714 } 1715 }
1715 } else { 1716 } else {
1716 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1717 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1717 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1718 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1718 0, 1 ); 1719 0, 1 );
1719 1720
1720 return; 1721 return;
1721 } 1722 }
1722 if ( loadbup ) { 1723 if ( loadbup ) {
1723 mView->openCalendar( fn ); 1724 mView->openCalendar( fn );
1724 KOPrefs::instance()->mLastLoadFile = fn; 1725 KOPrefs::instance()->mLastLoadFile = fn;
1725 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1726 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1726 setCaption(mess); 1727 setCaption(mess);
1727 } 1728 }
1728 1729
1729} 1730}
1730void MainWindow::quickImportIcal() 1731void MainWindow::quickImportIcal()
1731{ 1732{
1732 importFile( KOPrefs::instance()->mLastImportFile, false ); 1733 importFile( KOPrefs::instance()->mLastImportFile, false );
1733} 1734}
1734void MainWindow::importFile( QString fn, bool quick ) 1735void MainWindow::importFile( QString fn, bool quick )
1735{ 1736{
1736 QFileInfo info; 1737 QFileInfo info;
1737 info.setFile( fn ); 1738 info.setFile( fn );
1738 QString mess; 1739 QString mess;
1739 bool loadbup = true; 1740 bool loadbup = true;
1740 if ( !info. exists() ) { 1741 if ( !info. exists() ) {
1741 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1742 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1742 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1743 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1743 mess ); 1744 mess );
1744 return; 1745 return;
1745 } 1746 }
1746 int result = 0; 1747 int result = 0;
1747 if ( !quick ) { 1748 if ( !quick ) {
1748 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1749 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1749 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1750 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1750 mess, 1751 mess,
1751 "Import", "Cancel", 0, 1752 "Import", "Cancel", 0,
1752 0, 1 ); 1753 0, 1 );
1753 } 1754 }
1754 if ( result == 0 ) { 1755 if ( result == 0 ) {
1755 if ( mView->openCalendar( fn, true )) { 1756 if ( mView->openCalendar( fn, true )) {
1756 KOPrefs::instance()->mLastImportFile = fn; 1757 KOPrefs::instance()->mLastImportFile = fn;
1757 setCaption(i18n("Imported file successfully")); 1758 setCaption(i18n("Imported file successfully"));
1758 } else { 1759 } else {
1759 setCaption(i18n("Error importing file")); 1760 setCaption(i18n("Error importing file"));
1760 } 1761 }
1761 } 1762 }
1762} 1763}
1763 1764
1764void MainWindow::importIcal() 1765void MainWindow::importIcal()
1765{ 1766{
1766 1767
1767 QString fn =KOPrefs::instance()->mLastImportFile; 1768 QString fn =KOPrefs::instance()->mLastImportFile;
1768 1769
1769 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1770 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1770 if ( fn == "" ) 1771 if ( fn == "" )
1771 return; 1772 return;
1772 importFile( fn, true ); 1773 importFile( fn, true );
1773 1774
1774} 1775}
1775 1776
1776void MainWindow::exportVCalendar() 1777void MainWindow::exportVCalendar()
1777{ 1778{
1778 QString fn = KOPrefs::instance()->mLastVcalFile; 1779 QString fn = KOPrefs::instance()->mLastVcalFile;
1779 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1780 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1780 if ( fn == "" ) 1781 if ( fn == "" )
1781 return; 1782 return;
1782 QFileInfo info; 1783 QFileInfo info;
1783 info.setFile( fn ); 1784 info.setFile( fn );
1784 QString mes; 1785 QString mes;
1785 bool createbup = true; 1786 bool createbup = true;
1786 if ( info. exists() ) { 1787 if ( info. exists() ) {
1787 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1788 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1788 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1789 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1789 i18n("Overwrite!"), i18n("Cancel"), 0, 1790 i18n("Overwrite!"), i18n("Cancel"), 0,
1790 0, 1 ); 1791 0, 1 );
1791 if ( result != 0 ) { 1792 if ( result != 0 ) {
1792 createbup = false; 1793 createbup = false;
1793 } 1794 }
1794 } 1795 }
1795 if ( createbup ) { 1796 if ( createbup ) {
1796 if ( mView->exportVCalendar( fn ) ) { 1797 if ( mView->exportVCalendar( fn ) ) {
1797 KOPrefs::instance()->mLastVcalFile = fn; 1798 KOPrefs::instance()->mLastVcalFile = fn;
1798 if ( fn.length() > 20 ) 1799 if ( fn.length() > 20 )
1799 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1800 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1800 else 1801 else
1801 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1802 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1802 setCaption(mes); 1803 setCaption(mes);
1803 } 1804 }
1804 } 1805 }
1805 1806
1806} 1807}
1807 1808
1808void MainWindow::syncFileRequest() 1809void MainWindow::syncFileRequest()
1809{ 1810{
1810 save(); 1811 save();
1811} 1812}
1812void MainWindow::getFile( bool success ) 1813void MainWindow::getFile( bool success )
1813{ 1814{
1814 if ( ! success ) { 1815 if ( ! success ) {
1815 setCaption( i18n("Error receiving file. Nothing changed!") ); 1816 setCaption( i18n("Error receiving file. Nothing changed!") );
1816 return; 1817 return;
1817 } 1818 }
1818 mView->openCalendar( defaultFileName() ); 1819 mView->openCalendar( defaultFileName() );
1819 setCaption( i18n("Pi-Sync successful!") ); 1820 setCaption( i18n("Pi-Sync successful!") );
1820} 1821}
1821 1822
1822void MainWindow::printSel( ) 1823void MainWindow::printSel( )
1823{ 1824{
1824 mView->viewManager()->agendaView()->agenda()->printSelection(); 1825 mView->viewManager()->agendaView()->agenda()->printSelection();
1825} 1826}
1826 1827
1827void MainWindow::printCal() 1828void MainWindow::printCal()
1828{ 1829{
1829 mView->print();//mCp->showDialog(); 1830 mView->print();//mCp->showDialog();
1830} 1831}
1831 1832
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 08b1a3d..80fb147 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1210 +1,1214 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 prof << i18n("Last_file"); 104 prof << i18n("Last_file");
105 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
106 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
107 temp->writeConfig(&config); 107 temp->writeConfig(&config);
108 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
109 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] ); 110 temp->setName( prof[2] );
111 temp->writeConfig(&config); 111 temp->writeConfig(&config);
112 config.setGroup("General"); 112 config.setGroup("General");
113 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
114 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
115 config.sync(); 115 config.sync();
116 delete temp; 116 delete temp;
117 } 117 }
118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
119 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
120 unsigned int i; 120 unsigned int i;
121 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
122 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
123 if ( i == 2 ) 123 if ( i == 2 )
124 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
125 } 125 }
126 QDir app_dir; 126 QDir app_dir;
127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
128 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
129 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
130 } 130 }
131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
132 mSyncMenu->removeItem( 1000 ); 132 mSyncMenu->removeItem( 1000 );
133 } 133 }
134 mSyncMenu->removeItem( 1002 ); 134 mSyncMenu->removeItem( 1002 );
135} 135}
136 136
137void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
138{ 138{
139 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
140 if ( action == 0 ) { 140 if ( action == 0 ) {
141 141
142 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
143 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
144 // when we call it after the main event loop, it is ok 144 // when we call it after the main event loop, it is ok
145 // same behaviour when calling OM/Pi via QCOP for the first time 145 // same behaviour when calling OM/Pi via QCOP for the first time
146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
147 //confSync(); 147 //confSync();
148 148
149 return; 149 return;
150 } 150 }
151 if ( action == 1 ) { 151 if ( action == 1 ) {
152 multiSync( true ); 152 multiSync( true );
153 return; 153 return;
154 } 154 }
155 if ( action == 2 ) { 155 if ( action == 2 ) {
156 enableQuick(); 156 enableQuick();
157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
158 return; 158 return;
159 } 159 }
160 if ( action == 3 ) { 160 if ( action == 3 ) {
161 delete mServerSocket; 161 delete mServerSocket;
162 mServerSocket = 0; 162 mServerSocket = 0;
163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
164 return; 164 return;
165 } 165 }
166 166
167 if (blockSave()) 167 if (blockSave())
168 return; 168 return;
169 169
170 setBlockSave(true); 170 setBlockSave(true);
171 171
172 mCurrentSyncProfile = action - 1000 ; 172 mCurrentSyncProfile = action - 1000 ;
173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
174 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
176 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
178 temp->readConfig(&config); 178 temp->readConfig(&config);
179 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
180 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
181 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
182 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
183 mWriteBackInFuture = 0; 183 mWriteBackInFuture = 0;
184 if ( temp->getWriteBackFuture() ) 184 if ( temp->getWriteBackFuture() )
185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
186 mShowSyncSummary = temp->getShowSummaryAfterSync(); 186 mShowSyncSummary = temp->getShowSummaryAfterSync();
187 if ( action == 1000 ) { 187 if ( action == 1000 ) {
188 syncSharp(); 188 syncSharp();
189 189
190 } else if ( action == 1001 ) { 190 } else if ( action == 1001 ) {
191 syncLocalFile(); 191 syncLocalFile();
192 192
193 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
194 mWriteBackFile = false;
195 mAskForPreferences = false;
196 mShowSyncSummary = false;
197 mSyncAlgoPrefs = 3;
194 quickSyncLocalFile(); 198 quickSyncLocalFile();
195 199
196 } else if ( action >= 1003 ) { 200 } else if ( action >= 1003 ) {
197 if ( temp->getIsLocalFileSync() ) { 201 if ( temp->getIsLocalFileSync() ) {
198 switch(mTargetApp) 202 switch(mTargetApp)
199 { 203 {
200 case (KAPI): 204 case (KAPI):
201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
203 break; 207 break;
204 case (KOPI): 208 case (KOPI):
205 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
207 break; 211 break;
208 case (PWMPI): 212 case (PWMPI):
209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
211 break; 215 break;
212 default: 216 default:
213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
214 break; 218 break;
215 219
216 } 220 }
217 } else { 221 } else {
218 if ( temp->getIsPhoneSync() ) { 222 if ( temp->getIsPhoneSync() ) {
219 mPhoneDevice = temp->getPhoneDevice( ) ; 223 mPhoneDevice = temp->getPhoneDevice( ) ;
220 mPhoneConnection = temp->getPhoneConnection( ); 224 mPhoneConnection = temp->getPhoneConnection( );
221 mPhoneModel = temp->getPhoneModel( ); 225 mPhoneModel = temp->getPhoneModel( );
222 syncPhone(); 226 syncPhone();
223 } else if ( temp->getIsPiSync() ) { 227 } else if ( temp->getIsPiSync() ) {
224 if ( mTargetApp == KAPI ) { 228 if ( mTargetApp == KAPI ) {
225 mPassWordPiSync = temp->getRemotePwAB(); 229 mPassWordPiSync = temp->getRemotePwAB();
226 mActiveSyncPort = temp->getRemotePortAB(); 230 mActiveSyncPort = temp->getRemotePortAB();
227 mActiveSyncIP = temp->getRemoteIPAB(); 231 mActiveSyncIP = temp->getRemoteIPAB();
228 } else if ( mTargetApp == KOPI ) { 232 } else if ( mTargetApp == KOPI ) {
229 mPassWordPiSync = temp->getRemotePw(); 233 mPassWordPiSync = temp->getRemotePw();
230 mActiveSyncPort = temp->getRemotePort(); 234 mActiveSyncPort = temp->getRemotePort();
231 mActiveSyncIP = temp->getRemoteIP(); 235 mActiveSyncIP = temp->getRemoteIP();
232 } else { 236 } else {
233 mPassWordPiSync = temp->getRemotePwPWM(); 237 mPassWordPiSync = temp->getRemotePwPWM();
234 mActiveSyncPort = temp->getRemotePortPWM(); 238 mActiveSyncPort = temp->getRemotePortPWM();
235 mActiveSyncIP = temp->getRemoteIPPWM(); 239 mActiveSyncIP = temp->getRemoteIPPWM();
236 } 240 }
237 syncPi(); 241 syncPi();
238 } else 242 } else
239 syncRemote( temp ); 243 syncRemote( temp );
240 244
241 } 245 }
242 } 246 }
243 delete temp; 247 delete temp;
244 setBlockSave(false); 248 setBlockSave(false);
245} 249}
246 250
247void KSyncManager::enableQuick() 251void KSyncManager::enableQuick()
248{ 252{
249 QDialog dia ( 0, "input-dialog", true ); 253 QDialog dia ( 0, "input-dialog", true );
250 QLineEdit lab ( &dia ); 254 QLineEdit lab ( &dia );
251 QVBoxLayout lay( &dia ); 255 QVBoxLayout lay( &dia );
252 lab.setText( mPrefs->mPassiveSyncPort ); 256 lab.setText( mPrefs->mPassiveSyncPort );
253 lay.setMargin(7); 257 lay.setMargin(7);
254 lay.setSpacing(7); 258 lay.setSpacing(7);
255 int po = 9197+mTargetApp; 259 int po = 9197+mTargetApp;
256 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
257 lay.addWidget( &label); 261 lay.addWidget( &label);
258 lay.addWidget( &lab); 262 lay.addWidget( &lab);
259 263
260 QLineEdit lepw ( &dia ); 264 QLineEdit lepw ( &dia );
261 lepw.setText( mPrefs->mPassiveSyncPw ); 265 lepw.setText( mPrefs->mPassiveSyncPw );
262 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
263 lay.addWidget( &label2); 267 lay.addWidget( &label2);
264 lay.addWidget( &lepw); 268 lay.addWidget( &lepw);
265 dia.setFixedSize( 230,80 ); 269 dia.setFixedSize( 230,80 );
266 dia.setCaption( i18n("Enter port for Pi-Sync") ); 270 dia.setCaption( i18n("Enter port for Pi-Sync") );
267 QPushButton pb ( "OK", &dia); 271 QPushButton pb ( "OK", &dia);
268 lay.addWidget( &pb ); 272 lay.addWidget( &pb );
269 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
270 dia.show(); 274 dia.show();
271 if ( ! dia.exec() ) 275 if ( ! dia.exec() )
272 return; 276 return;
273 dia.hide(); 277 dia.hide();
274 qApp->processEvents(); 278 qApp->processEvents();
275 mPrefs->mPassiveSyncPw = lepw.text(); 279 mPrefs->mPassiveSyncPw = lepw.text();
276 mPrefs->mPassiveSyncPort = lab.text(); 280 mPrefs->mPassiveSyncPort = lab.text();
277 bool ok; 281 bool ok;
278 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
279 if ( ! ok ) { 283 if ( ! ok ) {
280 KMessageBox::information( 0, i18n("No valid port")); 284 KMessageBox::information( 0, i18n("No valid port"));
281 return; 285 return;
282 } 286 }
283 //qDebug("port %d ", port); 287 //qDebug("port %d ", port);
284 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
285 mServerSocket->setFileName( defaultFileName() ); 289 mServerSocket->setFileName( defaultFileName() );
286 //qDebug("connected "); 290 //qDebug("connected ");
287 if ( !mServerSocket->ok() ) { 291 if ( !mServerSocket->ok() ) {
288 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
289 delete mServerSocket; 293 delete mServerSocket;
290 mServerSocket = 0; 294 mServerSocket = 0;
291 return; 295 return;
292 } 296 }
293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
295} 299}
296 300
297void KSyncManager::syncLocalFile() 301void KSyncManager::syncLocalFile()
298{ 302{
299 303
300 QString fn =mPrefs->mLastSyncedLocalFile; 304 QString fn =mPrefs->mLastSyncedLocalFile;
301 QString ext; 305 QString ext;
302 306
303 switch(mTargetApp) 307 switch(mTargetApp)
304 { 308 {
305 case (KAPI): 309 case (KAPI):
306 ext = "(*.vcf)"; 310 ext = "(*.vcf)";
307 break; 311 break;
308 case (KOPI): 312 case (KOPI):
309 ext = "(*.ics/*.vcs)"; 313 ext = "(*.ics/*.vcs)";
310 break; 314 break;
311 case (PWMPI): 315 case (PWMPI):
312 ext = "(*.pwm)"; 316 ext = "(*.pwm)";
313 break; 317 break;
314 default: 318 default:
315 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
316 break; 320 break;
317 321
318 } 322 }
319 323
320 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
321 if ( fn == "" ) 325 if ( fn == "" )
322 return; 326 return;
323 if ( syncWithFile( fn, false ) ) { 327 if ( syncWithFile( fn, false ) ) {
324 qDebug("syncLocalFile() successful "); 328 qDebug("syncLocalFile() successful ");
325 } 329 }
326 330
327} 331}
328 332
329bool KSyncManager::syncWithFile( QString fn , bool quick ) 333bool KSyncManager::syncWithFile( QString fn , bool quick )
330{ 334{
331 bool ret = false; 335 bool ret = false;
332 QFileInfo info; 336 QFileInfo info;
333 info.setFile( fn ); 337 info.setFile( fn );
334 QString mess; 338 QString mess;
335 bool loadbup = true; 339 bool loadbup = true;
336 if ( !info. exists() ) { 340 if ( !info. exists() ) {
337 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
338 int result = QMessageBox::warning( mParent, i18n("Warning!"), 342 int result = QMessageBox::warning( mParent, i18n("Warning!"),
339 mess ); 343 mess );
340 return ret; 344 return ret;
341 } 345 }
342 int result = 0; 346 int result = 0;
343 if ( !quick ) { 347 if ( !quick ) {
344 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
345 result = QMessageBox::warning( mParent, i18n("Warning!"), 349 result = QMessageBox::warning( mParent, i18n("Warning!"),
346 mess, 350 mess,
347 i18n("Sync"), i18n("Cancel"), 0, 351 i18n("Sync"), i18n("Cancel"), 0,
348 0, 1 ); 352 0, 1 );
349 if ( result ) 353 if ( result )
350 return false; 354 return false;
351 } 355 }
352 if ( mAskForPreferences ) 356 if ( mAskForPreferences )
353 edit_sync_options(); 357 edit_sync_options();
354 if ( result == 0 ) { 358 if ( result == 0 ) {
355 //qDebug("Now sycing ... "); 359 //qDebug("Now sycing ... ");
356 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
357 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
358 else 362 else
359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
360 if ( ! quick ) 364 if ( ! quick )
361 mPrefs->mLastSyncedLocalFile = fn; 365 mPrefs->mLastSyncedLocalFile = fn;
362 } 366 }
363 return ret; 367 return ret;
364} 368}
365 369
366void KSyncManager::quickSyncLocalFile() 370void KSyncManager::quickSyncLocalFile()
367{ 371{
368 372
369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { 373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
370 qDebug("quick syncLocalFile() successful "); 374 qDebug("quick syncLocalFile() successful ");
371 375
372 } 376 }
373} 377}
374 378
375void KSyncManager::multiSync( bool askforPrefs ) 379void KSyncManager::multiSync( bool askforPrefs )
376{ 380{
377 if (blockSave()) 381 if (blockSave())
378 return; 382 return;
379 setBlockSave(true); 383 setBlockSave(true);
380 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
382 question, 386 question,
383 i18n("Yes"), i18n("No"), 387 i18n("Yes"), i18n("No"),
384 0, 0 ) != 0 ) { 388 0, 0 ) != 0 ) {
385 setBlockSave(false); 389 setBlockSave(false);
386 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
387 return; 391 return;
388 } 392 }
389 mCurrentSyncDevice = i18n("Multiple profiles") ; 393 mCurrentSyncDevice = i18n("Multiple profiles") ;
390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
391 if ( askforPrefs ) { 395 if ( askforPrefs ) {
392 edit_sync_options(); 396 edit_sync_options();
393 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
394 } 398 }
395 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
396 qApp->processEvents(); 400 qApp->processEvents();
397 int num = ringSync() ; 401 int num = ringSync() ;
398 if ( num > 1 ) 402 if ( num > 1 )
399 ringSync(); 403 ringSync();
400 setBlockSave(false); 404 setBlockSave(false);
401 if ( num ) 405 if ( num )
402 emit save(); 406 emit save();
403 if ( num ) 407 if ( num )
404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
405 else 409 else
406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
407 return; 411 return;
408} 412}
409 413
410int KSyncManager::ringSync() 414int KSyncManager::ringSync()
411{ 415{
412 int syncedProfiles = 0; 416 int syncedProfiles = 0;
413 unsigned int i; 417 unsigned int i;
414 QTime timer; 418 QTime timer;
415 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
416 QStringList syncProfileNames = mSyncProfileNames; 420 QStringList syncProfileNames = mSyncProfileNames;
417 KSyncProfile* temp = new KSyncProfile (); 421 KSyncProfile* temp = new KSyncProfile ();
418 mAskForPreferences = false; 422 mAskForPreferences = false;
419 for ( i = 0; i < syncProfileNames.count(); ++i ) { 423 for ( i = 0; i < syncProfileNames.count(); ++i ) {
420 mCurrentSyncProfile = i; 424 mCurrentSyncProfile = i;
421 temp->setName(syncProfileNames[mCurrentSyncProfile]); 425 temp->setName(syncProfileNames[mCurrentSyncProfile]);
422 temp->readConfig(&config); 426 temp->readConfig(&config);
423 427
424 bool includeInRingSync; 428 bool includeInRingSync;
425 switch(mTargetApp) 429 switch(mTargetApp)
426 { 430 {
427 case (KAPI): 431 case (KAPI):
428 includeInRingSync = temp->getIncludeInRingSyncAB(); 432 includeInRingSync = temp->getIncludeInRingSyncAB();
429 break; 433 break;
430 case (KOPI): 434 case (KOPI):
431 includeInRingSync = temp->getIncludeInRingSync(); 435 includeInRingSync = temp->getIncludeInRingSync();
432 break; 436 break;
433 case (PWMPI): 437 case (PWMPI):
434 includeInRingSync = temp->getIncludeInRingSyncPWM(); 438 includeInRingSync = temp->getIncludeInRingSyncPWM();
435 break; 439 break;
436 default: 440 default:
437 qDebug("KSyncManager::ringSync: invalid apptype selected"); 441 qDebug("KSyncManager::ringSync: invalid apptype selected");
438 break; 442 break;
439 443
440 } 444 }
441 445
442 446
443 if ( includeInRingSync && ( i < 1 || i > 2 )) { 447 if ( includeInRingSync && ( i < 1 || i > 2 )) {
444 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
445 ++syncedProfiles; 449 ++syncedProfiles;
446 // mAskForPreferences = temp->getAskForPreferences(); 450 // mAskForPreferences = temp->getAskForPreferences();
447 mWriteBackFile = temp->getWriteBackFile(); 451 mWriteBackFile = temp->getWriteBackFile();
448 mWriteBackExistingOnly = temp->getWriteBackExisting(); 452 mWriteBackExistingOnly = temp->getWriteBackExisting();
449 mWriteBackInFuture = 0; 453 mWriteBackInFuture = 0;
450 if ( temp->getWriteBackFuture() ) 454 if ( temp->getWriteBackFuture() )
451 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
452 mShowSyncSummary = false; 456 mShowSyncSummary = false;
453 mCurrentSyncDevice = syncProfileNames[i] ; 457 mCurrentSyncDevice = syncProfileNames[i] ;
454 mCurrentSyncName = mLocalMachineName; 458 mCurrentSyncName = mLocalMachineName;
455 if ( i == 0 ) { 459 if ( i == 0 ) {
456 syncSharp(); 460 syncSharp();
457 } else { 461 } else {
458 if ( temp->getIsLocalFileSync() ) { 462 if ( temp->getIsLocalFileSync() ) {
459 switch(mTargetApp) 463 switch(mTargetApp)
460 { 464 {
461 case (KAPI): 465 case (KAPI):
462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
464 break; 468 break;
465 case (KOPI): 469 case (KOPI):
466 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
468 break; 472 break;
469 case (PWMPI): 473 case (PWMPI):
470 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 474 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 475 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
472 break; 476 break;
473 default: 477 default:
474 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 478 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
475 break; 479 break;
476 } 480 }
477 } else { 481 } else {
478 if ( temp->getIsPhoneSync() ) { 482 if ( temp->getIsPhoneSync() ) {
479 mPhoneDevice = temp->getPhoneDevice( ) ; 483 mPhoneDevice = temp->getPhoneDevice( ) ;
480 mPhoneConnection = temp->getPhoneConnection( ); 484 mPhoneConnection = temp->getPhoneConnection( );
481 mPhoneModel = temp->getPhoneModel( ); 485 mPhoneModel = temp->getPhoneModel( );
482 syncPhone(); 486 syncPhone();
483 } else if ( temp->getIsPiSync() ) { 487 } else if ( temp->getIsPiSync() ) {
484 if ( mTargetApp == KAPI ) { 488 if ( mTargetApp == KAPI ) {
485 mPassWordPiSync = temp->getRemotePwAB(); 489 mPassWordPiSync = temp->getRemotePwAB();
486 mActiveSyncPort = temp->getRemotePortAB(); 490 mActiveSyncPort = temp->getRemotePortAB();
487 mActiveSyncIP = temp->getRemoteIPAB(); 491 mActiveSyncIP = temp->getRemoteIPAB();
488 } else if ( mTargetApp == KOPI ) { 492 } else if ( mTargetApp == KOPI ) {
489 mPassWordPiSync = temp->getRemotePw(); 493 mPassWordPiSync = temp->getRemotePw();
490 mActiveSyncPort = temp->getRemotePort(); 494 mActiveSyncPort = temp->getRemotePort();
491 mActiveSyncIP = temp->getRemoteIP(); 495 mActiveSyncIP = temp->getRemoteIP();
492 } else { 496 } else {
493 mPassWordPiSync = temp->getRemotePwPWM(); 497 mPassWordPiSync = temp->getRemotePwPWM();
494 mActiveSyncPort = temp->getRemotePortPWM(); 498 mActiveSyncPort = temp->getRemotePortPWM();
495 mActiveSyncIP = temp->getRemoteIPPWM(); 499 mActiveSyncIP = temp->getRemoteIPPWM();
496 } 500 }
497 syncPi(); 501 syncPi();
498 } else 502 } else
499 syncRemote( temp, false ); 503 syncRemote( temp, false );
500 504
501 } 505 }
502 } 506 }
503 timer.start(); 507 timer.start();
504 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 508 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
505 while ( timer.elapsed () < 2000 ) { 509 while ( timer.elapsed () < 2000 ) {
506 qApp->processEvents(); 510 qApp->processEvents();
507#ifndef _WIN32_ 511#ifndef _WIN32_
508 sleep (1); 512 sleep (1);
509#endif 513#endif
510 } 514 }
511 515
512 } 516 }
513 517
514 } 518 }
515 delete temp; 519 delete temp;
516 return syncedProfiles; 520 return syncedProfiles;
517} 521}
518 522
519void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 523void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
520{ 524{
521 QString question; 525 QString question;
522 if ( ask ) { 526 if ( ask ) {
523 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 527 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
524 if ( QMessageBox::information( mParent, i18n("Sync"), 528 if ( QMessageBox::information( mParent, i18n("Sync"),
525 question, 529 question,
526 i18n("Yes"), i18n("No"), 530 i18n("Yes"), i18n("No"),
527 0, 0 ) != 0 ) 531 0, 0 ) != 0 )
528 return; 532 return;
529 } 533 }
530 534
531 QString preCommand; 535 QString preCommand;
532 QString localTempFile; 536 QString localTempFile;
533 QString postCommand; 537 QString postCommand;
534 538
535 switch(mTargetApp) 539 switch(mTargetApp)
536 { 540 {
537 case (KAPI): 541 case (KAPI):
538 preCommand = prof->getPreSyncCommandAB(); 542 preCommand = prof->getPreSyncCommandAB();
539 postCommand = prof->getPostSyncCommandAB(); 543 postCommand = prof->getPostSyncCommandAB();
540 localTempFile = prof->getLocalTempFileAB(); 544 localTempFile = prof->getLocalTempFileAB();
541 break; 545 break;
542 case (KOPI): 546 case (KOPI):
543 preCommand = prof->getPreSyncCommand(); 547 preCommand = prof->getPreSyncCommand();
544 postCommand = prof->getPostSyncCommand(); 548 postCommand = prof->getPostSyncCommand();
545 localTempFile = prof->getLocalTempFile(); 549 localTempFile = prof->getLocalTempFile();
546 break; 550 break;
547 case (PWMPI): 551 case (PWMPI):
548 preCommand = prof->getPreSyncCommandPWM(); 552 preCommand = prof->getPreSyncCommandPWM();
549 postCommand = prof->getPostSyncCommandPWM(); 553 postCommand = prof->getPostSyncCommandPWM();
550 localTempFile = prof->getLocalTempFilePWM(); 554 localTempFile = prof->getLocalTempFilePWM();
551 break; 555 break;
552 default: 556 default:
553 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 557 qDebug("KSyncManager::syncRemote: invalid apptype selected");
554 break; 558 break;
555 } 559 }
556 560
557 561
558 int fi; 562 int fi;
559 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 563 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
560 QString pwd = getPassword(); 564 QString pwd = getPassword();
561 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 565 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
562 566
563 } 567 }
564 int maxlen = 30; 568 int maxlen = 30;
565 if ( QApplication::desktop()->width() > 320 ) 569 if ( QApplication::desktop()->width() > 320 )
566 maxlen += 25; 570 maxlen += 25;
567 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
568 int fileSize = 0; 572 int fileSize = 0;
569 int result = system ( preCommand ); 573 int result = system ( preCommand );
570 // 0 : okay 574 // 0 : okay
571 // 256: no such file or dir 575 // 256: no such file or dir
572 // 576 //
573 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 577 qDebug("KO: Remote copy result(0 = okay): %d ",result );
574 if ( result != 0 ) { 578 if ( result != 0 ) {
575 unsigned int len = maxlen; 579 unsigned int len = maxlen;
576 while ( len < preCommand.length() ) { 580 while ( len < preCommand.length() ) {
577 preCommand.insert( len , "\n" ); 581 preCommand.insert( len , "\n" );
578 len += maxlen +2; 582 len += maxlen +2;
579 } 583 }
580 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 584 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
581 QMessageBox::information( mParent, i18n("Sync - ERROR"), 585 QMessageBox::information( mParent, i18n("Sync - ERROR"),
582 question, 586 question,
583 i18n("Okay!")) ; 587 i18n("Okay!")) ;
584 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 588 mParent->topLevelWidget()->setCaption ("KDE-Pim");
585 return; 589 return;
586 } 590 }
587 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 591 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
588 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 592 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
589 593
590 if ( syncWithFile( localTempFile, true ) ) { 594 if ( syncWithFile( localTempFile, true ) ) {
591 595
592 if ( mWriteBackFile ) { 596 if ( mWriteBackFile ) {
593 int fi; 597 int fi;
594 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 598 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
595 QString pwd = getPassword(); 599 QString pwd = getPassword();
596 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
597 601
598 } 602 }
599 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
600 result = system ( postCommand ); 604 result = system ( postCommand );
601 qDebug("Writing back file result: %d ", result); 605 qDebug("Writing back file result: %d ", result);
602 if ( result != 0 ) { 606 if ( result != 0 ) {
603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
604 return; 608 return;
605 } else { 609 } else {
606 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
607 } 611 }
608 } 612 }
609 } 613 }
610 return; 614 return;
611} 615}
612void KSyncManager::edit_pisync_options() 616void KSyncManager::edit_pisync_options()
613{ 617{
614 QDialog dia( mParent, "dia", true ); 618 QDialog dia( mParent, "dia", true );
615 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 619 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
616 QVBoxLayout lay ( &dia ); 620 QVBoxLayout lay ( &dia );
617 lay.setSpacing( 5 ); 621 lay.setSpacing( 5 );
618 lay.setMargin( 3 ); 622 lay.setMargin( 3 );
619 QLabel lab1 ( i18n("Password for remote access:"), &dia); 623 QLabel lab1 ( i18n("Password for remote access:"), &dia);
620 lay.addWidget( &lab1 ); 624 lay.addWidget( &lab1 );
621 QLineEdit le1 (&dia ); 625 QLineEdit le1 (&dia );
622 lay.addWidget( &le1 ); 626 lay.addWidget( &le1 );
623 QLabel lab2 ( i18n("Remote IP address:"), &dia); 627 QLabel lab2 ( i18n("Remote IP address:"), &dia);
624 lay.addWidget( &lab2 ); 628 lay.addWidget( &lab2 );
625 QLineEdit le2 (&dia ); 629 QLineEdit le2 (&dia );
626 lay.addWidget( &le2 ); 630 lay.addWidget( &le2 );
627 QLabel lab3 ( i18n("Remote port number:"), &dia); 631 QLabel lab3 ( i18n("Remote port number:"), &dia);
628 lay.addWidget( &lab3 ); 632 lay.addWidget( &lab3 );
629 QLineEdit le3 (&dia ); 633 QLineEdit le3 (&dia );
630 lay.addWidget( &le3 ); 634 lay.addWidget( &le3 );
631 QPushButton pb ( "OK", &dia); 635 QPushButton pb ( "OK", &dia);
632 lay.addWidget( &pb ); 636 lay.addWidget( &pb );
633 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 637 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
634 le1.setText( mPassWordPiSync ); 638 le1.setText( mPassWordPiSync );
635 le2.setText( mActiveSyncIP ); 639 le2.setText( mActiveSyncIP );
636 le3.setText( mActiveSyncPort ); 640 le3.setText( mActiveSyncPort );
637 if ( dia.exec() ) { 641 if ( dia.exec() ) {
638 mPassWordPiSync = le1.text(); 642 mPassWordPiSync = le1.text();
639 mActiveSyncPort = le3.text(); 643 mActiveSyncPort = le3.text();
640 mActiveSyncIP = le2.text(); 644 mActiveSyncIP = le2.text();
641 } 645 }
642 646
643} 647}
644void KSyncManager::edit_sync_options() 648void KSyncManager::edit_sync_options()
645{ 649{
646 650
647 QDialog dia( mParent, "dia", true ); 651 QDialog dia( mParent, "dia", true );
648 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 652 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
649 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 653 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
650 QVBoxLayout lay ( &dia ); 654 QVBoxLayout lay ( &dia );
651 lay.setSpacing( 2 ); 655 lay.setSpacing( 2 );
652 lay.setMargin( 3 ); 656 lay.setMargin( 3 );
653 lay.addWidget(&gr); 657 lay.addWidget(&gr);
654 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 658 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
655 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 659 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
656 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 660 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
657 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 661 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
658 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 662 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
659 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 663 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
660 //QRadioButton both( i18n("Take both on conflict"), &gr ); 664 //QRadioButton both( i18n("Take both on conflict"), &gr );
661 QPushButton pb ( "OK", &dia); 665 QPushButton pb ( "OK", &dia);
662 lay.addWidget( &pb ); 666 lay.addWidget( &pb );
663 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 667 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
664 switch ( mSyncAlgoPrefs ) { 668 switch ( mSyncAlgoPrefs ) {
665 case 0: 669 case 0:
666 loc.setChecked( true); 670 loc.setChecked( true);
667 break; 671 break;
668 case 1: 672 case 1:
669 rem.setChecked( true ); 673 rem.setChecked( true );
670 break; 674 break;
671 case 2: 675 case 2:
672 newest.setChecked( true); 676 newest.setChecked( true);
673 break; 677 break;
674 case 3: 678 case 3:
675 ask.setChecked( true); 679 ask.setChecked( true);
676 break; 680 break;
677 case 4: 681 case 4:
678 f_loc.setChecked( true); 682 f_loc.setChecked( true);
679 break; 683 break;
680 case 5: 684 case 5:
681 f_rem.setChecked( true); 685 f_rem.setChecked( true);
682 break; 686 break;
683 case 6: 687 case 6:
684 // both.setChecked( true); 688 // both.setChecked( true);
685 break; 689 break;
686 default: 690 default:
687 break; 691 break;
688 } 692 }
689 if ( dia.exec() ) { 693 if ( dia.exec() ) {
690 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 694 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
691 } 695 }
692 696
693 697
694} 698}
695 699
696QString KSyncManager::getPassword( ) 700QString KSyncManager::getPassword( )
697{ 701{
698 QString retfile = ""; 702 QString retfile = "";
699 QDialog dia ( mParent, "input-dialog", true ); 703 QDialog dia ( mParent, "input-dialog", true );
700 QLineEdit lab ( &dia ); 704 QLineEdit lab ( &dia );
701 lab.setEchoMode( QLineEdit::Password ); 705 lab.setEchoMode( QLineEdit::Password );
702 QVBoxLayout lay( &dia ); 706 QVBoxLayout lay( &dia );
703 lay.setMargin(7); 707 lay.setMargin(7);
704 lay.setSpacing(7); 708 lay.setSpacing(7);
705 lay.addWidget( &lab); 709 lay.addWidget( &lab);
706 dia.setFixedSize( 230,50 ); 710 dia.setFixedSize( 230,50 );
707 dia.setCaption( i18n("Enter password") ); 711 dia.setCaption( i18n("Enter password") );
708 QPushButton pb ( "OK", &dia); 712 QPushButton pb ( "OK", &dia);
709 lay.addWidget( &pb ); 713 lay.addWidget( &pb );
710 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 714 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
711 dia.show(); 715 dia.show();
712 int res = dia.exec(); 716 int res = dia.exec();
713 if ( res ) 717 if ( res )
714 retfile = lab.text(); 718 retfile = lab.text();
715 dia.hide(); 719 dia.hide();
716 qApp->processEvents(); 720 qApp->processEvents();
717 return retfile; 721 return retfile;
718 722
719} 723}
720 724
721 725
722void KSyncManager::confSync() 726void KSyncManager::confSync()
723{ 727{
724 static KSyncPrefsDialog* sp = 0; 728 static KSyncPrefsDialog* sp = 0;
725 if ( ! sp ) { 729 if ( ! sp ) {
726 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 730 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
727 } 731 }
728 sp->usrReadConfig(); 732 sp->usrReadConfig();
729#ifndef DESKTOP_VERSION 733#ifndef DESKTOP_VERSION
730 sp->showMaximized(); 734 sp->showMaximized();
731#else 735#else
732 sp->show(); 736 sp->show();
733#endif 737#endif
734 sp->exec(); 738 sp->exec();
735 mSyncProfileNames = sp->getSyncProfileNames(); 739 mSyncProfileNames = sp->getSyncProfileNames();
736 mLocalMachineName = sp->getLocalMachineName (); 740 mLocalMachineName = sp->getLocalMachineName ();
737 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 741 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
738} 742}
739 743
740void KSyncManager::syncSharp() 744void KSyncManager::syncSharp()
741{ 745{
742 746
743 if ( ! syncExternalApplication("sharp") ) 747 if ( ! syncExternalApplication("sharp") )
744 qDebug("ERROR sync sharp ");; 748 qDebug("ERROR sync sharp ");;
745} 749}
746 750
747bool KSyncManager::syncExternalApplication(QString resource) 751bool KSyncManager::syncExternalApplication(QString resource)
748{ 752{
749 753
750 emit save(); 754 emit save();
751 755
752 if ( mAskForPreferences ) 756 if ( mAskForPreferences )
753 edit_sync_options(); 757 edit_sync_options();
754 758
755 qDebug("sync %s", resource.latin1()); 759 qDebug("sync %s", resource.latin1());
756 760
757 bool syncOK = mImplementation->syncExternal(this, resource); 761 bool syncOK = mImplementation->syncExternal(this, resource);
758 762
759 return syncOK; 763 return syncOK;
760 764
761} 765}
762 766
763void KSyncManager::syncPhone() 767void KSyncManager::syncPhone()
764{ 768{
765 769
766 syncExternalApplication("phone"); 770 syncExternalApplication("phone");
767 771
768} 772}
769 773
770void KSyncManager::showProgressBar(int percentage, QString caption, int total) 774void KSyncManager::showProgressBar(int percentage, QString caption, int total)
771{ 775{
772 if (!bar->isVisible()) 776 if (!bar->isVisible())
773 { 777 {
774 bar->setCaption (caption); 778 bar->setCaption (caption);
775 bar->setTotalSteps ( total ) ; 779 bar->setTotalSteps ( total ) ;
776 780
777 bar->show(); 781 bar->show();
778 } 782 }
779 783
780 bar->setProgress( percentage ); 784 bar->setProgress( percentage );
781} 785}
782 786
783void KSyncManager::hideProgressBar() 787void KSyncManager::hideProgressBar()
784{ 788{
785 bar->hide(); 789 bar->hide();
786} 790}
787 791
788bool KSyncManager::isProgressBarCanceled() 792bool KSyncManager::isProgressBarCanceled()
789{ 793{
790 return !bar->isVisible(); 794 return !bar->isVisible();
791} 795}
792 796
793QString KSyncManager::syncFileName() 797QString KSyncManager::syncFileName()
794{ 798{
795 799
796 QString fn = "tempfile"; 800 QString fn = "tempfile";
797 switch(mTargetApp) 801 switch(mTargetApp)
798 { 802 {
799 case (KAPI): 803 case (KAPI):
800 fn = "tempsyncab.vcf"; 804 fn = "tempsyncab.vcf";
801 break; 805 break;
802 case (KOPI): 806 case (KOPI):
803 fn = "tempsynccal.ics"; 807 fn = "tempsynccal.ics";
804 break; 808 break;
805 case (PWMPI): 809 case (PWMPI):
806 fn = "tempsyncpw.pwm"; 810 fn = "tempsyncpw.pwm";
807 break; 811 break;
808 default: 812 default:
809 break; 813 break;
810 } 814 }
811#ifdef _WIN32_ 815#ifdef _WIN32_
812 return locateLocal( "tmp", fn ); 816 return locateLocal( "tmp", fn );
813#else 817#else
814 return (QString( "/tmp/" )+ fn ); 818 return (QString( "/tmp/" )+ fn );
815#endif 819#endif
816} 820}
817 821
818void KSyncManager::syncPi() 822void KSyncManager::syncPi()
819{ 823{
820 qApp->processEvents(); 824 qApp->processEvents();
821 if ( mAskForPreferences ) 825 if ( mAskForPreferences )
822 edit_pisync_options(); 826 edit_pisync_options();
823 bool ok; 827 bool ok;
824 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 828 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
825 if ( ! ok ) { 829 if ( ! ok ) {
826 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 830 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
827 return; 831 return;
828 } 832 }
829 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 833 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
830 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 834 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
831 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
832 commandSocket->readFile( syncFileName() ); 836 commandSocket->readFile( syncFileName() );
833} 837}
834 838
835void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
836{ 840{
837 qDebug("MainWindow::deleteCommandSocket %d", state); 841 qDebug("MainWindow::deleteCommandSocket %d", state);
838 842
839 //enum { success, errorW, errorR, quiet }; 843 //enum { success, errorW, errorR, quiet };
840 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 844 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
841 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 845 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
842 delete s; 846 delete s;
843 if ( state == KCommandSocket::errorR ) { 847 if ( state == KCommandSocket::errorR ) {
844 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 848 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
845 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 849 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
846 commandSocket->sendStop(); 850 commandSocket->sendStop();
847 } 851 }
848 return; 852 return;
849 853
850 } else if ( state == KCommandSocket::errorW ) { 854 } else if ( state == KCommandSocket::errorW ) {
851 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 855 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
852 856
853 } else if ( state == KCommandSocket::successR ) { 857 } else if ( state == KCommandSocket::successR ) {
854 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 858 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
855 859
856 } else if ( state == KCommandSocket::successW ) { 860 } else if ( state == KCommandSocket::successW ) {
857 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 861 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
858 } 862 }
859 863
860 delete s; 864 delete s;
861} 865}
862 866
863void KSyncManager::readFileFromSocket() 867void KSyncManager::readFileFromSocket()
864{ 868{
865 QString fileName = syncFileName(); 869 QString fileName = syncFileName();
866 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 870 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
867 if ( ! syncWithFile( fileName , true ) ) { 871 if ( ! syncWithFile( fileName , true ) ) {
868 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 872 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
869 qDebug("Syncing failed "); 873 qDebug("Syncing failed ");
870 return; 874 return;
871 } 875 }
872 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 876 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
873 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 877 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
874 if ( mWriteBackFile ) 878 if ( mWriteBackFile )
875 commandSocket->writeFile( fileName ); 879 commandSocket->writeFile( fileName );
876 else { 880 else {
877 commandSocket->sendStop(); 881 commandSocket->sendStop();
878 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 882 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
879 } 883 }
880} 884}
881 885
882KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 886KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
883{ 887{
884 mPassWord = pw; 888 mPassWord = pw;
885 mSocket = 0; 889 mSocket = 0;
886 mSyncActionDialog = 0; 890 mSyncActionDialog = 0;
887 blockRC = false; 891 blockRC = false;
888}; 892};
889 893
890void KServerSocket::newConnection ( int socket ) 894void KServerSocket::newConnection ( int socket )
891{ 895{
892 // qDebug("KServerSocket:New connection %d ", socket); 896 // qDebug("KServerSocket:New connection %d ", socket);
893 if ( mSocket ) { 897 if ( mSocket ) {
894 qDebug("KServerSocket::newConnection Socket deleted! "); 898 qDebug("KServerSocket::newConnection Socket deleted! ");
895 delete mSocket; 899 delete mSocket;
896 mSocket = 0; 900 mSocket = 0;
897 } 901 }
898 mSocket = new QSocket( this ); 902 mSocket = new QSocket( this );
899 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 903 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
900 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 904 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
901 mSocket->setSocket( socket ); 905 mSocket->setSocket( socket );
902} 906}
903 907
904void KServerSocket::discardClient() 908void KServerSocket::discardClient()
905{ 909{
906 //qDebug(" KServerSocket::discardClient()"); 910 //qDebug(" KServerSocket::discardClient()");
907 if ( mSocket ) { 911 if ( mSocket ) {
908 delete mSocket; 912 delete mSocket;
909 mSocket = 0; 913 mSocket = 0;
910 } 914 }
911 //emit endConnect(); 915 //emit endConnect();
912} 916}
913void KServerSocket::readClient() 917void KServerSocket::readClient()
914{ 918{
915 if ( blockRC ) 919 if ( blockRC )
916 return; 920 return;
917 if ( mSocket == 0 ) { 921 if ( mSocket == 0 ) {
918 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 922 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
919 return; 923 return;
920 } 924 }
921 qDebug("KServerSocket readClient()"); 925 qDebug("KServerSocket readClient()");
922 if ( mSocket->canReadLine() ) { 926 if ( mSocket->canReadLine() ) {
923 QString line = mSocket->readLine(); 927 QString line = mSocket->readLine();
924 qDebug("KServerSocket readline: %s ", line.latin1()); 928 qDebug("KServerSocket readline: %s ", line.latin1());
925 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 929 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
926 if ( tokens[0] == "GET" ) { 930 if ( tokens[0] == "GET" ) {
927 if ( tokens[1] == mPassWord ) 931 if ( tokens[1] == mPassWord )
928 //emit sendFile( mSocket ); 932 //emit sendFile( mSocket );
929 send_file(); 933 send_file();
930 else { 934 else {
931 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 935 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
932 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 936 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
933 } 937 }
934 } 938 }
935 if ( tokens[0] == "PUT" ) { 939 if ( tokens[0] == "PUT" ) {
936 if ( tokens[1] == mPassWord ) { 940 if ( tokens[1] == mPassWord ) {
937 //emit getFile( mSocket ); 941 //emit getFile( mSocket );
938 blockRC = true; 942 blockRC = true;
939 get_file(); 943 get_file();
940 } 944 }
941 else { 945 else {
942 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 946 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
943 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 947 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
944 } 948 }
945 } 949 }
946 if ( tokens[0] == "STOP" ) { 950 if ( tokens[0] == "STOP" ) {
947 //emit endConnect(); 951 //emit endConnect();
948 end_connect(); 952 end_connect();
949 } 953 }
950 } 954 }
951} 955}
952void KServerSocket::end_connect() 956void KServerSocket::end_connect()
953{ 957{
954 delete mSyncActionDialog; 958 delete mSyncActionDialog;
955 mSyncActionDialog = 0; 959 mSyncActionDialog = 0;
956} 960}
957void KServerSocket::send_file() 961void KServerSocket::send_file()
958{ 962{
959 //qDebug("MainWindow::sendFile(QSocket* s) "); 963 //qDebug("MainWindow::sendFile(QSocket* s) ");
960 if ( mSyncActionDialog ) 964 if ( mSyncActionDialog )
961 delete mSyncActionDialog; 965 delete mSyncActionDialog;
962 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 966 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
963 mSyncActionDialog->setCaption(i18n("Received sync request")); 967 mSyncActionDialog->setCaption(i18n("Received sync request"));
964 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 968 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
965 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 969 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
966 lay->addWidget( label); 970 lay->addWidget( label);
967 lay->setMargin(7); 971 lay->setMargin(7);
968 lay->setSpacing(7); 972 lay->setSpacing(7);
969 mSyncActionDialog->setFixedSize( 230, 120); 973 mSyncActionDialog->setFixedSize( 230, 120);
970 mSyncActionDialog->show(); 974 mSyncActionDialog->show();
971 mSyncActionDialog->raise(); 975 mSyncActionDialog->raise();
972 qDebug("KSS::saving ... "); 976 qDebug("KSS::saving ... ");
973 emit request_file(); 977 emit request_file();
974 qApp->processEvents(); 978 qApp->processEvents();
975 QString fileName = mFileName; 979 QString fileName = mFileName;
976 QFile file( fileName ); 980 QFile file( fileName );
977 if (!file.open( IO_ReadOnly ) ) { 981 if (!file.open( IO_ReadOnly ) ) {
978 delete mSyncActionDialog; 982 delete mSyncActionDialog;
979 mSyncActionDialog = 0; 983 mSyncActionDialog = 0;
980 qDebug("KSS::error open file "); 984 qDebug("KSS::error open file ");
981 mSocket->close(); 985 mSocket->close();
982 if ( mSocket->state() == QSocket::Idle ) 986 if ( mSocket->state() == QSocket::Idle )
983 QTimer::singleShot( 10, this , SLOT ( discardClient())); 987 QTimer::singleShot( 10, this , SLOT ( discardClient()));
984 return ; 988 return ;
985 989
986 } 990 }
987 mSyncActionDialog->setCaption( i18n("Sending file...") ); 991 mSyncActionDialog->setCaption( i18n("Sending file...") );
988 QTextStream ts( &file ); 992 QTextStream ts( &file );
989 ts.setEncoding( QTextStream::Latin1 ); 993 ts.setEncoding( QTextStream::Latin1 );
990 994
991 QTextStream os( mSocket ); 995 QTextStream os( mSocket );
992 os.setEncoding( QTextStream::Latin1 ); 996 os.setEncoding( QTextStream::Latin1 );
993 while ( ! ts.atEnd() ) { 997 while ( ! ts.atEnd() ) {
994 os << ts.readLine() << "\n"; 998 os << ts.readLine() << "\n";
995 } 999 }
996 //os << ts.read(); 1000 //os << ts.read();
997 file.close(); 1001 file.close();
998 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1002 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
999 mSocket->close(); 1003 mSocket->close();
1000 if ( mSocket->state() == QSocket::Idle ) 1004 if ( mSocket->state() == QSocket::Idle )
1001 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1005 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1002} 1006}
1003void KServerSocket::get_file() 1007void KServerSocket::get_file()
1004{ 1008{
1005 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1009 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1006 1010
1007 piTime.start(); 1011 piTime.start();
1008 piFileString = ""; 1012 piFileString = "";
1009 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1013 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1010} 1014}
1011 1015
1012 1016
1013void KServerSocket::readBackFileFromSocket() 1017void KServerSocket::readBackFileFromSocket()
1014{ 1018{
1015 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1019 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1016 while ( mSocket->canReadLine () ) { 1020 while ( mSocket->canReadLine () ) {
1017 piTime.restart(); 1021 piTime.restart();
1018 QString line = mSocket->readLine (); 1022 QString line = mSocket->readLine ();
1019 piFileString += line; 1023 piFileString += line;
1020 //qDebug("readline: %s ", line.latin1()); 1024 //qDebug("readline: %s ", line.latin1());
1021 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1025 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1022 1026
1023 } 1027 }
1024 if ( piTime.elapsed () < 3000 ) { 1028 if ( piTime.elapsed () < 3000 ) {
1025 // wait for more 1029 // wait for more
1026 //qDebug("waitformore "); 1030 //qDebug("waitformore ");
1027 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1031 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1028 return; 1032 return;
1029 } 1033 }
1030 QString fileName = mFileName; 1034 QString fileName = mFileName;
1031 QFile file ( fileName ); 1035 QFile file ( fileName );
1032 if (!file.open( IO_WriteOnly ) ) { 1036 if (!file.open( IO_WriteOnly ) ) {
1033 delete mSyncActionDialog; 1037 delete mSyncActionDialog;
1034 mSyncActionDialog = 0; 1038 mSyncActionDialog = 0;
1035 qDebug("error open cal file "); 1039 qDebug("error open cal file ");
1036 piFileString = ""; 1040 piFileString = "";
1037 emit file_received( false ); 1041 emit file_received( false );
1038 blockRC = false; 1042 blockRC = false;
1039 return ; 1043 return ;
1040 1044
1041 } 1045 }
1042 1046
1043 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1047 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1044 QTextStream ts ( &file ); 1048 QTextStream ts ( &file );
1045 ts.setEncoding( QTextStream::Latin1 ); 1049 ts.setEncoding( QTextStream::Latin1 );
1046 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1050 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1047 ts << piFileString; 1051 ts << piFileString;
1048 mSocket->close(); 1052 mSocket->close();
1049 if ( mSocket->state() == QSocket::Idle ) 1053 if ( mSocket->state() == QSocket::Idle )
1050 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1054 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1051 file.close(); 1055 file.close();
1052 delete mSyncActionDialog; 1056 delete mSyncActionDialog;
1053 mSyncActionDialog = 0; 1057 mSyncActionDialog = 0;
1054 piFileString = ""; 1058 piFileString = "";
1055 blockRC = false; 1059 blockRC = false;
1056 emit file_received( true ); 1060 emit file_received( true );
1057 1061
1058} 1062}
1059 1063
1060KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1064KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1061{ 1065{
1062 mPassWord = password; 1066 mPassWord = password;
1063 mSocket = 0; 1067 mSocket = 0;
1064 mPort = port; 1068 mPort = port;
1065 mHost = host; 1069 mHost = host;
1066 1070
1067 mRetVal = quiet; 1071 mRetVal = quiet;
1068 mTimerSocket = new QTimer ( this ); 1072 mTimerSocket = new QTimer ( this );
1069 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1073 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1070} 1074}
1071void KCommandSocket::readFile( QString fn ) 1075void KCommandSocket::readFile( QString fn )
1072{ 1076{
1073 if ( !mSocket ) { 1077 if ( !mSocket ) {
1074 mSocket = new QSocket( this ); 1078 mSocket = new QSocket( this );
1075 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1079 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1076 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1080 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1077 } 1081 }
1078 mFileString = ""; 1082 mFileString = "";
1079 mFileName = fn; 1083 mFileName = fn;
1080 mFirst = true; 1084 mFirst = true;
1081 mSocket->connectToHost( mHost, mPort ); 1085 mSocket->connectToHost( mHost, mPort );
1082 QTextStream os( mSocket ); 1086 QTextStream os( mSocket );
1083 os.setEncoding( QTextStream::Latin1 ); 1087 os.setEncoding( QTextStream::Latin1 );
1084 os << "GET " << mPassWord << "\r\n"; 1088 os << "GET " << mPassWord << "\r\n";
1085 mTimerSocket->start( 10000 ); 1089 mTimerSocket->start( 10000 );
1086} 1090}
1087 1091
1088void KCommandSocket::writeFile( QString fileName ) 1092void KCommandSocket::writeFile( QString fileName )
1089{ 1093{
1090 if ( !mSocket ) { 1094 if ( !mSocket ) {
1091 mSocket = new QSocket( this ); 1095 mSocket = new QSocket( this );
1092 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1096 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1093 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1097 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1094 } 1098 }
1095 mFileName = fileName ; 1099 mFileName = fileName ;
1096 mSocket->connectToHost( mHost, mPort ); 1100 mSocket->connectToHost( mHost, mPort );
1097} 1101}
1098void KCommandSocket::writeFileToSocket() 1102void KCommandSocket::writeFileToSocket()
1099{ 1103{
1100 QFile file2( mFileName ); 1104 QFile file2( mFileName );
1101 if (!file2.open( IO_ReadOnly ) ) { 1105 if (!file2.open( IO_ReadOnly ) ) {
1102 mRetVal= errorW; 1106 mRetVal= errorW;
1103 mSocket->close(); 1107 mSocket->close();
1104 if ( mSocket->state() == QSocket::Idle ) 1108 if ( mSocket->state() == QSocket::Idle )
1105 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1109 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1106 return ; 1110 return ;
1107 } 1111 }
1108 QTextStream ts2( &file2 ); 1112 QTextStream ts2( &file2 );
1109 ts2.setEncoding( QTextStream::Latin1 ); 1113 ts2.setEncoding( QTextStream::Latin1 );
1110 QTextStream os2( mSocket ); 1114 QTextStream os2( mSocket );
1111 os2.setEncoding( QTextStream::Latin1 ); 1115 os2.setEncoding( QTextStream::Latin1 );
1112 os2 << "PUT " << mPassWord << "\r\n";; 1116 os2 << "PUT " << mPassWord << "\r\n";;
1113 while ( ! ts2.atEnd() ) { 1117 while ( ! ts2.atEnd() ) {
1114 os2 << ts2.readLine() << "\n"; 1118 os2 << ts2.readLine() << "\n";
1115 } 1119 }
1116 mRetVal= successW; 1120 mRetVal= successW;
1117 file2.close(); 1121 file2.close();
1118 mSocket->close(); 1122 mSocket->close();
1119 if ( mSocket->state() == QSocket::Idle ) 1123 if ( mSocket->state() == QSocket::Idle )
1120 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1124 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1121} 1125}
1122void KCommandSocket::sendStop() 1126void KCommandSocket::sendStop()
1123{ 1127{
1124 if ( !mSocket ) { 1128 if ( !mSocket ) {
1125 mSocket = new QSocket( this ); 1129 mSocket = new QSocket( this );
1126 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1130 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1127 } 1131 }
1128 mSocket->connectToHost( mHost, mPort ); 1132 mSocket->connectToHost( mHost, mPort );
1129 QTextStream os2( mSocket ); 1133 QTextStream os2( mSocket );
1130 os2.setEncoding( QTextStream::Latin1 ); 1134 os2.setEncoding( QTextStream::Latin1 );
1131 os2 << "STOP\r\n"; 1135 os2 << "STOP\r\n";
1132 mSocket->close(); 1136 mSocket->close();
1133 if ( mSocket->state() == QSocket::Idle ) 1137 if ( mSocket->state() == QSocket::Idle )
1134 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1138 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1135} 1139}
1136 1140
1137void KCommandSocket::startReadFileFromSocket() 1141void KCommandSocket::startReadFileFromSocket()
1138{ 1142{
1139 if ( ! mFirst ) 1143 if ( ! mFirst )
1140 return; 1144 return;
1141 mFirst = false; 1145 mFirst = false;
1142 mTimerSocket->stop(); 1146 mTimerSocket->stop();
1143 mFileString = ""; 1147 mFileString = "";
1144 mTime.start(); 1148 mTime.start();
1145 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1149 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1146 1150
1147} 1151}
1148void KCommandSocket::readFileFromSocket() 1152void KCommandSocket::readFileFromSocket()
1149{ 1153{
1150 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1154 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1151 while ( mSocket->canReadLine () ) { 1155 while ( mSocket->canReadLine () ) {
1152 mTime.restart(); 1156 mTime.restart();
1153 QString line = mSocket->readLine (); 1157 QString line = mSocket->readLine ();
1154 mFileString += line; 1158 mFileString += line;
1155 //qDebug("readline: %s ", line.latin1()); 1159 //qDebug("readline: %s ", line.latin1());
1156 } 1160 }
1157 if ( mTime.elapsed () < 3000 ) { 1161 if ( mTime.elapsed () < 3000 ) {
1158 // wait for more 1162 // wait for more
1159 //qDebug("waitformore "); 1163 //qDebug("waitformore ");
1160 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1164 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1161 return; 1165 return;
1162 } 1166 }
1163 QString fileName = mFileName; 1167 QString fileName = mFileName;
1164 QFile file ( fileName ); 1168 QFile file ( fileName );
1165 if (!file.open( IO_WriteOnly ) ) { 1169 if (!file.open( IO_WriteOnly ) ) {
1166 mFileString = ""; 1170 mFileString = "";
1167 mRetVal = errorR; 1171 mRetVal = errorR;
1168 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1172 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
1169 deleteSocket(); 1173 deleteSocket();
1170 return ; 1174 return ;
1171 1175
1172 } 1176 }
1173 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1177 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1174 QTextStream ts ( &file ); 1178 QTextStream ts ( &file );
1175 ts.setEncoding( QTextStream::Latin1 ); 1179 ts.setEncoding( QTextStream::Latin1 );
1176 ts << mFileString; 1180 ts << mFileString;
1177 file.close(); 1181 file.close();
1178 mFileString = ""; 1182 mFileString = "";
1179 mRetVal = successR; 1183 mRetVal = successR;
1180 mSocket->close(); 1184 mSocket->close();
1181 // if state is not idle, deleteSocket(); is called via 1185 // if state is not idle, deleteSocket(); is called via
1182 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1186 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1183 if ( mSocket->state() == QSocket::Idle ) 1187 if ( mSocket->state() == QSocket::Idle )
1184 deleteSocket(); 1188 deleteSocket();
1185} 1189}
1186 1190
1187void KCommandSocket::deleteSocket() 1191void KCommandSocket::deleteSocket()
1188{ 1192{
1189 //qDebug("KCommandSocket::deleteSocket() "); 1193 //qDebug("KCommandSocket::deleteSocket() ");
1190 if ( mTimerSocket->isActive () ) { 1194 if ( mTimerSocket->isActive () ) {
1191 mTimerSocket->stop(); 1195 mTimerSocket->stop();
1192 mRetVal = errorTO; 1196 mRetVal = errorTO;
1193 qDebug("Connection to remote host timed out"); 1197 qDebug("Connection to remote host timed out");
1194 if ( mSocket ) { 1198 if ( mSocket ) {
1195 mSocket->close(); 1199 mSocket->close();
1196 //if ( mSocket->state() == QSocket::Idle ) 1200 //if ( mSocket->state() == QSocket::Idle )
1197 // deleteSocket(); 1201 // deleteSocket();
1198 delete mSocket; 1202 delete mSocket;
1199 mSocket = 0; 1203 mSocket = 0;
1200 } 1204 }
1201 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1205 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1202 emit commandFinished( this, mRetVal ); 1206 emit commandFinished( this, mRetVal );
1203 return; 1207 return;
1204 } 1208 }
1205 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1209 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1206 if ( mSocket) 1210 if ( mSocket)
1207 delete mSocket; 1211 delete mSocket;
1208 mSocket = 0; 1212 mSocket = 0;
1209 emit commandFinished( this, mRetVal ); 1213 emit commandFinished( this, mRetVal );
1210} 1214}