summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index d484073..6b282e2 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1622 +1,1626 @@
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//US 35//US
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38//US #include "resource.h" 38//US #include "resource.h"
39#include "addressee.h" 39#include "addressee.h"
40 40
41using namespace KABC; 41using namespace KABC;
42 42
43static bool matchBinaryPattern( int value, int pattern ); 43static bool matchBinaryPattern( int value, int pattern );
44 44
45struct Addressee::AddresseeData : public KShared 45struct Addressee::AddresseeData : public KShared
46{ 46{
47 QString uid; 47 QString uid;
48 QString name; 48 QString name;
49 QString formattedName; 49 QString formattedName;
50 QString familyName; 50 QString familyName;
51 QString givenName; 51 QString givenName;
52 QString additionalName; 52 QString additionalName;
53 QString prefix; 53 QString prefix;
54 QString suffix; 54 QString suffix;
55 QString nickName; 55 QString nickName;
56 QDateTime birthday; 56 QDateTime birthday;
57 QString mailer; 57 QString mailer;
58 TimeZone timeZone; 58 TimeZone timeZone;
59 Geo geo; 59 Geo geo;
60 QString title; 60 QString title;
61 QString role; 61 QString role;
62 QString organization; 62 QString organization;
63 QString note; 63 QString note;
64 QString productId; 64 QString productId;
65 QDateTime revision; 65 QDateTime revision;
66 QString sortString; 66 QString sortString;
67 KURL url; 67 KURL url;
68 Secrecy secrecy; 68 Secrecy secrecy;
69 Picture logo; 69 Picture logo;
70 Picture photo; 70 Picture photo;
71 Sound sound; 71 Sound sound;
72 Agent agent; 72 Agent agent;
73 73
74 PhoneNumber::List phoneNumbers; 74 PhoneNumber::List phoneNumbers;
75 Address::List addresses; 75 Address::List addresses;
76 Key::List keys; 76 Key::List keys;
77 QStringList emails; 77 QStringList emails;
78 QStringList categories; 78 QStringList categories;
79 QStringList custom; 79 QStringList custom;
80 80
81 Resource *resource; 81 Resource *resource;
82 82
83 bool empty :1; 83 bool empty :1;
84 bool changed :1; 84 bool changed :1;
85}; 85};
86 86
87Addressee::Addressee() 87Addressee::Addressee()
88{ 88{
89 mData = new AddresseeData; 89 mData = new AddresseeData;
90 mData->empty = true; 90 mData->empty = true;
91 mData->changed = false; 91 mData->changed = false;
92 mData->resource = 0; 92 mData->resource = 0;
93} 93}
94 94
95Addressee::~Addressee() 95Addressee::~Addressee()
96{ 96{
97} 97}
98 98
99Addressee::Addressee( const Addressee &a ) 99Addressee::Addressee( const Addressee &a )
100{ 100{
101 mData = a.mData; 101 mData = a.mData;
102} 102}
103 103
104Addressee &Addressee::operator=( const Addressee &a ) 104Addressee &Addressee::operator=( const Addressee &a )
105{ 105{
106 mData = a.mData; 106 mData = a.mData;
107 return (*this); 107 return (*this);
108} 108}
109 109
110Addressee Addressee::copy() 110Addressee Addressee::copy()
111{ 111{
112 Addressee a; 112 Addressee a;
113 *(a.mData) = *mData; 113 *(a.mData) = *mData;
114 return a; 114 return a;
115} 115}
116 116
117void Addressee::detach() 117void Addressee::detach()
118{ 118{
119 if ( mData.count() == 1 ) return; 119 if ( mData.count() == 1 ) return;
120 *this = copy(); 120 *this = copy();
121} 121}
122 122
123bool Addressee::operator==( const Addressee &a ) const 123bool Addressee::operator==( const Addressee &a ) const
124{ 124{
125 if ( uid() != a.uid() ) return false; 125 if ( uid() != a.uid() ) return false;
126 if ( mData->name != a.mData->name ) return false; 126 if ( mData->name != a.mData->name ) return false;
127 if ( mData->formattedName != a.mData->formattedName ) return false; 127 if ( mData->formattedName != a.mData->formattedName ) return false;
128 if ( mData->familyName != a.mData->familyName ) return false; 128 if ( mData->familyName != a.mData->familyName ) return false;
129 if ( mData->givenName != a.mData->givenName ) return false; 129 if ( mData->givenName != a.mData->givenName ) return false;
130 if ( mData->additionalName != a.mData->additionalName ) return false; 130 if ( mData->additionalName != a.mData->additionalName ) return false;
131 if ( mData->prefix != a.mData->prefix ) return false; 131 if ( mData->prefix != a.mData->prefix ) return false;
132 if ( mData->suffix != a.mData->suffix ) return false; 132 if ( mData->suffix != a.mData->suffix ) return false;
133 if ( mData->nickName != a.mData->nickName ) return false; 133 if ( mData->nickName != a.mData->nickName ) return false;
134 if ( mData->birthday != a.mData->birthday ) return false; 134 if ( mData->birthday != a.mData->birthday ) return false;
135 if ( mData->mailer != a.mData->mailer ) return false; 135 if ( mData->mailer != a.mData->mailer ) return false;
136 if ( mData->timeZone != a.mData->timeZone ) return false; 136 if ( mData->timeZone != a.mData->timeZone ) return false;
137 if ( mData->geo != a.mData->geo ) return false; 137 if ( mData->geo != a.mData->geo ) return false;
138 if ( mData->title != a.mData->title ) return false; 138 if ( mData->title != a.mData->title ) return false;
139 if ( mData->role != a.mData->role ) return false; 139 if ( mData->role != a.mData->role ) return false;
140 if ( mData->organization != a.mData->organization ) return false; 140 if ( mData->organization != a.mData->organization ) return false;
141 if ( mData->note != a.mData->note ) return false; 141 if ( mData->note != a.mData->note ) return false;
142 if ( mData->productId != a.mData->productId ) return false; 142 if ( mData->productId != a.mData->productId ) return false;
143 if ( mData->revision != a.mData->revision ) return false; 143 if ( mData->revision != a.mData->revision ) return false;
144 if ( mData->sortString != a.mData->sortString ) return false; 144 if ( mData->sortString != a.mData->sortString ) return false;
145 if ( mData->secrecy != a.mData->secrecy ) return false; 145 if ( mData->secrecy != a.mData->secrecy ) return false;
146 if ( mData->logo != a.mData->logo ) return false; 146 if ( mData->logo != a.mData->logo ) return false;
147 if ( mData->photo != a.mData->photo ) return false; 147 if ( mData->photo != a.mData->photo ) return false;
148 if ( mData->sound != a.mData->sound ) return false; 148 if ( mData->sound != a.mData->sound ) return false;
149 if ( mData->agent != a.mData->agent ) return false; 149 if ( mData->agent != a.mData->agent ) return false;
150 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 150 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
151 ( mData->url != a.mData->url ) ) return false; 151 ( mData->url != a.mData->url ) ) return false;
152 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 152 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
153 if ( mData->addresses != a.mData->addresses ) return false; 153 if ( mData->addresses != a.mData->addresses ) return false;
154 if ( mData->keys != a.mData->keys ) return false; 154 if ( mData->keys != a.mData->keys ) return false;
155 if ( mData->emails != a.mData->emails ) return false; 155 if ( mData->emails != a.mData->emails ) return false;
156 if ( mData->categories != a.mData->categories ) return false; 156 if ( mData->categories != a.mData->categories ) return false;
157 if ( mData->custom != a.mData->custom ) return false; 157 if ( mData->custom != a.mData->custom ) return false;
158 158
159 return true; 159 return true;
160} 160}
161 161
162bool Addressee::operator!=( const Addressee &a ) const 162bool Addressee::operator!=( const Addressee &a ) const
163{ 163{
164 return !( a == *this ); 164 return !( a == *this );
165} 165}
166 166
167bool Addressee::isEmpty() const 167bool Addressee::isEmpty() const
168{ 168{
169 return mData->empty; 169 return mData->empty;
170} 170}
171 171
172void Addressee::setUid( const QString &id ) 172void Addressee::setUid( const QString &id )
173{ 173{
174 if ( id == mData->uid ) return; 174 if ( id == mData->uid ) return;
175 detach(); 175 detach();
176 mData->empty = false; 176 mData->empty = false;
177 mData->uid = id; 177 mData->uid = id;
178} 178}
179 179
180QString Addressee::uid() const 180QString Addressee::uid() const
181{ 181{
182 if ( mData->uid.isEmpty() ) 182 if ( mData->uid.isEmpty() )
183 mData->uid = KApplication::randomString( 10 ); 183 mData->uid = KApplication::randomString( 10 );
184 184
185 return mData->uid; 185 return mData->uid;
186} 186}
187 187
188QString Addressee::uidLabel() 188QString Addressee::uidLabel()
189{ 189{
190 return i18n("Unique Identifier"); 190 return i18n("Unique Identifier");
191} 191}
192 192
193void Addressee::setName( const QString &name ) 193void Addressee::setName( const QString &name )
194{ 194{
195 if ( name == mData->name ) return; 195 if ( name == mData->name ) return;
196 detach(); 196 detach();
197 mData->empty = false; 197 mData->empty = false;
198 mData->name = name; 198 mData->name = name;
199} 199}
200 200
201QString Addressee::name() const 201QString Addressee::name() const
202{ 202{
203 return mData->name; 203 return mData->name;
204} 204}
205 205
206QString Addressee::nameLabel() 206QString Addressee::nameLabel()
207{ 207{
208 return i18n("Name"); 208 return i18n("Name");
209} 209}
210 210
211 211
212void Addressee::setFormattedName( const QString &formattedName ) 212void Addressee::setFormattedName( const QString &formattedName )
213{ 213{
214 if ( formattedName == mData->formattedName ) return; 214 if ( formattedName == mData->formattedName ) return;
215 detach(); 215 detach();
216 mData->empty = false; 216 mData->empty = false;
217 mData->formattedName = formattedName; 217 mData->formattedName = formattedName;
218} 218}
219 219
220QString Addressee::formattedName() const 220QString Addressee::formattedName() const
221{ 221{
222 return mData->formattedName; 222 return mData->formattedName;
223} 223}
224 224
225QString Addressee::formattedNameLabel() 225QString Addressee::formattedNameLabel()
226{ 226{
227 return i18n("Formatted Name"); 227 return i18n("Formatted Name");
228} 228}
229 229
230 230
231void Addressee::setFamilyName( const QString &familyName ) 231void Addressee::setFamilyName( const QString &familyName )
232{ 232{
233 if ( familyName == mData->familyName ) return; 233 if ( familyName == mData->familyName ) return;
234 detach(); 234 detach();
235 mData->empty = false; 235 mData->empty = false;
236 mData->familyName = familyName; 236 mData->familyName = familyName;
237} 237}
238 238
239QString Addressee::familyName() const 239QString Addressee::familyName() const
240{ 240{
241 return mData->familyName; 241 return mData->familyName;
242} 242}
243 243
244QString Addressee::familyNameLabel() 244QString Addressee::familyNameLabel()
245{ 245{
246 return i18n("Family Name"); 246 return i18n("Family Name");
247} 247}
248 248
249 249
250void Addressee::setGivenName( const QString &givenName ) 250void Addressee::setGivenName( const QString &givenName )
251{ 251{
252 if ( givenName == mData->givenName ) return; 252 if ( givenName == mData->givenName ) return;
253 detach(); 253 detach();
254 mData->empty = false; 254 mData->empty = false;
255 mData->givenName = givenName; 255 mData->givenName = givenName;
256} 256}
257 257
258QString Addressee::givenName() const 258QString Addressee::givenName() const
259{ 259{
260 return mData->givenName; 260 return mData->givenName;
261} 261}
262 262
263QString Addressee::givenNameLabel() 263QString Addressee::givenNameLabel()
264{ 264{
265 return i18n("Given Name"); 265 return i18n("Given Name");
266} 266}
267 267
268 268
269void Addressee::setAdditionalName( const QString &additionalName ) 269void Addressee::setAdditionalName( const QString &additionalName )
270{ 270{
271 if ( additionalName == mData->additionalName ) return; 271 if ( additionalName == mData->additionalName ) return;
272 detach(); 272 detach();
273 mData->empty = false; 273 mData->empty = false;
274 mData->additionalName = additionalName; 274 mData->additionalName = additionalName;
275} 275}
276 276
277QString Addressee::additionalName() const 277QString Addressee::additionalName() const
278{ 278{
279 return mData->additionalName; 279 return mData->additionalName;
280} 280}
281 281
282QString Addressee::additionalNameLabel() 282QString Addressee::additionalNameLabel()
283{ 283{
284 return i18n("Additional Names"); 284 return i18n("Additional Names");
285} 285}
286 286
287 287
288void Addressee::setPrefix( const QString &prefix ) 288void Addressee::setPrefix( const QString &prefix )
289{ 289{
290 if ( prefix == mData->prefix ) return; 290 if ( prefix == mData->prefix ) return;
291 detach(); 291 detach();
292 mData->empty = false; 292 mData->empty = false;
293 mData->prefix = prefix; 293 mData->prefix = prefix;
294} 294}
295 295
296QString Addressee::prefix() const 296QString Addressee::prefix() const
297{ 297{
298 return mData->prefix; 298 return mData->prefix;
299} 299}
300 300
301QString Addressee::prefixLabel() 301QString Addressee::prefixLabel()
302{ 302{
303 return i18n("Honorific Prefixes"); 303 return i18n("Honorific Prefixes");
304} 304}
305 305
306 306
307void Addressee::setSuffix( const QString &suffix ) 307void Addressee::setSuffix( const QString &suffix )
308{ 308{
309 if ( suffix == mData->suffix ) return; 309 if ( suffix == mData->suffix ) return;
310 detach(); 310 detach();
311 mData->empty = false; 311 mData->empty = false;
312 mData->suffix = suffix; 312 mData->suffix = suffix;
313} 313}
314 314
315QString Addressee::suffix() const 315QString Addressee::suffix() const
316{ 316{
317 return mData->suffix; 317 return mData->suffix;
318} 318}
319 319
320QString Addressee::suffixLabel() 320QString Addressee::suffixLabel()
321{ 321{
322 return i18n("Honorific Suffixes"); 322 return i18n("Honorific Suffixes");
323} 323}
324 324
325 325
326void Addressee::setNickName( const QString &nickName ) 326void Addressee::setNickName( const QString &nickName )
327{ 327{
328 if ( nickName == mData->nickName ) return; 328 if ( nickName == mData->nickName ) return;
329 detach(); 329 detach();
330 mData->empty = false; 330 mData->empty = false;
331 mData->nickName = nickName; 331 mData->nickName = nickName;
332} 332}
333 333
334QString Addressee::nickName() const 334QString Addressee::nickName() const
335{ 335{
336 return mData->nickName; 336 return mData->nickName;
337} 337}
338 338
339QString Addressee::nickNameLabel() 339QString Addressee::nickNameLabel()
340{ 340{
341 return i18n("Nick Name"); 341 return i18n("Nick Name");
342} 342}
343 343
344 344
345void Addressee::setBirthday( const QDateTime &birthday ) 345void Addressee::setBirthday( const QDateTime &birthday )
346{ 346{
347 if ( birthday == mData->birthday ) return; 347 if ( birthday == mData->birthday ) return;
348 detach(); 348 detach();
349 mData->empty = false; 349 mData->empty = false;
350 mData->birthday = birthday; 350 mData->birthday = birthday;
351} 351}
352 352
353QDateTime Addressee::birthday() const 353QDateTime Addressee::birthday() const
354{ 354{
355 return mData->birthday; 355 return mData->birthday;
356} 356}
357 357
358QString Addressee::birthdayLabel() 358QString Addressee::birthdayLabel()
359{ 359{
360 return i18n("Birthday"); 360 return i18n("Birthday");
361} 361}
362 362
363 363
364QString Addressee::homeAddressStreetLabel() 364QString Addressee::homeAddressStreetLabel()
365{ 365{
366 return i18n("Home Address Street"); 366 return i18n("Home Address Street");
367} 367}
368 368
369 369
370QString Addressee::homeAddressLocalityLabel() 370QString Addressee::homeAddressLocalityLabel()
371{ 371{
372 return i18n("Home Address Locality"); 372 return i18n("Home Address Locality");
373} 373}
374 374
375 375
376QString Addressee::homeAddressRegionLabel() 376QString Addressee::homeAddressRegionLabel()
377{ 377{
378 return i18n("Home Address Region"); 378 return i18n("Home Address Region");
379} 379}
380 380
381 381
382QString Addressee::homeAddressPostalCodeLabel() 382QString Addressee::homeAddressPostalCodeLabel()
383{ 383{
384 return i18n("Home Address Postal Code"); 384 return i18n("Home Address Postal Code");
385} 385}
386 386
387 387
388QString Addressee::homeAddressCountryLabel() 388QString Addressee::homeAddressCountryLabel()
389{ 389{
390 return i18n("Home Address Country"); 390 return i18n("Home Address Country");
391} 391}
392 392
393 393
394QString Addressee::homeAddressLabelLabel() 394QString Addressee::homeAddressLabelLabel()
395{ 395{
396 return i18n("Home Address Label"); 396 return i18n("Home Address Label");
397} 397}
398 398
399 399
400QString Addressee::businessAddressStreetLabel() 400QString Addressee::businessAddressStreetLabel()
401{ 401{
402 return i18n("Business Address Street"); 402 return i18n("Business Address Street");
403} 403}
404 404
405 405
406QString Addressee::businessAddressLocalityLabel() 406QString Addressee::businessAddressLocalityLabel()
407{ 407{
408 return i18n("Business Address Locality"); 408 return i18n("Business Address Locality");
409} 409}
410 410
411 411
412QString Addressee::businessAddressRegionLabel() 412QString Addressee::businessAddressRegionLabel()
413{ 413{
414 return i18n("Business Address Region"); 414 return i18n("Business Address Region");
415} 415}
416 416
417 417
418QString Addressee::businessAddressPostalCodeLabel() 418QString Addressee::businessAddressPostalCodeLabel()
419{ 419{
420 return i18n("Business Address Postal Code"); 420 return i18n("Business Address Postal Code");
421} 421}
422 422
423 423
424QString Addressee::businessAddressCountryLabel() 424QString Addressee::businessAddressCountryLabel()
425{ 425{
426 return i18n("Business Address Country"); 426 return i18n("Business Address Country");
427} 427}
428 428
429 429
430QString Addressee::businessAddressLabelLabel() 430QString Addressee::businessAddressLabelLabel()
431{ 431{
432 return i18n("Business Address Label"); 432 return i18n("Business Address Label");
433} 433}
434 434
435 435
436QString Addressee::homePhoneLabel() 436QString Addressee::homePhoneLabel()
437{ 437{
438 return i18n("Home Phone"); 438 return i18n("Home Phone");
439} 439}
440 440
441 441
442QString Addressee::businessPhoneLabel() 442QString Addressee::businessPhoneLabel()
443{ 443{
444 return i18n("Business Phone"); 444 return i18n("Business Phone");
445} 445}
446 446
447 447
448QString Addressee::mobilePhoneLabel() 448QString Addressee::mobilePhoneLabel()
449{ 449{
450 return i18n("Mobile Phone"); 450 return i18n("Mobile Phone");
451} 451}
452 452
453 453
454QString Addressee::homeFaxLabel() 454QString Addressee::homeFaxLabel()
455{ 455{
456 return i18n("Home Fax"); 456 return i18n("Home Fax");
457} 457}
458 458
459 459
460QString Addressee::businessFaxLabel() 460QString Addressee::businessFaxLabel()
461{ 461{
462 return i18n("Business Fax"); 462 return i18n("Business Fax");
463} 463}
464 464
465 465
466QString Addressee::carPhoneLabel() 466QString Addressee::carPhoneLabel()
467{ 467{
468 return i18n("Car Phone"); 468 return i18n("Car Phone");
469} 469}
470 470
471 471
472QString Addressee::isdnLabel() 472QString Addressee::isdnLabel()
473{ 473{
474 return i18n("ISDN"); 474 return i18n("ISDN");
475} 475}
476 476
477 477
478QString Addressee::pagerLabel() 478QString Addressee::pagerLabel()
479{ 479{
480 return i18n("Pager"); 480 return i18n("Pager");
481} 481}
482 482
483QString Addressee::sipLabel()
484{
485 return i18n("SIP");
486}
483 487
484QString Addressee::emailLabel() 488QString Addressee::emailLabel()
485{ 489{
486 return i18n("Email Address"); 490 return i18n("Email Address");
487} 491}
488 492
489 493
490void Addressee::setMailer( const QString &mailer ) 494void Addressee::setMailer( const QString &mailer )
491{ 495{
492 if ( mailer == mData->mailer ) return; 496 if ( mailer == mData->mailer ) return;
493 detach(); 497 detach();
494 mData->empty = false; 498 mData->empty = false;
495 mData->mailer = mailer; 499 mData->mailer = mailer;
496} 500}
497 501
498QString Addressee::mailer() const 502QString Addressee::mailer() const
499{ 503{
500 return mData->mailer; 504 return mData->mailer;
501} 505}
502 506
503QString Addressee::mailerLabel() 507QString Addressee::mailerLabel()
504{ 508{
505 return i18n("Mail Client"); 509 return i18n("Mail Client");
506} 510}
507 511
508 512
509void Addressee::setTimeZone( const TimeZone &timeZone ) 513void Addressee::setTimeZone( const TimeZone &timeZone )
510{ 514{
511 if ( timeZone == mData->timeZone ) return; 515 if ( timeZone == mData->timeZone ) return;
512 detach(); 516 detach();
513 mData->empty = false; 517 mData->empty = false;
514 mData->timeZone = timeZone; 518 mData->timeZone = timeZone;
515} 519}
516 520
517TimeZone Addressee::timeZone() const 521TimeZone Addressee::timeZone() const
518{ 522{
519 return mData->timeZone; 523 return mData->timeZone;
520} 524}
521 525
522QString Addressee::timeZoneLabel() 526QString Addressee::timeZoneLabel()
523{ 527{
524 return i18n("Time Zone"); 528 return i18n("Time Zone");
525} 529}
526 530
527 531
528void Addressee::setGeo( const Geo &geo ) 532void Addressee::setGeo( const Geo &geo )
529{ 533{
530 if ( geo == mData->geo ) return; 534 if ( geo == mData->geo ) return;
531 detach(); 535 detach();
532 mData->empty = false; 536 mData->empty = false;
533 mData->geo = geo; 537 mData->geo = geo;
534} 538}
535 539
536Geo Addressee::geo() const 540Geo Addressee::geo() const
537{ 541{
538 return mData->geo; 542 return mData->geo;
539} 543}
540 544
541QString Addressee::geoLabel() 545QString Addressee::geoLabel()
542{ 546{
543 return i18n("Geographic Position"); 547 return i18n("Geographic Position");
544} 548}
545 549
546 550
547void Addressee::setTitle( const QString &title ) 551void Addressee::setTitle( const QString &title )
548{ 552{
549 if ( title == mData->title ) return; 553 if ( title == mData->title ) return;
550 detach(); 554 detach();
551 mData->empty = false; 555 mData->empty = false;
552 mData->title = title; 556 mData->title = title;
553} 557}
554 558
555QString Addressee::title() const 559QString Addressee::title() const
556{ 560{
557 return mData->title; 561 return mData->title;
558} 562}
559 563
560QString Addressee::titleLabel() 564QString Addressee::titleLabel()
561{ 565{
562 return i18n("Title"); 566 return i18n("Title");
563} 567}
564 568
565 569
566void Addressee::setRole( const QString &role ) 570void Addressee::setRole( const QString &role )
567{ 571{
568 if ( role == mData->role ) return; 572 if ( role == mData->role ) return;
569 detach(); 573 detach();
570 mData->empty = false; 574 mData->empty = false;
571 mData->role = role; 575 mData->role = role;
572} 576}
573 577
574QString Addressee::role() const 578QString Addressee::role() const
575{ 579{
576 return mData->role; 580 return mData->role;
577} 581}
578 582
579QString Addressee::roleLabel() 583QString Addressee::roleLabel()
580{ 584{
581 return i18n("Role"); 585 return i18n("Role");
582} 586}
583 587
584 588
585void Addressee::setOrganization( const QString &organization ) 589void Addressee::setOrganization( const QString &organization )
586{ 590{
587 if ( organization == mData->organization ) return; 591 if ( organization == mData->organization ) return;
588 detach(); 592 detach();
589 mData->empty = false; 593 mData->empty = false;
590 mData->organization = organization; 594 mData->organization = organization;
591} 595}
592 596
593QString Addressee::organization() const 597QString Addressee::organization() const
594{ 598{
595 return mData->organization; 599 return mData->organization;
596} 600}
597 601
598QString Addressee::organizationLabel() 602QString Addressee::organizationLabel()
599{ 603{
600 return i18n("Organization"); 604 return i18n("Organization");
601} 605}
602 606
603 607
604void Addressee::setNote( const QString &note ) 608void Addressee::setNote( const QString &note )
605{ 609{
606 if ( note == mData->note ) return; 610 if ( note == mData->note ) return;
607 detach(); 611 detach();
608 mData->empty = false; 612 mData->empty = false;
609 mData->note = note; 613 mData->note = note;
610} 614}
611 615
612QString Addressee::note() const 616QString Addressee::note() const
613{ 617{
614 return mData->note; 618 return mData->note;
615} 619}
616 620
617QString Addressee::noteLabel() 621QString Addressee::noteLabel()
618{ 622{
619 return i18n("Note"); 623 return i18n("Note");
620} 624}
621 625
622 626
623void Addressee::setProductId( const QString &productId ) 627void Addressee::setProductId( const QString &productId )
624{ 628{
625 if ( productId == mData->productId ) return; 629 if ( productId == mData->productId ) return;
626 detach(); 630 detach();
627 mData->empty = false; 631 mData->empty = false;
628 mData->productId = productId; 632 mData->productId = productId;
629} 633}
630 634
631QString Addressee::productId() const 635QString Addressee::productId() const
632{ 636{
633 return mData->productId; 637 return mData->productId;
634} 638}
635 639
636QString Addressee::productIdLabel() 640QString Addressee::productIdLabel()
637{ 641{
638 return i18n("Product Identifier"); 642 return i18n("Product Identifier");
639} 643}
640 644
641 645
642void Addressee::setRevision( const QDateTime &revision ) 646void Addressee::setRevision( const QDateTime &revision )
643{ 647{
644 if ( revision == mData->revision ) return; 648 if ( revision == mData->revision ) return;
645 detach(); 649 detach();
646 mData->empty = false; 650 mData->empty = false;
647 mData->revision = revision; 651 mData->revision = revision;
648} 652}
649 653
650QDateTime Addressee::revision() const 654QDateTime Addressee::revision() const
651{ 655{
652 return mData->revision; 656 return mData->revision;
653} 657}
654 658
655QString Addressee::revisionLabel() 659QString Addressee::revisionLabel()
656{ 660{
657 return i18n("Revision Date"); 661 return i18n("Revision Date");
658} 662}
659 663
660 664
661void Addressee::setSortString( const QString &sortString ) 665void Addressee::setSortString( const QString &sortString )
662{ 666{
663 if ( sortString == mData->sortString ) return; 667 if ( sortString == mData->sortString ) return;
664 detach(); 668 detach();
665 mData->empty = false; 669 mData->empty = false;
666 mData->sortString = sortString; 670 mData->sortString = sortString;
667} 671}
668 672
669QString Addressee::sortString() const 673QString Addressee::sortString() const
670{ 674{
671 return mData->sortString; 675 return mData->sortString;
672} 676}
673 677
674QString Addressee::sortStringLabel() 678QString Addressee::sortStringLabel()
675{ 679{
676 return i18n("Sort String"); 680 return i18n("Sort String");
677} 681}
678 682
679 683
680void Addressee::setUrl( const KURL &url ) 684void Addressee::setUrl( const KURL &url )
681{ 685{
682 if ( url == mData->url ) return; 686 if ( url == mData->url ) return;
683 detach(); 687 detach();
684 mData->empty = false; 688 mData->empty = false;
685 mData->url = url; 689 mData->url = url;
686} 690}
687 691
688KURL Addressee::url() const 692KURL Addressee::url() const
689{ 693{
690 return mData->url; 694 return mData->url;
691} 695}
692 696
693QString Addressee::urlLabel() 697QString Addressee::urlLabel()
694{ 698{
695 return i18n("URL"); 699 return i18n("URL");
696} 700}
697 701
698 702
699void Addressee::setSecrecy( const Secrecy &secrecy ) 703void Addressee::setSecrecy( const Secrecy &secrecy )
700{ 704{
701 if ( secrecy == mData->secrecy ) return; 705 if ( secrecy == mData->secrecy ) return;
702 detach(); 706 detach();
703 mData->empty = false; 707 mData->empty = false;
704 mData->secrecy = secrecy; 708 mData->secrecy = secrecy;
705} 709}
706 710
707Secrecy Addressee::secrecy() const 711Secrecy Addressee::secrecy() const
708{ 712{
709 return mData->secrecy; 713 return mData->secrecy;
710} 714}
711 715
712QString Addressee::secrecyLabel() 716QString Addressee::secrecyLabel()
713{ 717{
714 return i18n("Security Class"); 718 return i18n("Security Class");
715} 719}
716 720
717 721
718void Addressee::setLogo( const Picture &logo ) 722void Addressee::setLogo( const Picture &logo )
719{ 723{
720 if ( logo == mData->logo ) return; 724 if ( logo == mData->logo ) return;
721 detach(); 725 detach();
722 mData->empty = false; 726 mData->empty = false;
723 mData->logo = logo; 727 mData->logo = logo;
724} 728}
725 729
726Picture Addressee::logo() const 730Picture Addressee::logo() const
727{ 731{
728 return mData->logo; 732 return mData->logo;
729} 733}
730 734
731QString Addressee::logoLabel() 735QString Addressee::logoLabel()
732{ 736{
733 return i18n("Logo"); 737 return i18n("Logo");
734} 738}
735 739
736 740
737void Addressee::setPhoto( const Picture &photo ) 741void Addressee::setPhoto( const Picture &photo )
738{ 742{
739 if ( photo == mData->photo ) return; 743 if ( photo == mData->photo ) return;
740 detach(); 744 detach();
741 mData->empty = false; 745 mData->empty = false;
742 mData->photo = photo; 746 mData->photo = photo;
743} 747}
744 748
745Picture Addressee::photo() const 749Picture Addressee::photo() const
746{ 750{
747 return mData->photo; 751 return mData->photo;
748} 752}
749 753
750QString Addressee::photoLabel() 754QString Addressee::photoLabel()
751{ 755{
752 return i18n("Photo"); 756 return i18n("Photo");
753} 757}
754 758
755 759
756void Addressee::setSound( const Sound &sound ) 760void Addressee::setSound( const Sound &sound )
757{ 761{
758 if ( sound == mData->sound ) return; 762 if ( sound == mData->sound ) return;
759 detach(); 763 detach();
760 mData->empty = false; 764 mData->empty = false;
761 mData->sound = sound; 765 mData->sound = sound;
762} 766}
763 767
764Sound Addressee::sound() const 768Sound Addressee::sound() const
765{ 769{
766 return mData->sound; 770 return mData->sound;
767} 771}
768 772
769QString Addressee::soundLabel() 773QString Addressee::soundLabel()
770{ 774{
771 return i18n("Sound"); 775 return i18n("Sound");
772} 776}
773 777
774 778
775void Addressee::setAgent( const Agent &agent ) 779void Addressee::setAgent( const Agent &agent )
776{ 780{
777 if ( agent == mData->agent ) return; 781 if ( agent == mData->agent ) return;
778 detach(); 782 detach();
779 mData->empty = false; 783 mData->empty = false;
780 mData->agent = agent; 784 mData->agent = agent;
781} 785}
782 786
783Agent Addressee::agent() const 787Agent Addressee::agent() const
784{ 788{
785 return mData->agent; 789 return mData->agent;
786} 790}
787 791
788QString Addressee::agentLabel() 792QString Addressee::agentLabel()
789{ 793{
790 return i18n("Agent"); 794 return i18n("Agent");
791} 795}
792 796
793 797
794 798
795void Addressee::setNameFromString( const QString &str ) 799void Addressee::setNameFromString( const QString &str )
796{ 800{
797 setFormattedName( str ); 801 setFormattedName( str );
798 setName( str ); 802 setName( str );
799 803
800 QStringList titles; 804 QStringList titles;
801 titles += i18n( "Dr." ); 805 titles += i18n( "Dr." );
802 titles += i18n( "Miss" ); 806 titles += i18n( "Miss" );
803 titles += i18n( "Mr." ); 807 titles += i18n( "Mr." );
804 titles += i18n( "Mrs." ); 808 titles += i18n( "Mrs." );
805 titles += i18n( "Ms." ); 809 titles += i18n( "Ms." );
806 titles += i18n( "Prof." ); 810 titles += i18n( "Prof." );
807 811
808 QStringList suffixes; 812 QStringList suffixes;
809 suffixes += i18n( "I" ); 813 suffixes += i18n( "I" );
810 suffixes += i18n( "II" ); 814 suffixes += i18n( "II" );
811 suffixes += i18n( "III" ); 815 suffixes += i18n( "III" );
812 suffixes += i18n( "Jr." ); 816 suffixes += i18n( "Jr." );
813 suffixes += i18n( "Sr." ); 817 suffixes += i18n( "Sr." );
814 818
815 QStringList prefixes; 819 QStringList prefixes;
816 prefixes += "van"; 820 prefixes += "van";
817 prefixes += "von"; 821 prefixes += "von";
818 prefixes += "de"; 822 prefixes += "de";
819 823
820//US KConfig config( "kabcrc" ); 824//US KConfig config( "kabcrc" );
821 KConfig config( locateLocal( "config", "kabcrc") ); 825 KConfig config( locateLocal( "config", "kabcrc") );
822 config.setGroup( "General" ); 826 config.setGroup( "General" );
823 titles += config.readListEntry( "Prefixes" ); 827 titles += config.readListEntry( "Prefixes" );
824 titles.remove( "" ); 828 titles.remove( "" );
825 prefixes += config.readListEntry( "Inclusions" ); 829 prefixes += config.readListEntry( "Inclusions" );
826 prefixes.remove( "" ); 830 prefixes.remove( "" );
827 suffixes += config.readListEntry( "Suffixes" ); 831 suffixes += config.readListEntry( "Suffixes" );
828 suffixes.remove( "" ); 832 suffixes.remove( "" );
829 833
830 // clear all name parts 834 // clear all name parts
831 setPrefix( "" ); 835 setPrefix( "" );
832 setGivenName( "" ); 836 setGivenName( "" );
833 setAdditionalName( "" ); 837 setAdditionalName( "" );
834 setFamilyName( "" ); 838 setFamilyName( "" );
835 setSuffix( "" ); 839 setSuffix( "" );
836 840
837 if ( str.isEmpty() ) 841 if ( str.isEmpty() )
838 return; 842 return;
839 843
840 int i = str.find(','); 844 int i = str.find(',');
841 if( i < 0 ) { 845 if( i < 0 ) {
842 QStringList parts = QStringList::split( " ", str ); 846 QStringList parts = QStringList::split( " ", str );
843 int leftOffset = 0; 847 int leftOffset = 0;
844 int rightOffset = parts.count() - 1; 848 int rightOffset = parts.count() - 1;
845 849
846 QString suffix; 850 QString suffix;
847 while ( rightOffset >= 0 ) { 851 while ( rightOffset >= 0 ) {
848 if ( suffixes.contains( parts[ rightOffset ] ) ) { 852 if ( suffixes.contains( parts[ rightOffset ] ) ) {
849 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 853 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
850 rightOffset--; 854 rightOffset--;
851 } else 855 } else
852 break; 856 break;
853 } 857 }
854 setSuffix( suffix ); 858 setSuffix( suffix );
855 859
856 if ( rightOffset < 0 ) 860 if ( rightOffset < 0 )
857 return; 861 return;
858 862
859 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 863 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
860 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 864 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
861 rightOffset--; 865 rightOffset--;
862 } else 866 } else
863 setFamilyName( parts[ rightOffset ] ); 867 setFamilyName( parts[ rightOffset ] );
864 868
865 QString prefix; 869 QString prefix;
866 while ( leftOffset < rightOffset ) { 870 while ( leftOffset < rightOffset ) {
867 if ( titles.contains( parts[ leftOffset ] ) ) { 871 if ( titles.contains( parts[ leftOffset ] ) ) {
868 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 872 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
869 leftOffset++; 873 leftOffset++;
870 } else 874 } else
871 break; 875 break;
872 } 876 }
873 setPrefix( prefix ); 877 setPrefix( prefix );
874 878
875 if ( leftOffset < rightOffset ) { 879 if ( leftOffset < rightOffset ) {
876 setGivenName( parts[ leftOffset ] ); 880 setGivenName( parts[ leftOffset ] );
877 leftOffset++; 881 leftOffset++;
878 } 882 }
879 883
880 QString additionalName; 884 QString additionalName;
881 while ( leftOffset < rightOffset ) { 885 while ( leftOffset < rightOffset ) {
882 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 886 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
883 leftOffset++; 887 leftOffset++;
884 } 888 }
885 setAdditionalName( additionalName ); 889 setAdditionalName( additionalName );
886 } else { 890 } else {
887 QString part1 = str.left( i ); 891 QString part1 = str.left( i );
888 QString part2 = str.mid( i + 1 ); 892 QString part2 = str.mid( i + 1 );
889 893
890 QStringList parts = QStringList::split( " ", part1 ); 894 QStringList parts = QStringList::split( " ", part1 );
891 int leftOffset = 0; 895 int leftOffset = 0;
892 int rightOffset = parts.count() - 1; 896 int rightOffset = parts.count() - 1;
893 897
894 QString suffix; 898 QString suffix;
895 while ( rightOffset >= 0 ) { 899 while ( rightOffset >= 0 ) {
896 if ( suffixes.contains( parts[ rightOffset ] ) ) { 900 if ( suffixes.contains( parts[ rightOffset ] ) ) {
897 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 901 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
898 rightOffset--; 902 rightOffset--;
899 } else 903 } else
900 break; 904 break;
901 } 905 }
902 setSuffix( suffix ); 906 setSuffix( suffix );
903 907
904 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 908 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
905 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 909 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
906 rightOffset--; 910 rightOffset--;
907 } else 911 } else
908 setFamilyName( parts[ rightOffset ] ); 912 setFamilyName( parts[ rightOffset ] );
909 913
910 QString prefix; 914 QString prefix;
911 while ( leftOffset < rightOffset ) { 915 while ( leftOffset < rightOffset ) {
912 if ( titles.contains( parts[ leftOffset ] ) ) { 916 if ( titles.contains( parts[ leftOffset ] ) ) {
913 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 917 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
914 leftOffset++; 918 leftOffset++;
915 } else 919 } else
916 break; 920 break;
917 } 921 }
918 922
919 parts = QStringList::split( " ", part2 ); 923 parts = QStringList::split( " ", part2 );
920 924
921 leftOffset = 0; 925 leftOffset = 0;
922 rightOffset = parts.count(); 926 rightOffset = parts.count();
923 927
924 while ( leftOffset < rightOffset ) { 928 while ( leftOffset < rightOffset ) {
925 if ( titles.contains( parts[ leftOffset ] ) ) { 929 if ( titles.contains( parts[ leftOffset ] ) ) {
926 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 930 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
927 leftOffset++; 931 leftOffset++;
928 } else 932 } else
929 break; 933 break;
930 } 934 }
931 setPrefix( prefix ); 935 setPrefix( prefix );
932 936
933 if ( leftOffset < rightOffset ) { 937 if ( leftOffset < rightOffset ) {
934 setGivenName( parts[ leftOffset ] ); 938 setGivenName( parts[ leftOffset ] );
935 leftOffset++; 939 leftOffset++;
936 } 940 }
937 941
938 QString additionalName; 942 QString additionalName;
939 while ( leftOffset < rightOffset ) { 943 while ( leftOffset < rightOffset ) {
940 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 944 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
941 leftOffset++; 945 leftOffset++;
942 } 946 }
943 setAdditionalName( additionalName ); 947 setAdditionalName( additionalName );
944 } 948 }
945} 949}
946 950
947QString Addressee::realName() const 951QString Addressee::realName() const
948{ 952{
949 if ( !formattedName().isEmpty() ) 953 if ( !formattedName().isEmpty() )
950 return formattedName(); 954 return formattedName();
951 955
952 QString n = assembledName(); 956 QString n = assembledName();
953 957
954 if ( n.isEmpty() ) 958 if ( n.isEmpty() )
955 n = name(); 959 n = name();
956 960
957 return n; 961 return n;
958} 962}
959 963
960QString Addressee::assembledName() const 964QString Addressee::assembledName() const
961{ 965{
962 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 966 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
963 familyName() + " " + suffix(); 967 familyName() + " " + suffix();
964 968
965 return name.simplifyWhiteSpace(); 969 return name.simplifyWhiteSpace();
966} 970}
967 971
968QString Addressee::fullEmail( const QString &email ) const 972QString Addressee::fullEmail( const QString &email ) const
969{ 973{
970 QString e; 974 QString e;
971 if ( email.isNull() ) { 975 if ( email.isNull() ) {
972 e = preferredEmail(); 976 e = preferredEmail();
973 } else { 977 } else {
974 e = email; 978 e = email;
975 } 979 }
976 if ( e.isEmpty() ) return QString::null; 980 if ( e.isEmpty() ) return QString::null;
977 981
978 QString text; 982 QString text;
979 if ( realName().isEmpty() ) 983 if ( realName().isEmpty() )
980 text = e; 984 text = e;
981 else 985 else
982 text = assembledName() + " <" + e + ">"; 986 text = assembledName() + " <" + e + ">";
983 987
984 return text; 988 return text;
985} 989}
986 990
987void Addressee::insertEmail( const QString &email, bool preferred ) 991void Addressee::insertEmail( const QString &email, bool preferred )
988{ 992{
989 detach(); 993 detach();
990 994
991 QStringList::Iterator it = mData->emails.find( email ); 995 QStringList::Iterator it = mData->emails.find( email );
992 996
993 if ( it != mData->emails.end() ) { 997 if ( it != mData->emails.end() ) {
994 if ( !preferred || it == mData->emails.begin() ) return; 998 if ( !preferred || it == mData->emails.begin() ) return;
995 mData->emails.remove( it ); 999 mData->emails.remove( it );
996 mData->emails.prepend( email ); 1000 mData->emails.prepend( email );
997 } else { 1001 } else {
998 if ( preferred ) { 1002 if ( preferred ) {
999 mData->emails.prepend( email ); 1003 mData->emails.prepend( email );
1000 } else { 1004 } else {
1001 mData->emails.append( email ); 1005 mData->emails.append( email );
1002 } 1006 }
1003 } 1007 }
1004} 1008}
1005 1009
1006void Addressee::removeEmail( const QString &email ) 1010void Addressee::removeEmail( const QString &email )
1007{ 1011{
1008 detach(); 1012 detach();
1009 1013
1010 QStringList::Iterator it = mData->emails.find( email ); 1014 QStringList::Iterator it = mData->emails.find( email );
1011 if ( it == mData->emails.end() ) return; 1015 if ( it == mData->emails.end() ) return;
1012 1016
1013 mData->emails.remove( it ); 1017 mData->emails.remove( it );
1014} 1018}
1015 1019
1016QString Addressee::preferredEmail() const 1020QString Addressee::preferredEmail() const
1017{ 1021{
1018 if ( mData->emails.count() == 0 ) return QString::null; 1022 if ( mData->emails.count() == 0 ) return QString::null;
1019 else return mData->emails.first(); 1023 else return mData->emails.first();
1020} 1024}
1021 1025
1022QStringList Addressee::emails() const 1026QStringList Addressee::emails() const
1023{ 1027{
1024 return mData->emails; 1028 return mData->emails;
1025} 1029}
1026void Addressee::setEmails( const QStringList& emails ) { 1030void Addressee::setEmails( const QStringList& emails ) {
1027 detach(); 1031 detach();
1028 mData->emails = emails; 1032 mData->emails = emails;
1029} 1033}
1030void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1034void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1031{ 1035{
1032 detach(); 1036 detach();
1033 mData->empty = false; 1037 mData->empty = false;
1034 1038
1035 PhoneNumber::List::Iterator it; 1039 PhoneNumber::List::Iterator it;
1036 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1040 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1037 if ( (*it).id() == phoneNumber.id() ) { 1041 if ( (*it).id() == phoneNumber.id() ) {
1038 *it = phoneNumber; 1042 *it = phoneNumber;
1039 return; 1043 return;
1040 } 1044 }
1041 } 1045 }
1042 mData->phoneNumbers.append( phoneNumber ); 1046 mData->phoneNumbers.append( phoneNumber );
1043} 1047}
1044 1048
1045void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1049void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1046{ 1050{
1047 detach(); 1051 detach();
1048 1052
1049 PhoneNumber::List::Iterator it; 1053 PhoneNumber::List::Iterator it;
1050 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1054 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1051 if ( (*it).id() == phoneNumber.id() ) { 1055 if ( (*it).id() == phoneNumber.id() ) {
1052 mData->phoneNumbers.remove( it ); 1056 mData->phoneNumbers.remove( it );
1053 return; 1057 return;
1054 } 1058 }
1055 } 1059 }
1056} 1060}
1057 1061
1058PhoneNumber Addressee::phoneNumber( int type ) const 1062PhoneNumber Addressee::phoneNumber( int type ) const
1059{ 1063{
1060 PhoneNumber phoneNumber( "", type ); 1064 PhoneNumber phoneNumber( "", type );
1061 PhoneNumber::List::ConstIterator it; 1065 PhoneNumber::List::ConstIterator it;
1062 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1066 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1063 if ( matchBinaryPattern( (*it).type(), type ) ) { 1067 if ( matchBinaryPattern( (*it).type(), type ) ) {
1064 if ( (*it).type() & PhoneNumber::Pref ) 1068 if ( (*it).type() & PhoneNumber::Pref )
1065 return (*it); 1069 return (*it);
1066 else if ( phoneNumber.number().isEmpty() ) 1070 else if ( phoneNumber.number().isEmpty() )
1067 phoneNumber = (*it); 1071 phoneNumber = (*it);
1068 } 1072 }
1069 } 1073 }
1070 1074
1071 return phoneNumber; 1075 return phoneNumber;
1072} 1076}
1073 1077
1074PhoneNumber::List Addressee::phoneNumbers() const 1078PhoneNumber::List Addressee::phoneNumbers() const
1075{ 1079{
1076 return mData->phoneNumbers; 1080 return mData->phoneNumbers;
1077} 1081}
1078 1082
1079PhoneNumber::List Addressee::phoneNumbers( int type ) const 1083PhoneNumber::List Addressee::phoneNumbers( int type ) const
1080{ 1084{
1081 PhoneNumber::List list; 1085 PhoneNumber::List list;
1082 1086
1083 PhoneNumber::List::ConstIterator it; 1087 PhoneNumber::List::ConstIterator it;
1084 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1088 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1085 if ( matchBinaryPattern( (*it).type(), type ) ) { 1089 if ( matchBinaryPattern( (*it).type(), type ) ) {
1086 list.append( *it ); 1090 list.append( *it );
1087 } 1091 }
1088 } 1092 }
1089 return list; 1093 return list;
1090} 1094}
1091 1095
1092PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1096PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1093{ 1097{
1094 PhoneNumber::List::ConstIterator it; 1098 PhoneNumber::List::ConstIterator it;
1095 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1099 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1096 if ( (*it).id() == id ) { 1100 if ( (*it).id() == id ) {
1097 return *it; 1101 return *it;
1098 } 1102 }
1099 } 1103 }
1100 return PhoneNumber(); 1104 return PhoneNumber();
1101} 1105}
1102 1106
1103void Addressee::insertKey( const Key &key ) 1107void Addressee::insertKey( const Key &key )
1104{ 1108{
1105 detach(); 1109 detach();
1106 mData->empty = false; 1110 mData->empty = false;
1107 1111
1108 Key::List::Iterator it; 1112 Key::List::Iterator it;
1109 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1113 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1110 if ( (*it).id() == key.id() ) { 1114 if ( (*it).id() == key.id() ) {
1111 *it = key; 1115 *it = key;
1112 return; 1116 return;
1113 } 1117 }
1114 } 1118 }
1115 mData->keys.append( key ); 1119 mData->keys.append( key );
1116} 1120}
1117 1121
1118void Addressee::removeKey( const Key &key ) 1122void Addressee::removeKey( const Key &key )
1119{ 1123{
1120 detach(); 1124 detach();
1121 1125
1122 Key::List::Iterator it; 1126 Key::List::Iterator it;
1123 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1127 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1124 if ( (*it).id() == key.id() ) { 1128 if ( (*it).id() == key.id() ) {
1125 mData->keys.remove( key ); 1129 mData->keys.remove( key );
1126 return; 1130 return;
1127 } 1131 }
1128 } 1132 }
1129} 1133}
1130 1134
1131Key Addressee::key( int type, QString customTypeString ) const 1135Key Addressee::key( int type, QString customTypeString ) const
1132{ 1136{
1133 Key::List::ConstIterator it; 1137 Key::List::ConstIterator it;
1134 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1138 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1135 if ( (*it).type() == type ) { 1139 if ( (*it).type() == type ) {
1136 if ( type == Key::Custom ) { 1140 if ( type == Key::Custom ) {
1137 if ( customTypeString.isEmpty() ) { 1141 if ( customTypeString.isEmpty() ) {
1138 return *it; 1142 return *it;
1139 } else { 1143 } else {
1140 if ( (*it).customTypeString() == customTypeString ) 1144 if ( (*it).customTypeString() == customTypeString )
1141 return (*it); 1145 return (*it);
1142 } 1146 }
1143 } else { 1147 } else {
1144 return *it; 1148 return *it;
1145 } 1149 }
1146 } 1150 }
1147 } 1151 }
1148 return Key( QString(), type ); 1152 return Key( QString(), type );
1149} 1153}
1150void Addressee::setKeys( const Key::List& list ) { 1154void Addressee::setKeys( const Key::List& list ) {
1151 detach(); 1155 detach();
1152 mData->keys = list; 1156 mData->keys = list;
1153} 1157}
1154 1158
1155Key::List Addressee::keys() const 1159Key::List Addressee::keys() const
1156{ 1160{
1157 return mData->keys; 1161 return mData->keys;
1158} 1162}
1159 1163
1160Key::List Addressee::keys( int type, QString customTypeString ) const 1164Key::List Addressee::keys( int type, QString customTypeString ) const
1161{ 1165{
1162 Key::List list; 1166 Key::List list;
1163 1167
1164 Key::List::ConstIterator it; 1168 Key::List::ConstIterator it;
1165 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1169 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1166 if ( (*it).type() == type ) { 1170 if ( (*it).type() == type ) {
1167 if ( type == Key::Custom ) { 1171 if ( type == Key::Custom ) {
1168 if ( customTypeString.isEmpty() ) { 1172 if ( customTypeString.isEmpty() ) {
1169 list.append(*it); 1173 list.append(*it);
1170 } else { 1174 } else {
1171 if ( (*it).customTypeString() == customTypeString ) 1175 if ( (*it).customTypeString() == customTypeString )
1172 list.append(*it); 1176 list.append(*it);
1173 } 1177 }
1174 } else { 1178 } else {
1175 list.append(*it); 1179 list.append(*it);
1176 } 1180 }
1177 } 1181 }
1178 } 1182 }
1179 return list; 1183 return list;
1180} 1184}
1181 1185
1182Key Addressee::findKey( const QString &id ) const 1186Key Addressee::findKey( const QString &id ) const
1183{ 1187{
1184 Key::List::ConstIterator it; 1188 Key::List::ConstIterator it;
1185 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1189 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1186 if ( (*it).id() == id ) { 1190 if ( (*it).id() == id ) {
1187 return *it; 1191 return *it;
1188 } 1192 }
1189 } 1193 }
1190 return Key(); 1194 return Key();
1191} 1195}
1192 1196
1193QString Addressee::asString() const 1197QString Addressee::asString() const
1194{ 1198{
1195 return "Smith, agent Smith..."; 1199 return "Smith, agent Smith...";
1196} 1200}
1197 1201
1198void Addressee::dump() const 1202void Addressee::dump() const
1199{ 1203{
1200 return; 1204 return;
1201 kdDebug(5700) << "Addressee {" << endl; 1205 kdDebug(5700) << "Addressee {" << endl;
1202 1206
1203 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1207 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1204 1208
1205 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1209 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1206 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1210 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1207 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1211 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1208 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1212 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1209 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1213 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1210 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1214 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1211 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1215 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1212 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1216 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1213 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1217 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1214 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1218 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1215 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1219 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1216 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1220 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1217 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1221 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1218 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1222 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1219 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1223 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1220 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1224 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1221 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1225 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1222 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1226 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1223 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1227 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1224 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1228 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1225 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1229 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1226 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1230 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1227 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1231 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1228 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1232 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1229 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1233 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1230 1234
1231 kdDebug(5700) << " Emails {" << endl; 1235 kdDebug(5700) << " Emails {" << endl;
1232 QStringList e = emails(); 1236 QStringList e = emails();
1233 QStringList::ConstIterator it; 1237 QStringList::ConstIterator it;
1234 for( it = e.begin(); it != e.end(); ++it ) { 1238 for( it = e.begin(); it != e.end(); ++it ) {
1235 kdDebug(5700) << " " << (*it) << endl; 1239 kdDebug(5700) << " " << (*it) << endl;
1236 } 1240 }
1237 kdDebug(5700) << " }" << endl; 1241 kdDebug(5700) << " }" << endl;
1238 1242
1239 kdDebug(5700) << " PhoneNumbers {" << endl; 1243 kdDebug(5700) << " PhoneNumbers {" << endl;
1240 PhoneNumber::List p = phoneNumbers(); 1244 PhoneNumber::List p = phoneNumbers();
1241 PhoneNumber::List::ConstIterator it2; 1245 PhoneNumber::List::ConstIterator it2;
1242 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1246 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1243 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1247 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1244 } 1248 }
1245 kdDebug(5700) << " }" << endl; 1249 kdDebug(5700) << " }" << endl;
1246 1250
1247 Address::List a = addresses(); 1251 Address::List a = addresses();
1248 Address::List::ConstIterator it3; 1252 Address::List::ConstIterator it3;
1249 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1253 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1250 (*it3).dump(); 1254 (*it3).dump();
1251 } 1255 }
1252 1256
1253 kdDebug(5700) << " Keys {" << endl; 1257 kdDebug(5700) << " Keys {" << endl;
1254 Key::List k = keys(); 1258 Key::List k = keys();
1255 Key::List::ConstIterator it4; 1259 Key::List::ConstIterator it4;
1256 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1260 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1257 kdDebug(5700) << " Type: " << int((*it4).type()) << 1261 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1258 " Key: " << (*it4).textData() << 1262 " Key: " << (*it4).textData() <<
1259 " CustomString: " << (*it4).customTypeString() << endl; 1263 " CustomString: " << (*it4).customTypeString() << endl;
1260 } 1264 }
1261 kdDebug(5700) << " }" << endl; 1265 kdDebug(5700) << " }" << endl;
1262 1266
1263 kdDebug(5700) << "}" << endl; 1267 kdDebug(5700) << "}" << endl;
1264} 1268}
1265 1269
1266 1270
1267void Addressee::insertAddress( const Address &address ) 1271void Addressee::insertAddress( const Address &address )
1268{ 1272{
1269 detach(); 1273 detach();
1270 mData->empty = false; 1274 mData->empty = false;
1271 1275
1272 Address::List::Iterator it; 1276 Address::List::Iterator it;
1273 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1277 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1274 if ( (*it).id() == address.id() ) { 1278 if ( (*it).id() == address.id() ) {
1275 *it = address; 1279 *it = address;
1276 return; 1280 return;
1277 } 1281 }
1278 } 1282 }
1279 mData->addresses.append( address ); 1283 mData->addresses.append( address );
1280} 1284}
1281 1285
1282void Addressee::removeAddress( const Address &address ) 1286void Addressee::removeAddress( const Address &address )
1283{ 1287{
1284 detach(); 1288 detach();
1285 1289
1286 Address::List::Iterator it; 1290 Address::List::Iterator it;
1287 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1291 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1288 if ( (*it).id() == address.id() ) { 1292 if ( (*it).id() == address.id() ) {
1289 mData->addresses.remove( it ); 1293 mData->addresses.remove( it );
1290 return; 1294 return;
1291 } 1295 }
1292 } 1296 }
1293} 1297}
1294 1298
1295Address Addressee::address( int type ) const 1299Address Addressee::address( int type ) const
1296{ 1300{
1297 Address address( type ); 1301 Address address( type );
1298 Address::List::ConstIterator it; 1302 Address::List::ConstIterator it;
1299 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1303 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1300 if ( matchBinaryPattern( (*it).type(), type ) ) { 1304 if ( matchBinaryPattern( (*it).type(), type ) ) {
1301 if ( (*it).type() & Address::Pref ) 1305 if ( (*it).type() & Address::Pref )
1302 return (*it); 1306 return (*it);
1303 else if ( address.isEmpty() ) 1307 else if ( address.isEmpty() )
1304 address = (*it); 1308 address = (*it);
1305 } 1309 }
1306 } 1310 }
1307 1311
1308 return address; 1312 return address;
1309} 1313}
1310 1314
1311Address::List Addressee::addresses() const 1315Address::List Addressee::addresses() const
1312{ 1316{
1313 return mData->addresses; 1317 return mData->addresses;
1314} 1318}
1315 1319
1316Address::List Addressee::addresses( int type ) const 1320Address::List Addressee::addresses( int type ) const
1317{ 1321{
1318 Address::List list; 1322 Address::List list;
1319 1323
1320 Address::List::ConstIterator it; 1324 Address::List::ConstIterator it;
1321 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1325 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1322 if ( matchBinaryPattern( (*it).type(), type ) ) { 1326 if ( matchBinaryPattern( (*it).type(), type ) ) {
1323 list.append( *it ); 1327 list.append( *it );
1324 } 1328 }
1325 } 1329 }
1326 1330
1327 return list; 1331 return list;
1328} 1332}
1329 1333
1330Address Addressee::findAddress( const QString &id ) const 1334Address Addressee::findAddress( const QString &id ) const
1331{ 1335{
1332 Address::List::ConstIterator it; 1336 Address::List::ConstIterator it;
1333 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1337 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1334 if ( (*it).id() == id ) { 1338 if ( (*it).id() == id ) {
1335 return *it; 1339 return *it;
1336 } 1340 }
1337 } 1341 }
1338 return Address(); 1342 return Address();
1339} 1343}
1340 1344
1341void Addressee::insertCategory( const QString &c ) 1345void Addressee::insertCategory( const QString &c )
1342{ 1346{
1343 detach(); 1347 detach();
1344 mData->empty = false; 1348 mData->empty = false;
1345 1349
1346 if ( mData->categories.contains( c ) ) return; 1350 if ( mData->categories.contains( c ) ) return;
1347 1351
1348 mData->categories.append( c ); 1352 mData->categories.append( c );
1349} 1353}
1350 1354
1351void Addressee::removeCategory( const QString &c ) 1355void Addressee::removeCategory( const QString &c )
1352{ 1356{
1353 detach(); 1357 detach();
1354 1358
1355 QStringList::Iterator it = mData->categories.find( c ); 1359 QStringList::Iterator it = mData->categories.find( c );
1356 if ( it == mData->categories.end() ) return; 1360 if ( it == mData->categories.end() ) return;
1357 1361
1358 mData->categories.remove( it ); 1362 mData->categories.remove( it );
1359} 1363}
1360 1364
1361bool Addressee::hasCategory( const QString &c ) const 1365bool Addressee::hasCategory( const QString &c ) const
1362{ 1366{
1363 return ( mData->categories.contains( c ) ); 1367 return ( mData->categories.contains( c ) );
1364} 1368}
1365 1369
1366void Addressee::setCategories( const QStringList &c ) 1370void Addressee::setCategories( const QStringList &c )
1367{ 1371{
1368 detach(); 1372 detach();
1369 mData->empty = false; 1373 mData->empty = false;
1370 1374
1371 mData->categories = c; 1375 mData->categories = c;
1372} 1376}
1373 1377
1374QStringList Addressee::categories() const 1378QStringList Addressee::categories() const
1375{ 1379{
1376 return mData->categories; 1380 return mData->categories;
1377} 1381}
1378 1382
1379void Addressee::insertCustom( const QString &app, const QString &name, 1383void Addressee::insertCustom( const QString &app, const QString &name,
1380 const QString &value ) 1384 const QString &value )
1381{ 1385{
1382 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1386 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1383 1387
1384 detach(); 1388 detach();
1385 mData->empty = false; 1389 mData->empty = false;
1386 1390
1387 QString qualifiedName = app + "-" + name + ":"; 1391 QString qualifiedName = app + "-" + name + ":";
1388 1392
1389 QStringList::Iterator it; 1393 QStringList::Iterator it;
1390 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1394 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1391 if ( (*it).startsWith( qualifiedName ) ) { 1395 if ( (*it).startsWith( qualifiedName ) ) {
1392 (*it) = qualifiedName + value; 1396 (*it) = qualifiedName + value;
1393 return; 1397 return;
1394 } 1398 }
1395 } 1399 }
1396 1400
1397 mData->custom.append( qualifiedName + value ); 1401 mData->custom.append( qualifiedName + value );
1398} 1402}
1399 1403
1400void Addressee::removeCustom( const QString &app, const QString &name) 1404void Addressee::removeCustom( const QString &app, const QString &name)
1401{ 1405{
1402 detach(); 1406 detach();
1403 1407
1404 QString qualifiedName = app + "-" + name + ":"; 1408 QString qualifiedName = app + "-" + name + ":";
1405 1409
1406 QStringList::Iterator it; 1410 QStringList::Iterator it;
1407 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1411 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1408 if ( (*it).startsWith( qualifiedName ) ) { 1412 if ( (*it).startsWith( qualifiedName ) ) {
1409 mData->custom.remove( it ); 1413 mData->custom.remove( it );
1410 return; 1414 return;
1411 } 1415 }
1412 } 1416 }
1413} 1417}
1414 1418
1415QString Addressee::custom( const QString &app, const QString &name ) const 1419QString Addressee::custom( const QString &app, const QString &name ) const
1416{ 1420{
1417 QString qualifiedName = app + "-" + name + ":"; 1421 QString qualifiedName = app + "-" + name + ":";
1418 QString value; 1422 QString value;
1419 1423
1420 QStringList::ConstIterator it; 1424 QStringList::ConstIterator it;
1421 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1425 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1422 if ( (*it).startsWith( qualifiedName ) ) { 1426 if ( (*it).startsWith( qualifiedName ) ) {
1423 value = (*it).mid( (*it).find( ":" ) + 1 ); 1427 value = (*it).mid( (*it).find( ":" ) + 1 );
1424 break; 1428 break;
1425 } 1429 }
1426 } 1430 }
1427 1431
1428 return value; 1432 return value;
1429} 1433}
1430 1434
1431void Addressee::setCustoms( const QStringList &l ) 1435void Addressee::setCustoms( const QStringList &l )
1432{ 1436{
1433 detach(); 1437 detach();
1434 mData->empty = false; 1438 mData->empty = false;
1435 1439
1436 mData->custom = l; 1440 mData->custom = l;
1437} 1441}
1438 1442
1439QStringList Addressee::customs() const 1443QStringList Addressee::customs() const
1440{ 1444{
1441 return mData->custom; 1445 return mData->custom;
1442} 1446}
1443 1447
1444void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1448void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1445 QString &email) 1449 QString &email)
1446{ 1450{
1447 int startPos, endPos, len; 1451 int startPos, endPos, len;
1448 QString partA, partB, result; 1452 QString partA, partB, result;
1449 char endCh = '>'; 1453 char endCh = '>';
1450 1454
1451 startPos = rawEmail.find('<'); 1455 startPos = rawEmail.find('<');
1452 if (startPos < 0) 1456 if (startPos < 0)
1453 { 1457 {
1454 startPos = rawEmail.find('('); 1458 startPos = rawEmail.find('(');
1455 endCh = ')'; 1459 endCh = ')';
1456 } 1460 }
1457 if (startPos < 0) 1461 if (startPos < 0)
1458 { 1462 {
1459 // We couldn't find any separators, so we assume the whole string 1463 // We couldn't find any separators, so we assume the whole string
1460 // is the email address 1464 // is the email address
1461 email = rawEmail; 1465 email = rawEmail;
1462 fullName = ""; 1466 fullName = "";
1463 } 1467 }
1464 else 1468 else
1465 { 1469 {
1466 // We have a start position, try to find an end 1470 // We have a start position, try to find an end
1467 endPos = rawEmail.find(endCh, startPos+1); 1471 endPos = rawEmail.find(endCh, startPos+1);
1468 1472
1469 if (endPos < 0) 1473 if (endPos < 0)
1470 { 1474 {
1471 // We couldn't find the end of the email address. We can only 1475 // We couldn't find the end of the email address. We can only
1472 // assume the entire string is the email address. 1476 // assume the entire string is the email address.
1473 email = rawEmail; 1477 email = rawEmail;
1474 fullName = ""; 1478 fullName = "";
1475 } 1479 }
1476 else 1480 else
1477 { 1481 {
1478 // We have a start and end to the email address 1482 // We have a start and end to the email address
1479 1483
1480 // Grab the name part 1484 // Grab the name part
1481 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1485 fullName = rawEmail.left(startPos).stripWhiteSpace();
1482 1486
1483 // grab the email part 1487 // grab the email part
1484 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1488 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1485 1489
1486 // Check that we do not have any extra characters on the end of the 1490 // Check that we do not have any extra characters on the end of the
1487 // strings 1491 // strings
1488 len = fullName.length(); 1492 len = fullName.length();
1489 if (fullName[0]=='"' && fullName[len-1]=='"') 1493 if (fullName[0]=='"' && fullName[len-1]=='"')
1490 fullName = fullName.mid(1, len-2); 1494 fullName = fullName.mid(1, len-2);
1491 else if (fullName[0]=='<' && fullName[len-1]=='>') 1495 else if (fullName[0]=='<' && fullName[len-1]=='>')
1492 fullName = fullName.mid(1, len-2); 1496 fullName = fullName.mid(1, len-2);
1493 else if (fullName[0]=='(' && fullName[len-1]==')') 1497 else if (fullName[0]=='(' && fullName[len-1]==')')
1494 fullName = fullName.mid(1, len-2); 1498 fullName = fullName.mid(1, len-2);
1495 } 1499 }
1496 } 1500 }
1497} 1501}
1498 1502
1499void Addressee::setResource( Resource *resource ) 1503void Addressee::setResource( Resource *resource )
1500{ 1504{
1501 detach(); 1505 detach();
1502 mData->resource = resource; 1506 mData->resource = resource;
1503} 1507}
1504 1508
1505Resource *Addressee::resource() const 1509Resource *Addressee::resource() const
1506{ 1510{
1507 return mData->resource; 1511 return mData->resource;
1508} 1512}
1509 1513
1510//US 1514//US
1511QString Addressee::resourceLabel() 1515QString Addressee::resourceLabel()
1512{ 1516{
1513 return i18n("Resource"); 1517 return i18n("Resource");
1514} 1518}
1515 1519
1516void Addressee::setChanged( bool value ) 1520void Addressee::setChanged( bool value )
1517{ 1521{
1518 detach(); 1522 detach();
1519 mData->changed = value; 1523 mData->changed = value;
1520} 1524}
1521 1525
1522bool Addressee::changed() const 1526bool Addressee::changed() const
1523{ 1527{
1524 return mData->changed; 1528 return mData->changed;
1525} 1529}
1526 1530
1527QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1531QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1528{ 1532{
1529 if (!a.mData) return s; 1533 if (!a.mData) return s;
1530 1534
1531 s << a.uid(); 1535 s << a.uid();
1532 1536
1533 s << a.mData->name; 1537 s << a.mData->name;
1534 s << a.mData->formattedName; 1538 s << a.mData->formattedName;
1535 s << a.mData->familyName; 1539 s << a.mData->familyName;
1536 s << a.mData->givenName; 1540 s << a.mData->givenName;
1537 s << a.mData->additionalName; 1541 s << a.mData->additionalName;
1538 s << a.mData->prefix; 1542 s << a.mData->prefix;
1539 s << a.mData->suffix; 1543 s << a.mData->suffix;
1540 s << a.mData->nickName; 1544 s << a.mData->nickName;
1541 s << a.mData->birthday; 1545 s << a.mData->birthday;
1542 s << a.mData->mailer; 1546 s << a.mData->mailer;
1543 s << a.mData->timeZone; 1547 s << a.mData->timeZone;
1544 s << a.mData->geo; 1548 s << a.mData->geo;
1545 s << a.mData->title; 1549 s << a.mData->title;
1546 s << a.mData->role; 1550 s << a.mData->role;
1547 s << a.mData->organization; 1551 s << a.mData->organization;
1548 s << a.mData->note; 1552 s << a.mData->note;
1549 s << a.mData->productId; 1553 s << a.mData->productId;
1550 s << a.mData->revision; 1554 s << a.mData->revision;
1551 s << a.mData->sortString; 1555 s << a.mData->sortString;
1552 s << a.mData->url; 1556 s << a.mData->url;
1553 s << a.mData->secrecy; 1557 s << a.mData->secrecy;
1554 s << a.mData->logo; 1558 s << a.mData->logo;
1555 s << a.mData->photo; 1559 s << a.mData->photo;
1556 s << a.mData->sound; 1560 s << a.mData->sound;
1557 s << a.mData->agent; 1561 s << a.mData->agent;
1558 s << a.mData->phoneNumbers; 1562 s << a.mData->phoneNumbers;
1559 s << a.mData->addresses; 1563 s << a.mData->addresses;
1560 s << a.mData->emails; 1564 s << a.mData->emails;
1561 s << a.mData->categories; 1565 s << a.mData->categories;
1562 s << a.mData->custom; 1566 s << a.mData->custom;
1563 s << a.mData->keys; 1567 s << a.mData->keys;
1564 return s; 1568 return s;
1565} 1569}
1566 1570
1567QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1571QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1568{ 1572{
1569 if (!a.mData) return s; 1573 if (!a.mData) return s;
1570 1574
1571 s >> a.mData->uid; 1575 s >> a.mData->uid;
1572 1576
1573 s >> a.mData->name; 1577 s >> a.mData->name;
1574 s >> a.mData->formattedName; 1578 s >> a.mData->formattedName;
1575 s >> a.mData->familyName; 1579 s >> a.mData->familyName;
1576 s >> a.mData->givenName; 1580 s >> a.mData->givenName;
1577 s >> a.mData->additionalName; 1581 s >> a.mData->additionalName;
1578 s >> a.mData->prefix; 1582 s >> a.mData->prefix;
1579 s >> a.mData->suffix; 1583 s >> a.mData->suffix;
1580 s >> a.mData->nickName; 1584 s >> a.mData->nickName;
1581 s >> a.mData->birthday; 1585 s >> a.mData->birthday;
1582 s >> a.mData->mailer; 1586 s >> a.mData->mailer;
1583 s >> a.mData->timeZone; 1587 s >> a.mData->timeZone;
1584 s >> a.mData->geo; 1588 s >> a.mData->geo;
1585 s >> a.mData->title; 1589 s >> a.mData->title;
1586 s >> a.mData->role; 1590 s >> a.mData->role;
1587 s >> a.mData->organization; 1591 s >> a.mData->organization;
1588 s >> a.mData->note; 1592 s >> a.mData->note;
1589 s >> a.mData->productId; 1593 s >> a.mData->productId;
1590 s >> a.mData->revision; 1594 s >> a.mData->revision;
1591 s >> a.mData->sortString; 1595 s >> a.mData->sortString;
1592 s >> a.mData->url; 1596 s >> a.mData->url;
1593 s >> a.mData->secrecy; 1597 s >> a.mData->secrecy;
1594 s >> a.mData->logo; 1598 s >> a.mData->logo;
1595 s >> a.mData->photo; 1599 s >> a.mData->photo;
1596 s >> a.mData->sound; 1600 s >> a.mData->sound;
1597 s >> a.mData->agent; 1601 s >> a.mData->agent;
1598 s >> a.mData->phoneNumbers; 1602 s >> a.mData->phoneNumbers;
1599 s >> a.mData->addresses; 1603 s >> a.mData->addresses;
1600 s >> a.mData->emails; 1604 s >> a.mData->emails;
1601 s >> a.mData->categories; 1605 s >> a.mData->categories;
1602 s >> a.mData->custom; 1606 s >> a.mData->custom;
1603 s >> a.mData->keys; 1607 s >> a.mData->keys;
1604 1608
1605 a.mData->empty = false; 1609 a.mData->empty = false;
1606 1610
1607 return s; 1611 return s;
1608} 1612}
1609 1613
1610bool matchBinaryPattern( int value, int pattern ) 1614bool matchBinaryPattern( int value, int pattern )
1611{ 1615{
1612 /** 1616 /**
1613 We want to match all telephonnumbers/addresses which have the bits in the 1617 We want to match all telephonnumbers/addresses which have the bits in the
1614 pattern set. More are allowed. 1618 pattern set. More are allowed.
1615 if pattern == 0 we have a special handling, then we want only those with 1619 if pattern == 0 we have a special handling, then we want only those with
1616 exactly no bit set. 1620 exactly no bit set.
1617 */ 1621 */
1618 if ( pattern == 0 ) 1622 if ( pattern == 0 )
1619 return ( value == 0 ); 1623 return ( value == 0 );
1620 else 1624 else
1621 return ( pattern == ( pattern & value ) ); 1625 return ( pattern == ( pattern & value ) );
1622} 1626}