• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
addressee.cpp
1/*
2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 Copyright (c) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
5 Copyright (c) 2005 Ingo Kloecker <kloecker@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include <QtCore/QList>
24#include <QtCore/QRegExp>
25#include <QtCore/QSharedData>
26#include <QtCore/QUuid>
27
28#include <kdebug.h>
29#include <klocale.h>
30#include <klocalizedstring.h>
31
32#include "addresseehelper.h"
33#include "field.h"
34#ifndef KDEPIM_NO_KRESOURCES
35#include "resource.h"
36#endif
37#include "sortmode.h"
38
39#include "addressee.h"
40
41using namespace KABC;
42
43static bool matchBinaryPattern( int value, int pattern );
44
45template <class L>
46static bool listEquals( const QList<L>&, const QList<L>& );
47static bool listEquals( const QStringList&, const QStringList& );
48
49class Addressee::Private : public QSharedData
50{
51 public:
52 Private()
53 : mUid( QUuid::createUuid().toString().mid(1, 36) ), //We avoid the curly braces so the string is RFC4122 compliant and can be used as urn
54#ifndef KDEPIM_NO_KRESOURCES
55 mResource( 0 ),
56#endif
57 mEmpty( true ), mChanged( false )
58 {
59 }
60
61 Private( const Private &other )
62 : QSharedData( other )
63#ifndef KDEPIM_NO_KRESOURCES
64 ,mResource( 0 )
65#endif
66 {
67 mUid = other.mUid;
68 mName = other.mName;
69 mFormattedName = other.mFormattedName;
70 mFamilyName = other.mFamilyName;
71 mGivenName = other.mGivenName;
72 mAdditionalName = other.mAdditionalName;
73 mPrefix = other.mPrefix;
74 mSuffix = other.mSuffix;
75 mNickName = other.mNickName;
76 mBirthday = other.mBirthday;
77 mMailer = other.mMailer;
78 mTimeZone = other.mTimeZone;
79 mGeo = other.mGeo;
80 mTitle = other.mTitle;
81 mRole = other.mRole;
82 mOrganization = other.mOrganization;
83 mDepartment = other.mDepartment;
84 mNote = other.mNote;
85 mProductId = other.mProductId;
86 mRevision = other.mRevision;
87 mSortString = other.mSortString;
88 mUrl = other.mUrl;
89 mSecrecy = other.mSecrecy;
90 mLogo = other.mLogo;
91 mPhoto = other.mPhoto;
92 mSound = other.mSound;
93
94 mPhoneNumbers = other.mPhoneNumbers;
95 mAddresses = other.mAddresses;
96 mKeys = other.mKeys;
97 mEmails = other.mEmails;
98 mLangs = other.mLangs;
99 mGender = other.mGender;
100 mCategories = other.mCategories;
101 mCustomFields = other.mCustomFields;
102 mCalendarUrl = other.mCalendarUrl;
103 mSoundListExtra = other.mSoundListExtra;
104 mPhotoListExtra = other.mPhotoListExtra;
105 mLogoListExtra = other.mLogoListExtra;
106 mUrlListExtra = other.mUrlListExtra;
107 mSources = other.mSources;
108 mMembers = other.mMembers;
109 mRelationShips = other.mRelationShips;
110
111#ifndef KDEPIM_NO_KRESOURCES
112 mResource = other.mResource;
113#endif
114 mEmpty = other.mEmpty;
115 mChanged = other.mChanged;
116 }
117
118 ~Private()
119 {
120 }
121
122 QString mUid;
123 QString mName;
124 QString mFormattedName;
125 QString mFamilyName;
126 QString mGivenName;
127 QString mAdditionalName;
128 QString mPrefix;
129 QString mSuffix;
130 QString mNickName;
131 QDateTime mBirthday;
132 QString mMailer;
133 TimeZone mTimeZone;
134 Geo mGeo;
135 QString mTitle;
136 QString mRole;
137 QString mOrganization;
138 QString mDepartment;
139 QString mNote;
140 QString mProductId;
141 QDateTime mRevision;
142 QString mSortString;
143 KUrl mUrl;
144 Secrecy mSecrecy;
145 Picture mLogo;
146 Picture mPhoto;
147 Sound mSound;
148
149 PhoneNumber::List mPhoneNumbers;
150 Address::List mAddresses;
151 Key::List mKeys;
152 Email::List mEmails;
153 Lang::List mLangs;
154 Gender mGender;
155 QString mKind;
156 QStringList mCategories;
157 QMap<QString, QString> mCustomFields;
158 CalendarUrl::List mCalendarUrl;
159
160 Sound::List mSoundListExtra;
161 Picture::List mPhotoListExtra;
162 Picture::List mLogoListExtra;
163 QList<KUrl> mUrlListExtra;
164 QStringList mMembers;
165 QStringList mRelationShips;
166 QList<KUrl> mSources;
167
168#ifndef KDEPIM_NO_KRESOURCES
169 Resource *mResource;
170#endif
171
172 bool mEmpty :1;
173 bool mChanged :1;
174
175 static KABC::SortMode *mSortMode;
176};
177
178KABC::SortMode *Addressee::Private::mSortMode = 0;
179
180Addressee::Addressee()
181 : d( new Private )
182{
183}
184
185Addressee::~Addressee()
186{
187}
188
189Addressee::Addressee( const Addressee &other )
190 : d( other.d )
191{
192}
193
194Addressee& Addressee::operator=( const Addressee &other )
195{
196 if ( this != &other )
197 d = other.d;
198
199 return *this;
200}
201
202bool Addressee::operator==( const Addressee &addressee ) const
203{
204 if ( d->mUid != addressee.d->mUid ) {
205 kDebug() << "uid differs";
206 return false;
207 }
208
209 if ( d->mName != addressee.d->mName &&
210 !( d->mName.isEmpty() && addressee.d->mName.isEmpty() ) ) {
211 kDebug(5700) << "name differs";
212 return false;
213 }
214
215 if ( d->mFormattedName != addressee.d->mFormattedName &&
216 !( d->mFormattedName.isEmpty() && addressee.d->mFormattedName.isEmpty() ) ) {
217 kDebug(5700) << "formattedName differs";
218 return false;
219 }
220
221 if ( d->mFamilyName != addressee.d->mFamilyName &&
222 !( d->mFamilyName.isEmpty() && addressee.d->mFamilyName.isEmpty() ) ) {
223 kDebug(5700) << "familyName differs";
224 return false;
225 }
226
227 if ( d->mGivenName != addressee.d->mGivenName &&
228 !( d->mGivenName.isEmpty() && addressee.d->mGivenName.isEmpty() ) ) {
229 kDebug(5700) << "givenName differs";
230 return false;
231 }
232
233 if ( d->mAdditionalName != addressee.d->mAdditionalName &&
234 !( d->mAdditionalName.isEmpty() && addressee.d->mAdditionalName.isEmpty() ) ) {
235 kDebug(5700) << "additionalName differs";
236 return false;
237 }
238
239 if ( d->mPrefix != addressee.d->mPrefix &&
240 !( d->mPrefix.isEmpty() && addressee.d->mPrefix.isEmpty() ) ) {
241 kDebug(5700) << "prefix differs";
242 return false;
243 }
244
245 if ( d->mSuffix != addressee.d->mSuffix &&
246 !( d->mSuffix.isEmpty() && addressee.d->mSuffix.isEmpty() ) ) {
247 kDebug(5700) << "suffix differs";
248 return false;
249 }
250
251 if ( d->mNickName != addressee.d->mNickName &&
252 !( d->mNickName.isEmpty() && addressee.d->mNickName.isEmpty() ) ) {
253 kDebug(5700) << "nickName differs";
254 return false;
255 }
256
257 if ( d->mBirthday != addressee.d->mBirthday ) {
258 kDebug(5700) << "birthday differs";
259 return false;
260 }
261
262 if ( d->mMailer != addressee.d->mMailer &&
263 !( d->mMailer.isEmpty() && addressee.d->mMailer.isEmpty() ) ) {
264 kDebug(5700) << "mailer differs";
265 return false;
266 }
267
268 if ( d->mTimeZone != addressee.d->mTimeZone ) {
269 kDebug(5700) << "timeZone differs";
270 return false;
271 }
272
273 if ( d->mGeo != addressee.d->mGeo ) {
274 kDebug(5700) << "geo differs";
275 return false;
276 }
277
278 if ( d->mTitle != addressee.d->mTitle &&
279 !( d->mTitle.isEmpty() && addressee.d->mTitle.isEmpty() ) ) {
280 kDebug(5700) << "title differs";
281 return false;
282 }
283
284 if ( d->mRole != addressee.d->mRole &&
285 !( d->mRole.isEmpty() && addressee.d->mRole.isEmpty() ) ) {
286 kDebug(5700) << "role differs";
287 return false;
288 }
289
290 if ( d->mOrganization != addressee.d->mOrganization &&
291 !( d->mOrganization.isEmpty() && addressee.d->mOrganization.isEmpty() ) ) {
292 kDebug(5700) << "organization differs";
293 return false;
294 }
295
296 if ( d->mDepartment != addressee.d->mDepartment &&
297 !( d->mDepartment.isEmpty() && addressee.d->mDepartment.isEmpty() ) ) {
298 kDebug(5700) << "department differs";
299 return false;
300 }
301
302 if ( d->mNote != addressee.d->mNote &&
303 !( d->mNote.isEmpty() && addressee.d->mNote.isEmpty() ) ) {
304 kDebug(5700) << "note differs";
305 return false;
306 }
307
308 if ( d->mProductId != addressee.d->mProductId &&
309 !( d->mProductId.isEmpty() && addressee.d->mProductId.isEmpty() ) ) {
310 kDebug(5700) << "productId differs";
311 return false;
312 }
313
314 if ( d->mSortString != addressee.d->mSortString &&
315 !( d->mSortString.isEmpty() && addressee.d->mSortString.isEmpty() ) ) {
316 kDebug(5700) << "sortString differs";
317 return false;
318 }
319
320 if ( d->mSecrecy != addressee.d->mSecrecy ) {
321 kDebug(5700) << "secrecy differs";
322 return false;
323 }
324
325 if ( d->mLogo != addressee.d->mLogo ) {
326 kDebug(5700) << "logo differs";
327 return false;
328 }
329
330 if ( d->mPhoto != addressee.d->mPhoto ) {
331 kDebug(5700) << "photo differs";
332 return false;
333 }
334
335 if ( d->mSound != addressee.d->mSound ) {
336 kDebug(5700) << "sound differs";
337 return false;
338 }
339
340 if ( ( d->mUrl.isValid() || addressee.d->mUrl.isValid() ) &&
341 ( d->mUrl != addressee.d->mUrl ) ) {
342 kDebug() << "url differs";
343 return false;
344 }
345
346 if ( !listEquals( d->mPhoneNumbers, addressee.d->mPhoneNumbers ) ) {
347 kDebug() << "phoneNumbers differs";
348 return false;
349 }
350
351 if ( !listEquals( d->mAddresses, addressee.d->mAddresses ) ) {
352 kDebug() << "addresses differs";
353 return false;
354 }
355
356 if ( !listEquals( d->mKeys, addressee.d->mKeys ) ) {
357 kDebug() << "keys differs";
358 return false;
359 }
360
361 if ( !listEquals( d->mEmails, addressee.d->mEmails ) ) {
362 kDebug() << "emails differs";
363 return false;
364 }
365
366 if ( !listEquals( d->mCategories, addressee.d->mCategories ) ) {
367 kDebug() << "categories differs";
368 return false;
369 }
370
371 if ( d->mCustomFields != addressee.d->mCustomFields ) {
372 kDebug() << "custom differs";
373 return false;
374 }
375
376 if (d->mLangs != addressee.d->mLangs) {
377 kDebug() << "langs differs";
378 return false;
379 }
380 if (d->mGender != addressee.d->mGender) {
381 kDebug() << "gender differs";
382 return false;
383 }
384 if ( d->mKind != addressee.d->mKind ) {
385 kDebug() << "kind differs";
386 return false;
387 }
388 if ( !listEquals( d->mCalendarUrl, addressee.d->mCalendarUrl ) ) {
389 kDebug() << "calendarUrl differs";
390 return false;
391 }
392 if ( !listEquals( d->mSoundListExtra, addressee.d->mSoundListExtra ) ) {
393 kDebug() << "Extra sound differs";
394 return false;
395 }
396 if ( !listEquals( d->mPhotoListExtra, addressee.d->mPhotoListExtra ) ) {
397 kDebug() << "Extra photo differs";
398 return false;
399 }
400 if ( !listEquals( d->mLogoListExtra, addressee.d->mLogoListExtra ) ) {
401 kDebug() << "Extra logo differs";
402 return false;
403 }
404 if ( !listEquals( d->mUrlListExtra, addressee.d->mUrlListExtra ) ) {
405 kDebug() << "Extra url differs";
406 return false;
407 }
408 if (!listEquals( d->mMembers, addressee.d->mMembers)) {
409 kDebug() << "Members differs";
410 return false;
411 }
412 if (!listEquals( d->mRelationShips, addressee.d->mRelationShips)) {
413 kDebug() << "RelationShips differs";
414 return false;
415 }
416 if (!listEquals( d->mSources, addressee.d->mSources)) {
417 kDebug() << "Sources differs";
418 return false;
419 }
420 return true;
421}
422
423bool Addressee::operator!=( const Addressee &a ) const
424{
425 return !( a == *this );
426}
427
428bool Addressee::isEmpty() const
429{
430 return d->mEmpty;
431}
432
433void Addressee::setUid( const QString &id )
434{
435 if ( id == d->mUid )
436 return;
437
438 d->mEmpty = false;
439 d->mUid = id;
440}
441
442QString Addressee::uid() const
443{
444 return d->mUid;
445}
446
447QString Addressee::uidLabel()
448{
449 return i18n( "Unique Identifier" );
450}
451
452void Addressee::setName( const QString &name )
453{
454 if ( name == d->mName )
455 return;
456
457 d->mEmpty = false;
458 d->mName = name;
459}
460
461QString Addressee::name() const
462{
463 return d->mName;
464}
465
466QString Addressee::nameLabel()
467{
468 return i18n( "Name" );
469}
470
471void Addressee::setKind( const QString &kind )
472{
473 if ( kind == d->mKind )
474 return;
475
476 d->mEmpty = false;
477 d->mKind = kind;
478}
479
480void Addressee::insertCalendarUrl(const CalendarUrl &calendarUrl)
481{
482 d->mEmpty = false;
483 //TODO verify that there is not same calendarurl
484 if (calendarUrl.isValid()) {
485 d->mCalendarUrl.append(calendarUrl);
486 }
487}
488
489void Addressee::insertExtraSound(const Sound &sound)
490{
491 d->mSoundListExtra.append(sound);
492}
493
494void Addressee::setExtraSoundList(const KABC::Sound::List &soundList)
495{
496 d->mSoundListExtra = soundList;
497}
498
499KABC::Sound::List Addressee::extraSoundList() const
500{
501 return d->mSoundListExtra;
502}
503
504void Addressee::insertExtraPhoto(const Picture &picture)
505{
506 d->mPhotoListExtra.append(picture);
507}
508
509void Addressee::setExtraPhotoList(const Picture::List &pictureList)
510{
511 d->mPhotoListExtra = pictureList;
512}
513
514Picture::List Addressee::extraPhotoList() const
515{
516 return d->mPhotoListExtra;
517}
518
519void Addressee::insertExtraLogo(const Picture &logo)
520{
521 d->mLogoListExtra.append(logo);
522}
523
524void Addressee::setExtraLogoList(const Picture::List &logoList)
525{
526 d->mLogoListExtra = logoList;
527}
528
529Picture::List Addressee::extraLogoList() const
530{
531 return d->mLogoListExtra;
532}
533
534void Addressee::insertExtraUrl(const KUrl &url)
535{
536 d->mUrlListExtra.append(url);
537}
538
539void Addressee::setExtraUrlList(const QList<KUrl> &urlList)
540{
541 d->mUrlListExtra = urlList;
542}
543
544QList<KUrl> Addressee::extraUrlList() const
545{
546 return d->mUrlListExtra;
547}
548
549void Addressee::insertSourceUrl(const KUrl &url)
550{
551 d->mSources.append(url);
552}
553
554void Addressee::setSourcesUrlList(const QList<KUrl> &urlList)
555{
556 d->mSources = urlList;
557}
558
559QList<KUrl> Addressee::sourcesUrlList() const
560{
561 return d->mSources;
562}
563
564
565QString Addressee::kind() const
566{
567 return d->mKind;
568}
569
570void Addressee::setFormattedName( const QString &formattedName )
571{
572 if ( formattedName == d->mFormattedName )
573 return;
574
575 d->mEmpty = false;
576 d->mFormattedName = formattedName;
577}
578
579QString Addressee::formattedName() const
580{
581 return d->mFormattedName;
582}
583
584QString Addressee::formattedNameLabel()
585{
586 return i18n( "Formatted Name" );
587}
588
589
590void Addressee::setFamilyName( const QString &familyName )
591{
592 if ( familyName == d->mFamilyName )
593 return;
594
595 d->mEmpty = false;
596 d->mFamilyName = familyName;
597}
598
599QString Addressee::familyName() const
600{
601 return d->mFamilyName;
602}
603
604QString Addressee::familyNameLabel()
605{
606 return i18n( "Family Name" );
607}
608
609
610void Addressee::setGivenName( const QString &givenName )
611{
612 if ( givenName == d->mGivenName )
613 return;
614
615 d->mEmpty = false;
616 d->mGivenName = givenName;
617}
618
619QString Addressee::givenName() const
620{
621 return d->mGivenName;
622}
623
624QString Addressee::givenNameLabel()
625{
626 return i18n( "Given Name" );
627}
628
629
630void Addressee::setAdditionalName( const QString &additionalName )
631{
632 if ( additionalName == d->mAdditionalName )
633 return;
634
635 d->mEmpty = false;
636 d->mAdditionalName = additionalName;
637}
638
639QString Addressee::additionalName() const
640{
641 return d->mAdditionalName;
642}
643
644QString Addressee::additionalNameLabel()
645{
646 return i18n( "Additional Names" );
647}
648
649
650void Addressee::setPrefix( const QString &prefix )
651{
652 if ( prefix == d->mPrefix )
653 return;
654
655 d->mEmpty = false;
656 d->mPrefix = prefix;
657}
658
659QString Addressee::prefix() const
660{
661 return d->mPrefix;
662}
663
664QString Addressee::prefixLabel()
665{
666 return i18n( "Honorific Prefixes" );
667}
668
669
670void Addressee::setSuffix( const QString &suffix )
671{
672 if ( suffix == d->mSuffix )
673 return;
674
675 d->mEmpty = false;
676 d->mSuffix = suffix;
677}
678
679QString Addressee::suffix() const
680{
681 return d->mSuffix;
682}
683
684QString Addressee::suffixLabel()
685{
686 return i18n( "Honorific Suffixes" );
687}
688
689
690void Addressee::setNickName( const QString &nickName )
691{
692 if ( nickName == d->mNickName )
693 return;
694
695 d->mEmpty = false;
696 d->mNickName = nickName;
697}
698
699QString Addressee::nickName() const
700{
701 return d->mNickName;
702}
703
704QString Addressee::nickNameLabel()
705{
706 return i18n( "Nick Name" );
707}
708
709
710void Addressee::setBirthday( const QDateTime &birthday )
711{
712 if ( birthday == d->mBirthday )
713 return;
714
715 d->mEmpty = false;
716 d->mBirthday = birthday;
717}
718
719QDateTime Addressee::birthday() const
720{
721 return d->mBirthday;
722}
723
724QString Addressee::birthdayLabel()
725{
726 return i18n( "Birthday" );
727}
728
729
730QString Addressee::homeAddressStreetLabel()
731{
732 return i18n( "Home Address Street" );
733}
734
735
736QString Addressee::homeAddressPostOfficeBoxLabel()
737{
738 return i18n( "Home Address Post Office Box" );
739}
740
741
742QString Addressee::homeAddressLocalityLabel()
743{
744 return i18n( "Home Address City" );
745}
746
747
748QString Addressee::homeAddressRegionLabel()
749{
750 return i18n( "Home Address State" );
751}
752
753
754QString Addressee::homeAddressPostalCodeLabel()
755{
756 return i18n( "Home Address Zip Code" );
757}
758
759
760QString Addressee::homeAddressCountryLabel()
761{
762 return i18n( "Home Address Country" );
763}
764
765
766QString Addressee::homeAddressLabelLabel()
767{
768 return i18n( "Home Address Label" );
769}
770
771
772QString Addressee::businessAddressStreetLabel()
773{
774 return i18n( "Business Address Street" );
775}
776
777
778QString Addressee::businessAddressPostOfficeBoxLabel()
779{
780 return i18n( "Business Address Post Office Box" );
781}
782
783
784QString Addressee::businessAddressLocalityLabel()
785{
786 return i18n( "Business Address City" );
787}
788
789
790QString Addressee::businessAddressRegionLabel()
791{
792 return i18n( "Business Address State" );
793}
794
795
796QString Addressee::businessAddressPostalCodeLabel()
797{
798 return i18n( "Business Address Zip Code" );
799}
800
801
802QString Addressee::businessAddressCountryLabel()
803{
804 return i18n( "Business Address Country" );
805}
806
807
808QString Addressee::businessAddressLabelLabel()
809{
810 return i18n( "Business Address Label" );
811}
812
813
814QString Addressee::homePhoneLabel()
815{
816 return i18n( "Home Phone" );
817}
818
819
820QString Addressee::businessPhoneLabel()
821{
822 return i18n( "Business Phone" );
823}
824
825
826QString Addressee::mobilePhoneLabel()
827{
828 return i18n( "Mobile Phone" );
829}
830
831
832QString Addressee::homeFaxLabel()
833{
834 return i18n( "Home Fax" );
835}
836
837
838QString Addressee::businessFaxLabel()
839{
840 return i18n( "Business Fax" );
841}
842
843
844QString Addressee::carPhoneLabel()
845{
846 return i18n( "Car Phone" );
847}
848
849
850QString Addressee::isdnLabel()
851{
852 return i18n( "ISDN" );
853}
854
855
856QString Addressee::pagerLabel()
857{
858 return i18n( "Pager" );
859}
860
861
862QString Addressee::emailLabel()
863{
864 return i18n( "Email Address" );
865}
866
867
868void Addressee::setMailer( const QString &mailer )
869{
870 if ( mailer == d->mMailer )
871 return;
872
873 d->mEmpty = false;
874 d->mMailer = mailer;
875}
876
877QString Addressee::mailer() const
878{
879 return d->mMailer;
880}
881
882QString Addressee::mailerLabel()
883{
884 return i18n( "Mail Client" );
885}
886
887
888void Addressee::setTimeZone( const TimeZone &timeZone )
889{
890 if ( timeZone == d->mTimeZone )
891 return;
892
893 d->mEmpty = false;
894 d->mTimeZone = timeZone;
895}
896
897TimeZone Addressee::timeZone() const
898{
899 return d->mTimeZone;
900}
901
902QString Addressee::timeZoneLabel()
903{
904 return i18n( "Time Zone" );
905}
906
907
908void Addressee::setGeo( const Geo &geo )
909{
910 if ( geo == d->mGeo )
911 return;
912
913 d->mEmpty = false;
914 d->mGeo = geo;
915}
916
917Geo Addressee::geo() const
918{
919 return d->mGeo;
920}
921
922QString Addressee::geoLabel()
923{
924 return i18n( "Geographic Position" );
925}
926
927
928void Addressee::setTitle( const QString &title )
929{
930 if ( title == d->mTitle )
931 return;
932
933 d->mEmpty = false;
934 d->mTitle = title;
935}
936
937QString Addressee::title() const
938{
939 return d->mTitle;
940}
941
942QString Addressee::titleLabel()
943{
944 return i18nc( "a person's title", "Title" );
945}
946
947
948void Addressee::setRole( const QString &role )
949{
950 if ( role == d->mRole )
951 return;
952
953 d->mEmpty = false;
954 d->mRole = role;
955}
956
957QString Addressee::role() const
958{
959 return d->mRole;
960}
961
962QString Addressee::roleLabel()
963{
964 return i18nc( "of a person in an organization", "Role" );
965}
966
967
968void Addressee::setOrganization( const QString &organization )
969{
970 if ( organization == d->mOrganization )
971 return;
972
973 d->mEmpty = false;
974 d->mOrganization = organization;
975}
976
977QString Addressee::organization() const
978{
979 return d->mOrganization;
980}
981
982QString Addressee::organizationLabel()
983{
984 return i18n( "Organization" );
985}
986
987
988void Addressee::setDepartment( const QString &department )
989{
990 if ( department == d->mDepartment )
991 return;
992
993 d->mEmpty = false;
994 d->mDepartment = department;
995}
996
997QString Addressee::department() const
998{
999 return d->mDepartment;
1000}
1001
1002QString Addressee::departmentLabel()
1003{
1004 return i18n( "Department" );
1005}
1006
1007
1008void Addressee::setNote( const QString &note )
1009{
1010 if ( note == d->mNote )
1011 return;
1012
1013 d->mEmpty = false;
1014 d->mNote = note;
1015}
1016
1017QString Addressee::note() const
1018{
1019 return d->mNote;
1020}
1021
1022QString Addressee::noteLabel()
1023{
1024 return i18n( "Note" );
1025}
1026
1027
1028void Addressee::setProductId( const QString &productId )
1029{
1030 if ( productId == d->mProductId )
1031 return;
1032
1033 d->mEmpty = false;
1034 d->mProductId = productId;
1035}
1036
1037QString Addressee::productId() const
1038{
1039 return d->mProductId;
1040}
1041
1042QString Addressee::productIdLabel()
1043{
1044 return i18n( "Product Identifier" );
1045}
1046
1047
1048void Addressee::setRevision( const QDateTime &revision )
1049{
1050 if ( revision == d->mRevision )
1051 return;
1052
1053 d->mEmpty = false;
1054 d->mRevision = revision;
1055}
1056
1057QDateTime Addressee::revision() const
1058{
1059 return d->mRevision;
1060}
1061
1062QString Addressee::revisionLabel()
1063{
1064 return i18n( "Revision Date" );
1065}
1066
1067
1068void Addressee::setSortString( const QString &sortString )
1069{
1070 if ( sortString == d->mSortString )
1071 return;
1072
1073 d->mEmpty = false;
1074 d->mSortString = sortString;
1075}
1076
1077QString Addressee::sortString() const
1078{
1079 return d->mSortString;
1080}
1081
1082QString Addressee::sortStringLabel()
1083{
1084 return i18n( "Sort String" );
1085}
1086
1087
1088void Addressee::setUrl( const KUrl &url )
1089{
1090 if ( url == d->mUrl )
1091 return;
1092
1093 d->mEmpty = false;
1094 d->mUrl = url;
1095}
1096
1097KUrl Addressee::url() const
1098{
1099 return d->mUrl;
1100}
1101
1102QString Addressee::urlLabel()
1103{
1104 return i18n( "Homepage" );
1105}
1106
1107
1108void Addressee::setSecrecy( const Secrecy &secrecy )
1109{
1110 if ( secrecy == d->mSecrecy )
1111 return;
1112
1113 d->mEmpty = false;
1114 d->mSecrecy = secrecy;
1115}
1116
1117Secrecy Addressee::secrecy() const
1118{
1119 return d->mSecrecy;
1120}
1121
1122QString Addressee::secrecyLabel()
1123{
1124 return i18n( "Security Class" );
1125}
1126
1127
1128void Addressee::setLogo( const Picture &logo )
1129{
1130 if ( logo == d->mLogo )
1131 return;
1132
1133 d->mEmpty = false;
1134 d->mLogo = logo;
1135}
1136
1137Picture Addressee::logo() const
1138{
1139 return d->mLogo;
1140}
1141
1142QString Addressee::logoLabel()
1143{
1144 return i18n( "Logo" );
1145}
1146
1147
1148void Addressee::setPhoto( const Picture &photo )
1149{
1150 if ( photo == d->mPhoto )
1151 return;
1152
1153 d->mEmpty = false;
1154 d->mPhoto = photo;
1155}
1156
1157Picture Addressee::photo() const
1158{
1159 return d->mPhoto;
1160}
1161
1162QString Addressee::photoLabel()
1163{
1164 return i18n( "Photo" );
1165}
1166
1167
1168void Addressee::setSound( const Sound &sound )
1169{
1170 if ( sound == d->mSound )
1171 return;
1172
1173 d->mEmpty = false;
1174 d->mSound = sound;
1175}
1176
1177Sound Addressee::sound() const
1178{
1179 return d->mSound;
1180}
1181
1182QString Addressee::soundLabel()
1183{
1184 return i18n( "Sound" );
1185}
1186
1187
1188void Addressee::setNameFromString( const QString &s )
1189{
1190 QString str = s;
1191 //remove enclosing quotes from string
1192 if ( str.length() > 1 &&
1193 s[ 0 ] == QLatin1Char( '"' ) &&
1194 s[ s.length() - 1 ] == QLatin1Char( '"' ) ) {
1195 str = s.mid( 1, s.length() - 2 );
1196 }
1197
1198 setFormattedName( str );
1199 setName( str );
1200
1201 // clear all name parts
1202 setPrefix( QString() );
1203 setGivenName( QString() );
1204 setAdditionalName( QString() );
1205 setFamilyName( QString() );
1206 setSuffix( QString() );
1207
1208 if ( str.isEmpty() )
1209 return;
1210
1211 static QString spaceStr = QString::fromLatin1( " " );
1212 static QString emptyStr = QString::fromLatin1( "" );
1213 AddresseeHelper *helper = AddresseeHelper::self();
1214
1215 int i = str.indexOf( QLatin1Char( ',' ) );
1216 if ( i < 0 ) {
1217 QStringList parts = str.split( spaceStr );
1218 int leftOffset = 0;
1219 int rightOffset = parts.count() - 1;
1220
1221 QString suffix;
1222 while ( rightOffset >= 0 ) {
1223 if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
1224 suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : spaceStr ) );
1225 rightOffset--;
1226 } else
1227 break;
1228 }
1229 setSuffix( suffix );
1230
1231 if ( rightOffset < 0 )
1232 return;
1233
1234 if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 ].toLower() ) ) {
1235 setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
1236 rightOffset--;
1237 } else {
1238 if ( helper->tradeAsFamilyName() )
1239 setFamilyName( parts[ rightOffset ] );
1240 else
1241 setGivenName( parts[ rightOffset ] );
1242 }
1243
1244 QString prefix;
1245 while ( leftOffset < rightOffset ) {
1246 if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1247 prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1248 leftOffset++;
1249 } else
1250 break;
1251 }
1252 setPrefix( prefix );
1253
1254 if ( leftOffset < rightOffset ) {
1255 setGivenName( parts[ leftOffset ] );
1256 leftOffset++;
1257 }
1258
1259 QString additionalName;
1260 while ( leftOffset < rightOffset ) {
1261 additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1262 leftOffset++;
1263 }
1264 setAdditionalName( additionalName );
1265 } else {
1266 QString part1 = str.left( i );
1267 QString part2 = str.mid( i + 1 );
1268
1269 QStringList parts = part1.split( spaceStr );
1270 int leftOffset = 0;
1271 int rightOffset = parts.count() - 1;
1272
1273 if ( parts.count() > 0 ) {
1274
1275 QString suffix;
1276 while ( rightOffset >= 0 ) {
1277 if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
1278 suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : spaceStr ) );
1279 rightOffset--;
1280 } else
1281 break;
1282 }
1283 setSuffix( suffix );
1284
1285 if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 ].toLower() ) ) {
1286 setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
1287 rightOffset--;
1288 } else
1289 setFamilyName( parts[ rightOffset ] );
1290
1291 QString prefix;
1292 while ( leftOffset < rightOffset ) {
1293 if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1294 prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1295 leftOffset++;
1296 } else
1297 break;
1298 }
1299 } else {
1300 setPrefix( QString() );
1301 setFamilyName( QString() );
1302 setSuffix( QString() );
1303 }
1304
1305 parts = part2.split( spaceStr );
1306
1307 leftOffset = 0;
1308 rightOffset = parts.count();
1309
1310 if ( parts.count() > 0 ) {
1311
1312 QString prefix;
1313 while ( leftOffset < rightOffset ) {
1314 if ( helper->containsTitle( parts[ leftOffset ] ) ) {
1315 prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1316 leftOffset++;
1317 } else
1318 break;
1319 }
1320 setPrefix( prefix );
1321
1322 if ( leftOffset < rightOffset ) {
1323 setGivenName( parts[ leftOffset ] );
1324 leftOffset++;
1325 }
1326
1327 QString additionalName;
1328 while ( leftOffset < rightOffset ) {
1329 additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + parts[ leftOffset ] );
1330 leftOffset++;
1331 }
1332 setAdditionalName( additionalName );
1333 } else {
1334 setGivenName( QString() );
1335 setAdditionalName( QString() );
1336 }
1337 }
1338}
1339
1340QString Addressee::realName() const
1341{
1342 QString n( formattedName() );
1343 if ( !n.isEmpty() )
1344 return n;
1345
1346 n = assembledName();
1347 if ( !n.isEmpty() )
1348 return n;
1349
1350 n = name();
1351 if ( !n.isEmpty() )
1352 return n;
1353
1354 return organization();
1355}
1356
1357QString Addressee::assembledName() const
1358{
1359 const QString name = prefix() + QLatin1Char( ' ' ) +
1360 givenName() + QLatin1Char( ' ' ) +
1361 additionalName() + QLatin1Char( ' ' ) +
1362 familyName() + QLatin1Char( ' ' ) +
1363 suffix();
1364
1365 return name.simplified();
1366}
1367
1368QString Addressee::fullEmail( const QString &email ) const
1369{
1370 QString e;
1371 if ( email.isNull() ) {
1372 e = preferredEmail();
1373 } else {
1374 e = email;
1375 }
1376 if ( e.isEmpty() ) return QString();
1377
1378 QString text;
1379 if ( realName().isEmpty() )
1380 text = e;
1381 else {
1382 QRegExp needQuotes( QLatin1String( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ) );
1383 if ( realName().indexOf( needQuotes ) != -1 ) {
1384 QString name = realName();
1385 name.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) );
1386 text = QLatin1String( "\"" ) + name + QLatin1String( "\" <" ) + e + QLatin1Char( '>' );
1387 } else
1388 text = realName() + QLatin1String( " <" ) + e + QLatin1Char( '>' );
1389 }
1390
1391 return text;
1392}
1393
1394void Addressee::insertEmail( const QString &email, bool preferred, const QMap<QString, QStringList> &param )
1395{
1396 if ( email.simplified().isEmpty() )
1397 return;
1398
1399 for (int i = 0; i < d->mEmails.size(); ++i) {
1400 if (d->mEmails.at(i).mail() == email) {
1401 if (!preferred || i == 0) {
1402 return;
1403 }
1404 Email tempMail = d->mEmails.takeAt(i);
1405 d->mEmails.prepend( tempMail );
1406 return;
1407 }
1408 }
1409
1410 Email mail(email);
1411 mail.setParameters(param);
1412 d->mEmpty = false;
1413 if ( preferred ) {
1414 d->mEmails.prepend( mail );
1415 } else {
1416 d->mEmails.append( mail );
1417 }
1418}
1419
1420void Addressee::insertEmail( const QString &email, bool preferred )
1421{
1422 insertEmail(email, preferred, QMap<QString, QStringList>());
1423}
1424
1425void Addressee::removeEmail( const QString &email )
1426{
1427 for (int i = 0; i < d->mEmails.size(); ++i) {
1428 if (d->mEmails.at(i).mail() == email) {
1429 d->mEmails.removeAt(i);
1430 }
1431 }
1432}
1433
1434QString Addressee::preferredEmail() const
1435{
1436 if ( d->mEmails.count() == 0 )
1437 return QString();
1438 else
1439 return d->mEmails.first().mail();
1440}
1441
1442QStringList Addressee::emails() const
1443{
1444 QStringList list;
1445 const int numberOfEmail(d->mEmails.size());
1446 for (int i = 0; i < numberOfEmail; ++i) {
1447 list << d->mEmails.at(i).mail();
1448 }
1449
1450 return list;
1451}
1452
1453Email::List Addressee::emailList() const
1454{
1455 return d->mEmails;
1456}
1457
1458void Addressee::setEmailList(const Email::List &list)
1459{
1460 d->mEmails = list;
1461 d->mEmpty = false;
1462}
1463
1464void Addressee::setEmails( const QStringList& emails )
1465{
1466 d->mEmails.clear();
1467 for (int i = 0; i < emails.size(); ++i) {
1468 d->mEmails.append(Email(emails.at(i)));
1469 }
1470 d->mEmpty = false;
1471}
1472
1473void Addressee::removeLang( const QString &language )
1474{
1475 for (int i = 0; i < d->mLangs.size(); ++i) {
1476 if (d->mLangs.at(i).language() == language) {
1477 d->mLangs.removeAt(i);
1478 }
1479 }
1480}
1481
1482void Addressee::insertLang( const Lang &language )
1483{
1484 const QString languageStr = language.language();
1485 if (languageStr.simplified().isEmpty())
1486 return;
1487 d->mEmpty = false;
1488
1489 Lang::List::Iterator it;
1490 Lang::List::Iterator end(d->mLangs.end());
1491 for ( it = d->mLangs.begin(); it != end; ++it ) {
1492 if ( ( *it ).language() == languageStr ) {
1493 (*it).setParameters(language.parameters());
1494 return;
1495 }
1496 }
1497 d->mLangs.append( language );
1498}
1499
1500void Addressee::setLangs(const Lang::List &langs)
1501{
1502 d->mLangs = langs;
1503 d->mEmpty = false;
1504}
1505
1506Lang::List Addressee::langs() const
1507{
1508 return d->mLangs;
1509}
1510
1511void Addressee::setGender(const Gender &gender)
1512{
1513 if ( gender == d->mGender )
1514 return;
1515
1516 d->mEmpty = false;
1517 d->mGender = gender;
1518}
1519
1520Gender Addressee::gender() const
1521{
1522 return d->mGender;
1523}
1524
1525void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1526{
1527 d->mEmpty = false;
1528
1529 PhoneNumber::List::Iterator it;
1530 for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
1531 if ( ( *it ).id() == phoneNumber.id() ) {
1532 *it = phoneNumber;
1533 return;
1534 }
1535 }
1536 if ( !phoneNumber.number().simplified().isEmpty() )
1537 d->mPhoneNumbers.append( phoneNumber );
1538}
1539
1540void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1541{
1542 PhoneNumber::List::Iterator it;
1543 for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
1544 if ( ( *it ).id() == phoneNumber.id() ) {
1545 d->mPhoneNumbers.erase( it );
1546 return;
1547 }
1548 }
1549}
1550
1551PhoneNumber Addressee::phoneNumber( PhoneNumber::Type type ) const
1552{
1553 PhoneNumber phoneNumber( QString(), type );
1554 PhoneNumber::List::ConstIterator it;
1555 for ( it = d->mPhoneNumbers.constBegin(); it != d->mPhoneNumbers.constEnd(); ++it ) {
1556 if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1557 if ( ( *it ).type() & PhoneNumber::Pref ) {
1558 return ( *it );
1559 } else if ( phoneNumber.number().isEmpty() ) {
1560 phoneNumber = ( *it );
1561 }
1562 }
1563 }
1564
1565 return phoneNumber;
1566}
1567
1568PhoneNumber::List Addressee::phoneNumbers() const
1569{
1570 return d->mPhoneNumbers;
1571}
1572
1573PhoneNumber::List Addressee::phoneNumbers( PhoneNumber::Type type ) const
1574{
1575 PhoneNumber::List list;
1576
1577 PhoneNumber::List::ConstIterator it;
1578 PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
1579 for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
1580 if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1581 list.append( *it );
1582 }
1583 }
1584 return list;
1585}
1586
1587PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1588{
1589 PhoneNumber::List::ConstIterator it;
1590 PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
1591 for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
1592 if ( ( *it ).id() == id ) {
1593 return *it;
1594 }
1595 }
1596 return PhoneNumber();
1597}
1598
1599void Addressee::insertKey( const Key &key )
1600{
1601 d->mEmpty = false;
1602
1603 Key::List::Iterator it;
1604 for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
1605 if ( ( *it ).id() == key.id() ) {
1606 *it = key;
1607 return;
1608 }
1609 }
1610 d->mKeys.append( key );
1611}
1612
1613void Addressee::removeKey( const Key &key )
1614{
1615 Key::List::Iterator it;
1616 for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
1617 if ( ( *it ).id() == key.id() ) {
1618 d->mKeys.removeAll( key );
1619 return;
1620 }
1621 }
1622}
1623
1624Key Addressee::key( Key::Type type, QString customTypeString ) const
1625{
1626 Key::List::ConstIterator it;
1627 Key::List::ConstIterator end( d->mKeys.constEnd() );
1628 for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1629 if ( ( *it ).type() == type ) {
1630 if ( type == Key::Custom ) {
1631 if ( customTypeString.isEmpty() ) {
1632 return *it;
1633 } else {
1634 if ( ( *it ).customTypeString() == customTypeString )
1635 return ( *it );
1636 }
1637 } else {
1638 return *it;
1639 }
1640 }
1641 }
1642 return Key( QString(), type );
1643}
1644
1645void Addressee::setKeys( const Key::List& list )
1646{
1647 d->mEmpty = false;
1648 d->mKeys = list;
1649}
1650
1651Key::List Addressee::keys() const
1652{
1653 return d->mKeys;
1654}
1655
1656Key::List Addressee::keys( Key::Type type, QString customTypeString ) const
1657{
1658 Key::List list;
1659
1660 Key::List::ConstIterator it;
1661 Key::List::ConstIterator end( d->mKeys.constEnd() );
1662 for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1663 if ( ( *it ).type() == type ) {
1664 if ( type == Key::Custom ) {
1665 if ( customTypeString.isEmpty() ) {
1666 list.append( *it );
1667 } else {
1668 if ( ( *it ).customTypeString() == customTypeString )
1669 list.append( *it );
1670 }
1671 } else {
1672 list.append( *it );
1673 }
1674 }
1675 }
1676 return list;
1677}
1678
1679Key Addressee::findKey( const QString &id ) const
1680{
1681 Key::List::ConstIterator it;
1682 Key::List::ConstIterator end( d->mKeys.constEnd() );
1683 for ( it = d->mKeys.constBegin(); it != end; ++it ) {
1684 if ( ( *it ).id() == id ) {
1685 return *it;
1686 }
1687 }
1688 return Key();
1689}
1690
1691QString Addressee::toString() const
1692{
1693 QString str;
1694
1695 str += QLatin1String( "Addressee {\n" );
1696 str += QString::fromLatin1( " Uid: %1\n" ).arg( uid() );
1697
1698 str += QString::fromLatin1( " Name: %1\n" ).arg( name() );
1699 str += QString::fromLatin1( " FormattedName: %1\n" ).arg( formattedName() );
1700 str += QString::fromLatin1( " FamilyName: %1\n" ).arg( familyName() );
1701 str += QString::fromLatin1( " GivenName: %1\n" ).arg( givenName() );
1702 str += QString::fromLatin1( " AdditionalName: %1\n" ).arg( additionalName() );
1703 str += QString::fromLatin1( " Prefix: %1\n" ).arg( prefix() );
1704 str += QString::fromLatin1( " Suffix: %1\n" ).arg( suffix() );
1705 str += QString::fromLatin1( " NickName: %1\n" ).arg( nickName() );
1706 str += QString::fromLatin1( " Birthday: %1\n" ).arg( birthday().toString() );
1707 str += QString::fromLatin1( " Mailer: %1\n" ).arg( mailer() );
1708 str += QString::fromLatin1( " TimeZone: %1\n" ).arg( timeZone().toString() );
1709 str += QString::fromLatin1( " Geo: %1\n" ).arg( geo().toString() );
1710 str += QString::fromLatin1( " Title: %1\n" ).arg( title() );
1711 str += QString::fromLatin1( " Role: %1\n" ).arg( role() );
1712 str += QString::fromLatin1( " Organization: %1\n" ).arg( organization() );
1713 str += QString::fromLatin1( " Department: %1\n" ).arg( department() );
1714 str += QString::fromLatin1( " Note: %1\n" ).arg( note() );
1715 str += QString::fromLatin1( " ProductId: %1\n" ).arg( productId() );
1716 str += QString::fromLatin1( " Revision: %1\n" ).arg( revision().toString() );
1717 str += QString::fromLatin1( " SortString: %1\n" ).arg( sortString() );
1718 str += QString::fromLatin1( " Url: %1\n" ).arg( url().url() );
1719 str += QString::fromLatin1( " Secrecy: %1\n" ).arg( secrecy().toString() );
1720 str += QString::fromLatin1( " Logo: %1\n" ).arg( logo().toString() );
1721 str += QString::fromLatin1( " Photo: %1\n" ).arg( photo().toString() );
1722 str += QString::fromLatin1( " Sound: %1\n" ).arg( sound().toString() );
1723 str += QString::fromLatin1( " Gender: %1\n" ).arg( gender().toString() );
1724 str += QString::fromLatin1( " Kind: %1\n" ).arg(kind());
1725
1726 str += QLatin1String( " Emails {\n" );
1727 const Email::List listEmail = d->mEmails;
1728 Email::List::ConstIterator it5;
1729 for ( it5 = listEmail.begin(); it5 != listEmail.end(); ++it5 ) {
1730 str += ( *it5 ).toString();
1731 }
1732 str += QLatin1String( " }\n" );
1733
1734 str += QLatin1String( " Langs {\n" );
1735 const Lang::List listLang = d->mLangs;
1736 Lang::List::ConstIterator it6;
1737 for ( it6 = listLang.begin(); it6 != listLang.end(); ++it6 ) {
1738 str += ( *it6 ).toString();
1739 }
1740 str += QLatin1String( " }\n" );
1741
1742
1743 str += QLatin1String( " PhoneNumbers {\n" );
1744 const PhoneNumber::List p = phoneNumbers();
1745 PhoneNumber::List::ConstIterator it2;
1746 for ( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1747 str += ( *it2 ).toString();
1748 }
1749 str += QLatin1String( " }\n" );
1750
1751 str += QLatin1String( " Addresses {\n" );
1752 const Address::List a = addresses();
1753 Address::List::ConstIterator it3;
1754 for ( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1755 str += ( *it3 ).toString();
1756 }
1757 str += QLatin1String( " }\n" );
1758
1759 str += QLatin1String( " Keys {\n" );
1760 const Key::List k = keys();
1761 Key::List::ConstIterator it4;
1762 for ( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1763 str += ( *it4 ).toString();
1764 }
1765 str += QLatin1String( " }\n" );
1766
1767 str += QLatin1String( "}\n" );
1768
1769 return str;
1770}
1771
1772
1773void Addressee::insertAddress( const Address &address )
1774{
1775 if ( address.isEmpty() )
1776 return;
1777
1778 d->mEmpty = false;
1779
1780 Address::List::Iterator it;
1781 for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
1782 if ( ( *it ).id() == address.id() ) {
1783 *it = address;
1784 return;
1785 }
1786 }
1787
1788 d->mAddresses.append( address );
1789}
1790
1791void Addressee::removeAddress( const Address &address )
1792{
1793 Address::List::Iterator it;
1794 for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
1795 if ( ( *it ).id() == address.id() ) {
1796 d->mAddresses.erase( it );
1797 return;
1798 }
1799 }
1800}
1801
1802Address Addressee::address( Address::Type type ) const
1803{
1804 Address address( type );
1805 Address::List::ConstIterator it;
1806 Address::List::ConstIterator end( d->mAddresses.constEnd() );
1807 for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1808 if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1809 if ( ( *it ).type() & Address::Pref ) {
1810 return ( *it );
1811 } else if ( address.isEmpty() ) {
1812 address = ( *it );
1813 }
1814 }
1815 }
1816
1817 return address;
1818}
1819
1820Address::List Addressee::addresses() const
1821{
1822 return d->mAddresses;
1823}
1824
1825Address::List Addressee::addresses( Address::Type type ) const
1826{
1827 Address::List list;
1828
1829 Address::List::ConstIterator it;
1830 Address::List::ConstIterator end( d->mAddresses.constEnd() );
1831 for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1832 if ( matchBinaryPattern( ( *it ).type(), type ) ) {
1833 list.append( *it );
1834 }
1835 }
1836
1837 return list;
1838}
1839
1840Address Addressee::findAddress( const QString &id ) const
1841{
1842 Address::List::ConstIterator it;
1843 Address::List::ConstIterator end( d->mAddresses.constEnd() );
1844 for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
1845 if ( ( *it ).id() == id ) {
1846 return *it;
1847 }
1848 }
1849 return Address();
1850}
1851
1852void Addressee::insertMember( const QString & member)
1853{
1854 d->mEmpty = false;
1855
1856 if ( d->mMembers.contains( member ) )
1857 return;
1858
1859 d->mMembers.append( member );
1860}
1861
1862void Addressee::setMembers( const QStringList &m )
1863{
1864 d->mEmpty = false;
1865 d->mMembers = m;
1866}
1867
1868QStringList Addressee::members() const
1869{
1870 return d->mMembers;
1871}
1872
1873void Addressee::insertRelationShip(const QString &relation)
1874{
1875 d->mEmpty = false;
1876
1877 if ( d->mRelationShips.contains( relation ) )
1878 return;
1879
1880 d->mRelationShips.append( relation );
1881}
1882
1883void Addressee::setRelationShips(const QStringList &c)
1884{
1885 d->mEmpty = false;
1886 d->mRelationShips = c;
1887}
1888
1889QStringList Addressee::relationShips() const
1890{
1891 return d->mRelationShips;
1892}
1893
1894void Addressee::insertCategory( const QString &c )
1895{
1896 d->mEmpty = false;
1897
1898 if ( d->mCategories.contains( c ) )
1899 return;
1900
1901 d->mCategories.append( c );
1902}
1903
1904void Addressee::removeCategory( const QString &category )
1905{
1906 if ( d->mCategories.contains( category ) ) {
1907 d->mCategories.removeAll( category );
1908 }
1909}
1910
1911bool Addressee::hasCategory( const QString &category ) const
1912{
1913 return d->mCategories.contains( category );
1914}
1915
1916void Addressee::setCategories( const QStringList &c )
1917{
1918 d->mEmpty = false;
1919
1920 d->mCategories = c;
1921}
1922
1923QStringList Addressee::categories() const
1924{
1925 return d->mCategories;
1926}
1927
1928void Addressee::insertCustom( const QString &app, const QString &name,
1929 const QString &value )
1930{
1931 if ( value.isEmpty() || name.isEmpty() || app.isEmpty() ) {
1932 return;
1933 }
1934
1935 d->mEmpty = false;
1936
1937 const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1938
1939 d->mCustomFields.insert( qualifiedName, value );
1940}
1941
1942void Addressee::removeCustom( const QString &app, const QString &name )
1943{
1944 const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1945
1946 d->mCustomFields.remove( qualifiedName );
1947}
1948
1949QString Addressee::custom( const QString &app, const QString &name ) const
1950{
1951 const QString qualifiedName = app + QLatin1Char( '-' ) + name;
1952
1953 return d->mCustomFields.value( qualifiedName );
1954}
1955
1956void Addressee::setCustoms( const QStringList &customs )
1957{
1958 d->mEmpty = false;
1959
1960 d->mCustomFields.clear();
1961
1962 foreach ( const QString &custom, customs ) {
1963 const int index = custom.indexOf( QLatin1Char( ':' ) );
1964 if ( index == -1 )
1965 continue;
1966
1967 const QString qualifiedName = custom.left( index );
1968 const QString value = custom.mid( index + 1 );
1969
1970 d->mCustomFields.insert( qualifiedName, value );
1971 }
1972}
1973
1974QStringList Addressee::customs() const
1975{
1976 QStringList result;
1977
1978 QMapIterator<QString, QString> it( d->mCustomFields );
1979 while ( it.hasNext() ) {
1980 it.next();
1981 result << it.key() + QLatin1Char( ':' ) + it.value();
1982 }
1983
1984 return result;
1985}
1986
1987void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1988 QString &email )
1989{
1990 // This is a simplified version of KPIM::splitAddress().
1991
1992 fullName.clear();
1993 email.clear();
1994 if ( rawEmail.isEmpty() )
1995 return; // KPIM::AddressEmpty;
1996
1997 // The code works on 8-bit strings, so convert the input to UTF-8.
1998 QByteArray address = rawEmail.toUtf8();
1999
2000 QByteArray displayName;
2001 QByteArray addrSpec;
2002 QByteArray comment;
2003
2004 // The following is a primitive parser for a mailbox-list (cf. RFC 2822).
2005 // The purpose is to extract a displayable string from the mailboxes.
2006 // Comments in the addr-spec are not handled. No error checking is done.
2007
2008 enum { TopLevel, InComment, InAngleAddress } context = TopLevel;
2009 bool inQuotedString = false;
2010 int commentLevel = 0;
2011 bool stop = false;
2012
2013 for ( char* p = address.data(); *p && !stop; ++p ) {
2014 switch ( context ) {
2015 case TopLevel : {
2016 switch ( *p ) {
2017 case '"' : inQuotedString = !inQuotedString;
2018 displayName += *p;
2019 break;
2020 case '(' : if ( !inQuotedString ) {
2021 context = InComment;
2022 commentLevel = 1;
2023 }
2024 else
2025 displayName += *p;
2026 break;
2027 case '<' : if ( !inQuotedString ) {
2028 context = InAngleAddress;
2029 }
2030 else
2031 displayName += *p;
2032 break;
2033 case '\\' : // quoted character
2034 displayName += *p;
2035 ++p; // skip the '\'
2036 if ( *p )
2037 displayName += *p;
2038 else
2039 //return KPIM::UnexpectedEnd;
2040 goto ABORT_PARSING;
2041 break;
2042 case ',' : if ( !inQuotedString ) {
2043 //if ( allowMultipleAddresses )
2044 // stop = true;
2045 //else
2046 // return KPIM::UnexpectedComma;
2047 goto ABORT_PARSING;
2048 }
2049 else
2050 displayName += *p;
2051 break;
2052 default : displayName += *p;
2053 }
2054 break;
2055 }
2056 case InComment : {
2057 switch ( *p ) {
2058 case '(' : ++commentLevel;
2059 comment += *p;
2060 break;
2061 case ')' : --commentLevel;
2062 if ( commentLevel == 0 ) {
2063 context = TopLevel;
2064 comment += ' '; // separate the text of several comments
2065 }
2066 else
2067 comment += *p;
2068 break;
2069 case '\\' : // quoted character
2070 comment += *p;
2071 ++p; // skip the '\'
2072 if ( *p )
2073 comment += *p;
2074 else
2075 //return KPIM::UnexpectedEnd;
2076 goto ABORT_PARSING;
2077 break;
2078 default : comment += *p;
2079 }
2080 break;
2081 }
2082 case InAngleAddress : {
2083 switch ( *p ) {
2084 case '"' : inQuotedString = !inQuotedString;
2085 addrSpec += *p;
2086 break;
2087 case '>' : if ( !inQuotedString ) {
2088 context = TopLevel;
2089 }
2090 else
2091 addrSpec += *p;
2092 break;
2093 case '\\' : // quoted character
2094 addrSpec += *p;
2095 ++p; // skip the '\'
2096 if ( *p )
2097 addrSpec += *p;
2098 else
2099 //return KPIM::UnexpectedEnd;
2100 goto ABORT_PARSING;
2101 break;
2102 default : addrSpec += *p;
2103 }
2104 break;
2105 }
2106 } // switch ( context )
2107 }
2108
2109ABORT_PARSING:
2110 displayName = displayName.trimmed();
2111 comment = comment.trimmed();
2112 addrSpec = addrSpec.trimmed();
2113
2114 fullName = QString::fromUtf8( displayName );
2115 email = QString::fromUtf8( addrSpec );
2116
2117 // check for errors
2118 if ( inQuotedString )
2119 return; // KPIM::UnbalancedQuote;
2120 if ( context == InComment )
2121 return; // KPIM::UnbalancedParens;
2122 if ( context == InAngleAddress )
2123 return; // KPIM::UnclosedAngleAddr;
2124
2125 if ( addrSpec.isEmpty() ) {
2126 if ( displayName.isEmpty() )
2127 return; // KPIM::NoAddressSpec;
2128 else {
2129 //addrSpec = displayName;
2130 //displayName.truncate( 0 );
2131 // Address of the form "foo@bar" or "foo@bar (Name)".
2132 email = fullName;
2133 fullName = QString::fromUtf8( comment );
2134 }
2135 }
2136
2137 email = email.toLower();
2138 // Check that we do not have any extra characters on the end of the
2139 // strings
2140 unsigned int len = fullName.length();
2141 if ( fullName[ 0 ] == QLatin1Char( '"' ) && fullName[ len - 1 ] == QLatin1Char( '"' ) ) {
2142 fullName = fullName.mid( 1, len - 2 );
2143 }
2144}
2145
2146#ifndef KDEPIM_NO_KRESOURCES
2147void Addressee::setResource( Resource *resource )
2148{
2149 d->mResource = resource;
2150}
2151
2152Resource *Addressee::resource() const
2153{
2154 return d->mResource;
2155}
2156#endif
2157
2158void Addressee::setChanged( bool value )
2159{
2160 d->mChanged = value;
2161}
2162
2163bool Addressee::changed() const
2164{
2165 return d->mChanged;
2166}
2167
2168void Addressee::setSortMode( KABC::SortMode *mode )
2169{
2170 Private::mSortMode = mode;
2171}
2172
2173bool Addressee::operator< ( const Addressee &addr ) const
2174{
2175 if ( !Private::mSortMode )
2176 return false;
2177 else
2178 return Private::mSortMode->lesser( *this, addr );
2179}
2180
2181QString Addressee::mimeType()
2182{
2183 return QLatin1String( "text/directory" );
2184}
2185
2186QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2187{
2188 s << a.d->mUid;
2189
2190 s << a.d->mName;
2191 s << a.d->mFormattedName;
2192 s << a.d->mFamilyName;
2193 s << a.d->mGivenName;
2194 s << a.d->mAdditionalName;
2195 s << a.d->mPrefix;
2196 s << a.d->mSuffix;
2197 s << a.d->mNickName;
2198 s << a.d->mBirthday;
2199 s << a.d->mMailer;
2200 s << a.d->mTimeZone;
2201 s << a.d->mGeo;
2202 s << a.d->mTitle;
2203 s << a.d->mRole;
2204 s << a.d->mOrganization;
2205 s << a.d->mDepartment;
2206 s << a.d->mNote;
2207 s << a.d->mProductId;
2208 s << a.d->mRevision;
2209 s << a.d->mSortString;
2210 s << a.d->mUrl;
2211 s << a.d->mSecrecy;
2212 s << a.d->mLogo;
2213 s << a.d->mPhoto;
2214 s << a.d->mSound;
2215 s << a.d->mPhoneNumbers;
2216 s << a.d->mAddresses;
2217 s << a.d->mEmails;
2218 s << a.d->mCategories;
2219 s << a.customs();
2220 s << a.d->mKeys;
2221 s << a.d->mLangs;
2222 s << a.d->mGender;
2223 s << a.d->mKind;
2224 s << a.d->mCalendarUrl;
2225 s << a.d->mSoundListExtra;
2226 s << a.d->mPhotoListExtra;
2227 s << a.d->mLogoListExtra;
2228 s << a.d->mUrlListExtra;
2229 s << a.d->mMembers;
2230 s << a.d->mRelationShips;
2231 s << a.d->mSources;
2232 return s;
2233}
2234
2235QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2236{
2237 s >> a.d->mUid;
2238
2239 s >> a.d->mName;
2240 s >> a.d->mFormattedName;
2241 s >> a.d->mFamilyName;
2242 s >> a.d->mGivenName;
2243 s >> a.d->mAdditionalName;
2244 s >> a.d->mPrefix;
2245 s >> a.d->mSuffix;
2246 s >> a.d->mNickName;
2247 s >> a.d->mBirthday;
2248 s >> a.d->mMailer;
2249 s >> a.d->mTimeZone;
2250 s >> a.d->mGeo;
2251 s >> a.d->mTitle;
2252 s >> a.d->mRole;
2253 s >> a.d->mOrganization;
2254 s >> a.d->mDepartment;
2255 s >> a.d->mNote;
2256 s >> a.d->mProductId;
2257 s >> a.d->mRevision;
2258 s >> a.d->mSortString;
2259 s >> a.d->mUrl;
2260 s >> a.d->mSecrecy;
2261 s >> a.d->mLogo;
2262 s >> a.d->mPhoto;
2263 s >> a.d->mSound;
2264 s >> a.d->mPhoneNumbers;
2265 s >> a.d->mAddresses;
2266 s >> a.d->mEmails;
2267 s >> a.d->mCategories;
2268 QStringList customFields;
2269 s >> customFields;
2270 a.setCustoms( customFields );
2271 s >> a.d->mKeys;
2272 s >> a.d->mLangs;
2273 s >> a.d->mGender;
2274 s >> a.d->mKind;
2275 s >> a.d->mCalendarUrl;
2276 s >> a.d->mSoundListExtra;
2277 s >> a.d->mPhotoListExtra;
2278 s >> a.d->mLogoListExtra;
2279 s >> a.d->mUrlListExtra;
2280 s >> a.d->mMembers;
2281 s >> a.d->mRelationShips;
2282 s >> a.d->mSources;
2283 a.d->mEmpty = false;
2284
2285 return s;
2286}
2287
2288bool matchBinaryPattern( int value, int pattern )
2289{
2296 if ( pattern == 0 )
2297 return ( value == 0 );
2298 else
2299 return ( pattern == ( pattern & value ) );
2300}
2301
2302template <class L>
2303bool listEquals( const QList<L> &list, const QList<L> &pattern )
2304{
2305 if ( list.count() != pattern.count() )
2306 return false;
2307 const int numberOfElement( list.count() );
2308 for ( int i = 0; i < numberOfElement; ++i ) {
2309 if ( !pattern.contains( list[ i ] ) ) {
2310 return false;
2311 }
2312 }
2313
2314 return true;
2315}
2316
2317bool listEquals( const QStringList &list, const QStringList &pattern )
2318{
2319 if ( list.count() != pattern.count() )
2320 return false;
2321
2322 const int numberOfElement( list.count() );
2323 for ( int i = 0; i < numberOfElement; ++i ) {
2324 if ( !pattern.contains( list[ i ] ) ) {
2325 return false;
2326 }
2327 }
2328
2329 return true;
2330}
KABC::Address
Postal address information.
Definition address.h:38
KABC::Address::isEmpty
bool isEmpty() const
Returns true, if the address is empty.
Definition address.cpp:301
KABC::Address::Pref
@ Pref
preferred address
Definition address.h:58
KABC::Address::List
QList< Address > List
List of addresses.
Definition address.h:46
KABC::Address::id
QString id() const
Returns the unique identifier.
Definition address.cpp:317
KABC::AddresseeHelper
This singleton class stores static data, which is shared by all Addressee objects.
Definition addresseehelper.h:55
KABC::AddresseeHelper::containsSuffix
bool containsSuffix(const QString &suffix) const
Queries the list of honoric suffixes.
Definition addresseehelper.cpp:108
KABC::AddresseeHelper::self
static AddresseeHelper * self()
Singleton interface to this class.
Definition addresseehelper.cpp:34
KABC::AddresseeHelper::tradeAsFamilyName
bool tradeAsFamilyName() const
Returns whether or not a single name component should be interpreted as a family name.
Definition addresseehelper.cpp:113
KABC::AddresseeHelper::containsPrefix
bool containsPrefix(const QString &prefix) const
Queries the list of inclusions.
Definition addresseehelper.cpp:103
KABC::AddresseeHelper::containsTitle
bool containsTitle(const QString &title) const
Queries the list of honoric prefixes.
Definition addresseehelper.cpp:98
KABC::Addressee
address book entry
Definition addressee.h:79
KABC::Addressee::businessAddressRegionLabel
static QString businessAddressRegionLabel()
Return translated label for businessAddressRegion field.
Definition addressee.cpp:790
KABC::Addressee::sortStringLabel
static QString sortStringLabel()
Return translated label for sortString field.
Definition addressee.cpp:1082
KABC::Addressee::hasCategory
bool hasCategory(const QString &) const
Return, if addressee has the given category.
Definition addressee.cpp:1911
KABC::Addressee::setMailer
void setMailer(const QString &mailer)
Set mail client.
Definition addressee.cpp:868
KABC::Addressee::removeKey
void removeKey(const Key &key)
Remove a key.
Definition addressee.cpp:1613
KABC::Addressee::businessAddressPostOfficeBoxLabel
static QString businessAddressPostOfficeBoxLabel()
Return translated label for businessAddressPostOfficeBox field.
Definition addressee.cpp:778
KABC::Addressee::homeAddressPostalCodeLabel
static QString homeAddressPostalCodeLabel()
Return translated label for homeAddressPostalCode field.
Definition addressee.cpp:754
KABC::Addressee::setLogo
void setLogo(const Picture &logo)
Set logo.
Definition addressee.cpp:1128
KABC::Addressee::givenNameLabel
static QString givenNameLabel()
Return translated label for givenName field.
Definition addressee.cpp:624
KABC::Addressee::noteLabel
static QString noteLabel()
Return translated label for note field.
Definition addressee.cpp:1022
KABC::Addressee::~Addressee
~Addressee()
Destroys the address book entry.
Definition addressee.cpp:185
KABC::Addressee::setAdditionalName
void setAdditionalName(const QString &additionalName)
Set additional names.
Definition addressee.cpp:630
KABC::Addressee::familyName
QString familyName() const
Return family name.
Definition addressee.cpp:599
KABC::Addressee::mailer
QString mailer() const
Return mail client.
Definition addressee.cpp:877
KABC::Addressee::removePhoneNumber
void removePhoneNumber(const PhoneNumber &phoneNumber)
Remove phone number.
Definition addressee.cpp:1540
KABC::Addressee::setSecrecy
void setSecrecy(const Secrecy &secrecy)
Set security class.
Definition addressee.cpp:1108
KABC::Addressee::additionalNameLabel
static QString additionalNameLabel()
Return translated label for additionalName field.
Definition addressee.cpp:644
KABC::Addressee::operator==
bool operator==(const Addressee &) const
Equality operator.
Definition addressee.cpp:202
KABC::Addressee::setCustoms
void setCustoms(const QStringList &)
Set all custom entries.
Definition addressee.cpp:1956
KABC::Addressee::setBirthday
void setBirthday(const QDateTime &birthday)
Set birthday.
Definition addressee.cpp:710
KABC::Addressee::setOrganization
void setOrganization(const QString &organization)
Set organization.
Definition addressee.cpp:968
KABC::Addressee::emails
QStringList emails() const
Return list of all email addresses.
Definition addressee.cpp:1442
KABC::Addressee::organizationLabel
static QString organizationLabel()
Return translated label for organization field.
Definition addressee.cpp:982
KABC::Addressee::setKeys
void setKeys(const Key::List &keys)
Set the list of keys.
Definition addressee.cpp:1645
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition addressee.cpp:1525
KABC::Addressee::homeAddressPostOfficeBoxLabel
static QString homeAddressPostOfficeBoxLabel()
Return translated label for homeAddressPostOfficeBox field.
Definition addressee.cpp:736
KABC::Addressee::setPrefix
void setPrefix(const QString &prefix)
Set honorific prefixes.
Definition addressee.cpp:650
KABC::Addressee::nickName
QString nickName() const
Return nick name.
Definition addressee.cpp:699
KABC::Addressee::insertCustom
void insertCustom(const QString &app, const QString &name, const QString &value)
Insert custom entry.
Definition addressee.cpp:1928
KABC::Addressee::setProductId
void setProductId(const QString &productId)
Set product identifier.
Definition addressee.cpp:1028
KABC::Addressee::sortString
QString sortString() const
Return sort string.
Definition addressee.cpp:1077
KABC::Addressee::businessAddressLabelLabel
static QString businessAddressLabelLabel()
Return translated label for businessAddressLabel field.
Definition addressee.cpp:808
KABC::Addressee::url
KUrl url() const
Return homepage.
Definition addressee.cpp:1097
KABC::Addressee::setNameFromString
void setNameFromString(const QString &)
Set name fields by parsing the given string and trying to associate the parts of the string with acco...
Definition addressee.cpp:1188
KABC::Addressee::mimeType
static QString mimeType()
Returns the MIME type used for Addressees.
Definition addressee.cpp:2181
KABC::Addressee::operator=
Addressee & operator=(const Addressee &)
Assignment operator.
Definition addressee.cpp:194
KABC::Addressee::businessAddressStreetLabel
static QString businessAddressStreetLabel()
Return translated label for businessAddressStreet field.
Definition addressee.cpp:772
KABC::Addressee::businessAddressLocalityLabel
static QString businessAddressLocalityLabel()
Return translated label for businessAddressLocality field.
Definition addressee.cpp:784
KABC::Addressee::mailerLabel
static QString mailerLabel()
Return translated label for mailer field.
Definition addressee.cpp:882
KABC::Addressee::keys
Key::List keys() const
Return list of all keys.
Definition addressee.cpp:1651
KABC::Addressee::custom
QString custom(const QString &app, const QString &name) const
Return value of custom entry, identified by app and entry name.
Definition addressee.cpp:1949
KABC::Addressee::prefix
QString prefix() const
Return honorific prefixes.
Definition addressee.cpp:659
KABC::Addressee::organization
QString organization() const
Return organization.
Definition addressee.cpp:977
KABC::Addressee::homeAddressCountryLabel
static QString homeAddressCountryLabel()
Return translated label for homeAddressCountry field.
Definition addressee.cpp:760
KABC::Addressee::logoLabel
static QString logoLabel()
Return translated label for logo field.
Definition addressee.cpp:1142
KABC::Addressee::photoLabel
static QString photoLabel()
Return translated label for photo field.
Definition addressee.cpp:1162
KABC::Addressee::customs
QStringList customs() const
Return list of all custom entries.
Definition addressee.cpp:1974
KABC::Addressee::secrecyLabel
static QString secrecyLabel()
Return translated label for secrecy field.
Definition addressee.cpp:1122
KABC::Addressee::setRevision
void setRevision(const QDateTime &revision)
Set revision date.
Definition addressee.cpp:1048
KABC::Addressee::geo
Geo geo() const
Return geographic position.
Definition addressee.cpp:917
KABC::Addressee::setSuffix
void setSuffix(const QString &suffix)
Set honorific suffixes.
Definition addressee.cpp:670
KABC::Addressee::homePhoneLabel
static QString homePhoneLabel()
Return translated label for homePhone field.
Definition addressee.cpp:814
KABC::Addressee::soundLabel
static QString soundLabel()
Return translated label for sound field.
Definition addressee.cpp:1182
KABC::Addressee::removeEmail
void removeEmail(const QString &email)
Remove email address.
Definition addressee.cpp:1425
KABC::Addressee::homeAddressLabelLabel
static QString homeAddressLabelLabel()
Return translated label for homeAddressLabel field.
Definition addressee.cpp:766
KABC::Addressee::removeAddress
void removeAddress(const Address &address)
Remove address.
Definition addressee.cpp:1791
KABC::Addressee::sound
Sound sound() const
Return sound.
Definition addressee.cpp:1177
KABC::Addressee::urlLabel
static QString urlLabel()
Return translated label for url field.
Definition addressee.cpp:1102
KABC::Addressee::toString
QString toString() const
Returns string representation of the addressee.
Definition addressee.cpp:1691
KABC::Addressee::photo
Picture photo() const
Return photo.
Definition addressee.cpp:1157
KABC::Addressee::secrecy
Secrecy secrecy() const
Return security class.
Definition addressee.cpp:1117
KABC::Addressee::Addressee
Addressee()
Construct an empty address book entry.
Definition addressee.cpp:180
KABC::Addressee::businessAddressPostalCodeLabel
static QString businessAddressPostalCodeLabel()
Return translated label for businessAddressPostalCode field.
Definition addressee.cpp:796
KABC::Addressee::carPhoneLabel
static QString carPhoneLabel()
Return translated label for carPhone field.
Definition addressee.cpp:844
KABC::Addressee::suffix
QString suffix() const
Return honorific suffixes.
Definition addressee.cpp:679
KABC::Addressee::address
Address address(Address::Type type) const
Return address, which matches the given type.
Definition addressee.cpp:1802
KABC::Addressee::titleLabel
static QString titleLabel()
Return translated label for title field.
Definition addressee.cpp:942
KABC::Addressee::setGivenName
void setGivenName(const QString &givenName)
Set given name.
Definition addressee.cpp:610
KABC::Addressee::prefixLabel
static QString prefixLabel()
Return translated label for prefix field.
Definition addressee.cpp:664
KABC::Addressee::nameLabel
static QString nameLabel()
Return translated label for name field.
Definition addressee.cpp:466
KABC::Addressee::note
QString note() const
Return note.
Definition addressee.cpp:1017
KABC::Addressee::homeAddressStreetLabel
static QString homeAddressStreetLabel()
Return translated label for homeAddressStreet field.
Definition addressee.cpp:730
KABC::Addressee::uidLabel
static QString uidLabel()
Return translated label for uid field.
Definition addressee.cpp:447
KABC::Addressee::phoneNumber
PhoneNumber phoneNumber(PhoneNumber::Type type) const
Return phone number, which matches the given type.
Definition addressee.cpp:1551
KABC::Addressee::pagerLabel
static QString pagerLabel()
Return translated label for pager field.
Definition addressee.cpp:856
KABC::Addressee::operator!=
bool operator!=(const Addressee &) const
Not-equal operator.
Definition addressee.cpp:423
KABC::Addressee::birthday
QDateTime birthday() const
Return birthday.
Definition addressee.cpp:719
KABC::Addressee::setEmails
void setEmails(const QStringList &list)
Set the emails to list.
Definition addressee.cpp:1464
KABC::Addressee::setNickName
void setNickName(const QString &nickName)
Set nick name.
Definition addressee.cpp:690
KABC::Addressee::findKey
Key findKey(const QString &id) const
Return key with the given id.
Definition addressee.cpp:1679
KABC::Addressee::additionalName
QString additionalName() const
Return additional names.
Definition addressee.cpp:639
KABC::Addressee::parseEmailAddress
static void parseEmailAddress(const QString &rawEmail, QString &fullName, QString &email)
Parse full email address.
Definition addressee.cpp:1987
KABC::Addressee::isEmpty
bool isEmpty() const
Return, if the address book entry is empty.
Definition addressee.cpp:428
KABC::Addressee::setDepartment
void setDepartment(const QString &department)
Set department.
Definition addressee.cpp:988
KABC::Addressee::insertEmail
void insertEmail(const QString &email, bool preferred=false)
Insert an email address.
Definition addressee.cpp:1420
KABC::Addressee::preferredEmail
QString preferredEmail() const
Return preferred email address.
Definition addressee.cpp:1434
KABC::Addressee::role
QString role() const
Return role.
Definition addressee.cpp:957
KABC::Addressee::homeFaxLabel
static QString homeFaxLabel()
Return translated label for homeFax field.
Definition addressee.cpp:832
KABC::Addressee::timeZoneLabel
static QString timeZoneLabel()
Return translated label for timeZone field.
Definition addressee.cpp:902
KABC::Addressee::productId
QString productId() const
Return product identifier.
Definition addressee.cpp:1037
KABC::Addressee::revision
QDateTime revision() const
Return revision date.
Definition addressee.cpp:1057
KABC::Addressee::setSound
void setSound(const Sound &sound)
Set sound.
Definition addressee.cpp:1168
KABC::Addressee::removeCategory
void removeCategory(const QString &)
Remove category.
Definition addressee.cpp:1904
KABC::Addressee::setChanged
void setChanged(bool value)
Mark addressee as changed.
Definition addressee.cpp:2158
KABC::Addressee::removeCustom
void removeCustom(const QString &app, const QString &name)
Remove custom entry.
Definition addressee.cpp:1942
KABC::Addressee::setCategories
void setCategories(const QStringList &)
Set categories to given value.
Definition addressee.cpp:1916
KABC::Addressee::setTimeZone
void setTimeZone(const TimeZone &timeZone)
Set time zone.
Definition addressee.cpp:888
KABC::Addressee::realName
QString realName() const
Return the name of the addressee.
Definition addressee.cpp:1340
KABC::Addressee::title
QString title() const
Return title.
Definition addressee.cpp:937
KABC::Addressee::logo
Picture logo() const
Return logo.
Definition addressee.cpp:1137
KABC::Addressee::assembledName
QString assembledName() const
Return the name that consists of all name parts.
Definition addressee.cpp:1357
KABC::Addressee::setNote
void setNote(const QString &note)
Set note.
Definition addressee.cpp:1008
KABC::Addressee::formattedName
QString formattedName() const
Return formatted name.
Definition addressee.cpp:579
KABC::Addressee::suffixLabel
static QString suffixLabel()
Return translated label for suffix field.
Definition addressee.cpp:684
KABC::Addressee::geoLabel
static QString geoLabel()
Return translated label for geo field.
Definition addressee.cpp:922
KABC::Addressee::fullEmail
QString fullEmail(const QString &email=QString()) const
Return email address including real name.
Definition addressee.cpp:1368
KABC::Addressee::homeAddressLocalityLabel
static QString homeAddressLocalityLabel()
Return translated label for homeAddressLocality field.
Definition addressee.cpp:742
KABC::Addressee::roleLabel
static QString roleLabel()
Return translated label for role field.
Definition addressee.cpp:962
KABC::Addressee::setPhoto
void setPhoto(const Picture &photo)
Set photo.
Definition addressee.cpp:1148
KABC::Addressee::setName
void setName(const QString &name)
Set name.
Definition addressee.cpp:452
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition addressee.cpp:1773
KABC::Addressee::birthdayLabel
static QString birthdayLabel()
Return translated label for birthday field.
Definition addressee.cpp:724
KABC::Addressee::addresses
Address::List addresses() const
Return list of all addresses.
Definition addressee.cpp:1820
KABC::Addressee::changed
bool changed() const
Return whether the addressee is changed.
Definition addressee.cpp:2163
KABC::Addressee::timeZone
TimeZone timeZone() const
Return time zone.
Definition addressee.cpp:897
KABC::Addressee::setSortMode
static void setSortMode(KABC::SortMode *mode)
Sets the sort mode implementation.
Definition addressee.cpp:2168
KABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition addressee.cpp:1599
KABC::Addressee::setRole
void setRole(const QString &role)
Set role.
Definition addressee.cpp:948
KABC::Addressee::setResource
void setResource(Resource *resource)
Set resource where the addressee is from.
Definition addressee.cpp:2147
KABC::Addressee::businessPhoneLabel
static QString businessPhoneLabel()
Return translated label for businessPhone field.
Definition addressee.cpp:820
KABC::Addressee::resource
Resource * resource() const
Return pointer to resource.
Definition addressee.cpp:2152
KABC::Addressee::name
QString name() const
Return name.
Definition addressee.cpp:461
KABC::Addressee::givenName
QString givenName() const
Return given name.
Definition addressee.cpp:619
KABC::Addressee::revisionLabel
static QString revisionLabel()
Return translated label for revision field.
Definition addressee.cpp:1062
KABC::Addressee::setUrl
void setUrl(const KUrl &url)
Set homepage.
Definition addressee.cpp:1088
KABC::Addressee::setFormattedName
void setFormattedName(const QString &formattedName)
Set formatted name.
Definition addressee.cpp:570
KABC::Addressee::businessAddressCountryLabel
static QString businessAddressCountryLabel()
Return translated label for businessAddressCountry field.
Definition addressee.cpp:802
KABC::Addressee::homeAddressRegionLabel
static QString homeAddressRegionLabel()
Return translated label for homeAddressRegion field.
Definition addressee.cpp:748
KABC::Addressee::departmentLabel
static QString departmentLabel()
Return translated label for department field.
Definition addressee.cpp:1002
KABC::Addressee::findAddress
Address findAddress(const QString &id) const
Return address with the given id.
Definition addressee.cpp:1840
KABC::Addressee::familyNameLabel
static QString familyNameLabel()
Return translated label for familyName field.
Definition addressee.cpp:604
KABC::Addressee::setFamilyName
void setFamilyName(const QString &familyName)
Set family name.
Definition addressee.cpp:590
KABC::Addressee::categories
QStringList categories() const
Return list of all set categories.
Definition addressee.cpp:1923
KABC::Addressee::setTitle
void setTitle(const QString &title)
Set title.
Definition addressee.cpp:928
KABC::Addressee::nickNameLabel
static QString nickNameLabel()
Return translated label for nickName field.
Definition addressee.cpp:704
KABC::Addressee::isdnLabel
static QString isdnLabel()
Return translated label for isdn field.
Definition addressee.cpp:850
KABC::Addressee::productIdLabel
static QString productIdLabel()
Return translated label for productId field.
Definition addressee.cpp:1042
KABC::Addressee::findPhoneNumber
PhoneNumber findPhoneNumber(const QString &id) const
Return phone number with the given id.
Definition addressee.cpp:1587
KABC::Addressee::department
QString department() const
Return department.
Definition addressee.cpp:997
KABC::Addressee::operator<
bool operator<(const Addressee &addr) const
Return whether this addressee is "less-than" a given one.
Definition addressee.cpp:2173
KABC::Addressee::setUid
void setUid(const QString &uid)
Set unique identifier.
Definition addressee.cpp:433
KABC::Addressee::mobilePhoneLabel
static QString mobilePhoneLabel()
Return translated label for mobilePhone field.
Definition addressee.cpp:826
KABC::Addressee::uid
QString uid() const
Return unique identifier.
Definition addressee.cpp:442
KABC::Addressee::setGeo
void setGeo(const Geo &geo)
Set geographic position.
Definition addressee.cpp:908
KABC::Addressee::formattedNameLabel
static QString formattedNameLabel()
Return translated label for formattedName field.
Definition addressee.cpp:584
KABC::Addressee::phoneNumbers
PhoneNumber::List phoneNumbers() const
Return list of all phone numbers.
Definition addressee.cpp:1568
KABC::Addressee::emailLabel
static QString emailLabel()
Return translated label for email field.
Definition addressee.cpp:862
KABC::Addressee::businessFaxLabel
static QString businessFaxLabel()
Return translated label for businessFax field.
Definition addressee.cpp:838
KABC::Addressee::setSortString
void setSortString(const QString &sortString)
Set sort string.
Definition addressee.cpp:1068
KABC::Addressee::insertCategory
void insertCategory(const QString &)
Insert category.
Definition addressee.cpp:1894
KABC::Addressee::key
Key key(Key::Type type, QString customTypeString=QString()) const
Return key, which matches the given type.
Definition addressee.cpp:1624
KABC::Geo
Geographic position.
Definition geo.h:36
KABC::Key
A class to store an encryption key.
Definition key.h:35
KABC::Key::Type
Type
Key types.
Definition key.h:48
KABC::Key::Custom
@ Custom
Custom or IANA conform key.
Definition key.h:51
KABC::Key::id
QString id() const
Returns the unique identifier.
Definition key.cpp:126
KABC::Key::List
QList< Key > List
List of keys.
Definition key.h:43
KABC::PhoneNumber
Phonenumber information.
Definition phonenumber.h:39
KABC::PhoneNumber::Pref
@ Pref
Preferred number.
Definition phonenumber.h:51
KABC::PhoneNumber::id
QString id() const
Returns the unique identifier.
Definition phonenumber.cpp:118
KABC::PhoneNumber::List
QList< PhoneNumber > List
List of phone numbers.
Definition phonenumber.h:74
KABC::PhoneNumber::number
QString number() const
Returns the phone number.
Definition phonenumber.cpp:128
KABC::Picture
A class to store a picture of an addressee.
Definition picture.h:40
KABC::Resource
Definition resource.h:65
KABC::SortMode
Sort method for sorting an addressee list.
Definition sortmode.h:38
KABC::Sound
Class that holds a Sound clip for a contact.
Definition sound.h:59
KABC::TimeZone
Time zone information.
Definition timezone.h:36
KABC
Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
Definition address.h:29
KABC::operator<<
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
Definition address.cpp:680
KABC::operator>>
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
Definition address.cpp:688
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal