KContacts

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

KDE's Doxygen guidelines are available online.