summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp13
-rw-r--r--kaddressbook/kabcore.cpp3
2 files changed, 12 insertions, 4 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index 0b6a55e..46e14dd 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -75,274 +75,281 @@ bool OpieConverter::opieToAddressee( const OContact &contact, Addressee &addr )
75 // name 75 // name
76 addr.setFormattedName(contact.fileAs()); 76 addr.setFormattedName(contact.fileAs());
77 addr.setFamilyName( contact.lastName() ); 77 addr.setFamilyName( contact.lastName() );
78 addr.setGivenName( contact.firstName() ); 78 addr.setGivenName( contact.firstName() );
79 addr.setAdditionalName( contact.middleName() ); 79 addr.setAdditionalName( contact.middleName() );
80 addr.setPrefix( contact.title() ); 80 addr.setPrefix( contact.title() );
81 addr.setSuffix( contact.suffix() ); 81 addr.setSuffix( contact.suffix() );
82 82
83 83
84 // email 84 // email
85 QStringList emails = contact.emailList(); 85 QStringList emails = contact.emailList();
86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
88 } 88 }
89 89
90 if (!contact.defaultEmail().isEmpty()) 90 if (!contact.defaultEmail().isEmpty())
91 addr.insertEmail(contact.defaultEmail(), true); 91 addr.insertEmail(contact.defaultEmail(), true);
92 92
93 // home 93 // home
94 if ((!contact.homeStreet().isEmpty()) || 94 if ((!contact.homeStreet().isEmpty()) ||
95 (!contact.homeCity().isEmpty()) || 95 (!contact.homeCity().isEmpty()) ||
96 (!contact.homeState().isEmpty()) || 96 (!contact.homeState().isEmpty()) ||
97 (!contact.homeZip().isEmpty()) || 97 (!contact.homeZip().isEmpty()) ||
98 (!contact.homeCountry().isEmpty())) 98 (!contact.homeCountry().isEmpty()))
99 { 99 {
100 Address homeaddress; 100 Address homeaddress;
101 homeaddress.setType(Address::Home); 101 homeaddress.setType(Address::Home);
102//US homeaddress.setPostOfficeBox( "" ); 102//US homeaddress.setPostOfficeBox( "" );
103//US homeaddress.setExtended( "" ); 103//US homeaddress.setExtended( "" );
104 homeaddress.setStreet( contact.homeStreet() ); 104 homeaddress.setStreet( contact.homeStreet() );
105 homeaddress.setLocality( contact.homeCity() ); 105 homeaddress.setLocality( contact.homeCity() );
106 homeaddress.setRegion( contact.homeState() ); 106 homeaddress.setRegion( contact.homeState() );
107 homeaddress.setPostalCode( contact.homeZip() ); 107 homeaddress.setPostalCode( contact.homeZip() );
108 homeaddress.setCountry( contact.homeCountry() ); 108 homeaddress.setCountry( contact.homeCountry() );
109 109
110 addr.insertAddress( homeaddress ); 110 addr.insertAddress( homeaddress );
111 } 111 }
112 112
113 if (!contact.homePhone().isEmpty()) 113 if (!contact.homePhone().isEmpty())
114 { 114 {
115 PhoneNumber homephone; 115 PhoneNumber homephone;
116 homephone.setType( PhoneNumber::Home ); 116 homephone.setType( PhoneNumber::Home );
117 homephone.setNumber( contact.homePhone() ); 117 homephone.setNumber( contact.homePhone() );
118 addr.insertPhoneNumber( homephone ); 118 addr.insertPhoneNumber( homephone );
119 } 119 }
120 120
121 if (!contact.homeFax().isEmpty()) 121 if (!contact.homeFax().isEmpty())
122 { 122 {
123 PhoneNumber homefax; 123 PhoneNumber homefax;
124 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 124 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
125 homefax.setNumber( contact.homeFax() ); 125 homefax.setNumber( contact.homeFax() );
126 addr.insertPhoneNumber( homefax ); 126 addr.insertPhoneNumber( homefax );
127 } 127 }
128 128
129 if (!contact.homeMobile().isEmpty()) 129 if (!contact.homeMobile().isEmpty())
130 { 130 {
131 PhoneNumber homemobile; 131 PhoneNumber homemobile;
132 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 132 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
133 homemobile.setNumber( contact.homeMobile() ); 133 homemobile.setNumber( contact.homeMobile() );
134 addr.insertPhoneNumber( homemobile ); 134 addr.insertPhoneNumber( homemobile );
135 } 135 }
136 136
137 addr.setUrl( contact.homeWebpage() ); 137 addr.setUrl( contact.homeWebpage() );
138 138
139 139
140 // business 140 // business
141 if ((!contact.businessStreet().isEmpty()) || 141 if ((!contact.businessStreet().isEmpty()) ||
142 (!contact.businessCity().isEmpty()) || 142 (!contact.businessCity().isEmpty()) ||
143 (!contact.businessState().isEmpty()) || 143 (!contact.businessState().isEmpty()) ||
144 (!contact.businessZip().isEmpty()) || 144 (!contact.businessZip().isEmpty()) ||
145 (!contact.businessCountry().isEmpty())) 145 (!contact.businessCountry().isEmpty()))
146 { 146 {
147 Address businessaddress; 147 Address businessaddress;
148 businessaddress.setType(Address::Work); 148 businessaddress.setType(Address::Work);
149//US businessaddress.setPostOfficeBox( "" ); 149//US businessaddress.setPostOfficeBox( "" );
150//US businessaddress.setExtended( "" ); 150//US businessaddress.setExtended( "" );
151 businessaddress.setStreet( contact.businessStreet() ); 151 businessaddress.setStreet( contact.businessStreet() );
152 businessaddress.setLocality( contact.businessCity() ); 152 businessaddress.setLocality( contact.businessCity() );
153 businessaddress.setRegion( contact.businessState() ); 153 businessaddress.setRegion( contact.businessState() );
154 businessaddress.setPostalCode( contact.businessZip() ); 154 businessaddress.setPostalCode( contact.businessZip() );
155 businessaddress.setCountry( contact.businessCountry() ); 155 businessaddress.setCountry( contact.businessCountry() );
156 156
157 addr.insertAddress( businessaddress ); 157 addr.insertAddress( businessaddress );
158 } 158 }
159 159
160 160
161 if (!contact.businessPhone().isEmpty()) 161 if (!contact.businessPhone().isEmpty())
162 { 162 {
163 PhoneNumber businessphone; 163 PhoneNumber businessphone;
164 businessphone.setType( PhoneNumber::Work ); 164 businessphone.setType( PhoneNumber::Work );
165 businessphone.setNumber( contact.businessPhone() ); 165 businessphone.setNumber( contact.businessPhone() );
166 addr.insertPhoneNumber( businessphone ); 166 addr.insertPhoneNumber( businessphone );
167 } 167 }
168 168
169 if (!contact.businessFax().isEmpty()) 169 if (!contact.businessFax().isEmpty())
170 { 170 {
171 PhoneNumber businessfax; 171 PhoneNumber businessfax;
172 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 172 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
173 businessfax.setNumber( contact.businessFax() ); 173 businessfax.setNumber( contact.businessFax() );
174 addr.insertPhoneNumber( businessfax ); 174 addr.insertPhoneNumber( businessfax );
175 } 175 }
176 176
177 if (!contact.businessMobile().isEmpty()) 177 if (!contact.businessMobile().isEmpty())
178 { 178 {
179 PhoneNumber businessmobile; 179 PhoneNumber businessmobile;
180 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 180 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
181 businessmobile.setNumber( contact.businessMobile() ); 181 businessmobile.setNumber( contact.businessMobile() );
182 addr.insertPhoneNumber( businessmobile ); 182 addr.insertPhoneNumber( businessmobile );
183 } 183 }
184 184
185 if (!contact.businessPager().isEmpty()) 185 if (!contact.businessPager().isEmpty())
186 { 186 {
187 PhoneNumber businesspager; 187 PhoneNumber businesspager;
188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
189 businesspager.setNumber( contact.businessPager() ); 189 businesspager.setNumber( contact.businessPager() );
190 addr.insertPhoneNumber( businesspager ); 190 addr.insertPhoneNumber( businesspager );
191 } 191 }
192 192
193 addr.setRole( contact.jobTitle() ); //? 193 addr.setRole( contact.jobTitle() ); //?
194 addr.setOrganization( contact.company() ); 194 addr.setOrganization( contact.company() );
195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
200 200
201 //personal 201 //personal
202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 203 if (contact.gender() == 1)
204 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
205 else if (contact.gender() == 2)
206 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
204 207
205 if (contact.anniversary().isValid()) { 208 if (contact.anniversary().isValid()) {
206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 209 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
207//US 210//US
208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 211 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 212 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
210 } 213 }
211 214
212 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 215 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
213 if (contact.birthday().isValid()) 216 if (contact.birthday().isValid())
214 addr.setBirthday( contact.birthday() ); 217 addr.setBirthday( contact.birthday() );
215 218
216 addr.setNickName( contact.nickname() ); 219 addr.setNickName( contact.nickname() );
217 220
218 // others 221 // others
219 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 222 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
220 QString notes = contact.notes(); 223 QString notes = contact.notes();
221 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 224 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
222 225
223 addr.setNote( contact.notes() ); 226 addr.setNote( contact.notes() );
224 227
225 228
226 229
227//US QString groups() const { return find( Qtopia::Groups ); } 230//US QString groups() const { return find( Qtopia::Groups ); }
228//US QStringList groupList() const; 231//US QStringList groupList() const;
229 232
230 233
231 QStringList cats = contact.categoryNames("Contacts"); 234 QStringList cats = contact.categoryNames("Contacts");
232 addr.setCategories( cats ); 235 addr.setCategories( cats );
233// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 236// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
234// qDebug("Cat: %s", (*it).latin1()); 237// qDebug("Cat: %s", (*it).latin1());
235// } 238// }
236 239
237 240
238 return true; 241 return true;
239} 242}
240 243
241bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) 244bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
242{ 245{
243 // name 246 // name
244 contact.setLastName(addr.familyName()); 247 contact.setLastName(addr.familyName());
245 contact.setFirstName(addr.givenName()); 248 contact.setFirstName(addr.givenName());
246 contact.setMiddleName(addr.additionalName()); 249 contact.setMiddleName(addr.additionalName());
247 contact.setTitle(addr.prefix()); 250 contact.setTitle(addr.prefix());
248 contact.setSuffix(addr.suffix()); 251 contact.setSuffix(addr.suffix());
249 contact.setFileAs(); 252 contact.setFileAs();
250 253
251 254
252 // email 255 // email
253 QStringList emails = addr.emails(); 256 QStringList emails = addr.emails();
254 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 257 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
255 contact.insertEmail(*it); 258 contact.insertEmail(*it);
256 } 259 }
257 contact.setDefaultEmail( addr.preferredEmail() ); 260 contact.setDefaultEmail( addr.preferredEmail() );
258 261
259 262
260 // home 263 // home
261 const Address homeaddress = addr.address(Address::Home); 264 const Address homeaddress = addr.address(Address::Home);
262 if (!homeaddress.isEmpty()) { 265 if (!homeaddress.isEmpty()) {
263 contact.setHomeStreet(homeaddress.street()); 266 contact.setHomeStreet(homeaddress.street());
264 contact.setHomeCity(homeaddress.locality()); 267 contact.setHomeCity(homeaddress.locality());
265 contact.setHomeState(homeaddress.region()); 268 contact.setHomeState(homeaddress.region());
266 contact.setHomeZip(homeaddress.postalCode()); 269 contact.setHomeZip(homeaddress.postalCode());
267 contact.setHomeCountry(homeaddress.country()); 270 contact.setHomeCountry(homeaddress.country());
268 } 271 }
269 272
270 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 273 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
271 if (!homephone.number().isEmpty()) 274 if (!homephone.number().isEmpty())
272 contact.setHomePhone(homephone.number()); 275 contact.setHomePhone(homephone.number());
273 276
274 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 277 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
275 if (!homefax.number().isEmpty()) 278 if (!homefax.number().isEmpty())
276 contact.setHomeFax(homefax.number()); 279 contact.setHomeFax(homefax.number());
277 280
278 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 281 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
279 if (!homemobile.number().isEmpty()) 282 if (!homemobile.number().isEmpty())
280 contact.setHomeMobile(homemobile.number()); 283 contact.setHomeMobile(homemobile.number());
281 284
282 contact.setHomeWebpage(addr.url().url()); 285 contact.setHomeWebpage(addr.url().url());
283 286
284 287
285 // business 288 // business
286 const Address businessaddress = addr.address(Address::Work); 289 const Address businessaddress = addr.address(Address::Work);
287 if (!businessaddress.isEmpty()) { 290 if (!businessaddress.isEmpty()) {
288 contact.setBusinessStreet(businessaddress.street()); 291 contact.setBusinessStreet(businessaddress.street());
289 contact.setBusinessCity(businessaddress.locality()); 292 contact.setBusinessCity(businessaddress.locality());
290 contact.setBusinessState(businessaddress.region()); 293 contact.setBusinessState(businessaddress.region());
291 contact.setBusinessZip(businessaddress.postalCode()); 294 contact.setBusinessZip(businessaddress.postalCode());
292 contact.setBusinessCountry(businessaddress.country()); 295 contact.setBusinessCountry(businessaddress.country());
293 } 296 }
294 297
295 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 298 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
296 if (!businessphone.number().isEmpty()) 299 if (!businessphone.number().isEmpty())
297 contact.setBusinessPhone(businessphone.number()); 300 contact.setBusinessPhone(businessphone.number());
298 301
299 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 302 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
300 if (!businessfax.number().isEmpty()) 303 if (!businessfax.number().isEmpty())
301 contact.setBusinessFax(businessfax.number()); 304 contact.setBusinessFax(businessfax.number());
302 305
303 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 306 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
304 if (!businessmobile.number().isEmpty()) 307 if (!businessmobile.number().isEmpty())
305 contact.setBusinessMobile(businessmobile.number()); 308 contact.setBusinessMobile(businessmobile.number());
306 309
307 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 310 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
308 if (!businesspager.number().isEmpty()) 311 if (!businesspager.number().isEmpty())
309 contact.setBusinessPager(businesspager.number()); 312 contact.setBusinessPager(businesspager.number());
310 313
311 contact.setJobTitle(addr.role()); 314 contact.setJobTitle(addr.role());
312 contact.setCompany(addr.organization()); 315 contact.setCompany(addr.organization());
313 316
314 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 317 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
315 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 318 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
316 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 319 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
317 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 320 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
318 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 321 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
319 322
320 //personal 323 //personal
321 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 324 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
322 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); 325 QString gend = addr.custom( "KADDRESSBOOK", "X-Gender" );
323 326 if (gend == "female")
327 contact.setGender("1");
328 else if (gend == "male")
329 contact.setGender("2");
330
324 QDate dt = KGlobal::locale()->readDate( 331 QDate dt = KGlobal::locale()->readDate(
325 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 332 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
326 contact.setAnniversary( dt ); 333 contact.setAnniversary( dt );
327 334
328 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 335 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
329 336
330 contact.setBirthday(addr.birthday().date()); 337 contact.setBirthday(addr.birthday().date());
331 contact.setNickname(addr.nickName()); 338 contact.setNickname(addr.nickName());
332 339
333 // other 340 // other
334 contact.setNotes(addr.note()); 341 contact.setNotes(addr.note());
335 342
336//US QString groups() const { return find( Qtopia::Groups ); } 343//US QString groups() const { return find( Qtopia::Groups ); }
337//US QStringList groupList() const; 344//US QStringList groupList() const;
338 345
339 QStringList cats = addr.categories(); 346 QStringList cats = addr.categories();
340 347
341 QArray<int> iar; 348 QArray<int> iar;
342 if ( !cats.isEmpty() ) { 349 if ( !cats.isEmpty() ) {
343 QArray<int> iar = catDB->ids("contact", cats); 350 QArray<int> iar = catDB->ids("contact", cats);
344 contact.setCategories(iar); 351 contact.setCategories(iar);
345 } 352 }
346 353
347 return true; 354 return true;
348} 355}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1a34e4d..8daca33 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -38,257 +38,258 @@
38#include <kabc/errorhandler.h> 38#include <kabc/errorhandler.h>
39#include <kabc/resource.h> 39#include <kabc/resource.h>
40#include <kabc/vcardconverter.h> 40#include <kabc/vcardconverter.h>
41#include <kapplication.h> 41#include <kapplication.h>
42#include <kactionclasses.h> 42#include <kactionclasses.h>
43#include <kcmultidialog.h> 43#include <kcmultidialog.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <kdeversion.h> 45#include <kdeversion.h>
46#include <kkeydialog.h> 46#include <kkeydialog.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kprinter.h> 48#include <kprinter.h>
49#include <kprotocolinfo.h> 49#include <kprotocolinfo.h>
50#include <kresources/selectdialog.h> 50#include <kresources/selectdialog.h>
51#include <kstandarddirs.h> 51#include <kstandarddirs.h>
52#include <ktempfile.h> 52#include <ktempfile.h>
53#include <kxmlguiclient.h> 53#include <kxmlguiclient.h>
54#include <kaboutdata.h> 54#include <kaboutdata.h>
55#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
56 56
57#include "addresseeutil.h" 57#include "addresseeutil.h"
58#include "addresseeeditordialog.h" 58#include "addresseeeditordialog.h"
59#include "extensionmanager.h" 59#include "extensionmanager.h"
60#include "kstdaction.h" 60#include "kstdaction.h"
61#include "kaddressbookservice.h" 61#include "kaddressbookservice.h"
62#include "ldapsearchdialog.h" 62#include "ldapsearchdialog.h"
63#include "printing/printingwizard.h" 63#include "printing/printingwizard.h"
64#else // KAB_EMBEDDED 64#else // KAB_EMBEDDED
65 65
66#include <kapplication.h> 66#include <kapplication.h>
67#include "KDGanttMinimizeSplitter.h" 67#include "KDGanttMinimizeSplitter.h"
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include <qapp.h> 70#include <qapp.h>
71#include <qmenubar.h> 71#include <qmenubar.h>
72//#include <qtoolbar.h> 72//#include <qtoolbar.h>
73#include <qmessagebox.h> 73#include <qmessagebox.h>
74#include <kdebug.h> 74#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 75#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 76#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 77#include <ktoolbar.h>
78 78
79#include <kcmkabconfig.h> 79#include <kcmkabconfig.h>
80 80
81//US#include <qpe/resource.h> // needed for Resource::loadPixmap 81//US#include <qpe/resource.h> // needed for Resource::loadPixmap
82//#include <qlabel.h> 82//#include <qlabel.h>
83#endif // KAB_EMBEDDED 83#endif // KAB_EMBEDDED
84#include <kcmkabconfig.h> 84#include <kcmkabconfig.h>
85 85
86 86
87#include <kresources/selectdialog.h> 87#include <kresources/selectdialog.h>
88#include <kmessagebox.h> 88#include <kmessagebox.h>
89 89
90#include <picture.h> 90#include <picture.h>
91#include <resource.h> 91#include <resource.h>
92 92
93//US#include <qsplitter.h> 93//US#include <qsplitter.h>
94#include <qvbox.h> 94#include <qvbox.h>
95#include <qlayout.h> 95#include <qlayout.h>
96#include <qclipboard.h> 96#include <qclipboard.h>
97 97
98#include <libkdepim/categoryselectdialog.h> 98#include <libkdepim/categoryselectdialog.h>
99 99
100#include "addresseeutil.h" 100#include "addresseeutil.h"
101#include "undocmds.h" 101#include "undocmds.h"
102#include "addresseeeditordialog.h" 102#include "addresseeeditordialog.h"
103#include "viewmanager.h" 103#include "viewmanager.h"
104#include "details/detailsviewcontainer.h" 104#include "details/detailsviewcontainer.h"
105#include "kabprefs.h" 105#include "kabprefs.h"
106#include "xxportmanager.h" 106#include "xxportmanager.h"
107#include "incsearchwidget.h" 107#include "incsearchwidget.h"
108#include "jumpbuttonbar.h" 108#include "jumpbuttonbar.h"
109#include "extensionmanager.h" 109#include "extensionmanager.h"
110#include "addresseeconfig.h" 110#include "addresseeconfig.h"
111#include <kcmultidialog.h> 111#include <kcmultidialog.h>
112 112
113#ifdef _WIN32_ 113#ifdef _WIN32_
114 114
115#include "kaimportoldialog.h" 115#include "kaimportoldialog.h"
116#endif 116#endif
117 117
118bool pasteWithNewUid = true; 118bool pasteWithNewUid = true;
119 119
120#ifdef KAB_EMBEDDED 120#ifdef KAB_EMBEDDED
121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
125#else //KAB_EMBEDDED 125#else //KAB_EMBEDDED
126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
129 mReadWrite( readWrite ), mModified( false ) 129 mReadWrite( readWrite ), mModified( false )
130#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
131{ 131{
132#ifdef KAB_EMBEDDED 132#ifdef KAB_EMBEDDED
133 //US we define here our own global actioncollection. 133 //US we define here our own global actioncollection.
134 //mActionCollection = new KActionCollection(this); 134 //mActionCollection = new KActionCollection(this);
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 mExtensionBarSplitter = 0; 136 mExtensionBarSplitter = 0;
137 mIsPart = !parent->inherits( "KAddressBookMain" ); 137 mIsPart = !parent->inherits( "KAddressBookMain" );
138 138
139 mAddressBook = KABC::StdAddressBook::self(); 139 mAddressBook = KABC::StdAddressBook::self();
140 KABC::StdAddressBook::setAutomaticSave( false ); 140 KABC::StdAddressBook::setAutomaticSave( false );
141 141
142#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
143 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 143 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 146 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
147 SLOT( addressBookChanged() ) ); 147 SLOT( addressBookChanged() ) );
148 148
149 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 149 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
150 "X-Department", "KADDRESSBOOK" ); 150 "X-Department", "KADDRESSBOOK" );
151 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 151 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
152 "X-Profession", "KADDRESSBOOK" ); 152 "X-Profession", "KADDRESSBOOK" );
153 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 153 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
154 "X-AssistantsName", "KADDRESSBOOK" ); 154 "X-AssistantsName", "KADDRESSBOOK" );
155 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 155 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
156 "X-ManagersName", "KADDRESSBOOK" ); 156 "X-ManagersName", "KADDRESSBOOK" );
157 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 157 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
158 "X-SpousesName", "KADDRESSBOOK" ); 158 "X-SpousesName", "KADDRESSBOOK" );
159 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 159 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
160 "X-Office", "KADDRESSBOOK" ); 160 "X-Office", "KADDRESSBOOK" );
161 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 161 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
162 "X-IMAddress", "KADDRESSBOOK" ); 162 "X-IMAddress", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 163 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
164 "X-Anniversary", "KADDRESSBOOK" ); 164 "X-Anniversary", "KADDRESSBOOK" );
165 165
166//US added this field to become compatible with Opie addressbook 166 //US added this field to become compatible with Opie/qtopia addressbook
167 // values can be "female" or "male" or "". An empty field represents undefined.
167 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 168 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
168 "X-Gender", "KADDRESSBOOK" ); 169 "X-Gender", "KADDRESSBOOK" );
169 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 170 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
170 "X-Children", "KADDRESSBOOK" ); 171 "X-Children", "KADDRESSBOOK" );
171 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 172 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
172 "X-FreeBusyUrl", "KADDRESSBOOK" ); 173 "X-FreeBusyUrl", "KADDRESSBOOK" );
173 174
174 initGUI(); 175 initGUI();
175 176
176 mIncSearchWidget->setFocus(); 177 mIncSearchWidget->setFocus();
177 178
178 179
179 connect( mViewManager, SIGNAL( selected( const QString& ) ), 180 connect( mViewManager, SIGNAL( selected( const QString& ) ),
180 SLOT( setContactSelected( const QString& ) ) ); 181 SLOT( setContactSelected( const QString& ) ) );
181 connect( mViewManager, SIGNAL( executed( const QString& ) ), 182 connect( mViewManager, SIGNAL( executed( const QString& ) ),
182 SLOT( editContact( const QString& ) ) ); 183 SLOT( editContact( const QString& ) ) );
183 connect( mViewManager, SIGNAL( deleteRequest( ) ), 184 connect( mViewManager, SIGNAL( deleteRequest( ) ),
184 SLOT( deleteContacts( ) ) ); 185 SLOT( deleteContacts( ) ) );
185 connect( mViewManager, SIGNAL( modified() ), 186 connect( mViewManager, SIGNAL( modified() ),
186 SLOT( setModified() ) ); 187 SLOT( setModified() ) );
187 188
188 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 189 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
189 190
190 connect( mXXPortManager, SIGNAL( modified() ), 191 connect( mXXPortManager, SIGNAL( modified() ),
191 SLOT( setModified() ) ); 192 SLOT( setModified() ) );
192 193
193 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 194 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
194 SLOT( incrementalSearch( const QString& ) ) ); 195 SLOT( incrementalSearch( const QString& ) ) );
195 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 196 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
196 mJumpButtonBar, SLOT( recreateButtons() ) ); 197 mJumpButtonBar, SLOT( recreateButtons() ) );
197 198
198#ifndef KAB_EMBEDDED 199#ifndef KAB_EMBEDDED
199 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 200 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
200 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 201 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
201 202
202 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 203 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
203 SLOT( sendMail( const QString& ) ) ); 204 SLOT( sendMail( const QString& ) ) );
204 connect( mDetails, SIGNAL( browse( const QString& ) ), 205 connect( mDetails, SIGNAL( browse( const QString& ) ),
205 SLOT( browse( const QString& ) ) ); 206 SLOT( browse( const QString& ) ) );
206 207
207 mAddressBookService = new KAddressBookService( this ); 208 mAddressBookService = new KAddressBookService( this );
208 209
209#endif //KAB_EMBEDDED 210#endif //KAB_EMBEDDED
210 mEditorDialog = 0; 211 mEditorDialog = 0;
211 createAddresseeEditorDialog( this ); 212 createAddresseeEditorDialog( this );
212 setModified( false ); 213 setModified( false );
213} 214}
214 215
215KABCore::~KABCore() 216KABCore::~KABCore()
216{ 217{
217 // save(); 218 // save();
218 //saveSettings(); 219 //saveSettings();
219 //KABPrefs::instance()->writeConfig(); 220 //KABPrefs::instance()->writeConfig();
220 delete AddresseeConfig::instance(); 221 delete AddresseeConfig::instance();
221 mAddressBook = 0; 222 mAddressBook = 0;
222 KABC::StdAddressBook::close(); 223 KABC::StdAddressBook::close();
223 224
224#ifdef KAB_EMBEDDED 225#ifdef KAB_EMBEDDED
225 //US we define here our own global actioncollection. 226 //US we define here our own global actioncollection.
226 // delete mActionCollection; 227 // delete mActionCollection;
227#endif //KAB_EMBEDDED 228#endif //KAB_EMBEDDED
228 229
229} 230}
230 231
231void KABCore::restoreSettings() 232void KABCore::restoreSettings()
232{ 233{
233 bool state = KABPrefs::instance()->mJumpButtonBarVisible; 234 bool state = KABPrefs::instance()->mJumpButtonBarVisible;
234 235
235 mActionJumpBar->setChecked( state ); 236 mActionJumpBar->setChecked( state );
236 setJumpButtonBarVisible( state ); 237 setJumpButtonBarVisible( state );
237 238
238 state = KABPrefs::instance()->mDetailsPageVisible; 239 state = KABPrefs::instance()->mDetailsPageVisible;
239 240
240 mActionDetails->setChecked( state ); 241 mActionDetails->setChecked( state );
241 setDetailsVisible( state ); 242 setDetailsVisible( state );
242 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 243 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
243 if ( splitterSize.count() == 0 ) { 244 if ( splitterSize.count() == 0 ) {
244 splitterSize.append( width() / 2 ); 245 splitterSize.append( width() / 2 );
245 splitterSize.append( width() / 2 ); 246 splitterSize.append( width() / 2 );
246 } 247 }
247 mMiniSplitter->setSizes( splitterSize ); 248 mMiniSplitter->setSizes( splitterSize );
248 if ( mExtensionBarSplitter ) { 249 if ( mExtensionBarSplitter ) {
249 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 250 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
250 if ( splitterSize.count() == 0 ) { 251 if ( splitterSize.count() == 0 ) {
251 splitterSize.append( width() / 2 ); 252 splitterSize.append( width() / 2 );
252 splitterSize.append( width() / 2 ); 253 splitterSize.append( width() / 2 );
253 } 254 }
254 mExtensionBarSplitter->setSizes( splitterSize ); 255 mExtensionBarSplitter->setSizes( splitterSize );
255 256
256 } 257 }
257#ifndef KAB_EMBEDDED 258#ifndef KAB_EMBEDDED
258 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; 259 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter;
259 if ( splitterSize.count() == 0 ) { 260 if ( splitterSize.count() == 0 ) {
260 splitterSize.append( width() / 2 ); 261 splitterSize.append( width() / 2 );
261 splitterSize.append( width() / 2 ); 262 splitterSize.append( width() / 2 );
262 } 263 }
263 mExtensionBarSplitter->setSizes( splitterSize ); 264 mExtensionBarSplitter->setSizes( splitterSize );
264 265
265 splitterSize = KABPrefs::instance()->mDetailsSplitter; 266 splitterSize = KABPrefs::instance()->mDetailsSplitter;
266 if ( splitterSize.count() == 0 ) { 267 if ( splitterSize.count() == 0 ) {
267 splitterSize.append( height() / 2 ); 268 splitterSize.append( height() / 2 );
268 splitterSize.append( height() / 2 ); 269 splitterSize.append( height() / 2 );
269 } 270 }
270 mDetailsSplitter->setSizes( splitterSize ); 271 mDetailsSplitter->setSizes( splitterSize );
271 272
272 mExtensionManager->restoreSettings(); 273 mExtensionManager->restoreSettings();
273 274
274#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
275 276
276 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 277 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
277 278
278 mViewManager->restoreSettings(); 279 mViewManager->restoreSettings();
279 mExtensionManager->restoreSettings(); 280 mExtensionManager->restoreSettings();
280} 281}
281 282
282void KABCore::saveSettings() 283void KABCore::saveSettings()
283{ 284{
284 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 285 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
285 if ( mExtensionBarSplitter ) 286 if ( mExtensionBarSplitter )
286 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 287 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
287 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 288 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
288 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 289 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
289#ifndef KAB_EMBEDDED 290#ifndef KAB_EMBEDDED
290 291
291 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 292 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
292 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 293 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
293#endif //KAB_EMBEDDED 294#endif //KAB_EMBEDDED
294 mExtensionManager->saveSettings(); 295 mExtensionManager->saveSettings();