KContacts

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

KDE's Doxygen guidelines are available online.